From 21b38052cc66a0025a242b836f5f6a03159c4ee3 Mon Sep 17 00:00:00 2001 From: Fransolet Thomas Date: Tue, 27 Dec 2022 22:46:42 +0100 Subject: [PATCH] Fix images on languages update + add Beacon handling --- .../Slider/new_update_image_slider.dart | 17 +++++++ .../Section/section_detail_screen.dart | 50 +++++++++++++++---- 2 files changed, 58 insertions(+), 9 deletions(-) diff --git a/lib/Screens/Configurations/Section/SubSection/Slider/new_update_image_slider.dart b/lib/Screens/Configurations/Section/SubSection/Slider/new_update_image_slider.dart index 501edeb..1ac1845 100644 --- a/lib/Screens/Configurations/Section/SubSection/Slider/new_update_image_slider.dart +++ b/lib/Screens/Configurations/Section/SubSection/Slider/new_update_image_slider.dart @@ -128,6 +128,23 @@ getTranslations(BuildContext context, AppContext appContext, ImageDTO imageDTO, List translations = []; ManagerAppContext managerAppContext = appContext.getContext(); for(var language in managerAppContext.selectedConfiguration.languages) { + + if(imageDTO.title.where((element) => element.language == language).length == 0) { + imageDTO.title = []; + var translationTitleDTO = new TranslationDTO(); + translationTitleDTO.language = language; + translationTitleDTO.value = ""; + imageDTO.title.add(translationTitleDTO); + } + + if(imageDTO.description.where((element) => element.language == language).length == 0) { + imageDTO.description = []; + var translationDescriptionDTO = new TranslationDTO(); + translationDescriptionDTO.language = language; + translationDescriptionDTO.value = ""; + imageDTO.description.add(translationDescriptionDTO); + } + translations.add( Padding( padding: const EdgeInsets.all(8.0), diff --git a/lib/Screens/Configurations/Section/section_detail_screen.dart b/lib/Screens/Configurations/Section/section_detail_screen.dart index dfccada..398d015 100644 --- a/lib/Screens/Configurations/Section/section_detail_screen.dart +++ b/lib/Screens/Configurations/Section/section_detail_screen.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:manager_app/Components/audio_input_container.dart'; +import 'package:manager_app/Components/check_input_container.dart'; import 'package:manager_app/Components/confirmation_dialog.dart'; import 'package:manager_app/Components/fetch_section_icon.dart'; import 'package:manager_app/Components/image_input_container.dart'; @@ -149,14 +149,46 @@ class _SectionDetailScreenState extends State { mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ if(sectionDTO.type == SectionType.Article) - Container( - width: size.width *0.1, - height: 125, - child: QrImage( - data: sectionDTO.id, - version: QrVersions.auto, - size: 50.0, - ), + Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + width: size.width *0.1, + height: 125, + child: QrImage( + padding: EdgeInsets.only(left: 0.0, top: 5.0, bottom: 5.0), + data: sectionDTO.id, + version: QrVersions.auto, + size: 50.0, + ), + ), + SelectableText(sectionDTO.id, style: new TextStyle(fontSize: 15)) + ], + ), + CheckInputContainer( + label: "Beacon :", + isChecked: sectionDTO.isBeacon, + fontSize: 25, + onChanged: (value) { + setState(() { + sectionDTO.isBeacon = value; + save(true, sectionDTO, appContext); + }); + }, + ), + if(sectionDTO.isBeacon) + StringInputContainer( + label: "Identifiant Beacon :", + initialValue: sectionDTO != null ? sectionDTO.beaconId : "", + onChanged: (value) { + sectionDTO.beaconId = value; + }, + ), + ], ), Column( mainAxisAlignment: MainAxisAlignment.spaceAround,