From 72a96b08b64f3e749e8a897bccafcc67c325398b Mon Sep 17 00:00:00 2001 From: Fransolet Thomas Date: Sat, 3 Sep 2022 17:52:53 +0200 Subject: [PATCH] Add language selection --- .flutter-plugins-dependencies | 2 +- .packages | 2 +- assets/images/DE.png | Bin 0 -> 225 bytes assets/images/EN.png | Bin 0 -> 2032 bytes assets/images/FR.png | Bin 0 -> 233 bytes assets/images/NL.png | Bin 0 -> 219 bytes lib/Components/CustomAppBar.dart | 11 ++++ lib/Components/LanguageSelection.dart | 88 ++++++++++++++++++++++++++ lib/Components/SliderImages.dart | 3 - lib/Models/visitContext.dart | 11 ++-- lib/Screens/Article/article.dart | 47 ++++++++------ pubspec.yaml | 5 ++ 12 files changed, 141 insertions(+), 28 deletions(-) create mode 100644 assets/images/DE.png create mode 100644 assets/images/EN.png create mode 100644 assets/images/FR.png create mode 100644 assets/images/NL.png create mode 100644 lib/Components/LanguageSelection.dart diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index 305d80e..5cfbe18 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"qr_code_scanner","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\qr_code_scanner-1.0.0\\\\","native_build":true,"dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-2.0.3+1\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"qr_code_scanner","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\qr_code_scanner-1.0.0\\\\","native_build":true,"dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-2.0.3+1\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"sqflite","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-2.0.3+1\\\\","native_build":true,"dependencies":[]}],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"qr_code_scanner","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2022-08-31 18:00:02.358724","version":"3.0.3"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"qr_code_scanner","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\qr_code_scanner-1.0.0\\\\","native_build":true,"dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-2.0.3+1\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"qr_code_scanner","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\qr_code_scanner-1.0.0\\\\","native_build":true,"dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-2.0.3+1\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"sqflite","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-2.0.3+1\\\\","native_build":true,"dependencies":[]}],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"qr_code_scanner","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2022-09-03 17:27:02.945881","version":"3.0.3"} \ No newline at end of file diff --git a/.packages b/.packages index 2a5f97f..4791810 100644 --- a/.packages +++ b/.packages @@ -3,7 +3,7 @@ # # For more info see: https://dart.dev/go/dot-packages-deprecation # -# Generated by pub on 2022-08-31 16:18:04.785377. +# Generated by pub on 2022-09-03 17:19:05.522230. _fe_analyzer_shared:file:///C:/Users/thoma/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/_fe_analyzer_shared-31.0.0/lib/ analyzer:file:///C:/Users/thoma/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/analyzer-2.8.0/lib/ args:file:///C:/Users/thoma/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/args-2.3.1/lib/ diff --git a/assets/images/DE.png b/assets/images/DE.png new file mode 100644 index 0000000000000000000000000000000000000000..c4caaaf186a7db0af2c63a29d52a8b63542f28c9 GIT binary patch literal 225 zcmeAS@N?(olHy`uVBq!ia0vp^zd)FU8Aw(ga_0k5q5(c3u0Z<#IflDH@;bu{H-?uC z43iibR@g0(0!p-dx;TbZ+r)fMvt>23DN}M(&6M`&*=56x=TL;7I|hf`W4& z&CgypDW7bcvi@J$k2{8h00H)+wrXo?tM-q5)&1*Vzv}nv?pM{X z8E5g{J9Uh8U@+KDpVMA}(73wQzt{$0vwZ~u2Gh85);IVhY+w53<|Y?u0}<{n8;JMn zTEdKO@{Er_9;mG=m7k7!uSmufJ^VY5IM=9ehVU^PYipd3;^l#17>X=(#jA$Jxy%o9 z<+bC)+t3AyNNO78iMN;q$TuE(d0o+GmVOq}GiQ zvhEkQa}5p*NoE(S>-7#$C6`l#BQu|drsL9Tbq-J$-ZorKtr1^Hg0Aq#VNYp1S-l`r zaQ{$$mV*zAM5oU!3kIhjv&ND$2Rwp=?g2`k;B#Z!=-7NtLEHDY-wmC;AoBkEN7$~h zN!g%y_9JhC`cq>n<2U4yJ21T)%Km|+fA-FmR!1gP01uuCoX{@Qhs z@M`4Twcp^{kDfKVHK^ai zs8g1(X-yJOmBi`lkem+heyym=t`D>e#{G2Wq>QqDSCzA8_|Q{yovx2^IbFkbrMph+ zJ9Kz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kF(X?z}u^gQZWz?|-# b(1e-Zjb&Xz47`JW6qwIRyjPXy`K*5dHTxcW literal 0 HcmV?d00001 diff --git a/assets/images/FR.png b/assets/images/FR.png new file mode 100644 index 0000000000000000000000000000000000000000..feff21014358db4f4f59d35fce925ee3f8483049 GIT binary patch literal 233 zcmeAS@N?(olHy`uVBq!ia0vp^zd)FU8Aw(ga_0k5q5(c3uK)l4XHcH{R?~9j*4sa~ z?_rRf@J8MsHNK+-sG#4|#WAGf*4wj&j0^@G%mzAV4joBg_#e07!enK`2~{gshWwv$ lH*fpxw`IF&PyPM0uhYB#;db4>NkFGDc)I$ztaD0e0szrAdMf|` literal 0 HcmV?d00001 diff --git a/assets/images/NL.png b/assets/images/NL.png new file mode 100644 index 0000000000000000000000000000000000000000..e4563020d6dad7798fab7b059511ecd44d3d873e GIT binary patch literal 219 zcmeAS@N?(olHy`uVBq!ia0vp^zd)FU8Aw(ga_0k5q5(c3uK)l4f3j)YmIF7|$!I9L zb*~bV6Sr%#5N4AGDrod{aSW-r_4e#Rh64ryEC)hYIEgG0Xw^C*zwo})8{0G%wcVO! zyYJ?0zx@^uwft><@VsR} { }); } ) : null, + actions: [ + Padding( + padding: const EdgeInsets.only(right: 10.0), + child: SizedBox( + width: 50, + height: 50, + child: LanguageSelection() + ) + ), + ], flexibleSpace: Container( decoration: const BoxDecoration( gradient: LinearGradient( diff --git a/lib/Components/LanguageSelection.dart b/lib/Components/LanguageSelection.dart new file mode 100644 index 0000000..3c78983 --- /dev/null +++ b/lib/Components/LanguageSelection.dart @@ -0,0 +1,88 @@ +import 'package:flutter/material.dart'; +import 'package:mymuseum_visitapp/Models/visitContext.dart'; +import 'package:mymuseum_visitapp/app_context.dart'; +import 'package:mymuseum_visitapp/constants.dart'; +import 'package:provider/provider.dart'; + +class LanguageSelection extends StatefulWidget { + const LanguageSelection(); + + @override + _LanguageSelection createState() => _LanguageSelection(); +} + +class _LanguageSelection extends State with TickerProviderStateMixin { + List? languagesEnable; + double flagSize = 60; + + String? selectedLanguage; + double? elementMinimizedSize; + + @override + Widget build(BuildContext context) { + final appContext = Provider.of(context); + Size size = MediaQuery.of(context).size; + print("YOLOO"); + selectedLanguage = (appContext.getContext() as VisitAppContext).language; + print(selectedLanguage); + languagesEnable = ["FR", "EN", "NL", "DE"]; // TODO + //languagesEnable = (appContext.getContext() as VisitAppContext).configuration!.languages; // Todo filter language possible + print(languagesEnable); + + return PopupMenuButton( + icon: Container( + height: size.height *0.07, + width: size.width *0.07, + decoration: flagDecoration(selectedLanguage!), + ), + itemBuilder: (context){ + int i = 0; + List menuItems = []; + for(var language in languagesEnable!) { + menuItems.add(PopupMenuItem( + value: i, + child: Center( + child: Container( + width: size.width *0.07, + height: size.width *0.07, + decoration: flagDecoration(language), + ) + ), + )); + i = i+1; + } + return menuItems; + }, + onSelected:(value){ + // TODO update App context + update local DB + if(value == 0){ + print("My account menu is selected."); + }else if(value == 1){ + print("Settings menu is selected."); + }else if(value == 2){ + print("Logout menu is selected."); + } + } + ); + } + + flagDecoration(String language) { + return BoxDecoration( + color: kBackgroundColor, + shape: BoxShape.circle, + //border: Border.all(width: 1.5, color: kSecondGrey), + image: DecorationImage( + fit: BoxFit.contain, + image: AssetImage("assets/images/"+language+".png"), + ), + boxShadow: const [ + BoxShadow( + color: kSecondGrey, + spreadRadius: 0.5, + blurRadius: 5, + offset: Offset(0, 1.5), // changes position of shadow + ), + ], + ); + } +} \ No newline at end of file diff --git a/lib/Components/SliderImages.dart b/lib/Components/SliderImages.dart index 3460b74..3ffc17f 100644 --- a/lib/Components/SliderImages.dart +++ b/lib/Components/SliderImages.dart @@ -6,7 +6,6 @@ import 'package:mymuseum_visitapp/Models/resourceModel.dart'; import 'package:mymuseum_visitapp/app_context.dart'; import 'package:mymuseum_visitapp/constants.dart'; import 'package:provider/provider.dart'; -import 'package:photo_view/photo_view.dart'; class SliderImagesWidget extends StatefulWidget { final List resources; @@ -29,10 +28,8 @@ class _SliderImagesWidget extends State { @override void dispose() { - print("COUCOU DISPOSE"); sliderController = null; super.dispose(); - print("COUCOU DISPOSE AFTER"); } @override diff --git a/lib/Models/visitContext.dart b/lib/Models/visitContext.dart index 52de53a..e63b475 100644 --- a/lib/Models/visitContext.dart +++ b/lib/Models/visitContext.dart @@ -1,3 +1,5 @@ +import 'dart:convert'; + import 'package:flutter/material.dart'; import 'package:manager_api/api.dart'; @@ -7,15 +9,16 @@ class VisitAppContext with ChangeNotifier{ //String? host = ""; String? language = ""; List? configurations; + ConfigurationDTO? configuration; - VisitAppContext({this.language, this.id}); + VisitAppContext({this.language, this.id, this.configuration}); Map toMap() { return { 'id': id, //'host': host, 'language': language, - //'token': token + 'configuration': configuration == null ? null : jsonEncode(configuration?.toJson()), }; } @@ -24,13 +27,13 @@ class VisitAppContext with ChangeNotifier{ id: json['id'] as String, /*host: json['host'] as String,*/ language: json['language'] as String, - //token: json['token'] as String, + configuration: json['configuration'] == null ? null : ConfigurationDTO.fromJson(json['configuration']), ); } // Implement toString to make it easier to see information about @override String toString() { - return 'VisitAppContext{id: $id, language: $language}'; + return 'VisitAppContext{id: $id, language: $language, configuration: $configuration}'; } } \ No newline at end of file diff --git a/lib/Screens/Article/article.dart b/lib/Screens/Article/article.dart index 0aa264d..f10f71c 100644 --- a/lib/Screens/Article/article.dart +++ b/lib/Screens/Article/article.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:manager_api/api.dart'; +import 'package:mymuseum_visitapp/Components/CustomAppBar.dart'; import 'package:mymuseum_visitapp/Components/Loading.dart'; import 'package:mymuseum_visitapp/Components/ScannerBouton.dart'; import 'package:mymuseum_visitapp/Components/SliderImages.dart'; @@ -35,21 +36,22 @@ class _ArticlePageState extends State { Widget build(BuildContext context) { final appContext = Provider.of(context); Size size = MediaQuery.of(context).size; + final notchInset = MediaQuery.of(context).padding; return Scaffold( key: _scaffoldKey, - /*appBar: CustomAppBar( + appBar: CustomAppBar( title: sectionDTO != null ? TranslationHelper.get(sectionDTO!.title, appContext) : "", isHomeButton: false, - ),*/ + ), body: FutureBuilder( future: getArticle(appContext.clientAPI, widget.articleId), builder: (context, AsyncSnapshot snapshot) { if(articleDTO != null && sectionDTO != null) { return Column( children: [ - if(mainResource != null) + /*if(mainResource != null) Container( - height: size.height * 0.2, + height: size.height * 0.1, width: size.width, child: Stack( children: [ @@ -86,27 +88,34 @@ class _ArticlePageState extends State { ) ], ), - InkWell( - onTap: () { - print("play push"); - }, - child: const Center( - child: Padding( - padding: EdgeInsets.only(right: 20.0), - child: Icon(Icons.play_arrow, size: 35, color: kMainColor), - ), - ), - ) + if(articleDTO!.audioId != null) + InkWell( + onTap: () { + print("play push"); + }, + child: const Center( + child: Padding( + padding: EdgeInsets.only(right: 20.0), + child: Icon(Icons.play_arrow, size: 35, color: kMainColor), + ), + ), + ) ], ), ) ], ), ), - Positioned( - top: 0, + /*Positioned( + top: notchInset.top, left: 0, - child: Text("Coucou")) + child: InkWell( + onTap: () { + setState(() { + Navigator.of(context).pop(); + }); + }, + child: Text("Coucou")))*/ ], ), decoration: BoxDecoration( @@ -118,7 +127,7 @@ class _ArticlePageState extends State { //color: kMainColor ), ), - + */ if(articleDTO!.isContentTop!) diff --git a/pubspec.yaml b/pubspec.yaml index b966d16..7f21eb2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -70,6 +70,11 @@ flutter: # the material Icons class. uses-material-design: true + assets: + #- assets/icons/ + - assets/images/ + #- assets/animations/ + #- assets/files/ # To add assets to your application, add an assets section, like this: # assets: # - images/a_dot_burr.jpeg