Filtre de la liste nouvelle section (que article pour isMobile)

This commit is contained in:
Fransolet Thomas 2022-10-19 16:19:06 +02:00
parent 164f904f13
commit 7306373277
3 changed files with 39 additions and 29 deletions

View File

@ -118,7 +118,9 @@ class _MenuConfigState extends State<MenuConfig> {
menuDTO.sections.add(newSubsection);
widget.onChanged(jsonEncode(menuDTO).toString());
});
});
},
false
);
},
child: Container(
height: MediaQuery.of(context).size.width * 0.04,

View File

@ -8,11 +8,12 @@ import 'package:manager_app/app_context.dart';
import 'package:manager_app/constants.dart';
import 'package:managerapi/api.dart';
void showNewSection(String configurationId, AppContext appContext, BuildContext context, bool isSubSection, Function sendSubSection) {
void showNewSection(String configurationId, AppContext appContext, BuildContext contextBuild, bool isSubSection, Function sendSubSection, bool isMobile) {
SectionDTO sectionDTO = new SectionDTO();
sectionDTO.configurationId = configurationId;
sectionDTO.isSubSection = isSubSection;
sectionDTO.parentId = isSubSection ? appContext.getContext().selectedSection.id : null;
Size size = MediaQuery.of(contextBuild).size;
showDialog(
builder: (BuildContext context) => AlertDialog(
@ -20,31 +21,35 @@ void showNewSection(String configurationId, AppContext appContext, BuildContext
borderRadius: BorderRadius.all(Radius.circular(20.0))
),
content: SingleChildScrollView(
child: Column(
children: [
Text(isSubSection? "Nouvelle sous section": "Nouvelle section", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)),
Column(
children: [
StringInputContainer(
label: "Nom :",
initialValue: sectionDTO.label,
onChanged: (value) {
sectionDTO.label = value;
},
),
MultiSelectContainer(
label: "Type :",
initialValue: ["Map"],
isMultiple: false,
values: isSubSection ? section_types.where((sectionType) => sectionType != "Menu").toList(): section_types, // Todo get menu by enum type
onChanged: (value) {
var tempOutput = new List<String>.from(value);
sectionDTO.type = SectionType.fromJson(tempOutput[0]);
},
),
],
),
],
child: SizedBox(
width: size.width*0.3,
height: size.height*0.3,
child: Column(
children: [
Text(isSubSection? "Nouvelle sous section": "Nouvelle section", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)),
Column(
children: [
StringInputContainer(
label: "Nom :",
initialValue: sectionDTO.label,
onChanged: (value) {
sectionDTO.label = value;
},
),
MultiSelectContainer(
label: "Type :",
initialValue: isMobile ? ["Article"] : ["Map"],
isMultiple: false,
values: isMobile ? section_types.where((sectionType) => sectionType == "Article").toList(): isSubSection ? section_types.where((sectionType) => sectionType != "Menu").toList(): section_types, // Todo get menu by enum type
onChanged: (value) {
var tempOutput = new List<String>.from(value);
sectionDTO.type = SectionType.fromJson(tempOutput[0]);
},
),
],
),
],
),
),
),
actions: <Widget>[
@ -88,7 +93,7 @@ void showNewSection(String configurationId, AppContext appContext, BuildContext
],
),
],
), context: context
), context: contextBuild
);
}

View File

@ -58,6 +58,9 @@ class _SectionReorderListState extends State<SectionReorderList> {
final appContext = Provider.of<AppContext>(context);
Size size = MediaQuery.of(context).size;
ManagerAppContext managerAppContext = appContext.getContext();
ConfigurationDTO currentConfiguration = managerAppContext.selectedConfiguration;
return Stack(
children: [
Padding(
@ -138,7 +141,7 @@ class _SectionReorderListState extends State<SectionReorderList> {
right: 10,
child: InkWell(
onTap: () {
showNewSection(widget.configurationId, appContext, context, false, null);
showNewSection(widget.configurationId, appContext, context, false, null, currentConfiguration.isMobile);
},
child: Container(
height: MediaQuery.of(context).size.width * 0.04,