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); menuDTO.sections.add(newSubsection);
widget.onChanged(jsonEncode(menuDTO).toString()); widget.onChanged(jsonEncode(menuDTO).toString());
}); });
}); },
false
);
}, },
child: Container( child: Container(
height: MediaQuery.of(context).size.width * 0.04, 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:manager_app/constants.dart';
import 'package:managerapi/api.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 sectionDTO = new SectionDTO();
sectionDTO.configurationId = configurationId; sectionDTO.configurationId = configurationId;
sectionDTO.isSubSection = isSubSection; sectionDTO.isSubSection = isSubSection;
sectionDTO.parentId = isSubSection ? appContext.getContext().selectedSection.id : null; sectionDTO.parentId = isSubSection ? appContext.getContext().selectedSection.id : null;
Size size = MediaQuery.of(contextBuild).size;
showDialog( showDialog(
builder: (BuildContext context) => AlertDialog( builder: (BuildContext context) => AlertDialog(
@ -20,31 +21,35 @@ void showNewSection(String configurationId, AppContext appContext, BuildContext
borderRadius: BorderRadius.all(Radius.circular(20.0)) borderRadius: BorderRadius.all(Radius.circular(20.0))
), ),
content: SingleChildScrollView( content: SingleChildScrollView(
child: Column( child: SizedBox(
children: [ width: size.width*0.3,
Text(isSubSection? "Nouvelle sous section": "Nouvelle section", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)), height: size.height*0.3,
Column( child: Column(
children: [ children: [
StringInputContainer( Text(isSubSection? "Nouvelle sous section": "Nouvelle section", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)),
label: "Nom :", Column(
initialValue: sectionDTO.label, children: [
onChanged: (value) { StringInputContainer(
sectionDTO.label = value; label: "Nom :",
}, initialValue: sectionDTO.label,
), onChanged: (value) {
MultiSelectContainer( sectionDTO.label = value;
label: "Type :", },
initialValue: ["Map"], ),
isMultiple: false, MultiSelectContainer(
values: isSubSection ? section_types.where((sectionType) => sectionType != "Menu").toList(): section_types, // Todo get menu by enum type label: "Type :",
onChanged: (value) { initialValue: isMobile ? ["Article"] : ["Map"],
var tempOutput = new List<String>.from(value); isMultiple: false,
sectionDTO.type = SectionType.fromJson(tempOutput[0]); 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>[ 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); final appContext = Provider.of<AppContext>(context);
Size size = MediaQuery.of(context).size; Size size = MediaQuery.of(context).size;
ManagerAppContext managerAppContext = appContext.getContext();
ConfigurationDTO currentConfiguration = managerAppContext.selectedConfiguration;
return Stack( return Stack(
children: [ children: [
Padding( Padding(
@ -138,7 +141,7 @@ class _SectionReorderListState extends State<SectionReorderList> {
right: 10, right: 10,
child: InkWell( child: InkWell(
onTap: () { onTap: () {
showNewSection(widget.configurationId, appContext, context, false, null); showNewSection(widget.configurationId, appContext, context, false, null, currentConfiguration.isMobile);
}, },
child: Container( child: Container(
height: MediaQuery.of(context).size.width * 0.04, height: MediaQuery.of(context).size.width * 0.04,