Added practical infos to geopoint + update single select to dropdown
This commit is contained in:
parent
649955044f
commit
8893c75792
@ -1,18 +1,17 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
|
||||
import 'package:manager_api_new/api.dart';
|
||||
import 'package:manager_app/constants.dart';
|
||||
|
||||
class DropDownInputContainer extends StatefulWidget {
|
||||
final String label;
|
||||
final List<CategorieDTO> categories;
|
||||
final CategorieDTO? initialValue;
|
||||
final ValueChanged<CategorieDTO>? onChange;
|
||||
final List<String> values;
|
||||
final String? initialValue;
|
||||
final ValueChanged<String>? onChange;
|
||||
|
||||
const DropDownInputContainer({
|
||||
Key? key,
|
||||
required this.label,
|
||||
required this.categories,
|
||||
required this.initialValue,
|
||||
required this.values,
|
||||
this.initialValue,
|
||||
this.onChange,
|
||||
}) : super(key: key);
|
||||
|
||||
@ -21,56 +20,49 @@ class DropDownInputContainer extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _DropDownInputContainerState extends State<DropDownInputContainer> {
|
||||
List<CategorieDTO> categoriesToShow = [];
|
||||
CategorieDTO? selectedCategorieDTO;
|
||||
late String? selectedValue;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
if(widget.initialValue != null) {
|
||||
selectedCategorieDTO = widget.categories.firstWhere((element) => element.order == widget.initialValue!.order);
|
||||
}
|
||||
List<TranslationDTO> label = [];
|
||||
label.add(TranslationDTO(language: "FR", value: "Aucune catégorie"));
|
||||
categoriesToShow.add(CategorieDTO(order: -1, label: label));
|
||||
categoriesToShow.addAll(widget.categories);
|
||||
super.initState();
|
||||
selectedValue = widget.initialValue;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
/*final appContext = Provider.of<AppContext>(context);
|
||||
Size size = MediaQuery.of(context).size;*/
|
||||
|
||||
return Row(
|
||||
children: [
|
||||
Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: Text(widget.label, style: TextStyle(fontSize: 25, fontWeight: FontWeight.w300))
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: Text(
|
||||
widget.label,
|
||||
style: TextStyle(fontSize: 25, fontWeight: FontWeight.w300),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: DropdownButton<CategorieDTO>(
|
||||
value: selectedCategorieDTO,
|
||||
child: DropdownButton<String>(
|
||||
value: selectedValue,
|
||||
icon: const Icon(Icons.arrow_downward),
|
||||
iconSize: 24,
|
||||
elevation: 16,
|
||||
style: const TextStyle(color: kWhite),
|
||||
style: const TextStyle(color: Colors.black),
|
||||
underline: Container(
|
||||
height: 2,
|
||||
color: kPrimaryColor,
|
||||
),
|
||||
onChanged: (CategorieDTO? newValue) {
|
||||
onChanged: (String? newValue) {
|
||||
setState(() {
|
||||
selectedCategorieDTO = newValue!;
|
||||
widget.onChange!(selectedCategorieDTO!);
|
||||
selectedValue = newValue;
|
||||
widget.onChange!(selectedValue!);
|
||||
});
|
||||
},
|
||||
items: categoriesToShow.map<DropdownMenuItem<CategorieDTO>>((CategorieDTO value) {
|
||||
return DropdownMenuItem<CategorieDTO>(
|
||||
items: widget.values.map<DropdownMenuItem<String>>((String value) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: value,
|
||||
child: HtmlWidget(
|
||||
value.label == null ? "" : value.label![0].value!,
|
||||
textStyle: TextStyle(fontSize: 15, color: Colors.black, fontWeight: FontWeight.w400)
|
||||
child: Text(
|
||||
value,
|
||||
style: TextStyle(fontSize: 15),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
@ -79,5 +71,4 @@ class _DropDownInputContainerState extends State<DropDownInputContainer> {
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
83
lib/Components/dropDown_input_container_categories.dart
Normal file
83
lib/Components/dropDown_input_container_categories.dart
Normal file
@ -0,0 +1,83 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
|
||||
import 'package:manager_api_new/api.dart';
|
||||
import 'package:manager_app/constants.dart';
|
||||
|
||||
class DropDownInputContainerCategories extends StatefulWidget {
|
||||
final String label;
|
||||
final List<CategorieDTO> categories;
|
||||
final CategorieDTO? initialValue;
|
||||
final ValueChanged<CategorieDTO>? onChange;
|
||||
const DropDownInputContainerCategories({
|
||||
Key? key,
|
||||
required this.label,
|
||||
required this.categories,
|
||||
required this.initialValue,
|
||||
this.onChange,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
_DropDownInputContainerCategoriesState createState() => _DropDownInputContainerCategoriesState();
|
||||
}
|
||||
|
||||
class _DropDownInputContainerCategoriesState extends State<DropDownInputContainerCategories> {
|
||||
List<CategorieDTO> categoriesToShow = [];
|
||||
CategorieDTO? selectedCategorieDTO;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
if(widget.initialValue != null) {
|
||||
selectedCategorieDTO = widget.categories.firstWhere((element) => element.order == widget.initialValue!.order);
|
||||
}
|
||||
List<TranslationDTO> label = [];
|
||||
label.add(TranslationDTO(language: "FR", value: "Aucune catégorie"));
|
||||
categoriesToShow.add(CategorieDTO(order: -1, label: label));
|
||||
categoriesToShow.addAll(widget.categories);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
/*final appContext = Provider.of<AppContext>(context);
|
||||
Size size = MediaQuery.of(context).size;*/
|
||||
|
||||
return Row(
|
||||
children: [
|
||||
Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: Text(widget.label, style: TextStyle(fontSize: 25, fontWeight: FontWeight.w300))
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: DropdownButton<CategorieDTO>(
|
||||
value: selectedCategorieDTO,
|
||||
icon: const Icon(Icons.arrow_downward),
|
||||
iconSize: 24,
|
||||
elevation: 16,
|
||||
style: const TextStyle(color: kWhite),
|
||||
underline: Container(
|
||||
height: 2,
|
||||
color: kPrimaryColor,
|
||||
),
|
||||
onChanged: (CategorieDTO? newValue) {
|
||||
setState(() {
|
||||
selectedCategorieDTO = newValue!;
|
||||
widget.onChange!(selectedCategorieDTO!);
|
||||
});
|
||||
},
|
||||
items: categoriesToShow.map<DropdownMenuItem<CategorieDTO>>((CategorieDTO value) {
|
||||
return DropdownMenuItem<CategorieDTO>(
|
||||
value: value,
|
||||
child: HtmlWidget(
|
||||
value.label == null ? "" : value.label![0].value!,
|
||||
textStyle: TextStyle(fontSize: 15, color: Colors.black, fontWeight: FontWeight.w400)
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,6 +2,7 @@ import 'package:diacritic/diacritic.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
|
||||
import 'package:manager_app/Components/category_input_container.dart';
|
||||
import 'package:manager_app/Components/dropDown_input_container.dart';
|
||||
import 'package:manager_app/Components/fetch_section_icon.dart';
|
||||
import 'package:manager_app/Components/resource_input_container.dart';
|
||||
import 'package:manager_app/Components/multi_select_container.dart';
|
||||
@ -179,29 +180,22 @@ class _MapConfigState extends State<MapConfig> {
|
||||
children: [
|
||||
if(mapDTO.mapProvider == MapProvider.Google)
|
||||
// Map Type
|
||||
MultiSelectContainer(
|
||||
DropDownInputContainer(
|
||||
label: "Type:",
|
||||
initialValue: [mapType], //mapDTO.mapType.toString()
|
||||
isMultiple: false,
|
||||
values: map_types,
|
||||
onChanged: (value) {
|
||||
var tempOutput = new List<String>.from(value);
|
||||
print("Type MAP");
|
||||
print(value);
|
||||
mapDTO.mapType = MapTypeApp.fromJson(tempOutput[0]);
|
||||
initialValue: mapType,
|
||||
onChange: (String? value) {
|
||||
mapDTO.mapType = MapTypeApp.fromJson(value);
|
||||
widget.onChanged(jsonEncode(mapDTO).toString());
|
||||
},
|
||||
),
|
||||
if(mapDTO.mapProvider == MapProvider.MapBox)
|
||||
MultiSelectContainer(
|
||||
DropDownInputContainer(
|
||||
label: "Type:",
|
||||
initialValue: [mapTypeMapBox], //mapDTO.mapType.toString()
|
||||
isMultiple: false,
|
||||
values: map_types_mapBox,
|
||||
onChanged: (value) {
|
||||
var tempOutput = new List<String>.from(value);
|
||||
print(value);
|
||||
mapDTO.mapTypeMapbox = MapTypeMapBox.fromJson(tempOutput[0]);
|
||||
initialValue: mapTypeMapBox,
|
||||
onChange: (String? value) {
|
||||
mapDTO.mapTypeMapbox = MapTypeMapBox.fromJson(value);
|
||||
widget.onChanged(jsonEncode(mapDTO).toString());
|
||||
},
|
||||
),
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:location_picker_flutter_map/location_picker_flutter_map.dart';
|
||||
import 'package:manager_app/Components/dropDown_input_container.dart';
|
||||
import 'package:manager_app/Components/dropDown_input_container_categories.dart';
|
||||
import 'package:manager_app/Components/loading_common.dart';
|
||||
import 'package:manager_app/Components/multi_string_input_container.dart';
|
||||
import 'package:manager_app/Components/rounded_button.dart';
|
||||
@ -38,7 +38,7 @@ void showNewOrUpdateGeoPoint(MapDTO mapDTO, GeoPointDTO? inputGeoPointDTO, Funct
|
||||
borderRadius: BorderRadius.all(Radius.circular(20.0))
|
||||
),
|
||||
content: Container(
|
||||
width: size.width *0.8,
|
||||
width: size.width *0.85,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
@ -121,8 +121,7 @@ void showNewOrUpdateGeoPoint(MapDTO mapDTO, GeoPointDTO? inputGeoPointDTO, Funct
|
||||
],
|
||||
),*/
|
||||
Container(
|
||||
height: size.height * 0.2,
|
||||
width: double.infinity,
|
||||
height: 100,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
@ -163,10 +162,104 @@ void showNewOrUpdateGeoPoint(MapDTO mapDTO, GeoPointDTO? inputGeoPointDTO, Funct
|
||||
isTitle: false
|
||||
),
|
||||
),
|
||||
Container(
|
||||
constraints: BoxConstraints(minHeight: 50, maxHeight: 80),
|
||||
child: MultiStringInputContainer(
|
||||
label: "Site:",
|
||||
modalLabel: "Site web",
|
||||
fontSize: 20,
|
||||
isHTML: true,
|
||||
color: kPrimaryColor,
|
||||
initialValue: geoPointDTO.site != null ? geoPointDTO.site! : [],
|
||||
isMandatory: false,
|
||||
onGetResult: (value) {
|
||||
if (geoPointDTO.site != value) {
|
||||
geoPointDTO.site = value;
|
||||
}
|
||||
},
|
||||
maxLines: 1,
|
||||
isTitle: false
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: 100,
|
||||
width: double.infinity,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Container(
|
||||
constraints: BoxConstraints(minHeight: 50, maxHeight: 80),
|
||||
child: MultiStringInputContainer(
|
||||
label: "Prix:",
|
||||
modalLabel: "Prix",
|
||||
fontSize: 20,
|
||||
isHTML: true,
|
||||
color: kPrimaryColor,
|
||||
initialValue: geoPointDTO.prices != null ? geoPointDTO.prices! : [],
|
||||
isMandatory: false,
|
||||
onGetResult: (value) {
|
||||
if (geoPointDTO.prices != value) {
|
||||
geoPointDTO.prices = value;
|
||||
}
|
||||
},
|
||||
maxLines: 1,
|
||||
isTitle: false
|
||||
),
|
||||
),
|
||||
Container(
|
||||
constraints: BoxConstraints(minHeight: 50, maxHeight: 80),
|
||||
child: MultiStringInputContainer(
|
||||
label: "Téléphone:",
|
||||
modalLabel: "Téléphone",
|
||||
fontSize: 20,
|
||||
isHTML: true,
|
||||
color: kPrimaryColor,
|
||||
initialValue: geoPointDTO.phone != null ? geoPointDTO.phone! : [],
|
||||
isMandatory: false,
|
||||
onGetResult: (value) {
|
||||
if (geoPointDTO.phone != value) {
|
||||
geoPointDTO.phone = value;
|
||||
}
|
||||
},
|
||||
maxLines: 1,
|
||||
isTitle: false
|
||||
),
|
||||
),
|
||||
Container(
|
||||
constraints: BoxConstraints(minHeight: 50, maxHeight: 80),
|
||||
child: MultiStringInputContainer(
|
||||
label: "Email:",
|
||||
modalLabel: "Email",
|
||||
fontSize: 20,
|
||||
isHTML: true,
|
||||
color: kPrimaryColor,
|
||||
initialValue: geoPointDTO.email != null ? geoPointDTO.email! : [],
|
||||
isMandatory: false,
|
||||
onGetResult: (value) {
|
||||
if (geoPointDTO.email != value) {
|
||||
geoPointDTO.email = value;
|
||||
}
|
||||
},
|
||||
maxLines: 1,
|
||||
isTitle: false
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: 100,
|
||||
width: double.infinity,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
if(mapDTO.categories != null && mapDTO.categories!.isNotEmpty)
|
||||
Container(
|
||||
constraints: BoxConstraints(minHeight: 50, maxHeight: 80),
|
||||
child: DropDownInputContainer(
|
||||
child: DropDownInputContainerCategories(
|
||||
label: "Choisir une catégorie:",
|
||||
categories: mapDTO.categories!,
|
||||
initialValue: geoPointDTO.categorie,
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:manager_app/Components/dropDown_input_container.dart';
|
||||
import 'package:manager_app/Components/message_notification.dart';
|
||||
import 'package:manager_app/Components/multi_select_container.dart';
|
||||
import 'package:manager_app/Components/rounded_button.dart';
|
||||
@ -24,8 +25,8 @@ void showNewSection(String configurationId, AppContext appContext, BuildContext
|
||||
),
|
||||
content: SingleChildScrollView(
|
||||
child: SizedBox(
|
||||
width: size.width*0.4,
|
||||
height: size.height*0.4,
|
||||
width: 750,
|
||||
height: 250,
|
||||
child: Container(
|
||||
constraints: BoxConstraints(minHeight: 300, minWidth: 300),
|
||||
child: Column(
|
||||
@ -43,7 +44,15 @@ void showNewSection(String configurationId, AppContext appContext, BuildContext
|
||||
},
|
||||
),
|
||||
),
|
||||
MultiSelectContainer(
|
||||
DropDownInputContainer(
|
||||
label: "Type:",
|
||||
values: isMobile ? section_types.where((sectionType) => sectionType == "Article" || sectionType == "Quizz").toList(): isSubSection ? section_types.where((sectionType) => sectionType != "Menu" && sectionType != "Article").toList(): section_types.where((sectionType) => sectionType != "Article").toList(), // Todo get menu by enum type
|
||||
initialValue: isMobile ? "Article" : "Map",
|
||||
onChange: (String? value) {
|
||||
sectionDTO.type = SectionType.fromJson(value);
|
||||
},
|
||||
),
|
||||
/*MultiSelectContainer(
|
||||
label: "Type:",
|
||||
initialValue: isMobile ? ["Article"] : ["Map"],
|
||||
isMultiple: false,
|
||||
@ -52,7 +61,7 @@ void showNewSection(String configurationId, AppContext appContext, BuildContext
|
||||
var tempOutput = new List<String>.from(value);
|
||||
sectionDTO.type = SectionType.fromJson(tempOutput[0]);
|
||||
},
|
||||
),
|
||||
),*/
|
||||
],
|
||||
),
|
||||
],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user