From a646adc550d64749171b9a80f350f96f3504264d Mon Sep 17 00:00:00 2001 From: Thomas Fransolet Date: Wed, 27 Dec 2023 18:11:25 +0100 Subject: [PATCH] update service generation + Update Quiz + Puzzle + Map --- lib/Components/category_input_container.dart | 148 ++++++++++ lib/Components/dropDown_input_container.dart | 83 ++++++ ...i_string_input_and_resource_container.dart | 97 +++++++ .../multi_string_input_html_modal.dart | 73 ++++- lib/Components/resource_input_container.dart | 10 +- ...nslation_input_and_resource_container.dart | 230 ++++++++++++++++ .../translation_input_container.dart | 2 +- .../Section/SubSection/Map/category_list.dart | 253 ++++++++++++++++++ .../Section/SubSection/Map/map_config.dart | 53 ++-- .../SubSection/Map/new_update_categorie.dart | 155 +++++++++++ .../Map/showNewOrUpdateGeoPoint.dart | 23 +- .../SubSection/Puzzle/puzzle_config.dart | 11 +- .../Quizz/new_update_question_quizz.dart | 24 +- ...w_update_response_quizz - deprecated.dart} | 35 +-- ... new_update_score_quizz - deprecated.dart} | 57 ++-- .../SubSection/Quizz/quizz_answer_list.dart | 120 +++++---- .../SubSection/Quizz/quizz_config.dart | 116 +++++--- .../configuration_detail_screen.dart | 16 +- lib/Screens/Main/main_screen.dart | 2 - lib/api/swagger.yaml | 66 +++-- manager_api_new/.openapi-generator/FILES | 2 + manager_api_new/README.md | 1 + manager_api_new/doc/CategorieDTO.md | 5 +- manager_api_new/doc/GeoPointDTOCategorie.md | 5 +- manager_api_new/doc/LevelDTO.md | 5 +- manager_api_new/doc/PuzzleDTO.md | 4 +- manager_api_new/doc/QuestionDTO.md | 8 +- manager_api_new/doc/QuizzDTOBadLevel.md | 5 +- manager_api_new/doc/ResponseDTO.md | 5 +- .../doc/TranslationAndResourceDTO.md | 19 ++ manager_api_new/lib/api.dart | 1 + manager_api_new/lib/api_client.dart | 2 + manager_api_new/lib/model/categorie_dto.dart | 55 +++- manager_api_new/lib/model/geo_point_dto.dart | 4 +- .../lib/model/geo_point_dto_categorie.dart | 55 +++- manager_api_new/lib/model/level_dto.dart | 49 +--- manager_api_new/lib/model/puzzle_dto.dart | 8 +- manager_api_new/lib/model/question_dto.dart | 54 ++-- .../lib/model/quizz_dto_bad_level.dart | 49 +--- manager_api_new/lib/model/response_dto.dart | 45 +--- .../model/translation_and_resource_dto.dart | 162 +++++++++++ .../translation_and_resource_dto_test.dart | 47 ++++ 42 files changed, 1746 insertions(+), 418 deletions(-) create mode 100644 lib/Components/category_input_container.dart create mode 100644 lib/Components/dropDown_input_container.dart create mode 100644 lib/Components/multi_string_input_and_resource_container.dart create mode 100644 lib/Components/translation_input_and_resource_container.dart create mode 100644 lib/Screens/Configurations/Section/SubSection/Map/category_list.dart create mode 100644 lib/Screens/Configurations/Section/SubSection/Map/new_update_categorie.dart rename lib/Screens/Configurations/Section/SubSection/Quizz/{new_update_response_quizz.dart => new_update_response_quizz - deprecated.dart} (79%) rename lib/Screens/Configurations/Section/SubSection/Quizz/{new_update_score_quizz.dart => new_update_score_quizz - deprecated.dart} (75%) create mode 100644 manager_api_new/doc/TranslationAndResourceDTO.md create mode 100644 manager_api_new/lib/model/translation_and_resource_dto.dart create mode 100644 manager_api_new/test/translation_and_resource_dto_test.dart diff --git a/lib/Components/category_input_container.dart b/lib/Components/category_input_container.dart new file mode 100644 index 0000000..5ae87ac --- /dev/null +++ b/lib/Components/category_input_container.dart @@ -0,0 +1,148 @@ +import 'package:auto_size_text/auto_size_text.dart'; +import 'package:collection/collection.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/Components/rounded_button.dart'; +import 'package:manager_app/Screens/Configurations/Section/SubSection/Map/category_list.dart'; +import 'package:manager_app/app_context.dart'; +import 'package:manager_app/constants.dart'; + +class CategoryInputContainer extends StatefulWidget { + final Color color; + final String label; + final List initialValue; + final ValueChanged> onChanged; + const CategoryInputContainer({ + Key? key, + this.color = kSecond, + required this.label, + required this.initialValue, + required this.onChanged, + }) : super(key: key); + + @override + _CategoryInputContainerState createState() => _CategoryInputContainerState(); +} + +class _CategoryInputContainerState extends State { + + @override + void initState() { + super.initState(); + } + + @override + Widget build(BuildContext context) { + Size size = MediaQuery.of(context).size; + + 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(8.0), + child: Container( + width: size.width *0.15, + child: InkWell( + onTap: () { + List newValues = []; + List initials = widget.initialValue; + showCreateOrUpdateCategories("Catégories", initials, newValues, (value) { + widget.onChanged(value); + }, context); + }, + child: Container( + decoration: BoxDecoration( + color: kPrimaryColor, + borderRadius: BorderRadius.circular(50), + ), + child: Padding( + padding: const EdgeInsets.only(left: 5, right: 5, top: 15, bottom: 15), + child: Center( + child: AutoSizeText( + "Changer", + style: TextStyle(color: kWhite), + maxLines: 2, + ) + ), + ) + ), + ), + ), + ), + ], + ), + ); + } +} + +showCreateOrUpdateCategories(String modalLabel, List values, List newValues, Function onGetResult, BuildContext context) { + showDialog( + builder: (BuildContext context) { + Size size = MediaQuery.of(context).size; + return AlertDialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(20.0)) + ), + title: Center(child: Text(modalLabel)), + content: SingleChildScrollView( + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + border: Border.all(width: 0.75, color: kSecond) + ), + height: size.height * 0.7, + width: size.width * 0.65, + child: CategoryList(categories: values, onChanged: (result) { + newValues = result; + onGetResult(result); + }), + ) + ), + actions: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Container( + width: 180, + height: 70, + child: RoundedButton( + text: "Annuler", + icon: Icons.undo, + color: kSecond, + press: () { + onGetResult(values); + Navigator.of(context).pop(); + }, + fontSize: 20, + ), + ), + Container( + width: 180, + height: 70, + child: RoundedButton( + text: "Valider", + icon: Icons.check, + color: kPrimaryColor, + textColor: kWhite, + press: () { + /*Function deepEq = const DeepCollectionEquality().equals; + if (!deepEq(values, newValues)) { + onGetResult(newValues); + }*/ + Navigator.of(context).pop(); + }, + fontSize: 20, + ), + ), + ], + ), + ], + ); + }, context: context + ); +} \ No newline at end of file diff --git a/lib/Components/dropDown_input_container.dart b/lib/Components/dropDown_input_container.dart new file mode 100644 index 0000000..e528bba --- /dev/null +++ b/lib/Components/dropDown_input_container.dart @@ -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 DropDownInputContainer extends StatefulWidget { + final String label; + final List categories; + final CategorieDTO? initialValue; + final ValueChanged? onChange; + const DropDownInputContainer({ + Key? key, + required this.label, + required this.categories, + required this.initialValue, + this.onChange, + }) : super(key: key); + + @override + _DropDownInputContainerState createState() => _DropDownInputContainerState(); +} + +class _DropDownInputContainerState extends State { + List categoriesToShow = []; + CategorieDTO? selectedCategorieDTO; + + @override + void initState() { + if(widget.initialValue != null) { + selectedCategorieDTO = widget.categories.firstWhere((element) => element.order == widget.initialValue!.order); + } + List 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(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( + 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>((CategorieDTO value) { + return DropdownMenuItem( + value: value, + child: HtmlWidget( + value.label == null ? "" : value.label![0].value!, + textStyle: TextStyle(fontSize: 15, color: Colors.black, fontWeight: FontWeight.w400) + ), + ); + }).toList(), + ), + ), + ], + ); + } + +} \ No newline at end of file diff --git a/lib/Components/multi_string_input_and_resource_container.dart b/lib/Components/multi_string_input_and_resource_container.dart new file mode 100644 index 0000000..2491ceb --- /dev/null +++ b/lib/Components/multi_string_input_and_resource_container.dart @@ -0,0 +1,97 @@ +import 'dart:convert'; + +import 'package:auto_size_text/auto_size_text.dart'; +import 'package:flutter/material.dart'; +import 'package:manager_app/Components/multi_input_modal.dart'; +import 'package:manager_app/Components/multi_string_input_html_modal.dart'; +import 'package:manager_app/constants.dart'; +import 'package:manager_api_new/api.dart'; + +class MultiStringInputAndResourceContainer extends StatelessWidget { + final Color color; + final String label; + final String modalLabel; + final List initialValue; + final Function onGetResult; + final int maxLines; + final bool isTitle; + final bool isAudio; + final double fontSize; + const MultiStringInputAndResourceContainer({ + Key? key, + this.color = kSecond, + required this.label, + required this.modalLabel, + required this.initialValue, + required this.onGetResult, + required this.maxLines, + required this.isTitle, + this.isAudio = false, + this.fontSize = 25, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + + Size size = MediaQuery.of(context).size; + return Container( + child: Row( + children: [ + Align( + alignment: AlignmentDirectional.centerStart, + child: AutoSizeText( + label, + style: TextStyle(fontSize: fontSize, fontWeight: FontWeight.w300), + maxLines: 2, + maxFontSize: fontSize, + textAlign: TextAlign.center, + ) + ), + Padding( + padding: const EdgeInsets.all(10.0), + child: Container( + width: size.width *0.15, + child: InkWell( + onTap: () { + List newValues = []; + + List initials = initialValue; + if(initials == null) { + initials = []; + } + + languages.forEach((value) { + if(initials.map((iv) => iv.language).contains(value)) { + newValues.add(TranslationAndResourceDTO.fromJson(jsonDecode(jsonEncode(initials.firstWhere((element) => element.language == value)))!)!); + } else { + // New language + newValues.add(TranslationAndResourceDTO(language: value, value: "", resourceType: null, resourceId: null, resourceUrl: null)); + } + }); + + showMultiStringInputAndResourceHTML(label, modalLabel, isTitle, initials, newValues, onGetResult, maxLines, isAudio, context); + }, + child: Container( + decoration: BoxDecoration( + color: color, + borderRadius: BorderRadius.circular(50), + ), + child: Padding( + padding: const EdgeInsets.only(left: 5, right: 5, top: 15, bottom: 15), + child: Center( + child: AutoSizeText( + isAudio ? "Changer audios" : "Changer traductions", + style: TextStyle(color: kWhite), + maxLines: 2, + ) + ), + ) + ), + ), + ), + ), + ], + ), + ); + } +} \ No newline at end of file diff --git a/lib/Components/multi_string_input_html_modal.dart b/lib/Components/multi_string_input_html_modal.dart index 8905509..9c8226c 100644 --- a/lib/Components/multi_string_input_html_modal.dart +++ b/lib/Components/multi_string_input_html_modal.dart @@ -1,6 +1,8 @@ import 'dart:ui'; import 'package:flutter/material.dart'; +import 'package:manager_app/Components/message_notification.dart'; import 'package:manager_app/Components/rounded_button.dart'; +import 'package:manager_app/Components/translation_input_and_resource_container.dart'; import 'package:manager_app/Components/translation_input_container.dart'; import 'package:manager_app/constants.dart'; import 'package:manager_api_new/api.dart'; @@ -46,9 +48,15 @@ showMultiStringInputHTML (String label, String modalLabel, bool isTitle, List label.value == null || label.value!.trim() == "")) { + showNotification(kPrimaryColor, kWhite, "La traduction n'est pas complète", context, null); + } else { + onGetResult(newValues); + Navigator.of(context).pop(); + } + } else { + Navigator.of(context).pop(); } - Navigator.of(context).pop(); }, fontSize: 20, ), @@ -60,3 +68,64 @@ showMultiStringInputHTML (String label, String modalLabel, bool isTitle, List values, List newValues, Function onGetResult, int maxLines, bool isAudio, BuildContext context) { + showDialog( + builder: (BuildContext context) { + return AlertDialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(20.0)) + ), + title: Center(child: Text(modalLabel)), + content: SingleChildScrollView( + child: TranslationInputAndResourceContainer(isTitle: isTitle, values: values, newValues: newValues, onGetResult: onGetResult, maxLines: maxLines, isAudio: isAudio) + ), + actions: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Container( + width: 180, + height: 70, + child: RoundedButton( + text: "Annuler", + icon: Icons.undo, + color: kSecond, + press: () { + onGetResult(values); + Navigator.of(context).pop(); + }, + fontSize: 20, + ), + ), + Container( + width: 180, + height: 70, + child: RoundedButton( + text: "Valider", + icon: Icons.check, + color: kPrimaryColor, + textColor: kWhite, + press: () { + Function deepEq = const DeepCollectionEquality().equals; + if (!deepEq(values, newValues)) { + if(newValues.any((label) => label.value == null || label.value!.trim() == "")) { + showNotification(kPrimaryColor, kWhite, "La traduction n'est pas complète", context, null); + } else { + onGetResult(newValues); + Navigator.of(context).pop(); + } + } else { + Navigator.of(context).pop(); + } + }, + fontSize: 20, + ), + ), + ], + ), + ], + ); + }, context: context + ); +} diff --git a/lib/Components/resource_input_container.dart b/lib/Components/resource_input_container.dart index 4774552..bf92328 100644 --- a/lib/Components/resource_input_container.dart +++ b/lib/Components/resource_input_container.dart @@ -17,6 +17,7 @@ class ResourceInputContainer extends StatefulWidget { final bool isSmall; final double fontSize; final List inResourceTypes; + final bool isLanguageTab; const ResourceInputContainer({ Key? key, this.color = kSecond, @@ -26,7 +27,8 @@ class ResourceInputContainer extends StatefulWidget { this.imageFit = BoxFit.cover, this.isSmall = false, this.fontSize = 25, - this.inResourceTypes = const [ResourceType.Image, ResourceType.ImageUrl] + this.inResourceTypes = const [ResourceType.Image, ResourceType.ImageUrl], + this.isLanguageTab = false }) : super(key: key); @override @@ -44,7 +46,10 @@ class _ResourceInputContainerState extends State { @override Widget build(BuildContext context) { - Size size = MediaQuery.of(context).size; + if(widget.isLanguageTab) { + resourceIdToShow = widget.initialValue; + } + return Container( child: Row( children: [ @@ -95,7 +100,6 @@ class _ResourceInputContainerState extends State { if (resourceIdToShow != null) { Size size = MediaQuery.of(context).size; final appContext = Provider.of(context); - print("TODO get element"); return FutureBuilder( future: getResource(resourceIdToShow!, appContext), builder: (context, AsyncSnapshot snapshot) { diff --git a/lib/Components/translation_input_and_resource_container.dart b/lib/Components/translation_input_and_resource_container.dart new file mode 100644 index 0000000..f09e3fe --- /dev/null +++ b/lib/Components/translation_input_and_resource_container.dart @@ -0,0 +1,230 @@ +import 'package:flutter/material.dart'; +import 'package:manager_api_new/api.dart'; +import 'package:manager_app/Components/audio_input_container.dart'; +import 'package:manager_app/Components/resource_input_container.dart'; +import 'package:manager_app/app_context.dart'; +import 'package:manager_app/constants.dart'; +import 'package:provider/provider.dart'; +import 'package:quill_html_editor/quill_html_editor.dart'; + +import 'flag_decoration.dart'; + +class _TranslationInputAndResourceContainerState extends State with TickerProviderStateMixin { + TabController? _tabController; + QuillEditorController controllerQuill = QuillEditorController(); + ValueNotifier? currentLanguage; + + @override + void initState() { + super.initState(); + _tabController = new TabController(length: widget.newValues.length, vsync: this); + currentLanguage = ValueNotifier(widget.newValues.first.language!); + controllerQuill.insertText(widget.newValues[_tabController!.index].value!); + + controllerQuill.onTextChanged((p0) async { + var plainText = await controllerQuill.getPlainText(); + if(widget.isTitle) { + if(plainText.length > 60) { + print("to much text au dessus"); + controllerQuill.undo(); + } + } else { + if(plainText.length > 2500) { + print("to much text description au dessus"); + controllerQuill.undo(); + } + } + }); + + _tabController!.addListener(() { + if (!_tabController!.indexIsChanging) { + setState(() { + currentLanguage!.value = widget.newValues[_tabController!.index].language; + if(!widget.isAudio) { + controllerQuill.clear(); + controllerQuill.insertText(widget.newValues[_tabController!.index].value!); + } + }); + } + }); + } + + @override + void dispose() { + super.dispose(); + _tabController!.dispose(); + } + + @override + Widget build(BuildContext context) { + final customToolBarList = widget.isTitle ? [ + ToolBarStyle.bold, + ToolBarStyle.italic, + ToolBarStyle.color, + ToolBarStyle.background, + ToolBarStyle.clean + ] : [ + ToolBarStyle.bold, + ToolBarStyle.italic, + ToolBarStyle.color, + ToolBarStyle.background, + ToolBarStyle.listBullet, + ToolBarStyle.listOrdered, + ToolBarStyle.clean + ]; + + return Container( + height: widget.isTitle ? MediaQuery.of(context).size.height *0.45 : MediaQuery.of(context).size.height *0.5, + //color: Colors.orange, + width: MediaQuery.of(context).size.width *0.7, + constraints: BoxConstraints( + minHeight: 300, + minWidth: 300 + ), + child: DefaultTabController( + length: widget.newValues.length, + child: Column( + children: [ + RotatedBox( + quarterTurns: 0, // Can be used to test vertical tab in case of smaller screen + child: TabBar( + indicatorColor: kPrimaryColor, + //overlayColor: MaterialStateProperty().c, + labelColor: kPrimaryColor, + unselectedLabelColor: Colors.black, + controller: _tabController, + tabs: widget.newValues.map((v) => Tab(icon: FlagDecoration(language: v.language!))).toList(), // text: v.language!.toUpperCase(), + ), + ), + getTranslation(context, Provider.of(context), controllerQuill, customToolBarList, widget.isTitle, widget.isAudio, widget.newValues, currentLanguage!) + ], + ), + ), + ); + } + + getTranslation(BuildContext context, AppContext appContext, QuillEditorController controllerQuill, List customToolBarList, bool isTitle, bool isAudio, List newValues, ValueNotifier currentLanguage) { + return Padding( + padding: const EdgeInsets.all(6.0), + child: Padding( + padding: const EdgeInsets.only(left: 8.0), + child: Container( + width: MediaQuery.of(context).size.width *0.7, + //color: Colors.blueAccent, + height: widget.isTitle ? MediaQuery.of(context).size.height *0.32 : MediaQuery.of(context).size.height *0.37, + child: !isAudio ? + Column( + children: [ + ToolBar( + toolBarColor: kSecond, + activeIconColor: kPrimaryColor, + padding: const EdgeInsets.all(8), + iconSize: 20, + toolBarConfig: customToolBarList, + controller: controllerQuill, + customButtons: [], + ), + SingleChildScrollView( + child: Column( + children: [ + Container( + height: widget.isTitle ? MediaQuery.of(context).size.height *0.13 : MediaQuery.of(context).size.height *0.2, + child: QuillHtmlEditor( + text: newValues.where((element) => element.language! == currentLanguage.value).first.value!, + hintText: '', + controller: controllerQuill, + minHeight: widget.isTitle ? 80 : 240, + /*textStyle: _editorTextStyle, + hintTextStyle: _hintTextStyle,*/ + hintTextAlign: TextAlign.start, + padding: const EdgeInsets.only(left: 10, right: 10, top: 5), + hintTextPadding: EdgeInsets.zero, + backgroundColor: kBackgroundColor, + ensureVisible: true, + inputAction: widget.isTitle ? InputAction.send : InputAction.newline, // don't accept enter if title + //onFocusChanged: (hasFocus) => debugPrint('has focus $hasFocus'), + //onTextChanged: (text) => debugPrint('widget text change $text'), + onTextChanged: (value) { + newValues.where((element) => element.language! == currentLanguage.value).first.value = value; + }, + onEditorCreated: () => debugPrint('Editor has been loaded'), + onEditorResized: (height) => + debugPrint('Editor resized $height'), + onSelectionChanged: (sel) => + debugPrint('${sel.index},${sel.length}'), + ), + ), + ValueListenableBuilder( + valueListenable: currentLanguage, + builder: (context, value, _) { + return ResourceInputContainer( + label: "Ressource à afficher :", + initialValue: newValues.where((element) => element.language! == value).first.resourceId, + color: kPrimaryColor, + inResourceTypes: [ResourceType.Image, ResourceType.ImageUrl, ResourceType.Video, ResourceType.VideoUrl, ResourceType.Audio], + isLanguageTab: true, + onChanged: (ResourceDTO resource) { + setState(() { + if(resource.id == null) { + newValues.where((element) => element.language! == value).first.resourceId = null; + newValues.where((element) => element.language! == value).first.resourceUrl = null; + newValues.where((element) => element.language! == value).first.resourceType = null; + } else { + newValues.where((element) => element.language! == value).first.resourceId = resource.id; + newValues.where((element) => element.language! == value).first.resourceUrl = resource.url; + newValues.where((element) => element.language! == value).first.resourceType = resource.type; + } + }); + }, + isSmall: true + ); + } + ), + ], + ), + ), + ], + ) : + Container( + width: 250, + height: 120, + child: ValueListenableBuilder( + valueListenable: currentLanguage, + builder: (context, value, _) { + return AudioInputContainer( + initialValue: newValues.where((element) => element.language! == value).first.value, + color: kPrimaryColor, + onChanged: (ResourceDTO resource) { + newValues.where((element) => element.language! == value).first.value = resource.id; + }, + ); + } + ), + ), + ), + ), + ); + } +} + +class TranslationInputAndResourceContainer extends StatefulWidget { + TranslationInputAndResourceContainer({ + Key? key, + required this.isTitle, + required this.values, + required this.newValues, + required this.onGetResult, + required this.maxLines, + required this.isAudio, + }) : super(key: key); + + bool isTitle; + List values; + List newValues; + Function onGetResult; + int maxLines; + bool isAudio; + + @override + State createState() => _TranslationInputAndResourceContainerState(); +} diff --git a/lib/Components/translation_input_container.dart b/lib/Components/translation_input_container.dart index d189f90..539e4a9 100644 --- a/lib/Components/translation_input_container.dart +++ b/lib/Components/translation_input_container.dart @@ -94,7 +94,7 @@ class _TranslationInputContainerState extends State w backgroundColor: kBackgroundColor, ensureVisible: true, inputAction: widget.isTitle ? InputAction.send : InputAction.newline, // don't accept enter if title - onFocusChanged: (hasFocus) => debugPrint('has focus $hasFocus'), + //onFocusChanged: (hasFocus) => debugPrint('has focus $hasFocus'), //onTextChanged: (text) => debugPrint('widget text change $text'), onTextChanged: (value) { newValues.where((element) => element.language! == currentLanguage.value).first.value = value; diff --git a/lib/Screens/Configurations/Section/SubSection/Map/category_list.dart b/lib/Screens/Configurations/Section/SubSection/Map/category_list.dart new file mode 100644 index 0000000..ecfc8d9 --- /dev/null +++ b/lib/Screens/Configurations/Section/SubSection/Map/category_list.dart @@ -0,0 +1,253 @@ +import 'dart:convert'; + +import 'package:auto_size_text/auto_size_text.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_widget_from_html/flutter_widget_from_html.dart'; +import 'package:manager_app/Components/multi_string_input_html_modal.dart'; +import 'package:manager_app/Screens/Configurations/Section/SubSection/Map/new_update_categorie.dart'; +import 'package:manager_app/app_context.dart'; +import 'package:manager_app/constants.dart'; +import 'package:manager_api_new/api.dart'; +import 'package:provider/provider.dart'; + +class CategoryList extends StatefulWidget { + final List categories; + final ValueChanged> onChanged; + const CategoryList({ + Key? key, + required this.categories, + required this.onChanged, + }) : super(key: key); + + @override + _CategoryListState createState() => _CategoryListState(); +} + +class _CategoryListState extends State { + late List categoriesMiddle; + + @override + void initState() { + super.initState(); + categoriesMiddle = new List.from(widget.categories); + categoriesMiddle.sort((a, b) => a.order!.compareTo(b.order!)); + } + + void _resetOrder() { + setState( + () { + var i = 0; + categoriesMiddle.forEach((category) { + category.order = i; + i++; + }); + widget.onChanged(categoriesMiddle); + }, + ); + } + + void _onReorder(int oldIndex, int newIndex) { + setState( + () { + if (newIndex > oldIndex) { + newIndex -= 1; + } + final CategorieDTO item = categoriesMiddle.removeAt(oldIndex); + categoriesMiddle.insert(newIndex, item); + + var i = 0; + categoriesMiddle.forEach((category) { + category.order = i; + i++; + }); + widget.onChanged(categoriesMiddle); + }, + ); + } + + @override + Widget build(BuildContext context) { + final appContext = Provider.of(context); + Size size = MediaQuery.of(context).size; + + return Stack( + children: [ + Padding( + padding: const EdgeInsets.only(left: 15.0, right: 15.0, bottom: 15.0, top: 32.5), + child: ReorderableListView.builder( + shrinkWrap: true, + padding: const EdgeInsets.only(right: 125), + itemBuilder: (BuildContext context, int index) { + return Container( + key: ValueKey(index), + decoration: boxDecoration(), + padding: const EdgeInsets.all(2), + margin: EdgeInsets.symmetric(vertical: 3, horizontal: 3), + child: getElement(index, categoriesMiddle[index], size, appContext), + ); + }, + itemCount: categoriesMiddle.length, + onReorder: _onReorder + ), + ), + Positioned( + top: 10, + right: 10, + child: InkWell( + onTap: () async { + CategorieDTO newCategory = CategorieDTO(order: null); + + var result = await showNewOrUpdateCategory(newCategory, appContext, context, "Création catégorie"); + if (result != null) + { + setState(() { + result.order = categoriesMiddle.length; + categoriesMiddle.add(result); + widget.onChanged(categoriesMiddle); + }); + } + }, + 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: kSuccess, + 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, CategorieDTO category, Size size, AppContext appContext) { + return Stack( + children: [ + Container( + width: size.width *0.8, + height: 50, + child: Row( + children: [ + if(category.iconResourceId != null) Container( + height: 60, + width: 60, + decoration: imageBoxDecoration(category, appContext), + margin: EdgeInsets.symmetric(horizontal: 10), + ), + Center( + child: Padding( + padding: const EdgeInsets.all(2.0), + child: HtmlWidget( + category.label == null ? "" : category.label![0].value!, + //textAlign: TextAlign.left, + textStyle: TextStyle(fontSize: 15) + ), + ), + ), + ], + ), + ), + Positioned( + right: 35, + bottom: 3, + child: Row( + children: [ + Tooltip( + message: "Modifier", + child: InkWell( + onTap: () async { + var result = await showNewOrUpdateCategory(category, appContext, context, "Modification catégorie"); + if (result != null) + { + setState(() { + print("RESUUULT MODIFYY "); + category = result; + categoriesMiddle[category.order!] = category; + widget.onChanged(categoriesMiddle); + }); + } + }, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Icon( + Icons.edit, + color: kPrimaryColor, + size: 25.0, + ), + ) + ), + ), + Tooltip( + message: "Supprimer", + child: InkWell( + onTap: () { + setState(() { + categoriesMiddle.removeAt(category.order!); + _resetOrder(); + widget.onChanged(categoriesMiddle); + }); + }, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Icon( + Icons.delete, + color: kError, + size: 25.0, + ), + ) + ), + ), + ], + ) + ), + ], + ); + } +} + +boxDecoration() { + return BoxDecoration( + color: 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 + ), + ], + ); +} + +imageBoxDecoration(CategorieDTO categorieDTO, appContext) { + return BoxDecoration( + color: kBackgroundColor, + shape: BoxShape.rectangle, + border: Border.all(width: 1.5, color: kSecond), + borderRadius: BorderRadius.circular(10.0), + image: categorieDTO.iconUrl != null ? new DecorationImage( + fit: BoxFit.cover, + image: new NetworkImage( + categorieDTO.iconUrl!, + ), + ) : null, + ); +} \ No newline at end of file diff --git a/lib/Screens/Configurations/Section/SubSection/Map/map_config.dart b/lib/Screens/Configurations/Section/SubSection/Map/map_config.dart index 20d903f..1fa6c9d 100644 --- a/lib/Screens/Configurations/Section/SubSection/Map/map_config.dart +++ b/lib/Screens/Configurations/Section/SubSection/Map/map_config.dart @@ -1,6 +1,7 @@ import 'package:auto_size_text/auto_size_text.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/fetch_section_icon.dart'; import 'package:manager_app/Components/resource_input_container.dart'; import 'package:manager_app/Components/multi_select_container.dart'; @@ -129,6 +130,20 @@ class _MapConfigState extends State { mapDTO.zoom = value.toInt(); widget.onChanged(jsonEncode(mapDTO).toString()); }, + ), + Container( + height: 70, + child: CategoryInputContainer( + label: "Catégories :", + initialValue: mapDTO.categories != null ? mapDTO.categories! : [], + color: kPrimaryColor, + onChanged: (List? value) { + if(value != null) { + mapDTO.categories = value; + widget.onChanged(jsonEncode(mapDTO).toString()); + } + }, + ), ) ], ), @@ -176,15 +191,16 @@ class _MapConfigState extends State { child: InkWell( onTap: () { showNewOrUpdateGeoPoint( - null, - (GeoPointDTO geoPoint) { - setState(() { - mapDTO.points!.add(geoPoint); - widget.onChanged(jsonEncode(mapDTO).toString()); - }); - }, - appContext, - context); + mapDTO, + 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, @@ -252,15 +268,16 @@ class _MapConfigState extends State { child: InkWell( onTap: () { showNewOrUpdateGeoPoint( - mapDTO.points![index], - (GeoPointDTO geoPoint) { - setState(() { - mapDTO.points![index] = geoPoint; - widget.onChanged(jsonEncode(mapDTO).toString()); - }); - }, - appContext, - context); + mapDTO, + mapDTO.points![index], + (GeoPointDTO geoPoint) { + setState(() { + mapDTO.points![index] = geoPoint; + widget.onChanged(jsonEncode(mapDTO).toString()); + }); + }, + appContext, + context); }, child: Icon( Icons.edit, diff --git a/lib/Screens/Configurations/Section/SubSection/Map/new_update_categorie.dart b/lib/Screens/Configurations/Section/SubSection/Map/new_update_categorie.dart new file mode 100644 index 0000000..7eae586 --- /dev/null +++ b/lib/Screens/Configurations/Section/SubSection/Map/new_update_categorie.dart @@ -0,0 +1,155 @@ +import 'dart:convert'; + +import 'package:auto_size_text/auto_size_text.dart'; +import 'package:manager_app/Components/multi_string_input_and_resource_container.dart'; +import 'package:manager_app/Components/multi_string_input_html_modal.dart'; +import 'package:manager_app/Components/resource_input_container.dart'; +import 'package:flutter/material.dart'; +import 'package:manager_app/Components/multi_string_input_container.dart'; +import 'package:manager_app/Components/rounded_button.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:manager_api_new/api.dart'; + +Future showNewOrUpdateCategory(CategorieDTO? inputCategorieDTO, AppContext appContext, BuildContext context, String text) async { + CategorieDTO categorieDTO = new CategorieDTO(); + + if (inputCategorieDTO != null) { + categorieDTO = inputCategorieDTO; + } else { + categorieDTO.label = []; + + ManagerAppContext managerAppContext = appContext.getContext(); + managerAppContext.selectedConfiguration!.languages!.forEach((element) { + var translationMessageDTO = new TranslationDTO(); + translationMessageDTO.language = element; + translationMessageDTO.value = ""; + + categorieDTO.label!.add(translationMessageDTO); + }); + } + + List newValues = []; + + List initials = []; + + languages.forEach((value) { + if(initials.map((iv) => iv.language).contains(value)) { + newValues.add(TranslationDTO.fromJson(jsonDecode(jsonEncode(initials.firstWhere((element) => element.language == value)))!)!); + } else { + // New language + newValues.add(TranslationDTO(language: value, value: "")); + } + }); + + Size size = MediaQuery.of(context).size; + var result = await showDialog( + builder: (BuildContext dialogContext) => AlertDialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(20.0)) + ), + content: Container( + width: size.width *0.5, + child: SingleChildScrollView( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text(text, style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Container( + height: size.height * 0.2, + constraints: BoxConstraints(minHeight: 50, maxHeight: 80), + child: MultiStringInputContainer( + label: "Nom affiché :", + modalLabel: text, + fontSize: 20, + color: kPrimaryColor, + initialValue: categorieDTO.label != null ? categorieDTO.label! : [], + onGetResult: (value) { + if (categorieDTO.label != value) { + categorieDTO.label = value; + } + }, + maxLines: 1, + isTitle: true, + isHTML: true, + ) + ), + Container( + height: size.height * 0.2, + constraints: BoxConstraints(minHeight: 50, maxHeight: 80), + child: ResourceInputContainer( + label: "Icône catégorie :", + initialValue: categorieDTO.iconResourceId, + color: kPrimaryColor, + onChanged: (ResourceDTO resource) { + if(resource.id == null) { + categorieDTO.iconResourceId = null; + categorieDTO.iconUrl = null; + } else { + categorieDTO.iconResourceId = resource.id; + categorieDTO.iconUrl = resource.url; + print("Icône catégorieIcône catégorie"); + print(categorieDTO); + } + }, + isSmall: true + ), + ), + ], + ), + ], + ), + ), + ), + 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.pop(dialogContext); + }, + fontSize: 20, + ), + ), + ), + Align( + alignment: AlignmentDirectional.bottomEnd, + child: Container( + width: inputCategorieDTO != null ? 220: 150, + height: 70, + child: RoundedButton( + text: inputCategorieDTO != null ? "Sauvegarder" : "Créer", + icon: Icons.check, + color: kPrimaryColor, + textColor: kWhite, + press: () { + if(categorieDTO.label != null && categorieDTO.label!.isNotEmpty) + { + Navigator.pop(dialogContext, categorieDTO); + } + }, + fontSize: 20, + ), + ), + ), + ], + ), + ], + ), context: context + ); + return result; +} diff --git a/lib/Screens/Configurations/Section/SubSection/Map/showNewOrUpdateGeoPoint.dart b/lib/Screens/Configurations/Section/SubSection/Map/showNewOrUpdateGeoPoint.dart index e12099a..094a39e 100644 --- a/lib/Screens/Configurations/Section/SubSection/Map/showNewOrUpdateGeoPoint.dart +++ b/lib/Screens/Configurations/Section/SubSection/Map/showNewOrUpdateGeoPoint.dart @@ -1,5 +1,6 @@ import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; +import 'package:manager_app/Components/dropDown_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/string_input_container.dart'; @@ -10,7 +11,7 @@ import 'package:manager_app/app_context.dart'; import 'package:manager_app/constants.dart'; import 'package:manager_api_new/api.dart'; -void showNewOrUpdateGeoPoint(GeoPointDTO? inputGeoPointDTO, Function getResult, AppContext appContext, BuildContext context) { +void showNewOrUpdateGeoPoint(MapDTO mapDTO, GeoPointDTO? inputGeoPointDTO, Function getResult, AppContext appContext, BuildContext context) { GeoPointDTO geoPointDTO = new GeoPointDTO(); if (inputGeoPointDTO != null) { @@ -37,7 +38,7 @@ void showNewOrUpdateGeoPoint(GeoPointDTO? inputGeoPointDTO, Function getResult, borderRadius: BorderRadius.all(Radius.circular(20.0)) ), content: Container( - width: size.width *0.7, + width: size.width *0.8, child: SingleChildScrollView( child: Column( children: [ @@ -113,6 +114,24 @@ void showNewOrUpdateGeoPoint(GeoPointDTO? inputGeoPointDTO, Function getResult, isTitle: false ), ), + if(mapDTO.categories != null && mapDTO.categories!.isNotEmpty) + Container( + constraints: BoxConstraints(minHeight: 50, maxHeight: 80), + child: DropDownInputContainer( + label: "Choisir une catégorie:", + categories: mapDTO.categories!, + initialValue: geoPointDTO.categorie, + onChange: (CategorieDTO? value) { + if(value != null && value.order != -1) + { + geoPointDTO.categorie = value; + } else + { + geoPointDTO.categorie = null; + } + }, + ), + ), ], ), ), diff --git a/lib/Screens/Configurations/Section/SubSection/Puzzle/puzzle_config.dart b/lib/Screens/Configurations/Section/SubSection/Puzzle/puzzle_config.dart index f4e9c25..df758e6 100644 --- a/lib/Screens/Configurations/Section/SubSection/Puzzle/puzzle_config.dart +++ b/lib/Screens/Configurations/Section/SubSection/Puzzle/puzzle_config.dart @@ -1,5 +1,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:manager_app/Components/multi_string_input_and_resource_container.dart'; import 'package:manager_app/Components/multi_string_input_container.dart'; import 'package:manager_app/Components/resource_input_container.dart'; import 'package:manager_api_new/api.dart'; @@ -57,11 +58,10 @@ class _PuzzleConfigState extends State { ), Container( height: 100, - child: MultiStringInputContainer( + child: MultiStringInputAndResourceContainer( label: "Message départ :", modalLabel: "Message départ", fontSize: 20, - isHTML: true, color: kPrimaryColor, initialValue: puzzleDTO.messageDebut != null ? puzzleDTO.messageDebut! : [], onGetResult: (value) { @@ -75,16 +75,15 @@ class _PuzzleConfigState extends State { } }, maxLines: 1, - isTitle: true + isTitle: false ) ), Container( height: 100, - child: MultiStringInputContainer( + child: MultiStringInputAndResourceContainer( label: "Message fin :", modalLabel: "Message fin", fontSize: 20, - isHTML: true, color: kPrimaryColor, initialValue: puzzleDTO.messageFin != null ? puzzleDTO.messageFin! : [], onGetResult: (value) { @@ -96,7 +95,7 @@ class _PuzzleConfigState extends State { } }, maxLines: 1, - isTitle: true + isTitle: false ) ), ], diff --git a/lib/Screens/Configurations/Section/SubSection/Quizz/new_update_question_quizz.dart b/lib/Screens/Configurations/Section/SubSection/Quizz/new_update_question_quizz.dart index 825214c..936c0e4 100644 --- a/lib/Screens/Configurations/Section/SubSection/Quizz/new_update_question_quizz.dart +++ b/lib/Screens/Configurations/Section/SubSection/Quizz/new_update_question_quizz.dart @@ -1,4 +1,5 @@ import 'package:auto_size_text/auto_size_text.dart'; +import 'package:manager_app/Components/multi_string_input_and_resource_container.dart'; import 'package:manager_app/Components/resource_input_container.dart'; import 'package:flutter/material.dart'; import 'package:manager_app/Components/message_notification.dart'; @@ -17,11 +18,11 @@ Future showNewOrUpdateQuestionQuizz(QuestionDTO? inputQuestionDTO, if (inputQuestionDTO != null) { questionDTO = inputQuestionDTO; } else { - questionDTO.label = []; + questionDTO.label = []; ManagerAppContext managerAppContext = appContext.getContext(); managerAppContext.selectedConfiguration!.languages!.forEach((element) { - var translationMessageDTO = new TranslationDTO(); + var translationMessageDTO = new TranslationAndResourceDTO(); translationMessageDTO.language = element; translationMessageDTO.value = ""; @@ -56,16 +57,18 @@ Future showNewOrUpdateQuestionQuizz(QuestionDTO? inputQuestionDTO, mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ ResourceInputContainer( - label: "Image :", - initialValue: questionDTO.resourceId, + label: "Image fond d'écran :", + initialValue: questionDTO.imageBackgroundResourceId, color: kPrimaryColor, onChanged: (ResourceDTO resource) { if(resource.id == null) { - questionDTO.resourceId = null; - questionDTO.resourceUrl = null; + questionDTO.imageBackgroundResourceId = null; + questionDTO.imageBackgroundResourceUrl = null; + questionDTO.imageBackgroundResourceType = null; } else { - questionDTO.resourceId = resource.id; - questionDTO.resourceUrl = resource.url; + questionDTO.imageBackgroundResourceId = resource.id; + questionDTO.imageBackgroundResourceUrl = resource.url; + questionDTO.imageBackgroundResourceType = resource.type; } }, isSmall: true @@ -74,11 +77,10 @@ Future showNewOrUpdateQuestionQuizz(QuestionDTO? inputQuestionDTO, //color: Colors.orangeAccent, height: size.height * 0.15, constraints: BoxConstraints(minHeight: 50, maxHeight: 80), - child: MultiStringInputContainer( - label: "Question:", + child: MultiStringInputAndResourceContainer( + label: "Question :", modalLabel: "Question", fontSize: 20, - isHTML: true, color: kPrimaryColor, initialValue: questionDTO.label != null ? questionDTO.label! : [], onGetResult: (value) { diff --git a/lib/Screens/Configurations/Section/SubSection/Quizz/new_update_response_quizz.dart b/lib/Screens/Configurations/Section/SubSection/Quizz/new_update_response_quizz - deprecated.dart similarity index 79% rename from lib/Screens/Configurations/Section/SubSection/Quizz/new_update_response_quizz.dart rename to lib/Screens/Configurations/Section/SubSection/Quizz/new_update_response_quizz - deprecated.dart index fb0038e..cfa9f91 100644 --- a/lib/Screens/Configurations/Section/SubSection/Quizz/new_update_response_quizz.dart +++ b/lib/Screens/Configurations/Section/SubSection/Quizz/new_update_response_quizz - deprecated.dart @@ -1,6 +1,7 @@ import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; import 'package:manager_app/Components/message_notification.dart'; +import 'package:manager_app/Components/multi_string_input_and_resource_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/text_form_input_container.dart'; @@ -9,17 +10,18 @@ import 'package:manager_app/app_context.dart'; import 'package:manager_app/constants.dart'; import 'package:manager_api_new/api.dart'; +@deprecated Future showNewOrUpdateResponseQuizz(ResponseDTO? inputResponseDTO, AppContext appContext, BuildContext context, String text) async { ResponseDTO responseDTO = new ResponseDTO(); if (inputResponseDTO != null) { responseDTO = inputResponseDTO; } else { - responseDTO.label = []; + responseDTO.label = []; ManagerAppContext managerAppContext = appContext.getContext(); managerAppContext.selectedConfiguration!.languages!.forEach((element) { - var translationMessageDTO = new TranslationDTO(); + var translationMessageDTO = new TranslationAndResourceDTO(); translationMessageDTO.language = element; translationMessageDTO.value = ""; @@ -29,6 +31,8 @@ Future showNewOrUpdateResponseQuizz(ResponseDTO? inputResponseDTO, Size size = MediaQuery.of(context).size; + + //showMultiStringInputHTML("Réponse", "Modifier la réponse:", false, initials, newValues, onGetResult, 1, false, context); var result = await showDialog( @@ -47,12 +51,11 @@ Future showNewOrUpdateResponseQuizz(ResponseDTO? inputResponseDTO, height: size.height * 0.25, width: double.infinity, child: Container( - constraints: BoxConstraints(minHeight: 50, maxHeight: 80), - child: MultiStringInputContainer( - label: "Modifier la réponse:", + constraints: BoxConstraints(minHeight: 50, maxHeight: 50), + child: MultiStringInputAndResourceContainer( + label: inputResponseDTO != null ? "Modifier les réponses :" : "Créer les réponses :", modalLabel: "Réponse", fontSize: 20, - isHTML: true, color: kPrimaryColor, initialValue: responseDTO.label != null ? responseDTO.label! : [], onGetResult: (value) { @@ -65,26 +68,6 @@ Future showNewOrUpdateResponseQuizz(ResponseDTO? inputResponseDTO, ), ), ), - /*Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Align( - alignment: AlignmentDirectional.centerStart, - child: Text("La réponse est valide:", style: TextStyle(fontSize: 25, fontWeight: FontWeight.w300)) - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Checkbox( - value: responseDTO.isGood, - checkColor: Colors.white, - activeColor: kPrimaryColor, - onChanged: (bool value) { - responseDTO.isGood = !responseDTO.isGood; - }, - ), - ), - ], - ),*/ ], ), ), diff --git a/lib/Screens/Configurations/Section/SubSection/Quizz/new_update_score_quizz.dart b/lib/Screens/Configurations/Section/SubSection/Quizz/new_update_score_quizz - deprecated.dart similarity index 75% rename from lib/Screens/Configurations/Section/SubSection/Quizz/new_update_score_quizz.dart rename to lib/Screens/Configurations/Section/SubSection/Quizz/new_update_score_quizz - deprecated.dart index ef428d0..63ac66c 100644 --- a/lib/Screens/Configurations/Section/SubSection/Quizz/new_update_score_quizz.dart +++ b/lib/Screens/Configurations/Section/SubSection/Quizz/new_update_score_quizz - deprecated.dart @@ -1,4 +1,8 @@ +import 'dart:convert'; + import 'package:auto_size_text/auto_size_text.dart'; +import 'package:manager_app/Components/multi_string_input_and_resource_container.dart'; +import 'package:manager_app/Components/multi_string_input_html_modal.dart'; import 'package:manager_app/Components/resource_input_container.dart'; import 'package:flutter/material.dart'; import 'package:manager_app/Components/multi_string_input_container.dart'; @@ -9,17 +13,18 @@ import 'package:manager_app/app_context.dart'; import 'package:manager_app/constants.dart'; import 'package:manager_api_new/api.dart'; +@deprecated Future showNewOrUpdateScoreQuizz(LevelDTO? inputLevelDTO, AppContext appContext, BuildContext context, String text) async { LevelDTO levelDTO = new LevelDTO(); if (inputLevelDTO != null) { levelDTO = inputLevelDTO; } else { - levelDTO.label = []; + levelDTO.label = []; ManagerAppContext managerAppContext = appContext.getContext(); managerAppContext.selectedConfiguration!.languages!.forEach((element) { - var translationMessageDTO = new TranslationDTO(); + var translationMessageDTO = new TranslationAndResourceDTO(); translationMessageDTO.language = element; translationMessageDTO.value = ""; @@ -27,6 +32,32 @@ Future showNewOrUpdateScoreQuizz(LevelDTO? inputLevelDTO, AppContext }); } + List newValues = []; + + List initials = []; + + languages.forEach((value) { + if(initials.map((iv) => iv.language).contains(value)) { + newValues.add(TranslationAndResourceDTO.fromJson(jsonDecode(jsonEncode(initials.firstWhere((element) => element.language == value)))!)!); + } else { + // New language + newValues.add(TranslationAndResourceDTO(language: value, value: "")); + } + }); + + showMultiStringInputAndResourceHTML("Message pour un mauvais score", "Message pour un mauvais score", true, initials, newValues, (value) { + print("RTESULTYTYT "); + print(value); + if(value != null && value.isNotEmpty) { + levelDTO.label = value; + print("RETURN VALUE"); + print(levelDTO); + return levelDTO; + } + }, 1, false, context); + + + Size size = MediaQuery.of(context).size; var result = await showDialog( builder: (BuildContext dialogContext) => AlertDialog( @@ -43,31 +74,13 @@ Future showNewOrUpdateScoreQuizz(LevelDTO? inputLevelDTO, AppContext Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - Center( - child: ResourceInputContainer( - label: "Image :", - initialValue: levelDTO.resourceId, - color: kPrimaryColor, - onChanged: (ResourceDTO resource) { - if(resource.id == null) { - levelDTO.resourceId = null; - levelDTO.resourceUrl = null; - } else { - levelDTO.resourceId = resource.id; - levelDTO.resourceUrl = resource.url; - } - }, - isSmall: true - ), - ), Container( height: size.height * 0.2, constraints: BoxConstraints(minHeight: 50, maxHeight: 80), - child: MultiStringInputContainer( + child: MultiStringInputAndResourceContainer( label: "Message:", - modalLabel: "Message", + modalLabel: text, fontSize: 20, - isHTML: true, color: kPrimaryColor, initialValue: levelDTO.label != null ? levelDTO.label! : [], onGetResult: (value) { diff --git a/lib/Screens/Configurations/Section/SubSection/Quizz/quizz_answer_list.dart b/lib/Screens/Configurations/Section/SubSection/Quizz/quizz_answer_list.dart index 3ecfd2d..c55b06c 100644 --- a/lib/Screens/Configurations/Section/SubSection/Quizz/quizz_answer_list.dart +++ b/lib/Screens/Configurations/Section/SubSection/Quizz/quizz_answer_list.dart @@ -9,7 +9,7 @@ import 'package:manager_app/constants.dart'; import 'package:manager_api_new/api.dart'; import 'package:provider/provider.dart'; -import 'new_update_response_quizz.dart'; +import 'new_update_response_quizz - deprecated.dart'; class QuizzResponseList extends StatefulWidget { final List responses; @@ -33,6 +33,19 @@ class _QuizzResponseListState extends State { responsesMiddle = new List.from(widget.responses); } + void _resetOrder() { + setState( + () { + var i = 0; + responsesMiddle.forEach((category) { + category.order = i; + i++; + }); + widget.onChanged(responsesMiddle); + }, + ); + } + void _onReorder(int oldIndex, int newIndex) { setState( () { @@ -86,46 +99,62 @@ class _QuizzResponseListState extends State { ), ), if(responsesMiddle.length < 4) - Positioned( - bottom: 10, - right: 10, - child: InkWell( - onTap: () async { - var result = await showNewOrUpdateResponseQuizz(null, appContext, context, "Réponse"); - if (result != null) - { - setState(() { - result.order = responsesMiddle.length; - result.isGood = false; - responsesMiddle.add(result); - widget.onChanged(responsesMiddle); + Positioned( + bottom: 10, + right: 10, + child: InkWell( + onTap: () async { + ResponseDTO newResponse = ResponseDTO(order: null); + + List newValues = []; + + List initials = []; + + languages.forEach((value) { + if(initials.map((iv) => iv.language).contains(value)) { + newValues.add(TranslationAndResourceDTO.fromJson(jsonDecode(jsonEncode(initials.firstWhere((element) => element.language == value)))!)!); + } else { + // New language + newValues.add(TranslationAndResourceDTO(language: value, value: "")); + } }); - } - }, - 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: kSuccess, - 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 - ), - ], + + showMultiStringInputAndResourceHTML("Réponse", "Créer la réponse", true, initials, newValues, (value) { + if(value != null && value.isNotEmpty) { + setState(() { + newResponse.label = value; + newResponse.order = responsesMiddle.length; + newResponse.isGood = false; + responsesMiddle.add(newResponse); + widget.onChanged(responsesMiddle); + }); + } + }, 1, false, 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: kSuccess, + 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 + ), + ], + ), ), ), - ), - ) + ) ], ); } @@ -177,27 +206,27 @@ class _QuizzResponseListState extends State { message: "Modifier", child: InkWell( onTap: () async { - List newValues = []; + List newValues = []; - List initials = response.label!; + List initials = response.label!; if(initials == null) { initials = []; } languages.forEach((value) { if(initials.map((iv) => iv.language).contains(value)) { - newValues.add(TranslationDTO.fromJson(jsonDecode(jsonEncode(initials.firstWhere((element) => element.language == value)))!)!); + newValues.add(TranslationAndResourceDTO.fromJson(jsonDecode(jsonEncode(initials.firstWhere((element) => element.language == value)))!)!); } else { // New language - newValues.add(TranslationDTO(language: value, value: null)); + newValues.add(TranslationAndResourceDTO(language: value, value: "")); } }); - showMultiStringInputHTML("Réponse", "Modifier la réponse", true, initials, newValues, (value) { + showMultiStringInputAndResourceHTML("Réponse", "Modifier la réponse", true, initials, newValues, (value) { setState(() { - if (response.label! != value) { + if (value != null && response.label! != value) { response.label = value; - responsesMiddle[response.order!] = value; + responsesMiddle[response.order!] = response; widget.onChanged(responsesMiddle); } }); @@ -219,6 +248,7 @@ class _QuizzResponseListState extends State { onTap: () { setState(() { responsesMiddle.removeAt(response.order!); + _resetOrder(); widget.onChanged(responsesMiddle); }); }, diff --git a/lib/Screens/Configurations/Section/SubSection/Quizz/quizz_config.dart b/lib/Screens/Configurations/Section/SubSection/Quizz/quizz_config.dart index 9841865..a0efaf6 100644 --- a/lib/Screens/Configurations/Section/SubSection/Quizz/quizz_config.dart +++ b/lib/Screens/Configurations/Section/SubSection/Quizz/quizz_config.dart @@ -1,6 +1,9 @@ import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_widget_from_html/flutter_widget_from_html.dart'; +import 'package:manager_app/Components/multi_string_input_html_modal.dart'; import 'package:manager_app/Components/rounded_button.dart'; +import 'package:manager_app/Models/managerContext.dart'; import 'package:manager_app/app_context.dart'; import 'package:manager_app/constants.dart'; import 'package:manager_api_new/api.dart'; @@ -9,7 +12,7 @@ import 'dart:convert'; import 'package:provider/provider.dart'; import 'new_update_question_quizz.dart'; -import 'new_update_score_quizz.dart'; +import 'new_update_score_quizz - deprecated.dart'; class QuizzConfig extends StatefulWidget { final String? color; @@ -84,14 +87,7 @@ class _QuizzConfigState extends State { textColor: kWhite, icon: Icons.message, press: () async { - var result = await showNewOrUpdateScoreQuizz(quizzDTO.badLevel, appContext, context, "Message pour un mauvais score"); - if (result != null) - { - setState(() { - quizzDTO.badLevel = result; - widget.onChanged(jsonEncode(quizzDTO).toString()); - }); - } + updateScoreQuizMessage(context, appContext, quizzDTO.badLevel, "Message pour un mauvais score", 0); }, fontSize: 20, horizontal: 10, @@ -107,14 +103,7 @@ class _QuizzConfigState extends State { textColor: kWhite, icon: Icons.message, press: () async { - var result = await showNewOrUpdateScoreQuizz(quizzDTO.mediumLevel, appContext, context, "Message pour un moyen score"); - if (result != null) - { - setState(() { - quizzDTO.mediumLevel = result; - widget.onChanged(jsonEncode(quizzDTO).toString()); - }); - } + updateScoreQuizMessage(context, appContext, quizzDTO.mediumLevel, "Message pour un score moyen", 1); }, fontSize: 20, horizontal: 10, @@ -130,14 +119,7 @@ class _QuizzConfigState extends State { textColor: kWhite, icon: Icons.message, press: () async { - var result = await showNewOrUpdateScoreQuizz(quizzDTO.goodLevel, appContext, context, "Message pour un bon score"); - if (result != null) - { - setState(() { - quizzDTO.goodLevel = result; - widget.onChanged(jsonEncode(quizzDTO).toString()); - }); - } + updateScoreQuizMessage(context, appContext, quizzDTO.goodLevel, "Message pour un bon score", 2); }, fontSize: 20, horizontal: 10, @@ -153,14 +135,7 @@ class _QuizzConfigState extends State { textColor: kWhite, icon: Icons.message, press: () async { - var result = await showNewOrUpdateScoreQuizz(quizzDTO.greatLevel, appContext, context, "Message pour un excellent score"); - if (result != null) - { - setState(() { - quizzDTO.greatLevel = result; - widget.onChanged(jsonEncode(quizzDTO).toString()); - }); - } + updateScoreQuizMessage(context, appContext, quizzDTO.greatLevel, "Message pour un excellent score", 3); }, fontSize: 20, horizontal: 10, @@ -263,7 +238,7 @@ class _QuizzConfigState extends State { height: 75, child: Row( children: [ - if(question.resourceUrl != null) Container( + if(question.imageBackgroundResourceUrl != null) Container( height: 60, width: 60, decoration: imageBoxDecoration(question, appContext), @@ -272,11 +247,9 @@ class _QuizzConfigState extends State { Center( child: Padding( padding: const EdgeInsets.all(2.0), - child: AutoSizeText( - question.label == null ? "" : question.label![0].value!, - style: new TextStyle(fontSize: 15), - maxLines: 2, - textAlign: TextAlign.center, + child: HtmlWidget( + question.label == null ? "" : question.label![0].value!, + textStyle: TextStyle(fontSize: 15) ), ), ), @@ -341,6 +314,65 @@ class _QuizzConfigState extends State { ], ); } + + updateScoreQuizMessage(BuildContext context, AppContext appContext, LevelDTO? inLevelDTO, String text, int levelToUpdate) { + LevelDTO levelDTO = new LevelDTO(); + + if (inLevelDTO != null) { + levelDTO = inLevelDTO; + } else { + levelDTO.label = []; + + ManagerAppContext managerAppContext = appContext.getContext(); + managerAppContext.selectedConfiguration!.languages!.forEach((element) { + var translationMessageDTO = new TranslationAndResourceDTO(); + translationMessageDTO.language = element; + translationMessageDTO.value = ""; + + levelDTO.label!.add(translationMessageDTO); + }); + } + + List newValues = []; + + List initials = levelDTO.label!; + + languages.forEach((value) { + if(initials.map((iv) => iv.language).contains(value)) { + newValues.add(TranslationAndResourceDTO.fromJson(jsonDecode(jsonEncode(initials.firstWhere((element) => element.language == value)))!)!); + } else { + // New language + newValues.add(TranslationAndResourceDTO(language: value, value: "")); + } + }); + + showMultiStringInputAndResourceHTML(text, text, true, initials, newValues, (value) { + if(value != null && value.isNotEmpty) { + levelDTO.label = value; + setState(() { + switch(levelToUpdate) { + case 0: + // badLevel + quizzDTO.badLevel = levelDTO; + break; + case 1: + // mediumLevel + quizzDTO.mediumLevel = levelDTO; + break; + case 2: + // goodLevel + quizzDTO.goodLevel = levelDTO; + break; + case 3: + // greatLevel + quizzDTO.greatLevel = levelDTO; + break; + } + widget.onChanged(jsonEncode(quizzDTO).toString()); + }); + } + }, 1, false, context); + } } boxDecoration() { @@ -366,11 +398,11 @@ imageBoxDecoration(QuestionDTO questionDTO, appContext) { shape: BoxShape.rectangle, border: Border.all(width: 1.5, color: kSecond), borderRadius: BorderRadius.circular(10.0), - image: questionDTO.resourceUrl != null ? new DecorationImage( + image: questionDTO.imageBackgroundResourceUrl != null ? new DecorationImage( fit: BoxFit.cover, image: new NetworkImage( - questionDTO.resourceUrl!, + questionDTO.imageBackgroundResourceUrl!, ), ) : null, ); -} \ No newline at end of file +} diff --git a/lib/Screens/Configurations/configuration_detail_screen.dart b/lib/Screens/Configurations/configuration_detail_screen.dart index 69dbb1d..0ea5b20 100644 --- a/lib/Screens/Configurations/configuration_detail_screen.dart +++ b/lib/Screens/Configurations/configuration_detail_screen.dart @@ -209,13 +209,6 @@ class _ConfigurationDetailScreenState extends State { mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start, children: [ - /*ColorPickerInputContainer( - label: "Couleur principal :", - color: configurationDTO.primaryColor, - onChanged: (value) { - configurationDTO.primaryColor = value; - }, - ),*/ CheckInputContainer( icon: Icons.signal_wifi_off, label: "Hors ligne :", @@ -287,6 +280,15 @@ class _ConfigurationDetailScreenState extends State { configurationDTO.secondaryColor = value; }, ), + if(!configurationDTO.isMobile!) + ColorPickerInputContainer( + label: "Couleur pincipale :", + fontSize: 20, + color: configurationDTO.primaryColor, + onChanged: (value) { + configurationDTO.primaryColor = value; + }, + ), if(configurationDTO.isMobile!) Padding( padding: const EdgeInsets.only(bottom: 15), diff --git a/lib/Screens/Main/main_screen.dart b/lib/Screens/Main/main_screen.dart index 98c56ba..7c3cafa 100644 --- a/lib/Screens/Main/main_screen.dart +++ b/lib/Screens/Main/main_screen.dart @@ -21,8 +21,6 @@ class _MainScreenState extends State { final appContext = Provider.of(context); ManagerAppContext managerAppContext = appContext.getContext(); - print(managerAppContext.instanceId); - var isFortSt = managerAppContext.instanceId == "633ee379d9405f32f166f047"; if(!ResponsiveBreakpoints.of(context).equals(TABLET) || isFortSt) { diff --git a/lib/api/swagger.yaml b/lib/api/swagger.yaml index e873dc2..e6997e0 100644 --- a/lib/api/swagger.yaml +++ b/lib/api/swagger.yaml @@ -2175,12 +2175,24 @@ components: type: object additionalProperties: false properties: - name: - type: string + label: + type: array nullable: true + items: + $ref: '#/components/schemas/TranslationDTO' icon: type: string nullable: true + iconResourceId: + type: string + nullable: true + iconUrl: + type: string + nullable: true + order: + type: integer + format: int32 + nullable: true SliderDTO: type: object additionalProperties: false @@ -2279,12 +2291,33 @@ components: type: array nullable: true items: - $ref: '#/components/schemas/TranslationDTO' + $ref: '#/components/schemas/TranslationAndResourceDTO' responses: type: array nullable: true items: $ref: '#/components/schemas/ResponseDTO' + imageBackgroundResourceId: + type: string + nullable: true + imageBackgroundResourceType: + $ref: '#/components/schemas/ResourceType' + imageBackgroundResourceUrl: + type: string + nullable: true + order: + type: integer + format: int32 + TranslationAndResourceDTO: + type: object + additionalProperties: false + properties: + language: + type: string + nullable: true + value: + type: string + nullable: true resourceId: type: string nullable: true @@ -2293,9 +2326,6 @@ components: resourceUrl: type: string nullable: true - order: - type: integer - format: int32 ResponseDTO: type: object additionalProperties: false @@ -2304,17 +2334,9 @@ components: type: array nullable: true items: - $ref: '#/components/schemas/TranslationDTO' + $ref: '#/components/schemas/TranslationAndResourceDTO' isGood: type: boolean - resourceId: - type: string - nullable: true - resourceType: - $ref: '#/components/schemas/ResourceType' - resourceUrl: - type: string - nullable: true order: type: integer format: int32 @@ -2326,15 +2348,7 @@ components: type: array nullable: true items: - $ref: '#/components/schemas/TranslationDTO' - resourceId: - type: string - nullable: true - resourceType: - $ref: '#/components/schemas/ResourceType' - resourceUrl: - type: string - nullable: true + $ref: '#/components/schemas/TranslationAndResourceDTO' ArticleDTO: type: object additionalProperties: false @@ -2376,12 +2390,12 @@ components: type: array nullable: true items: - $ref: '#/components/schemas/TranslationDTO' + $ref: '#/components/schemas/TranslationAndResourceDTO' messageFin: type: array nullable: true items: - $ref: '#/components/schemas/TranslationDTO' + $ref: '#/components/schemas/TranslationAndResourceDTO' image: nullable: true oneOf: diff --git a/manager_api_new/.openapi-generator/FILES b/manager_api_new/.openapi-generator/FILES index 0fd499a..091da7e 100644 --- a/manager_api_new/.openapi-generator/FILES +++ b/manager_api_new/.openapi-generator/FILES @@ -42,6 +42,7 @@ doc/SectionDTO.md doc/SectionType.md doc/SliderDTO.md doc/TokenDTO.md +doc/TranslationAndResourceDTO.md doc/TranslationDTO.md doc/User.md doc/UserApi.md @@ -99,6 +100,7 @@ lib/model/section_dto.dart lib/model/section_type.dart lib/model/slider_dto.dart lib/model/token_dto.dart +lib/model/translation_and_resource_dto.dart lib/model/translation_dto.dart lib/model/user.dart lib/model/user_detail_dto.dart diff --git a/manager_api_new/README.md b/manager_api_new/README.md index fe30308..a9315b2 100644 --- a/manager_api_new/README.md +++ b/manager_api_new/README.md @@ -157,6 +157,7 @@ Class | Method | HTTP request | Description - [SectionType](doc\/SectionType.md) - [SliderDTO](doc\/SliderDTO.md) - [TokenDTO](doc\/TokenDTO.md) + - [TranslationAndResourceDTO](doc\/TranslationAndResourceDTO.md) - [TranslationDTO](doc\/TranslationDTO.md) - [User](doc\/User.md) - [UserDetailDTO](doc\/UserDetailDTO.md) diff --git a/manager_api_new/doc/CategorieDTO.md b/manager_api_new/doc/CategorieDTO.md index 2bb0200..121d37f 100644 --- a/manager_api_new/doc/CategorieDTO.md +++ b/manager_api_new/doc/CategorieDTO.md @@ -8,8 +8,11 @@ import 'package:manager_api_new/api.dart'; ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**name** | **String** | | [optional] +**label** | [**List**](TranslationDTO.md) | | [optional] [default to const []] **icon** | **String** | | [optional] +**iconResourceId** | **String** | | [optional] +**iconUrl** | **String** | | [optional] +**order** | **int** | | [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_new/doc/GeoPointDTOCategorie.md b/manager_api_new/doc/GeoPointDTOCategorie.md index 55eb3f0..1a7db19 100644 --- a/manager_api_new/doc/GeoPointDTOCategorie.md +++ b/manager_api_new/doc/GeoPointDTOCategorie.md @@ -8,8 +8,11 @@ import 'package:manager_api_new/api.dart'; ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**name** | **String** | | [optional] +**label** | [**List**](TranslationDTO.md) | | [optional] [default to const []] **icon** | **String** | | [optional] +**iconResourceId** | **String** | | [optional] +**iconUrl** | **String** | | [optional] +**order** | **int** | | [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_new/doc/LevelDTO.md b/manager_api_new/doc/LevelDTO.md index cc90072..5627672 100644 --- a/manager_api_new/doc/LevelDTO.md +++ b/manager_api_new/doc/LevelDTO.md @@ -8,10 +8,7 @@ import 'package:manager_api_new/api.dart'; ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**label** | [**List**](TranslationDTO.md) | | [optional] [default to const []] -**resourceId** | **String** | | [optional] -**resourceType** | [**ResourceType**](ResourceType.md) | | [optional] -**resourceUrl** | **String** | | [optional] +**label** | [**List**](TranslationAndResourceDTO.md) | | [optional] [default to const []] [[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_new/doc/PuzzleDTO.md b/manager_api_new/doc/PuzzleDTO.md index 152c9aa..3e290e8 100644 --- a/manager_api_new/doc/PuzzleDTO.md +++ b/manager_api_new/doc/PuzzleDTO.md @@ -8,8 +8,8 @@ import 'package:manager_api_new/api.dart'; ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**messageDebut** | [**List**](TranslationDTO.md) | | [optional] [default to const []] -**messageFin** | [**List**](TranslationDTO.md) | | [optional] [default to const []] +**messageDebut** | [**List**](TranslationAndResourceDTO.md) | | [optional] [default to const []] +**messageFin** | [**List**](TranslationAndResourceDTO.md) | | [optional] [default to const []] **image** | [**PuzzleDTOImage**](PuzzleDTOImage.md) | | [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_new/doc/QuestionDTO.md b/manager_api_new/doc/QuestionDTO.md index 51cce4a..b597774 100644 --- a/manager_api_new/doc/QuestionDTO.md +++ b/manager_api_new/doc/QuestionDTO.md @@ -8,11 +8,11 @@ import 'package:manager_api_new/api.dart'; ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**label** | [**List**](TranslationDTO.md) | | [optional] [default to const []] +**label** | [**List**](TranslationAndResourceDTO.md) | | [optional] [default to const []] **responses** | [**List**](ResponseDTO.md) | | [optional] [default to const []] -**resourceId** | **String** | | [optional] -**resourceType** | [**ResourceType**](ResourceType.md) | | [optional] -**resourceUrl** | **String** | | [optional] +**imageBackgroundResourceId** | **String** | | [optional] +**imageBackgroundResourceType** | [**ResourceType**](ResourceType.md) | | [optional] +**imageBackgroundResourceUrl** | **String** | | [optional] **order** | **int** | | [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_new/doc/QuizzDTOBadLevel.md b/manager_api_new/doc/QuizzDTOBadLevel.md index f7f96ac..c89cf1c 100644 --- a/manager_api_new/doc/QuizzDTOBadLevel.md +++ b/manager_api_new/doc/QuizzDTOBadLevel.md @@ -8,10 +8,7 @@ import 'package:manager_api_new/api.dart'; ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**label** | [**List**](TranslationDTO.md) | | [optional] [default to const []] -**resourceId** | **String** | | [optional] -**resourceType** | [**ResourceType**](ResourceType.md) | | [optional] -**resourceUrl** | **String** | | [optional] +**label** | [**List**](TranslationAndResourceDTO.md) | | [optional] [default to const []] [[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_new/doc/ResponseDTO.md b/manager_api_new/doc/ResponseDTO.md index 54c80e2..71c91bd 100644 --- a/manager_api_new/doc/ResponseDTO.md +++ b/manager_api_new/doc/ResponseDTO.md @@ -8,11 +8,8 @@ import 'package:manager_api_new/api.dart'; ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**label** | [**List**](TranslationDTO.md) | | [optional] [default to const []] +**label** | [**List**](TranslationAndResourceDTO.md) | | [optional] [default to const []] **isGood** | **bool** | | [optional] -**resourceId** | **String** | | [optional] -**resourceType** | [**ResourceType**](ResourceType.md) | | [optional] -**resourceUrl** | **String** | | [optional] **order** | **int** | | [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_new/doc/TranslationAndResourceDTO.md b/manager_api_new/doc/TranslationAndResourceDTO.md new file mode 100644 index 0000000..4326887 --- /dev/null +++ b/manager_api_new/doc/TranslationAndResourceDTO.md @@ -0,0 +1,19 @@ +# manager_api_new.model.TranslationAndResourceDTO + +## Load the model package +```dart +import 'package:manager_api_new/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**language** | **String** | | [optional] +**value** | **String** | | [optional] +**resourceId** | **String** | | [optional] +**resourceType** | [**ResourceType**](ResourceType.md) | | [optional] +**resourceUrl** | **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_new/lib/api.dart b/manager_api_new/lib/api.dart index d05a44a..3a2761d 100644 --- a/manager_api_new/lib/api.dart +++ b/manager_api_new/lib/api.dart @@ -69,6 +69,7 @@ part 'model/section_dto.dart'; part 'model/section_type.dart'; part 'model/slider_dto.dart'; part 'model/token_dto.dart'; +part 'model/translation_and_resource_dto.dart'; part 'model/translation_dto.dart'; part 'model/user.dart'; part 'model/user_detail_dto.dart'; diff --git a/manager_api_new/lib/api_client.dart b/manager_api_new/lib/api_client.dart index d12228b..0193f94 100644 --- a/manager_api_new/lib/api_client.dart +++ b/manager_api_new/lib/api_client.dart @@ -249,6 +249,8 @@ class ApiClient { return SliderDTO.fromJson(value); case 'TokenDTO': return TokenDTO.fromJson(value); + case 'TranslationAndResourceDTO': + return TranslationAndResourceDTO.fromJson(value); case 'TranslationDTO': return TranslationDTO.fromJson(value); case 'User': diff --git a/manager_api_new/lib/model/categorie_dto.dart b/manager_api_new/lib/model/categorie_dto.dart index ce4fcbe..823a423 100644 --- a/manager_api_new/lib/model/categorie_dto.dart +++ b/manager_api_new/lib/model/categorie_dto.dart @@ -13,40 +13,70 @@ part of openapi.api; class CategorieDTO { /// Returns a new [CategorieDTO] instance. CategorieDTO({ - this.name, + this.label = const [], this.icon, + this.iconResourceId, + this.iconUrl, + this.order, }); - String? name; + List? label; String? icon; + String? iconResourceId; + + String? iconUrl; + + int? order; + @override bool operator ==(Object other) => identical(this, other) || other is CategorieDTO && - other.name == name && - other.icon == icon; + other.label == label && + other.icon == icon && + other.iconResourceId == iconResourceId && + other.iconUrl == iconUrl && + other.order == order; @override int get hashCode => // ignore: unnecessary_parenthesis - (name == null ? 0 : name!.hashCode) + - (icon == null ? 0 : icon!.hashCode); + (label == null ? 0 : label!.hashCode) + + (icon == null ? 0 : icon!.hashCode) + + (iconResourceId == null ? 0 : iconResourceId!.hashCode) + + (iconUrl == null ? 0 : iconUrl!.hashCode) + + (order == null ? 0 : order!.hashCode); @override - String toString() => 'CategorieDTO[name=$name, icon=$icon]'; + String toString() => 'CategorieDTO[label=$label, icon=$icon, iconResourceId=$iconResourceId, iconUrl=$iconUrl, order=$order]'; Map toJson() { final json = {}; - if (this.name != null) { - json[r'name'] = this.name; + if (this.label != null) { + json[r'label'] = this.label; } else { - json[r'name'] = null; + json[r'label'] = null; } if (this.icon != null) { json[r'icon'] = this.icon; } else { json[r'icon'] = null; } + if (this.iconResourceId != null) { + json[r'iconResourceId'] = this.iconResourceId; + } else { + json[r'iconResourceId'] = null; + } + if (this.iconUrl != null) { + json[r'iconUrl'] = this.iconUrl; + } else { + json[r'iconUrl'] = null; + } + if (this.order != null) { + json[r'order'] = this.order; + } else { + json[r'order'] = null; + } return json; } @@ -69,8 +99,11 @@ class CategorieDTO { }()); return CategorieDTO( - name: mapValueOfType(json, r'name'), + label: TranslationDTO.listFromJson(json[r'label']), icon: mapValueOfType(json, r'icon'), + iconResourceId: mapValueOfType(json, r'iconResourceId'), + iconUrl: mapValueOfType(json, r'iconUrl'), + order: mapValueOfType(json, r'order'), ); } return null; diff --git a/manager_api_new/lib/model/geo_point_dto.dart b/manager_api_new/lib/model/geo_point_dto.dart index 0055667..38be1f2 100644 --- a/manager_api_new/lib/model/geo_point_dto.dart +++ b/manager_api_new/lib/model/geo_point_dto.dart @@ -36,7 +36,7 @@ class GeoPointDTO { List? contents; - GeoPointDTOCategorie? categorie; + CategorieDTO? categorie; String? latitude; @@ -129,7 +129,7 @@ class GeoPointDTO { title: TranslationDTO.listFromJson(json[r'title']), description: TranslationDTO.listFromJson(json[r'description']), contents: ContentGeoPoint.listFromJson(json[r'contents']), - categorie: GeoPointDTOCategorie.fromJson(json[r'categorie']), + categorie: CategorieDTO.fromJson(json[r'categorie']), latitude: mapValueOfType(json, r'latitude'), longitude: mapValueOfType(json, r'longitude'), ); diff --git a/manager_api_new/lib/model/geo_point_dto_categorie.dart b/manager_api_new/lib/model/geo_point_dto_categorie.dart index 184646a..ad87bbb 100644 --- a/manager_api_new/lib/model/geo_point_dto_categorie.dart +++ b/manager_api_new/lib/model/geo_point_dto_categorie.dart @@ -13,40 +13,70 @@ part of openapi.api; class GeoPointDTOCategorie { /// Returns a new [GeoPointDTOCategorie] instance. GeoPointDTOCategorie({ - this.name, + this.label = const [], this.icon, + this.iconResourceId, + this.iconUrl, + this.order, }); - String? name; + List? label; String? icon; + String? iconResourceId; + + String? iconUrl; + + int? order; + @override bool operator ==(Object other) => identical(this, other) || other is GeoPointDTOCategorie && - other.name == name && - other.icon == icon; + other.label == label && + other.icon == icon && + other.iconResourceId == iconResourceId && + other.iconUrl == iconUrl && + other.order == order; @override int get hashCode => // ignore: unnecessary_parenthesis - (name == null ? 0 : name!.hashCode) + - (icon == null ? 0 : icon!.hashCode); + (label == null ? 0 : label!.hashCode) + + (icon == null ? 0 : icon!.hashCode) + + (iconResourceId == null ? 0 : iconResourceId!.hashCode) + + (iconUrl == null ? 0 : iconUrl!.hashCode) + + (order == null ? 0 : order!.hashCode); @override - String toString() => 'GeoPointDTOCategorie[name=$name, icon=$icon]'; + String toString() => 'GeoPointDTOCategorie[label=$label, icon=$icon, iconResourceId=$iconResourceId, iconUrl=$iconUrl, order=$order]'; Map toJson() { final json = {}; - if (this.name != null) { - json[r'name'] = this.name; + if (this.label != null) { + json[r'label'] = this.label; } else { - json[r'name'] = null; + json[r'label'] = null; } if (this.icon != null) { json[r'icon'] = this.icon; } else { json[r'icon'] = null; } + if (this.iconResourceId != null) { + json[r'iconResourceId'] = this.iconResourceId; + } else { + json[r'iconResourceId'] = null; + } + if (this.iconUrl != null) { + json[r'iconUrl'] = this.iconUrl; + } else { + json[r'iconUrl'] = null; + } + if (this.order != null) { + json[r'order'] = this.order; + } else { + json[r'order'] = null; + } return json; } @@ -69,8 +99,11 @@ class GeoPointDTOCategorie { }()); return GeoPointDTOCategorie( - name: mapValueOfType(json, r'name'), + label: TranslationDTO.listFromJson(json[r'label']), icon: mapValueOfType(json, r'icon'), + iconResourceId: mapValueOfType(json, r'iconResourceId'), + iconUrl: mapValueOfType(json, r'iconUrl'), + order: mapValueOfType(json, r'order'), ); } return null; diff --git a/manager_api_new/lib/model/level_dto.dart b/manager_api_new/lib/model/level_dto.dart index ae154d9..79e8ea1 100644 --- a/manager_api_new/lib/model/level_dto.dart +++ b/manager_api_new/lib/model/level_dto.dart @@ -14,42 +14,21 @@ class LevelDTO { /// Returns a new [LevelDTO] instance. LevelDTO({ this.label = const [], - this.resourceId, - this.resourceType, - this.resourceUrl, }); - List? label; - - String? resourceId; - - /// - /// Please note: This property should have been non-nullable! Since the specification file - /// does not include a default value (using the "default:" property), however, the generated - /// source code must fall back to having a nullable type. - /// Consider adding a "default:" property in the specification file to hide this note. - /// - ResourceType? resourceType; - - String? resourceUrl; + List? label; @override bool operator ==(Object other) => identical(this, other) || other is LevelDTO && - other.label == label && - other.resourceId == resourceId && - other.resourceType == resourceType && - other.resourceUrl == resourceUrl; + other.label == label; @override int get hashCode => // ignore: unnecessary_parenthesis - (label == null ? 0 : label!.hashCode) + - (resourceId == null ? 0 : resourceId!.hashCode) + - (resourceType == null ? 0 : resourceType!.hashCode) + - (resourceUrl == null ? 0 : resourceUrl!.hashCode); + (label == null ? 0 : label!.hashCode); @override - String toString() => 'LevelDTO[label=$label, resourceId=$resourceId, resourceType=$resourceType, resourceUrl=$resourceUrl]'; + String toString() => 'LevelDTO[label=$label]'; Map toJson() { final json = {}; @@ -58,21 +37,6 @@ class LevelDTO { } else { json[r'label'] = null; } - if (this.resourceId != null) { - json[r'resourceId'] = this.resourceId; - } else { - json[r'resourceId'] = null; - } - if (this.resourceType != null) { - json[r'resourceType'] = this.resourceType; - } else { - json[r'resourceType'] = null; - } - if (this.resourceUrl != null) { - json[r'resourceUrl'] = this.resourceUrl; - } else { - json[r'resourceUrl'] = null; - } return json; } @@ -95,10 +59,7 @@ class LevelDTO { }()); return LevelDTO( - label: TranslationDTO.listFromJson(json[r'label']), - resourceId: mapValueOfType(json, r'resourceId'), - resourceType: ResourceType.fromJson(json[r'resourceType']), - resourceUrl: mapValueOfType(json, r'resourceUrl'), + label: TranslationAndResourceDTO.listFromJson(json[r'label']), ); } return null; diff --git a/manager_api_new/lib/model/puzzle_dto.dart b/manager_api_new/lib/model/puzzle_dto.dart index 4b89f15..2955a13 100644 --- a/manager_api_new/lib/model/puzzle_dto.dart +++ b/manager_api_new/lib/model/puzzle_dto.dart @@ -18,9 +18,9 @@ class PuzzleDTO { this.image, }); - List? messageDebut; + List? messageDebut; - List? messageFin; + List? messageFin; PuzzleDTOImage? image; @@ -79,8 +79,8 @@ class PuzzleDTO { }()); return PuzzleDTO( - messageDebut: TranslationDTO.listFromJson(json[r'messageDebut']), - messageFin: TranslationDTO.listFromJson(json[r'messageFin']), + messageDebut: TranslationAndResourceDTO.listFromJson(json[r'messageDebut']), + messageFin: TranslationAndResourceDTO.listFromJson(json[r'messageFin']), image: PuzzleDTOImage.fromJson(json[r'image']), ); } diff --git a/manager_api_new/lib/model/question_dto.dart b/manager_api_new/lib/model/question_dto.dart index e2ee08c..4eb1254 100644 --- a/manager_api_new/lib/model/question_dto.dart +++ b/manager_api_new/lib/model/question_dto.dart @@ -15,17 +15,17 @@ class QuestionDTO { QuestionDTO({ this.label = const [], this.responses = const [], - this.resourceId, - this.resourceType, - this.resourceUrl, + this.imageBackgroundResourceId, + this.imageBackgroundResourceType, + this.imageBackgroundResourceUrl, this.order, }); - List? label; + List? label; List? responses; - String? resourceId; + String? imageBackgroundResourceId; /// /// Please note: This property should have been non-nullable! Since the specification file @@ -33,9 +33,9 @@ class QuestionDTO { /// source code must fall back to having a nullable type. /// Consider adding a "default:" property in the specification file to hide this note. /// - ResourceType? resourceType; + ResourceType? imageBackgroundResourceType; - String? resourceUrl; + String? imageBackgroundResourceUrl; /// /// Please note: This property should have been non-nullable! Since the specification file @@ -49,9 +49,9 @@ class QuestionDTO { bool operator ==(Object other) => identical(this, other) || other is QuestionDTO && other.label == label && other.responses == responses && - other.resourceId == resourceId && - other.resourceType == resourceType && - other.resourceUrl == resourceUrl && + other.imageBackgroundResourceId == imageBackgroundResourceId && + other.imageBackgroundResourceType == imageBackgroundResourceType && + other.imageBackgroundResourceUrl == imageBackgroundResourceUrl && other.order == order; @override @@ -59,13 +59,13 @@ class QuestionDTO { // ignore: unnecessary_parenthesis (label == null ? 0 : label!.hashCode) + (responses == null ? 0 : responses!.hashCode) + - (resourceId == null ? 0 : resourceId!.hashCode) + - (resourceType == null ? 0 : resourceType!.hashCode) + - (resourceUrl == null ? 0 : resourceUrl!.hashCode) + + (imageBackgroundResourceId == null ? 0 : imageBackgroundResourceId!.hashCode) + + (imageBackgroundResourceType == null ? 0 : imageBackgroundResourceType!.hashCode) + + (imageBackgroundResourceUrl == null ? 0 : imageBackgroundResourceUrl!.hashCode) + (order == null ? 0 : order!.hashCode); @override - String toString() => 'QuestionDTO[label=$label, responses=$responses, resourceId=$resourceId, resourceType=$resourceType, resourceUrl=$resourceUrl, order=$order]'; + String toString() => 'QuestionDTO[label=$label, responses=$responses, imageBackgroundResourceId=$imageBackgroundResourceId, imageBackgroundResourceType=$imageBackgroundResourceType, imageBackgroundResourceUrl=$imageBackgroundResourceUrl, order=$order]'; Map toJson() { final json = {}; @@ -79,20 +79,20 @@ class QuestionDTO { } else { json[r'responses'] = null; } - if (this.resourceId != null) { - json[r'resourceId'] = this.resourceId; + if (this.imageBackgroundResourceId != null) { + json[r'imageBackgroundResourceId'] = this.imageBackgroundResourceId; } else { - json[r'resourceId'] = null; + json[r'imageBackgroundResourceId'] = null; } - if (this.resourceType != null) { - json[r'resourceType'] = this.resourceType; + if (this.imageBackgroundResourceType != null) { + json[r'imageBackgroundResourceType'] = this.imageBackgroundResourceType; } else { - json[r'resourceType'] = null; + json[r'imageBackgroundResourceType'] = null; } - if (this.resourceUrl != null) { - json[r'resourceUrl'] = this.resourceUrl; + if (this.imageBackgroundResourceUrl != null) { + json[r'imageBackgroundResourceUrl'] = this.imageBackgroundResourceUrl; } else { - json[r'resourceUrl'] = null; + json[r'imageBackgroundResourceUrl'] = null; } if (this.order != null) { json[r'order'] = this.order; @@ -121,11 +121,11 @@ class QuestionDTO { }()); return QuestionDTO( - label: TranslationDTO.listFromJson(json[r'label']), + label: TranslationAndResourceDTO.listFromJson(json[r'label']), responses: ResponseDTO.listFromJson(json[r'responses']), - resourceId: mapValueOfType(json, r'resourceId'), - resourceType: ResourceType.fromJson(json[r'resourceType']), - resourceUrl: mapValueOfType(json, r'resourceUrl'), + imageBackgroundResourceId: mapValueOfType(json, r'imageBackgroundResourceId'), + imageBackgroundResourceType: ResourceType.fromJson(json[r'imageBackgroundResourceType']), + imageBackgroundResourceUrl: mapValueOfType(json, r'imageBackgroundResourceUrl'), order: mapValueOfType(json, r'order'), ); } diff --git a/manager_api_new/lib/model/quizz_dto_bad_level.dart b/manager_api_new/lib/model/quizz_dto_bad_level.dart index 63b674b..3e2fee2 100644 --- a/manager_api_new/lib/model/quizz_dto_bad_level.dart +++ b/manager_api_new/lib/model/quizz_dto_bad_level.dart @@ -14,42 +14,21 @@ class QuizzDTOBadLevel { /// Returns a new [QuizzDTOBadLevel] instance. QuizzDTOBadLevel({ this.label = const [], - this.resourceId, - this.resourceType, - this.resourceUrl, }); - List? label; - - String? resourceId; - - /// - /// Please note: This property should have been non-nullable! Since the specification file - /// does not include a default value (using the "default:" property), however, the generated - /// source code must fall back to having a nullable type. - /// Consider adding a "default:" property in the specification file to hide this note. - /// - ResourceType? resourceType; - - String? resourceUrl; + List? label; @override bool operator ==(Object other) => identical(this, other) || other is QuizzDTOBadLevel && - other.label == label && - other.resourceId == resourceId && - other.resourceType == resourceType && - other.resourceUrl == resourceUrl; + other.label == label; @override int get hashCode => // ignore: unnecessary_parenthesis - (label == null ? 0 : label!.hashCode) + - (resourceId == null ? 0 : resourceId!.hashCode) + - (resourceType == null ? 0 : resourceType!.hashCode) + - (resourceUrl == null ? 0 : resourceUrl!.hashCode); + (label == null ? 0 : label!.hashCode); @override - String toString() => 'QuizzDTOBadLevel[label=$label, resourceId=$resourceId, resourceType=$resourceType, resourceUrl=$resourceUrl]'; + String toString() => 'QuizzDTOBadLevel[label=$label]'; Map toJson() { final json = {}; @@ -58,21 +37,6 @@ class QuizzDTOBadLevel { } else { json[r'label'] = null; } - if (this.resourceId != null) { - json[r'resourceId'] = this.resourceId; - } else { - json[r'resourceId'] = null; - } - if (this.resourceType != null) { - json[r'resourceType'] = this.resourceType; - } else { - json[r'resourceType'] = null; - } - if (this.resourceUrl != null) { - json[r'resourceUrl'] = this.resourceUrl; - } else { - json[r'resourceUrl'] = null; - } return json; } @@ -95,10 +59,7 @@ class QuizzDTOBadLevel { }()); return QuizzDTOBadLevel( - label: TranslationDTO.listFromJson(json[r'label']), - resourceId: mapValueOfType(json, r'resourceId'), - resourceType: ResourceType.fromJson(json[r'resourceType']), - resourceUrl: mapValueOfType(json, r'resourceUrl'), + label: TranslationAndResourceDTO.listFromJson(json[r'label']), ); } return null; diff --git a/manager_api_new/lib/model/response_dto.dart b/manager_api_new/lib/model/response_dto.dart index d72237a..6963754 100644 --- a/manager_api_new/lib/model/response_dto.dart +++ b/manager_api_new/lib/model/response_dto.dart @@ -15,13 +15,10 @@ class ResponseDTO { ResponseDTO({ this.label = const [], this.isGood, - this.resourceId, - this.resourceType, - this.resourceUrl, this.order, }); - List? label; + List? label; /// /// Please note: This property should have been non-nullable! Since the specification file @@ -31,18 +28,6 @@ class ResponseDTO { /// bool? isGood; - String? resourceId; - - /// - /// Please note: This property should have been non-nullable! Since the specification file - /// does not include a default value (using the "default:" property), however, the generated - /// source code must fall back to having a nullable type. - /// Consider adding a "default:" property in the specification file to hide this note. - /// - ResourceType? resourceType; - - String? resourceUrl; - /// /// Please note: This property should have been non-nullable! Since the specification file /// does not include a default value (using the "default:" property), however, the generated @@ -55,9 +40,6 @@ class ResponseDTO { bool operator ==(Object other) => identical(this, other) || other is ResponseDTO && other.label == label && other.isGood == isGood && - other.resourceId == resourceId && - other.resourceType == resourceType && - other.resourceUrl == resourceUrl && other.order == order; @override @@ -65,13 +47,10 @@ class ResponseDTO { // ignore: unnecessary_parenthesis (label == null ? 0 : label!.hashCode) + (isGood == null ? 0 : isGood!.hashCode) + - (resourceId == null ? 0 : resourceId!.hashCode) + - (resourceType == null ? 0 : resourceType!.hashCode) + - (resourceUrl == null ? 0 : resourceUrl!.hashCode) + (order == null ? 0 : order!.hashCode); @override - String toString() => 'ResponseDTO[label=$label, isGood=$isGood, resourceId=$resourceId, resourceType=$resourceType, resourceUrl=$resourceUrl, order=$order]'; + String toString() => 'ResponseDTO[label=$label, isGood=$isGood, order=$order]'; Map toJson() { final json = {}; @@ -85,21 +64,6 @@ class ResponseDTO { } else { json[r'isGood'] = null; } - if (this.resourceId != null) { - json[r'resourceId'] = this.resourceId; - } else { - json[r'resourceId'] = null; - } - if (this.resourceType != null) { - json[r'resourceType'] = this.resourceType; - } else { - json[r'resourceType'] = null; - } - if (this.resourceUrl != null) { - json[r'resourceUrl'] = this.resourceUrl; - } else { - json[r'resourceUrl'] = null; - } if (this.order != null) { json[r'order'] = this.order; } else { @@ -127,11 +91,8 @@ class ResponseDTO { }()); return ResponseDTO( - label: TranslationDTO.listFromJson(json[r'label']), + label: TranslationAndResourceDTO.listFromJson(json[r'label']), isGood: mapValueOfType(json, r'isGood'), - resourceId: mapValueOfType(json, r'resourceId'), - resourceType: ResourceType.fromJson(json[r'resourceType']), - resourceUrl: mapValueOfType(json, r'resourceUrl'), order: mapValueOfType(json, r'order'), ); } diff --git a/manager_api_new/lib/model/translation_and_resource_dto.dart b/manager_api_new/lib/model/translation_and_resource_dto.dart new file mode 100644 index 0000000..f365b2e --- /dev/null +++ b/manager_api_new/lib/model/translation_and_resource_dto.dart @@ -0,0 +1,162 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// +// @dart=2.12 + +// ignore_for_file: unused_element, unused_import +// ignore_for_file: always_put_required_named_parameters_first +// ignore_for_file: constant_identifier_names +// ignore_for_file: lines_longer_than_80_chars + +part of openapi.api; + +class TranslationAndResourceDTO { + /// Returns a new [TranslationAndResourceDTO] instance. + TranslationAndResourceDTO({ + this.language, + this.value, + this.resourceId, + this.resourceType, + this.resourceUrl, + }); + + String? language; + + String? value; + + String? resourceId; + + /// + /// Please note: This property should have been non-nullable! Since the specification file + /// does not include a default value (using the "default:" property), however, the generated + /// source code must fall back to having a nullable type. + /// Consider adding a "default:" property in the specification file to hide this note. + /// + ResourceType? resourceType; + + String? resourceUrl; + + @override + bool operator ==(Object other) => identical(this, other) || other is TranslationAndResourceDTO && + other.language == language && + other.value == value && + other.resourceId == resourceId && + other.resourceType == resourceType && + other.resourceUrl == resourceUrl; + + @override + int get hashCode => + // ignore: unnecessary_parenthesis + (language == null ? 0 : language!.hashCode) + + (value == null ? 0 : value!.hashCode) + + (resourceId == null ? 0 : resourceId!.hashCode) + + (resourceType == null ? 0 : resourceType!.hashCode) + + (resourceUrl == null ? 0 : resourceUrl!.hashCode); + + @override + String toString() => 'TranslationAndResourceDTO[language=$language, value=$value, resourceId=$resourceId, resourceType=$resourceType, resourceUrl=$resourceUrl]'; + + Map toJson() { + final json = {}; + if (this.language != null) { + json[r'language'] = this.language; + } else { + json[r'language'] = null; + } + if (this.value != null) { + json[r'value'] = this.value; + } else { + json[r'value'] = null; + } + if (this.resourceId != null) { + json[r'resourceId'] = this.resourceId; + } else { + json[r'resourceId'] = null; + } + if (this.resourceType != null) { + json[r'resourceType'] = this.resourceType; + } else { + json[r'resourceType'] = null; + } + if (this.resourceUrl != null) { + json[r'resourceUrl'] = this.resourceUrl; + } else { + json[r'resourceUrl'] = null; + } + return json; + } + + /// Returns a new [TranslationAndResourceDTO] instance and imports its values from + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static TranslationAndResourceDTO? fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + + // Ensure that the map contains the required keys. + // Note 1: the values aren't checked for validity beyond being non-null. + // Note 2: this code is stripped in release mode! + assert(() { + requiredKeys.forEach((key) { + assert(json.containsKey(key), 'Required key "TranslationAndResourceDTO[$key]" is missing from JSON.'); + assert(json[key] != null, 'Required key "TranslationAndResourceDTO[$key]" has a null value in JSON.'); + }); + return true; + }()); + + return TranslationAndResourceDTO( + language: mapValueOfType(json, r'language'), + value: mapValueOfType(json, r'value'), + resourceId: mapValueOfType(json, r'resourceId'), + resourceType: ResourceType.fromJson(json[r'resourceType']), + resourceUrl: mapValueOfType(json, r'resourceUrl'), + ); + } + return null; + } + + static List listFromJson(dynamic json, {bool growable = false,}) { + final result = []; + if (json is List && json.isNotEmpty) { + for (final row in json) { + final value = TranslationAndResourceDTO.fromJson(row); + if (value != null) { + result.add(value); + } + } + } + return result.toList(growable: growable); + } + + static Map mapFromJson(dynamic json) { + final map = {}; + if (json is Map && json.isNotEmpty) { + json = json.cast(); // ignore: parameter_assignments + for (final entry in json.entries) { + final value = TranslationAndResourceDTO.fromJson(entry.value); + if (value != null) { + map[entry.key] = value; + } + } + } + return map; + } + + // maps a json object with a list of TranslationAndResourceDTO-objects as value to a dart map + static Map> mapListFromJson(dynamic json, {bool growable = false,}) { + final map = >{}; + if (json is Map && json.isNotEmpty) { + // ignore: parameter_assignments + json = json.cast(); + for (final entry in json.entries) { + map[entry.key] = TranslationAndResourceDTO.listFromJson(entry.value, growable: growable,); + } + } + return map; + } + + /// The list of required keys that must be present in a JSON. + static const requiredKeys = { + }; +} + diff --git a/manager_api_new/test/translation_and_resource_dto_test.dart b/manager_api_new/test/translation_and_resource_dto_test.dart new file mode 100644 index 0000000..520204e --- /dev/null +++ b/manager_api_new/test/translation_and_resource_dto_test.dart @@ -0,0 +1,47 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// +// @dart=2.12 + +// ignore_for_file: unused_element, unused_import +// ignore_for_file: always_put_required_named_parameters_first +// ignore_for_file: constant_identifier_names +// ignore_for_file: lines_longer_than_80_chars + +import 'package:manager_api_new/api.dart'; +import 'package:test/test.dart'; + +// tests for TranslationAndResourceDTO +void main() { + // final instance = TranslationAndResourceDTO(); + + group('test TranslationAndResourceDTO', () { + // String language + test('to test the property `language`', () async { + // TODO + }); + + // String value + test('to test the property `value`', () async { + // TODO + }); + + // String resourceId + test('to test the property `resourceId`', () async { + // TODO + }); + + // ResourceType resourceType + test('to test the property `resourceType`', () async { + // TODO + }); + + // String resourceUrl + test('to test the property `resourceUrl`', () async { + // TODO + }); + + + }); + +}