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/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';
|
import 'package:manager_app/constants.dart';
|
||||||
|
|
||||||
class DropDownInputContainer extends StatefulWidget {
|
class DropDownInputContainer extends StatefulWidget {
|
||||||
final String label;
|
final String label;
|
||||||
final List<CategorieDTO> categories;
|
final List<String> values;
|
||||||
final CategorieDTO? initialValue;
|
final String? initialValue;
|
||||||
final ValueChanged<CategorieDTO>? onChange;
|
final ValueChanged<String>? onChange;
|
||||||
|
|
||||||
const DropDownInputContainer({
|
const DropDownInputContainer({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.label,
|
required this.label,
|
||||||
required this.categories,
|
required this.values,
|
||||||
required this.initialValue,
|
this.initialValue,
|
||||||
this.onChange,
|
this.onChange,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@ -21,56 +20,49 @@ class DropDownInputContainer extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _DropDownInputContainerState extends State<DropDownInputContainer> {
|
class _DropDownInputContainerState extends State<DropDownInputContainer> {
|
||||||
List<CategorieDTO> categoriesToShow = [];
|
late String? selectedValue;
|
||||||
CategorieDTO? selectedCategorieDTO;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
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();
|
super.initState();
|
||||||
|
selectedValue = widget.initialValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
/*final appContext = Provider.of<AppContext>(context);
|
|
||||||
Size size = MediaQuery.of(context).size;*/
|
|
||||||
|
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
Align(
|
Align(
|
||||||
alignment: AlignmentDirectional.centerStart,
|
alignment: AlignmentDirectional.centerStart,
|
||||||
child: Text(widget.label, style: TextStyle(fontSize: 25, fontWeight: FontWeight.w300))
|
child: Text(
|
||||||
|
widget.label,
|
||||||
|
style: TextStyle(fontSize: 25, fontWeight: FontWeight.w300),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: DropdownButton<CategorieDTO>(
|
child: DropdownButton<String>(
|
||||||
value: selectedCategorieDTO,
|
value: selectedValue,
|
||||||
icon: const Icon(Icons.arrow_downward),
|
icon: const Icon(Icons.arrow_downward),
|
||||||
iconSize: 24,
|
iconSize: 24,
|
||||||
elevation: 16,
|
elevation: 16,
|
||||||
style: const TextStyle(color: kWhite),
|
style: const TextStyle(color: Colors.black),
|
||||||
underline: Container(
|
underline: Container(
|
||||||
height: 2,
|
height: 2,
|
||||||
color: kPrimaryColor,
|
color: kPrimaryColor,
|
||||||
),
|
),
|
||||||
onChanged: (CategorieDTO? newValue) {
|
onChanged: (String? newValue) {
|
||||||
setState(() {
|
setState(() {
|
||||||
selectedCategorieDTO = newValue!;
|
selectedValue = newValue;
|
||||||
widget.onChange!(selectedCategorieDTO!);
|
widget.onChange!(selectedValue!);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
items: categoriesToShow.map<DropdownMenuItem<CategorieDTO>>((CategorieDTO value) {
|
items: widget.values.map<DropdownMenuItem<String>>((String value) {
|
||||||
return DropdownMenuItem<CategorieDTO>(
|
return DropdownMenuItem<String>(
|
||||||
value: value,
|
value: value,
|
||||||
child: HtmlWidget(
|
child: Text(
|
||||||
value.label == null ? "" : value.label![0].value!,
|
value,
|
||||||
textStyle: TextStyle(fontSize: 15, color: Colors.black, fontWeight: FontWeight.w400)
|
style: TextStyle(fontSize: 15),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).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/material.dart';
|
||||||
import 'package:flutter_widget_from_html/flutter_widget_from_html.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/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/fetch_section_icon.dart';
|
||||||
import 'package:manager_app/Components/resource_input_container.dart';
|
import 'package:manager_app/Components/resource_input_container.dart';
|
||||||
import 'package:manager_app/Components/multi_select_container.dart';
|
import 'package:manager_app/Components/multi_select_container.dart';
|
||||||
@ -179,29 +180,22 @@ class _MapConfigState extends State<MapConfig> {
|
|||||||
children: [
|
children: [
|
||||||
if(mapDTO.mapProvider == MapProvider.Google)
|
if(mapDTO.mapProvider == MapProvider.Google)
|
||||||
// Map Type
|
// Map Type
|
||||||
MultiSelectContainer(
|
DropDownInputContainer(
|
||||||
label: "Type:",
|
label: "Type:",
|
||||||
initialValue: [mapType], //mapDTO.mapType.toString()
|
|
||||||
isMultiple: false,
|
|
||||||
values: map_types,
|
values: map_types,
|
||||||
onChanged: (value) {
|
initialValue: mapType,
|
||||||
var tempOutput = new List<String>.from(value);
|
onChange: (String? value) {
|
||||||
print("Type MAP");
|
mapDTO.mapType = MapTypeApp.fromJson(value);
|
||||||
print(value);
|
|
||||||
mapDTO.mapType = MapTypeApp.fromJson(tempOutput[0]);
|
|
||||||
widget.onChanged(jsonEncode(mapDTO).toString());
|
widget.onChanged(jsonEncode(mapDTO).toString());
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
if(mapDTO.mapProvider == MapProvider.MapBox)
|
if(mapDTO.mapProvider == MapProvider.MapBox)
|
||||||
MultiSelectContainer(
|
DropDownInputContainer(
|
||||||
label: "Type:",
|
label: "Type:",
|
||||||
initialValue: [mapTypeMapBox], //mapDTO.mapType.toString()
|
|
||||||
isMultiple: false,
|
|
||||||
values: map_types_mapBox,
|
values: map_types_mapBox,
|
||||||
onChanged: (value) {
|
initialValue: mapTypeMapBox,
|
||||||
var tempOutput = new List<String>.from(value);
|
onChange: (String? value) {
|
||||||
print(value);
|
mapDTO.mapTypeMapbox = MapTypeMapBox.fromJson(value);
|
||||||
mapDTO.mapTypeMapbox = MapTypeMapBox.fromJson(tempOutput[0]);
|
|
||||||
widget.onChanged(jsonEncode(mapDTO).toString());
|
widget.onChanged(jsonEncode(mapDTO).toString());
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:location_picker_flutter_map/location_picker_flutter_map.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/loading_common.dart';
|
||||||
import 'package:manager_app/Components/multi_string_input_container.dart';
|
import 'package:manager_app/Components/multi_string_input_container.dart';
|
||||||
import 'package:manager_app/Components/rounded_button.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))
|
borderRadius: BorderRadius.all(Radius.circular(20.0))
|
||||||
),
|
),
|
||||||
content: Container(
|
content: Container(
|
||||||
width: size.width *0.8,
|
width: size.width *0.85,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
@ -121,8 +121,7 @@ void showNewOrUpdateGeoPoint(MapDTO mapDTO, GeoPointDTO? inputGeoPointDTO, Funct
|
|||||||
],
|
],
|
||||||
),*/
|
),*/
|
||||||
Container(
|
Container(
|
||||||
height: size.height * 0.2,
|
height: 100,
|
||||||
width: double.infinity,
|
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: [
|
children: [
|
||||||
@ -163,10 +162,104 @@ void showNewOrUpdateGeoPoint(MapDTO mapDTO, GeoPointDTO? inputGeoPointDTO, Funct
|
|||||||
isTitle: false
|
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)
|
if(mapDTO.categories != null && mapDTO.categories!.isNotEmpty)
|
||||||
Container(
|
Container(
|
||||||
constraints: BoxConstraints(minHeight: 50, maxHeight: 80),
|
constraints: BoxConstraints(minHeight: 50, maxHeight: 80),
|
||||||
child: DropDownInputContainer(
|
child: DropDownInputContainerCategories(
|
||||||
label: "Choisir une catégorie:",
|
label: "Choisir une catégorie:",
|
||||||
categories: mapDTO.categories!,
|
categories: mapDTO.categories!,
|
||||||
initialValue: geoPointDTO.categorie,
|
initialValue: geoPointDTO.categorie,
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
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/message_notification.dart';
|
||||||
import 'package:manager_app/Components/multi_select_container.dart';
|
import 'package:manager_app/Components/multi_select_container.dart';
|
||||||
import 'package:manager_app/Components/rounded_button.dart';
|
import 'package:manager_app/Components/rounded_button.dart';
|
||||||
@ -24,8 +25,8 @@ void showNewSection(String configurationId, AppContext appContext, BuildContext
|
|||||||
),
|
),
|
||||||
content: SingleChildScrollView(
|
content: SingleChildScrollView(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: size.width*0.4,
|
width: 750,
|
||||||
height: size.height*0.4,
|
height: 250,
|
||||||
child: Container(
|
child: Container(
|
||||||
constraints: BoxConstraints(minHeight: 300, minWidth: 300),
|
constraints: BoxConstraints(minHeight: 300, minWidth: 300),
|
||||||
child: Column(
|
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:",
|
label: "Type:",
|
||||||
initialValue: isMobile ? ["Article"] : ["Map"],
|
initialValue: isMobile ? ["Article"] : ["Map"],
|
||||||
isMultiple: false,
|
isMultiple: false,
|
||||||
@ -52,7 +61,7 @@ void showNewSection(String configurationId, AppContext appContext, BuildContext
|
|||||||
var tempOutput = new List<String>.from(value);
|
var tempOutput = new List<String>.from(value);
|
||||||
sectionDTO.type = SectionType.fromJson(tempOutput[0]);
|
sectionDTO.type = SectionType.fromJson(tempOutput[0]);
|
||||||
},
|
},
|
||||||
),
|
),*/
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user