diff --git a/lib/Components/image_input_container.dart b/lib/Components/image_input_container.dart index 5f75605..32b65b0 100644 --- a/lib/Components/image_input_container.dart +++ b/lib/Components/image_input_container.dart @@ -12,12 +12,14 @@ class ImageInputContainer extends StatefulWidget { final String label; final String initialValue; final ValueChanged onChanged; + final BoxFit imageFit; const ImageInputContainer({ Key key, this.color = kSecond, this.label, this.initialValue, this.onChanged, + this.imageFit = BoxFit.cover, }) : super(key: key); @override @@ -123,9 +125,10 @@ class _ImageInputContainerState extends State { boxDecoration(ResourceDetailDTO resourceDetailDTO, appContext) { return BoxDecoration( shape: BoxShape.rectangle, + color: kWhite, borderRadius: BorderRadius.circular(30.0), image: new DecorationImage( - fit: BoxFit.cover, + fit: widget.imageFit, image: new NetworkImage( resourceDetailDTO.type == ResourceType.image ? appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resourceDetailDTO.id : resourceDetailDTO.data, ), diff --git a/lib/Components/multi_input_modal.dart b/lib/Components/multi_input_modal.dart index 051d6e8..f650e4a 100644 --- a/lib/Components/multi_input_modal.dart +++ b/lib/Components/multi_input_modal.dart @@ -1,29 +1,42 @@ +import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; import 'package:manager_app/Components/rounded_button.dart'; import 'package:manager_app/Components/string_input_container.dart'; +import 'package:manager_app/Components/text_form_input_container.dart'; import 'package:manager_app/Components/translation_tab.dart'; +import 'package:manager_app/Models/managerContext.dart'; +import 'package:manager_app/app_context.dart'; import 'package:manager_app/constants.dart'; import 'package:managerapi/api.dart'; import 'package:collection/collection.dart'; +import 'package:provider/provider.dart'; -showMultiStringInput (String text, List values, List newValues, Function onGetResult, int maxLines, BuildContext context) { /*Function onSelect,*/ +showMultiStringInput (String label, String modalLabel, List values, List newValues, Function onGetResult, int maxLines, BuildContext context) { /*Function onSelect,*/ showDialog( builder: (BuildContext context) => AlertDialog( shape: RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(20.0)) ), - title: Text(text), + title: Center(child: Text(modalLabel)), content: SingleChildScrollView( child: Column( children: [ Container( + child: SingleChildScrollView( + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: getTranslations(context, Provider.of(context), label, newValues), + ), + ), + ), + /*Container( width: 500, height: 200, child: TranslationTab( translations: newValues, maxLines: maxLines ) - ), + ),*/ /*Column( children: showValues(newValues), ),*/ @@ -72,6 +85,54 @@ showMultiStringInput (String text, List values, List newValues) { + List translations = []; + ManagerAppContext managerAppContext = appContext.getContext(); + for(var language in managerAppContext.selectedConfiguration.languages) { + translations.add( + Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Container( + width: MediaQuery.of(context).size.width *0.05, + height: MediaQuery.of(context).size.height *0.10, + decoration: BoxDecoration( + border: Border( + right: BorderSide(width: 1.5, color: kSecond), + ), + ), + child: Center(child: AutoSizeText(language.toUpperCase())) + ), + Padding( + padding: const EdgeInsets.only(left: 8.0), + child: Container( + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + TextFormInputContainer( + label: label, + color: kWhite, + isTitle: true, + initialValue: newValues.where((element) => element.language == language).first.value, + onChanged: (value) { + newValues.where((element) => element.language == language).first.value = value; + }, + ), + ], + ), + ), + ) + ], + ), + ) + ); + } + return translations; +} /* showValues(List newValues) { List valuesToShow = new List(); diff --git a/lib/Components/multi_string_input_container.dart b/lib/Components/multi_string_input_container.dart index 53a1a1e..8290f9f 100644 --- a/lib/Components/multi_string_input_container.dart +++ b/lib/Components/multi_string_input_container.dart @@ -9,6 +9,7 @@ import 'package:managerapi/api.dart'; class MultiStringContainer extends StatelessWidget { final Color color; final String label; + final String modalLabel; final List initialValue; final Function onGetResult; final int maxLines; @@ -16,6 +17,7 @@ class MultiStringContainer extends StatelessWidget { Key key, this.color = kSecond, this.label, + this.modalLabel, this.initialValue, this.onGetResult, this.maxLines, @@ -43,7 +45,7 @@ class MultiStringContainer extends StatelessWidget { initialValue.forEach((value) { newValues.add(TranslationDTO.fromJson(jsonDecode(jsonEncode(value)))); }); - showMultiStringInput(label, initialValue, newValues, onGetResult, maxLines, context); + showMultiStringInput(label, modalLabel, initialValue, newValues, onGetResult, maxLines, context); }, child: Container( decoration: BoxDecoration( diff --git a/lib/Components/slider_input_container.dart b/lib/Components/slider_input_container.dart new file mode 100644 index 0000000..bba21bf --- /dev/null +++ b/lib/Components/slider_input_container.dart @@ -0,0 +1,63 @@ +import 'package:flutter/material.dart'; +import 'package:manager_app/Components/rounded_input_field.dart'; +import 'package:manager_app/constants.dart'; + +class SliderInputContainer extends StatefulWidget { + final Color color; + final String label; + final double initialValue; + final int min; + final int max; + final ValueChanged onChanged; + const SliderInputContainer({ + Key key, + this.color = kSecond, + this.label, + this.initialValue, + this.min, + this.max, + this.onChanged, + }) : super(key: key); + + @override + _SliderInputContainerState createState() => _SliderInputContainerState(); +} + +class _SliderInputContainerState extends State { + double currentValue; + + @override + void initState() { + super.initState(); + currentValue = widget.initialValue; + } + + @override + Widget build(BuildContext context) { + return Container( + child: Row( + children: [ + Align( + alignment: AlignmentDirectional.centerStart, + child: Text(widget.label, style: TextStyle(fontSize: 25, fontWeight: FontWeight.w300)) + ), + Padding( + padding: const EdgeInsets.all(10.0), + child: Slider( + value: currentValue, + onChanged: (value) { + setState(() => currentValue = value); + widget.onChanged(value); + }, + divisions: widget.max - widget.min, + min: widget.min.toDouble(), + max: widget.max.toDouble(), + label: "$currentValue", + activeColor: widget.color, + ), + ), + ], + ), + ); + } +} \ No newline at end of file diff --git a/lib/Screens/Configurations/Section/SubSection/listViewcard.dart b/lib/Screens/Configurations/Section/SubSection/listViewcard.dart index a286357..1cd3e95 100644 --- a/lib/Screens/Configurations/Section/SubSection/listViewcard.dart +++ b/lib/Screens/Configurations/Section/SubSection/listViewcard.dart @@ -117,7 +117,7 @@ class _ListViewCard extends State { boxDecoration(ImageDTO imageDTO, appContext) { return BoxDecoration( - color: imageDTO.title == null ? Colors.lightGreen : kBackgroundColor, + color: kBackgroundColor, shape: BoxShape.rectangle, border: Border.all(width: 1.5, color: kSecond), borderRadius: BorderRadius.circular(10.0), diff --git a/lib/Screens/Configurations/Section/SubSection/map_config.dart b/lib/Screens/Configurations/Section/SubSection/map_config.dart index e69de29..2cf9a83 100644 --- a/lib/Screens/Configurations/Section/SubSection/map_config.dart +++ b/lib/Screens/Configurations/Section/SubSection/map_config.dart @@ -0,0 +1,269 @@ +import 'package:auto_size_text/auto_size_text.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:manager_app/Components/fetch_section_icon.dart'; +import 'package:manager_app/Components/image_input_container.dart'; +import 'package:manager_app/Components/multi_select_container.dart'; +import 'package:manager_app/Components/slider_input_container.dart'; +import 'package:manager_app/Screens/Configurations/Section/SubSection/showNewOrUpdateGeoPoint.dart'; +import 'package:manager_app/app_context.dart'; +import 'package:manager_app/constants.dart'; +import 'package:managerapi/api.dart'; +import 'dart:convert'; + +import 'package:provider/provider.dart'; + +class MapConfig extends StatefulWidget { + final String color; + final String label; + final String initialValue; + final ValueChanged onChanged; + const MapConfig({ + Key key, + this.color, + this.label, + this.initialValue, + this.onChanged, + }) : super(key: key); + + @override + _MapConfigState createState() => _MapConfigState(); +} + +class _MapConfigState extends State { + MapDTO mapDTO; + + @override + void initState() { + super.initState(); + + mapDTO = MapDTO.fromJson(json.decode(widget.initialValue)); + List test = new List.from(mapDTO.points); + mapDTO.points = test; + } + + @override + Widget build(BuildContext context) { + final appContext = Provider.of(context); + Size size = MediaQuery.of(context).size; + + return + SingleChildScrollView( + child: Column( + children: [ + Container( + height: size.height * 0.15, + width: double.infinity, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + // Icon + ImageInputContainer( + label: "Icône:", + initialValue: mapDTO.iconResourceId, + color: kPrimaryColor, + imageFit: BoxFit.contain, + onChanged: (ResourceDTO resource) { + mapDTO.iconSource = resource.type == ResourceType.imageUrl ? resource.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id; + mapDTO.iconResourceId = resource.id; + widget.onChanged(jsonEncode(mapDTO).toString()); + }, + ), + // Map Type + MultiSelectContainer( + label: "Type :", + initialValue: [mapDTO.mapType.toString()], + isMultiple: false, + values: map_types, + onChanged: (value) { + var tempOutput = new List.from(value); + mapDTO.mapType = MapType.fromJson(tempOutput[0]); + widget.onChanged(jsonEncode(mapDTO).toString()); + }, + ), + // Zoom + SliderInputContainer( + label: "Zoom:", + initialValue: mapDTO.zoom != null ? mapDTO.zoom.toDouble() : 18, + color: kPrimaryColor, + min: 0, + max: 30, + onChanged: (double value) { + mapDTO.zoom = value.toInt(); + widget.onChanged(jsonEncode(mapDTO).toString()); + }, + ) + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(25), + border: Border.all(width: 1.5, color: kSecond) + ), + child: Stack( + children: [ + Padding( + padding: const EdgeInsets.only(top: 40, left: 10, right: 10, bottom: 10), + child: GridView.builder( + shrinkWrap: true, + gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 8), + itemCount: mapDTO.points.length, + itemBuilder: (BuildContext context, int index) { + return + Container( + decoration: boxDecoration(mapDTO.points[index], appContext), + padding: const EdgeInsets.all(5), + margin: EdgeInsets.symmetric(vertical: 10, horizontal: 10), + child: getElement(index, mapDTO.points[index], size, appContext), + ); + } + ), + ), + Positioned( + top: 10, + left: 10, + child: Text( + "Points géographiques", + style: TextStyle(fontSize: 15), + ), + ), + Positioned( + bottom: 10, + right: 10, + child: InkWell( + onTap: () { + showNewOrUpdateGeoPoint( + null, + (GeoPointDTO geoPoint) { + setState(() { + mapDTO.points.add(geoPoint); + widget.onChanged(jsonEncode(mapDTO).toString()); + }); + }, + appContext, + context); + }, + child: Container( + height: MediaQuery.of(context).size.width * 0.04, + width: MediaQuery.of(context).size.width * 0.04, + child: Icon( + Icons.add, + color: kTextLightColor, + size: 30.0, + ), + decoration: BoxDecoration( + color: Colors.lightGreen, + shape: BoxShape.rectangle, + borderRadius: BorderRadius.circular(20.0), + boxShadow: [ + BoxShadow( + color: kSecond, + spreadRadius: 0.5, + blurRadius: 5, + offset: Offset(0, 1.5), // changes position of shadow + ), + ], + ), + ), + ), + ) + ]), + ), + ), + ], + ), + ); + } + + getElement(int index, GeoPointDTO point, Size size, AppContext appContext) { + return Container( + width: double.infinity, + height: double.infinity, + child: Stack( + children: [ + Center( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: AutoSizeText( + point.title == null ? "" : point.title[0].value, + style: new TextStyle(fontSize: 20), + maxLines: 2, + textAlign: TextAlign.center, + ), + ), + ), + Positioned( + top: 0, + right: 0, + child: Icon( + getSectionIcon(SectionType.map), + color: kSecond, + size: 18.0, + ), + ), + Positioned( + bottom: 0, + left: 0, + child: InkWell( + onTap: () { + showNewOrUpdateGeoPoint( + mapDTO.points[index], + (GeoPointDTO geoPoint) { + setState(() { + mapDTO.points[index] = geoPoint; + widget.onChanged(jsonEncode(mapDTO).toString()); + }); + }, + appContext, + context); + }, + child: Icon( + Icons.edit, + color: kPrimaryColor, + size: 20.0, + ) + ), + ), + Positioned( + bottom: 0, + right: 0, + child: InkWell( + onTap: () { + setState(() { + mapDTO.points.removeAt(index); + }); + widget.onChanged(jsonEncode(mapDTO).toString()); + }, + child: Icon( + Icons.delete, + color: kPrimaryColor, + size: 20.0, + ) + ), + ) + ], + ), + ); + } +} + + +boxDecoration(GeoPointDTO geoPointDTO, appContext) { + return BoxDecoration( + color: geoPointDTO.title == null ? Colors.lightGreen : kBackgroundColor, + shape: BoxShape.rectangle, + border: Border.all(width: 1.5, color: kSecond), + borderRadius: BorderRadius.circular(10.0), + boxShadow: [ + BoxShadow( + color: kSecond, + spreadRadius: 0.5, + blurRadius: 5, + offset: Offset(0, 1.5), // changes position of shadow + ), + ], + ); +} \ No newline at end of file diff --git a/lib/Screens/Configurations/Section/SubSection/showNewOrUpdateGeoPoint.dart b/lib/Screens/Configurations/Section/SubSection/showNewOrUpdateGeoPoint.dart new file mode 100644 index 0000000..7a186ae --- /dev/null +++ b/lib/Screens/Configurations/Section/SubSection/showNewOrUpdateGeoPoint.dart @@ -0,0 +1,194 @@ +import 'package:auto_size_text/auto_size_text.dart'; +import 'package:manager_app/Components/image_input_container.dart'; +import 'package:flutter/material.dart'; +import 'package:manager_app/Components/rounded_button.dart'; +import 'package:manager_app/Components/string_input_container.dart'; +import 'package:manager_app/Components/text_form_input_container.dart'; +import 'package:manager_app/Models/managerContext.dart'; +import 'package:manager_app/app_context.dart'; +import 'package:manager_app/constants.dart'; +import 'package:managerapi/api.dart'; + +void showNewOrUpdateGeoPoint(GeoPointDTO inputGeoPointDTO, Function getResult, AppContext appContext, BuildContext context) { + GeoPointDTO geoPointDTO = new GeoPointDTO(); + + print("showNewOrUpdateGeoPoint"); + print(inputGeoPointDTO); + if (inputGeoPointDTO != null) { + geoPointDTO = inputGeoPointDTO; + } else { + geoPointDTO.title = []; + geoPointDTO.description = []; + + ManagerAppContext managerAppContext = appContext.getContext(); + managerAppContext.selectedConfiguration.languages.forEach((element) { + var translationDTO = new TranslationDTO(); + translationDTO.language = element; + translationDTO.value = ""; + geoPointDTO.title.add(translationDTO); + geoPointDTO.description.add(translationDTO); + }); + } + + Size size = MediaQuery.of(context).size; + showDialog( + builder: (BuildContext context) => AlertDialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(20.0)) + ), + content: Container( + width: size.width *0.5, + child: SingleChildScrollView( + child: Column( + children: [ + Text("Point géographique", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)), + Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + ImageInputContainer( + label: "Image :", + initialValue: geoPointDTO.imageResourceId, + color: kPrimaryColor, + onChanged: (ResourceDTO resource) { + geoPointDTO.imageSource = resource.type == ResourceType.imageUrl ? resource.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id; + geoPointDTO.imageResourceId = resource.id; + }, + ), + Column( + children: [ + StringInputContainer( + label: "Latitude :", + initialValue: geoPointDTO.latitude, + onChanged: (value) { + geoPointDTO.latitude = value; + }, + ), + StringInputContainer( + label: "Longitude :", + initialValue: geoPointDTO.longitude, + onChanged: (value) { + geoPointDTO.longitude = value; + }, + ) + ], + ) + ], + ), + Container( + child: SingleChildScrollView( + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: getTranslations(context, appContext, geoPointDTO), + ), + ), + ), + ], + ), + ], + ), + ), + ), + actions: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Align( + alignment: AlignmentDirectional.bottomEnd, + child: Container( + width: 175, + height: 70, + child: RoundedButton( + text: "Annuler", + icon: Icons.undo, + color: kSecond, + press: () { + Navigator.of(context).pop(); + }, + fontSize: 20, + ), + ), + ), + Align( + alignment: AlignmentDirectional.bottomEnd, + child: Container( + width: geoPointDTO != null ? 220: 150, + height: 70, + child: RoundedButton( + text: geoPointDTO != null ? "Sauvegarder" : "Créer", + icon: Icons.check, + color: kPrimaryColor, + textColor: kWhite, + press: () { + getResult(geoPointDTO); + Navigator.of(context).pop(); + }, + fontSize: 20, + ), + ), + ), + ], + ), + ], + ), context: context + ); +} + +getTranslations(BuildContext context, AppContext appContext, GeoPointDTO geoPointDTO) { + List translations = []; + ManagerAppContext managerAppContext = appContext.getContext(); + for(var language in managerAppContext.selectedConfiguration.languages) { + translations.add( + Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Container( + width: MediaQuery.of(context).size.width *0.05, + height: MediaQuery.of(context).size.height *0.2, + decoration: BoxDecoration( + border: Border( + right: BorderSide(width: 1.5, color: kSecond), + ), + ), + child: Center(child: AutoSizeText(language.toUpperCase())) + ), + Padding( + padding: const EdgeInsets.only(left: 8.0), + child: Container( + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + TextFormInputContainer( + label: "Titre:", + color: kWhite, + isTitle: true, + initialValue: geoPointDTO.title.where((element) => element.language == language).first.value, + onChanged: (value) { + geoPointDTO.title.where((element) => element.language == language).first.value = value; + }, + ), + TextFormInputContainer( + label: "Description:", + color: kWhite, + isTitle: false, + initialValue: geoPointDTO.description.where((element) => element.language == language).first.value, + onChanged: (value) { + geoPointDTO.description.where((element) => element.language == language).first.value = value; + }, + ), + ], + ), + ), + ) + ], + ), + ) + ); + } + return translations; +} + diff --git a/lib/Screens/Configurations/Section/SubSection/slider_config.dart b/lib/Screens/Configurations/Section/SubSection/slider_config.dart index 69e7a5e..2cb89fe 100644 --- a/lib/Screens/Configurations/Section/SubSection/slider_config.dart +++ b/lib/Screens/Configurations/Section/SubSection/slider_config.dart @@ -1,7 +1,3 @@ -import 'package:auto_size_text/auto_size_text.dart'; -import 'package:drag_and_drop_lists/drag_and_drop_item.dart'; -import 'package:drag_and_drop_lists/drag_and_drop_list.dart'; -import 'package:drag_and_drop_lists/drag_and_drop_lists.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:manager_app/Screens/Configurations/Section/SubSection/listViewcard.dart'; diff --git a/lib/Screens/Configurations/Section/section_detail_screen.dart b/lib/Screens/Configurations/Section/section_detail_screen.dart index e4e42d6..7cf183c 100644 --- a/lib/Screens/Configurations/Section/section_detail_screen.dart +++ b/lib/Screens/Configurations/Section/section_detail_screen.dart @@ -17,6 +17,8 @@ import 'package:managerapi/api.dart'; import 'package:provider/provider.dart'; import 'package:intl/intl.dart'; +import 'SubSection/map_config.dart'; + class SectionDetailScreen extends StatefulWidget { final String id; SectionDetailScreen({Key key, @required this.id}) : super(key: key); @@ -67,7 +69,6 @@ class _SectionDetailScreenState extends State { Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ - Text(sectionDTO.label, style: TextStyle(fontSize: 30, fontWeight: FontWeight.w400)), Padding( padding: const EdgeInsets.all(8.0), child: Icon( @@ -75,7 +76,8 @@ class _SectionDetailScreenState extends State { color: kPrimaryColor, size: 25, ), - ) + ), + Text(sectionDTO.label, style: TextStyle(fontSize: 30, fontWeight: FontWeight.w400)), ], ), Padding( @@ -110,6 +112,8 @@ class _SectionDetailScreenState extends State { ), ), // TITLE Container( + /*height: size.height*0.4, + color: Colors.lightBlue,*/ child: Padding( padding: const EdgeInsets.all(10.0), child: Container( @@ -132,17 +136,6 @@ class _SectionDetailScreenState extends State { sectionDTO.label = value; }, ), - MultiSelectContainer( - label: "Type :", - initialValue: [sectionDTO.type.toString()], - isMultiple: false, - values: section_types, - onChanged: (value) { - var tempOutput = new List.from(value); - sectionDTO.type = SectionType.fromJson(tempOutput[0]); - }, - ), - ImageInputContainer( label: "Image :", initialValue: sectionDTO.imageId, @@ -160,6 +153,7 @@ class _SectionDetailScreenState extends State { children: [ MultiStringContainer( label: "Titre :", + modalLabel: "Titre", color: kPrimaryColor, initialValue: sectionDTO.title, onGetResult: (value) { @@ -172,6 +166,7 @@ class _SectionDetailScreenState extends State { ), MultiStringContainer( label: "Description :", + modalLabel: "Description", color: kPrimaryColor, initialValue: sectionDTO.description, onGetResult: (value) { @@ -193,7 +188,7 @@ class _SectionDetailScreenState extends State { ), ),// FIELDS SECTION Container( - height: size.height * 0.4, + height: size.height * 0.45, width: size.width * 0.8, child: Padding( padding: const EdgeInsets.all(10.0), @@ -298,7 +293,14 @@ class _SectionDetailScreenState extends State { getSpecificData(SectionDTO sectionDTO, AppContext appContext) { switch(sectionDTO.type) { case SectionType.map: - return Text("map"); + return MapConfig( + initialValue: sectionDTO.data, + onChanged: (String data) { + print("Received info in parent"); + print(data); + sectionDTO.data = data; + }, + ); case SectionType.slider: return SliderConfig( initialValue: sectionDTO.data, diff --git a/lib/Screens/Configurations/configurations_screen.dart b/lib/Screens/Configurations/configurations_screen.dart index 7286cb8..0857bb9 100644 --- a/lib/Screens/Configurations/configurations_screen.dart +++ b/lib/Screens/Configurations/configurations_screen.dart @@ -35,23 +35,19 @@ class _ConfigurationsScreenState extends State { return ConfigurationDetailScreen(id: managerAppContext.selectedConfiguration.id); } else { return Container( - child: Column( - children: [ - FutureBuilder( - future: getConfigurations(appContext), - builder: (context, AsyncSnapshot snapshot) { - if (snapshot.connectionState == ConnectionState.done) { - var tempOutput = new List.from(snapshot.data); - tempOutput.add(ConfigurationDTO(id: null)); - return bodyGrid(tempOutput, size, appContext); - } else if (snapshot.connectionState == ConnectionState.none) { - return Text("No data"); - } else { - return Center(child: Container(height: size.height * 0.2, child: Text('LOADING TODO FRAISE'))); - } - } - ), - ] + child: FutureBuilder( + future: getConfigurations(appContext), + builder: (context, AsyncSnapshot snapshot) { + if (snapshot.connectionState == ConnectionState.done) { + var tempOutput = new List.from(snapshot.data); + tempOutput.add(ConfigurationDTO(id: null)); + return bodyGrid(tempOutput, size, appContext); + } else if (snapshot.connectionState == ConnectionState.none) { + return Text("No data"); + } else { + return Center(child: Container(height: size.height * 0.2, child: Text('LOADING TODO FRAISE'))); + } + } ), ); } diff --git a/lib/Screens/Resources/resources_screen.dart b/lib/Screens/Resources/resources_screen.dart index fd98205..fcb8e54 100644 --- a/lib/Screens/Resources/resources_screen.dart +++ b/lib/Screens/Resources/resources_screen.dart @@ -29,23 +29,19 @@ class _ResourcesScreenState extends State { Size size = MediaQuery.of(context).size; return Container( - child: Column( - children: [ - FutureBuilder( - future: getResources(widget.onGetResult, widget.isImage, appContext), - builder: (context, AsyncSnapshot snapshot) { - if (snapshot.connectionState == ConnectionState.done) { - var tempOutput = new List.from(snapshot.data); - tempOutput.add(ResourceDTO(id: null)); - return bodyGrid(tempOutput, size, appContext); - } else if (snapshot.connectionState == ConnectionState.none) { - return Text("No data"); - } else { - return Center(child: Container(height: size.height * 0.2, child: Text('LOADING TODO FRAISE'))); - } - } - ), - ] + child: FutureBuilder( + future: getResources(widget.onGetResult, widget.isImage, appContext), + builder: (context, AsyncSnapshot snapshot) { + if (snapshot.connectionState == ConnectionState.done) { + var tempOutput = new List.from(snapshot.data); + tempOutput.add(ResourceDTO(id: null)); + return bodyGrid(tempOutput, size, appContext); + } else if (snapshot.connectionState == ConnectionState.none) { + return Text("No data"); + } else { + return Center(child: Container(height: size.height * 0.2, child: Text('LOADING TODO FRAISE'))); + } + } ), ); } diff --git a/lib/constants.dart b/lib/constants.dart index db0aaab..dd5a5fd 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -5,7 +5,6 @@ import 'package:flutter/material.dart'; const kTitleTextColor = Color(0xFF303030); const kBodyTextColor = Color(0xFF4B4B4B); // TODO - const kBackgroundColor = Color(0xFFf5f5f7); const kPrimaryColor = Color(0xFFCA413F); const kTextLightColor = Color(0xFFFCFDFD); @@ -14,6 +13,7 @@ const kWhite = Color(0xFFFFFFFF); const kBlack = Color(0xFF000000); const List section_types = ["Map", "Slider", "Video", "Web", "Menu"]; +const List map_types = ["none", "normal", "satellite", "terrain", "hybrid"]; /* const kTextStyle = TextStyle( diff --git a/manager_api/doc/GeoPointDTO.md b/manager_api/doc/GeoPointDTO.md index 115600a..d20baca 100644 --- a/manager_api/doc/GeoPointDTO.md +++ b/manager_api/doc/GeoPointDTO.md @@ -11,9 +11,8 @@ Name | Type | Description | Notes **id** | **int** | | [optional] **title** | [**List**](TranslationDTO.md) | | [optional] [default to const []] **description** | [**List**](TranslationDTO.md) | | [optional] [default to const []] -**image** | **String** | | [optional] -**imageType** | **String** | | [optional] -**text** | [**List**](TranslationDTO.md) | | [optional] [default to const []] +**imageResourceId** | **String** | | [optional] +**imageSource** | **String** | | [optional] **latitude** | **String** | | [optional] **longitude** | **String** | | [optional] diff --git a/manager_api/doc/MapDTO.md b/manager_api/doc/MapDTO.md index 6a09f34..107bd50 100644 --- a/manager_api/doc/MapDTO.md +++ b/manager_api/doc/MapDTO.md @@ -11,7 +11,8 @@ Name | Type | Description | Notes **zoom** | **int** | | [optional] **mapType** | [**MapType**](MapType.md) | | [optional] **points** | [**List**](GeoPointDTO.md) | | [optional] [default to const []] -**icon** | **String** | | [optional] +**iconResourceId** | **String** | | [optional] +**iconSource** | **String** | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/manager_api/lib/model/geo_point_dto.dart b/manager_api/lib/model/geo_point_dto.dart index 985e070..88f69cf 100644 --- a/manager_api/lib/model/geo_point_dto.dart +++ b/manager_api/lib/model/geo_point_dto.dart @@ -15,9 +15,8 @@ class GeoPointDTO { this.id, this.title, this.description, - this.image, - this.imageType, - this.text, + this.imageResourceId, + this.imageSource, this.latitude, this.longitude, }); @@ -28,11 +27,9 @@ class GeoPointDTO { List description; - String image; + String imageResourceId; - String imageType; - - List text; + String imageSource; String latitude; @@ -43,9 +40,8 @@ class GeoPointDTO { other.id == id && other.title == title && other.description == description && - other.image == image && - other.imageType == imageType && - other.text == text && + other.imageResourceId == imageResourceId && + other.imageSource == imageSource && other.latitude == latitude && other.longitude == longitude; @@ -54,14 +50,13 @@ class GeoPointDTO { (id == null ? 0 : id.hashCode) + (title == null ? 0 : title.hashCode) + (description == null ? 0 : description.hashCode) + - (image == null ? 0 : image.hashCode) + - (imageType == null ? 0 : imageType.hashCode) + - (text == null ? 0 : text.hashCode) + + (imageResourceId == null ? 0 : imageResourceId.hashCode) + + (imageSource == null ? 0 : imageSource.hashCode) + (latitude == null ? 0 : latitude.hashCode) + (longitude == null ? 0 : longitude.hashCode); @override - String toString() => 'GeoPointDTO[id=$id, title=$title, description=$description, image=$image, imageType=$imageType, text=$text, latitude=$latitude, longitude=$longitude]'; + String toString() => 'GeoPointDTO[id=$id, title=$title, description=$description, imageResourceId=$imageResourceId, imageSource=$imageSource, latitude=$latitude, longitude=$longitude]'; Map toJson() { final json = {}; @@ -74,14 +69,11 @@ class GeoPointDTO { if (description != null) { json[r'description'] = description; } - if (image != null) { - json[r'image'] = image; + if (imageResourceId != null) { + json[r'imageResourceId'] = imageResourceId; } - if (imageType != null) { - json[r'imageType'] = imageType; - } - if (text != null) { - json[r'text'] = text; + if (imageSource != null) { + json[r'imageSource'] = imageSource; } if (latitude != null) { json[r'latitude'] = latitude; @@ -100,9 +92,8 @@ class GeoPointDTO { id: json[r'id'], title: TranslationDTO.listFromJson(json[r'title']), description: TranslationDTO.listFromJson(json[r'description']), - image: json[r'image'], - imageType: json[r'imageType'], - text: TranslationDTO.listFromJson(json[r'text']), + imageResourceId: json[r'imageResourceId'], + imageSource: json[r'imageSource'], latitude: json[r'latitude'], longitude: json[r'longitude'], ); diff --git a/manager_api/lib/model/map_dto.dart b/manager_api/lib/model/map_dto.dart index ed2c20e..40c624c 100644 --- a/manager_api/lib/model/map_dto.dart +++ b/manager_api/lib/model/map_dto.dart @@ -15,7 +15,8 @@ class MapDTO { this.zoom, this.mapType, this.points, - this.icon, + this.iconResourceId, + this.iconSource, }); int zoom; @@ -24,24 +25,28 @@ class MapDTO { List points; - String icon; + String iconResourceId; + + String iconSource; @override bool operator ==(Object other) => identical(this, other) || other is MapDTO && other.zoom == zoom && other.mapType == mapType && other.points == points && - other.icon == icon; + other.iconResourceId == iconResourceId && + other.iconSource == iconSource; @override int get hashCode => (zoom == null ? 0 : zoom.hashCode) + (mapType == null ? 0 : mapType.hashCode) + (points == null ? 0 : points.hashCode) + - (icon == null ? 0 : icon.hashCode); + (iconResourceId == null ? 0 : iconResourceId.hashCode) + + (iconSource == null ? 0 : iconSource.hashCode); @override - String toString() => 'MapDTO[zoom=$zoom, mapType=$mapType, points=$points, icon=$icon]'; + String toString() => 'MapDTO[zoom=$zoom, mapType=$mapType, points=$points, iconResourceId=$iconResourceId, iconSource=$iconSource]'; Map toJson() { final json = {}; @@ -54,8 +59,11 @@ class MapDTO { if (points != null) { json[r'points'] = points; } - if (icon != null) { - json[r'icon'] = icon; + if (iconResourceId != null) { + json[r'iconResourceId'] = iconResourceId; + } + if (iconSource != null) { + json[r'iconSource'] = iconSource; } return json; } @@ -68,7 +76,8 @@ class MapDTO { zoom: json[r'zoom'], mapType: MapType.fromJson(json[r'mapType']), points: GeoPointDTO.listFromJson(json[r'points']), - icon: json[r'icon'], + iconResourceId: json[r'iconResourceId'], + iconSource: json[r'iconSource'], ); static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => diff --git a/manager_api/swagger.yaml b/manager_api/swagger.yaml index 01e30c1..686a8f4 100644 --- a/manager_api/swagger.yaml +++ b/manager_api/swagger.yaml @@ -1375,7 +1375,10 @@ components: nullable: true items: $ref: '#/components/schemas/GeoPointDTO' - icon: + iconResourceId: + type: string + nullable: true + iconSource: type: string nullable: true MapType: @@ -1410,17 +1413,12 @@ components: nullable: true items: $ref: '#/components/schemas/TranslationDTO' - image: + imageResourceId: type: string nullable: true - imageType: + imageSource: type: string nullable: true - text: - type: array - nullable: true - items: - $ref: '#/components/schemas/TranslationDTO' latitude: type: string nullable: true