diff --git a/lib/Components/Buttons/rounded_button.dart b/lib/Components/Buttons/rounded_button.dart index 2a6ce58..994547a 100644 --- a/lib/Components/Buttons/rounded_button.dart +++ b/lib/Components/Buttons/rounded_button.dart @@ -1,4 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:tablet_app/Models/tabletContext.dart'; +import 'package:tablet_app/app_context.dart'; import 'package:tablet_app/constants.dart'; class RoundedButton extends StatelessWidget { @@ -24,6 +27,9 @@ class RoundedButton extends StatelessWidget { @override Widget build(BuildContext context) { + final appContext = Provider.of(context); + TabletAppContext tabletAppContext = appContext.getContext(); + //Size size = MediaQuery.of(context).size; return TextButton( style: ButtonStyle( @@ -31,7 +37,7 @@ class RoundedButton extends StatelessWidget { backgroundColor: MaterialStateColor.resolveWith((states) => color!), shape: MaterialStateProperty.all( RoundedRectangleBorder( - borderRadius: BorderRadius.circular(30.0), + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0), ) ) ), diff --git a/lib/Helpers/translations.dart b/lib/Helpers/translations.dart index 207e7a0..b6e196e 100644 --- a/lib/Helpers/translations.dart +++ b/lib/Helpers/translations.dart @@ -12,6 +12,9 @@ List translations = [ "friday": "Vendredi", "saturday": "Samedi", "sunday": "Dimanche", + "menu": "Menu", + "quiz.seeResponses": "Voir les réponses", + "quiz.restart": "Recommencer" }), Translation(language: "EN", data: { "weather.hourly": "Hourly", @@ -23,7 +26,10 @@ List translations = [ "thursday": "Thursday", "friday": "Friday", "saturday": "Saturday", - "sunday": "Sunday" + "sunday": "Sunday", + "menu": "Menu", + "quiz.seeResponses": "See the answers", + "quiz.restart": "Restart" }), Translation(language: "DE", data: { "weather.hourly": "Nächste Stunden", @@ -35,7 +41,10 @@ List translations = [ "thursday": "Donnerstag", "friday": "Freitag", "saturday": "Samstag", - "sunday": "Sonntag" + "sunday": "Sonntag", + "menu": "Speisekarte", + "quiz.seeResponses": "Sehen Sie sich die Antworten an", + "quiz.restart": "Neu starten" }), Translation(language: "NL", data: { "weather.hourly": "Volgende uren", @@ -47,7 +56,10 @@ List translations = [ "thursday": "Donderdag", "friday": "Vrijdag", "saturday": "Zaterdag", - "sunday": "Zondag" + "sunday": "Zondag", + "menu": "Menu", + "quiz.seeResponses": "Zie de antwoorden", + "quiz.restart": "Herstarten" }), Translation(language: "IT", data: { "weather.hourly": "Le prossime ore", @@ -59,7 +71,10 @@ List translations = [ "thursday": "Giovedì", "friday": "Venerdì", "saturday": "Sabato", - "sunday": "Domenica" + "sunday": "Domenica", + "menu": "Menù", + "quiz.seeResponses": "Vedi le risposte", + "quiz.restart": "Ricomincia" }), Translation(language: "ES", data: { "weather.hourly": "Próximas horas", @@ -71,7 +86,10 @@ List translations = [ "thursday": "Jueves", "friday": "Viernes", "saturday": "Sábado", - "sunday": "Domingo" + "sunday": "Domingo", + "menu": "Menú", + "quiz.seeResponses": "Ver las respuestas", + "quiz.restart": "Reanudar" }), Translation(language: "PL", data: { "weather.hourly": "Następne godziny", @@ -83,7 +101,10 @@ List translations = [ "thursday": "Czwartek", "friday": "Piątek", "saturday": "Sobota", - "sunday": "Niedziela" + "sunday": "Niedziela", + "menu": "Menu", + "quiz.seeResponses": "Zobacz odpowiedzi", + "quiz.restart": "Uruchom ponownie" }), Translation(language: "CN", data: { "weather.hourly": "接下来的几个小时", @@ -95,7 +116,10 @@ List translations = [ "thursday": "星期四", "friday": "星期五", "saturday": "星期六", - "sunday": "星期日" + "sunday": "星期日", + "menu": "菜单", + "quiz.seeResponses": "查看答案", + "quiz.restart": "重新开始" }), Translation(language: "UK", data: { "weather.hourly": "Наступні години", @@ -107,7 +131,10 @@ List translations = [ "thursday": "Четвер", "friday": "П'ятниця", "saturday": "Субота", - "sunday": "Неділя" + "sunday": "Неділя", + "menu": "Меню", + "quiz.seeResponses": "Подивіться відповіді", + "quiz.restart": "Перезапустіть" }), Translation(language: "AR", data: { "weather.hourly": "الساعات القادمة", @@ -119,6 +146,9 @@ List translations = [ "thursday": "الخميس", "friday": "الجمعة", "saturday": "السبت", - "sunday": "الأحد" + "sunday": "الأحد", + "menu": "القائمة", + "quiz.seeResponses": "انظر الإجابات", + "quiz.restart": "إعادة تشغيل" }), ]; \ No newline at end of file diff --git a/lib/Screens/Agenda/agenda_view.dart b/lib/Screens/Agenda/agenda_view.dart index 32e9e5c..035b943 100644 --- a/lib/Screens/Agenda/agenda_view.dart +++ b/lib/Screens/Agenda/agenda_view.dart @@ -111,10 +111,7 @@ class _AgendaView extends State { child: Container( decoration: BoxDecoration( color: kBackgroundColor, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(30.0), - bottomLeft: Radius.circular(30.0), - ), + borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 30.0)), ), child: Padding( padding: const EdgeInsets.all(8.0), @@ -132,7 +129,7 @@ class _AgendaView extends State { Expanded( flex: 4, child: Padding( - padding: const EdgeInsets.only(left: 8.0), + padding: const EdgeInsets.only(left: 8.0, bottom: 2.0, top: 2.0), child: Container( child: ValueListenableBuilder>( valueListenable: filteredAgenda, diff --git a/lib/Screens/Agenda/event_list_item.dart b/lib/Screens/Agenda/event_list_item.dart index 9ddcb72..ef645b4 100644 --- a/lib/Screens/Agenda/event_list_item.dart +++ b/lib/Screens/Agenda/event_list_item.dart @@ -32,7 +32,7 @@ class EventListItem extends StatelessWidget { return Container( margin: const EdgeInsets.all(10.0), decoration: BoxDecoration( - borderRadius: BorderRadius.circular(20.0), + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0), //color: Colors.red, boxShadow: const [ BoxShadow( @@ -53,7 +53,7 @@ class EventListItem extends StatelessWidget { child: Stack( children: [ eventAgenda.image != null ? ClipRRect( - borderRadius: const BorderRadius.only(topLeft: Radius.circular(20.0), topRight: Radius.circular(20.0)), + borderRadius: BorderRadius.only(topLeft: Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0), topRight: Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)), child: Container( //color: Colors.green, //constraints: const BoxConstraints(maxHeight: 175), @@ -79,10 +79,10 @@ class EventListItem extends StatelessWidget { right: 0.0, bottom: 0.0, child: Container( - decoration: const BoxDecoration( - color: kTestSecondColor, // TODO + decoration: BoxDecoration( + color: primaryColor, borderRadius: BorderRadius.only( - topLeft: Radius.circular(20.0), + topLeft: Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0), ), ), child: Padding( @@ -125,9 +125,9 @@ class EventListItem extends StatelessWidget { constraints: BoxConstraints(maxHeight: 120),*/ child: Container( width: size.width, - decoration: const BoxDecoration( + decoration: BoxDecoration( color: Colors.white, - borderRadius: BorderRadius.only(bottomLeft: Radius.circular(20.0), bottomRight: Radius.circular(20.0)), + borderRadius: BorderRadius.only(bottomLeft: Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0), bottomRight: Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)), border: Border(top: BorderSide(width: 0.1, color: kMainGrey)) ), child: Padding( diff --git a/lib/Screens/Agenda/event_popup.dart b/lib/Screens/Agenda/event_popup.dart index e5d05d7..4952903 100644 --- a/lib/Screens/Agenda/event_popup.dart +++ b/lib/Screens/Agenda/event_popup.dart @@ -11,11 +11,14 @@ import 'package:flutter_widget_from_html/flutter_widget_from_html.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart' as mapBox; import 'package:manager_api/api.dart'; +import 'package:provider/provider.dart'; import 'package:qr_flutter/qr_flutter.dart'; import 'package:tablet_app/Components/loading_common.dart'; import 'package:tablet_app/Components/video_viewer_youtube.dart'; import 'package:tablet_app/Models/agenda.dart'; import 'package:intl/intl.dart'; +import 'package:tablet_app/Models/tabletContext.dart'; +import 'package:tablet_app/app_context.dart'; import 'package:tablet_app/constants.dart'; class EventPopup extends StatefulWidget { @@ -90,6 +93,8 @@ class _EventPopupState extends State { @override Widget build(BuildContext context) { + final appContext = Provider.of(context); + TabletAppContext tabletAppContext = appContext.getContext(); var dateToShow = widget.eventAgenda.dateFrom!.isAtSameMomentAs(widget.eventAgenda.dateTo!) ? "${formatter.format(widget.eventAgenda.dateFrom!)}": "${formatter.format(widget.eventAgenda.dateFrom!)} - ${formatter.format(widget.eventAgenda.dateTo!)}"; Size size = MediaQuery.of(context).size; @@ -101,14 +106,14 @@ class _EventPopupState extends State { } return AlertDialog( - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(20.0)) + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)) ), contentPadding: EdgeInsets.zero, // title: Text(eventAgenda.name!), content: Container( decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(20.0)), + borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)), color: kBackgroundColor, ), height: size.height * 0.85, @@ -125,11 +130,11 @@ class _EventPopupState extends State { width: 50, height: 50, decoration: BoxDecoration( - color: kMainGrey, + color: kBackgroundGrey, shape: BoxShape.circle, boxShadow: [ BoxShadow( - color: kMainGrey, + color: kBackgroundGrey, spreadRadius: 0.5, blurRadius: 1.1, offset: Offset(0, 1.1), // changes position of shadow @@ -147,7 +152,7 @@ class _EventPopupState extends State { Row( children: [ widget.eventAgenda.image != null ? ClipRRect( - borderRadius: const BorderRadius.only(topLeft: Radius.circular(20.0), bottomLeft: Radius.circular(20.0)), + borderRadius: BorderRadius.only(topLeft: Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0), bottomLeft: Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)), child: Container( child: Center( child: Container( @@ -225,7 +230,7 @@ class _EventPopupState extends State { width: size.width * 0.38, decoration: BoxDecoration( color: kBackgroundLight, - borderRadius: BorderRadius.all(Radius.circular(20.0)) + borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)) ), child: Padding( padding: const EdgeInsets.only(left: 20, right: 10, bottom: 10, top: 15), diff --git a/lib/Screens/Agenda/month_filter.dart b/lib/Screens/Agenda/month_filter.dart index 9523a91..dc05e50 100644 --- a/lib/Screens/Agenda/month_filter.dart +++ b/lib/Screens/Agenda/month_filter.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:tablet_app/Helpers/translationHelper.dart'; import 'package:tablet_app/Models/agenda.dart'; +import 'package:tablet_app/Models/tabletContext.dart'; import 'package:tablet_app/app_context.dart'; import 'package:tablet_app/constants.dart'; @@ -30,11 +31,14 @@ class _MonthFilterState extends State { List> sortedMonths = _getSortedMonths(); final appContext = Provider.of(context); + TabletAppContext tabletAppContext = appContext.getContext(); + var primaryColor = tabletAppContext.configuration != null ? tabletAppContext.configuration!.primaryColor != null ? new Color(int.parse(tabletAppContext.configuration!.primaryColor!.split('(0x')[1].split(')')[0], radix: 16)) : kTestSecondColor : kTestSecondColor; + return ListView.builder( itemCount: sortedMonths.length + 1, // +1 for "Tout (nbr total events)" itemBuilder: (context, index) { if (index == 0) { - return _buildAllItem(appContext); + return _buildAllItem(appContext, primaryColor); } else { final monthYear = sortedMonths[index - 1]['monthYear']; @@ -54,7 +58,7 @@ class _MonthFilterState extends State { style: TextStyle( fontSize: 15.0, fontWeight: _selectedMonth == monthYear ? FontWeight.bold : FontWeight.normal, - color: _selectedMonth == monthYear ? kTestSecondColor : null, + color: _selectedMonth == monthYear ? primaryColor : null, ), ), onTap: () { @@ -63,7 +67,7 @@ class _MonthFilterState extends State { }); widget.onMonthSelected(filteredEvents); }, - tileColor: _selectedMonth == monthYear ? kTestSecondColor : null, + tileColor: _selectedMonth == monthYear ? primaryColor : null, ); } else { // Si nbrEvents est 0, ne retourne pas de widget @@ -82,7 +86,7 @@ class _MonthFilterState extends State { return translatedMonthName; } - Widget _buildAllItem(AppContext appContext) { + Widget _buildAllItem(AppContext appContext, Color primaryColor) { int totalEvents = widget.events.length; return ListTile( title: Text( @@ -90,7 +94,7 @@ class _MonthFilterState extends State { style: TextStyle( fontSize: 15.0, fontWeight: _selectedMonth == null ? FontWeight.bold : FontWeight.normal, - color: _selectedMonth == null ? kTestSecondColor : null, + color: _selectedMonth == null ? primaryColor : null, ), ), onTap: () { @@ -99,7 +103,7 @@ class _MonthFilterState extends State { }); widget.onMonthSelected(widget.events); }, - tileColor: _selectedMonth == null ? kTestSecondColor : null, + tileColor: _selectedMonth == null ? primaryColor : null, ); } diff --git a/lib/Screens/Configuration/dropDown_configuration.dart b/lib/Screens/Configuration/dropDown_configuration.dart index d6617f8..23b33d8 100644 --- a/lib/Screens/Configuration/dropDown_configuration.dart +++ b/lib/Screens/Configuration/dropDown_configuration.dart @@ -33,7 +33,7 @@ class _DropDownConfigState extends State { style: const TextStyle(color: kMainGrey), underline: Container( height: 2, - color: kMainRed, // TODO CHANGEEEEE + color: kTestSecondColor, ), onChanged: (ConfigurationDTO? newValue) { setState(() { diff --git a/lib/Screens/MainView/language_selection.dart b/lib/Screens/MainView/language_selection.dart index 7751614..b449565 100644 --- a/lib/Screens/MainView/language_selection.dart +++ b/lib/Screens/MainView/language_selection.dart @@ -64,7 +64,7 @@ class _LanguageSelection extends State with TickerProviderSta top: 0, right: 0, child: Padding( - padding: const EdgeInsets.only(right: 0.0, top: 25.0), + padding: const EdgeInsets.only(right: 0.0, top: 10.0), child: InkWell( onTap: () { minimizedAnimation(size); @@ -85,7 +85,7 @@ class _LanguageSelection extends State with TickerProviderSta right: _rightLanguage, bottom: _bottomLanguage, child: Padding( - padding: const EdgeInsets.only(top: 25.0), + padding: const EdgeInsets.only(top: 10.0), child: ListView( children: [ if(minimized) ... [ diff --git a/lib/Screens/MainView/main_view.dart b/lib/Screens/MainView/main_view.dart index 4c05034..02ce751 100644 --- a/lib/Screens/MainView/main_view.dart +++ b/lib/Screens/MainView/main_view.dart @@ -4,10 +4,12 @@ import 'dart:io'; import 'dart:math'; import 'package:cached_network_image/cached_network_image.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_widget_from_html/flutter_widget_from_html.dart'; import 'package:manager_api/api.dart'; import 'package:provider/provider.dart'; @@ -16,11 +18,12 @@ import 'package:tablet_app/Components/loading_common.dart'; import 'package:tablet_app/Helpers/DatabaseHelper.dart'; import 'package:tablet_app/Helpers/ImageCustomProvider.dart'; import 'package:tablet_app/Helpers/MQTTHelper.dart'; +import 'package:tablet_app/Helpers/translationHelper.dart'; import 'package:tablet_app/Models/WeatherData.dart'; import 'package:tablet_app/Screens/Agenda/agenda_view.dart'; import 'package:tablet_app/Screens/Article/article_view.dart'; import 'package:tablet_app/Screens/Configuration/config_view.dart'; -import 'package:tablet_app/Screens/MainView/weather_view.dart'; +import 'package:tablet_app/Screens/Weather/weather_view.dart'; import 'package:tablet_app/Screens/Map/map_context.dart'; import 'package:tablet_app/Screens/Map/map_view.dart'; import 'package:tablet_app/Models/map-marker.dart'; @@ -54,6 +57,8 @@ class _MainViewWidget extends State { late Color backgroundColor; int rowCount = 4; + bool isImageBackground = false; + List? sectionsLocal; bool isInit = true; // Use to make it faster and to load resource at init bool isDialogOpen = false; @@ -65,7 +70,9 @@ class _MainViewWidget extends State { if(configurationDTO.isHour != null && configurationDTO.isHour!) { Timer.periodic(Duration(seconds: 1), (Timer t) => _getTime(currentHourDate)); } - print("Init state helloowww"); + + isImageBackground = configurationDTO.isSectionImageBackground ?? true; + super.initState(); } @@ -75,7 +82,7 @@ class _MainViewWidget extends State { //setState(() { //_timeString = formattedDateTime; - valueNotifier.value = (DateTime.now().toUtc()).add(Duration(hours: 1)); + valueNotifier.value = (DateTime.now().toUtc()).add(Duration(hours: 2)); //}); } @@ -88,14 +95,16 @@ class _MainViewWidget extends State { backgroundColor = appContext.getContext().configuration != null ? new Color(int.parse(appContext.getContext().configuration.secondaryColor.split('(0x')[1].split(')')[0], radix: 16)) : Colors.white; Color textColor = backgroundColor.computeLuminance() > 0.5 ? Colors.black : Colors.white; + TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext; // TODO REMOVE /*if (!MQTTHelper.instance.isInstantiated) MQTTHelper.instance.connect(appContext);*/ if(sectionSelected != null) { var elementToShow; + print(sectionSelected!.type); switch (sectionSelected!.type) { - case SectionType.map : // MAP + case SectionType.Map : // MAP elementToShow = ChangeNotifierProvider( create: (_) => MapContext(new MapMarker( @@ -110,33 +119,36 @@ class _MainViewWidget extends State { : CircularProgressIndicator()),*/ ); break; - case SectionType.web : // WEB + case SectionType.Web : // WEB elementToShow = WebView(section: sectionSelected); break; - case SectionType.video : // Video + case SectionType.Video : // Video elementToShow = VideoView(section: sectionSelected); break; - case SectionType.slider : + case SectionType.Slider : elementToShow = SliderView(section: sectionSelected); break; - case SectionType.menu : - elementToShow = MenuView(section: sectionSelected!); + case SectionType.Menu : + elementToShow = MenuView(section: sectionSelected!, isImageBackground: isImageBackground); break; - case SectionType.quizz : + case SectionType.Quizz : elementToShow = QuizzView(section: sectionSelected); break; - case SectionType.pdf : + case SectionType.Pdf : elementToShow = PDFViewWidget(section: sectionSelected); break; - case SectionType.puzzle : + case SectionType.Puzzle : elementToShow = PuzzleView(section: sectionSelected); break; - case SectionType.agenda : + case SectionType.Agenda : elementToShow = AgendaView(section: sectionSelected); break; /*case SectionType.article : // TODO elementToShow = ArticleView(section: sectionSelected); break;*/ + case SectionType.Weather : + elementToShow = WeatherView(section: sectionSelected); + break; default: elementToShow = Text("Ce type n'est pas supporté"); break; @@ -154,91 +166,149 @@ class _MainViewWidget extends State { image: ImageCustomProvider.getImageProvider(appContext, configurationDTO.imageId!, configurationDTO.imageSource!), ), ) : null, - child: Column( - children: [ - Container( - width: size.width, - height: size.height * 0.12, - child: Row( - children: [ - Padding( - padding: const EdgeInsets.only(left: 15.0, top: 10.0), - child: AspectRatio( - aspectRatio: 4 / 4, - child: Container( - /*width: 125, - height: 125,*/ - decoration: boxDecoration(appContext, sectionSelected!, true), - ), - ), - ), - SizedBox( - width: 25, - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.start, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + decoration : BoxDecoration( + color: kBackgroundLight, + shape: BoxShape.rectangle, + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 30.0), + boxShadow: [ + BoxShadow( + color: kBackgroundSecondGrey, + spreadRadius: 0.5, + blurRadius: 5, + offset: Offset(0, 1.5), // changes position of shadow + ), + ], + ), + child: Column( + children: [ + Expanded( + flex: 1, + //height: size.height * 0.1, + child: Container( + //color: Colors.greenAccent, + width: size.width, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, children: [ - Expanded( - child: Align( - alignment: Alignment.centerLeft, - child: HtmlWidget( - sectionSelected!.title!.firstWhere((translation) => translation.language == appContext.getContext().language).value!, - textStyle: new TextStyle(fontSize: kIsWeb ? kWebSectionTitleDetailSize : kSectionTitleDetailSize, color: textColor), - ) - ) + Container( + //color: Colors.grey, + //width: size.width * 0.8, + child: Padding( + padding: const EdgeInsets.only(left: 15.0, top: 10.0, bottom: 10.0), + child: Container( + //color: Colors.grey, + child: AspectRatio( + aspectRatio: 4 / 4, + child: isImageBackground ? Container( + /*width: 125, + height: 125,*/ + decoration: boxDecoration(appContext, sectionSelected!, true), + ) : Container( + decoration: BoxDecoration( + color: sectionSelected!.imageSource == null ? kBackgroundLight : null, // default color if no image + shape: BoxShape.rectangle, + image: sectionSelected!.imageSource != null ? new DecorationImage( + fit: BoxFit.cover, + image: ImageCustomProvider.getImageProvider(appContext, sectionSelected!.imageId!, sectionSelected!.imageSource!), + ): null, + ), + ), + ), + ), + ), ), - if(sectionSelected!.description!.firstWhere((translation) => translation.language == appContext.getContext().language).value != null && sectionSelected!.description!.firstWhere((translation) => translation.language == appContext.getContext().language).value!.trim().isNotEmpty) - Expanded( - child: Align( - alignment: Alignment.centerLeft, - child: HtmlWidget( - sectionSelected!.description!.firstWhere((translation) => translation.language == appContext.getContext().language).value!, - textStyle: new TextStyle(fontSize: kIsWeb? kWebSectionDescriptionDetailSize : kSectionDescriptionDetailSize, color: textColor), - ) - ) - ) + Container( + //width: size.width, + //color: Colors.green, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Align( + alignment: Alignment.center, + child: HtmlWidget( + sectionSelected!.title!.firstWhere((translation) => translation.language == appContext.getContext().language).value!, + textStyle: new TextStyle(fontSize: kIsWeb ? kWebSectionTitleDetailSize : kSectionTitleDetailSize, color: textColor, fontFamily: 'Roboto'), + ) + ), + if(sectionSelected!.description!.firstWhere((translation) => translation.language == appContext.getContext().language).value != null && sectionSelected!.description!.firstWhere((translation) => translation.language == appContext.getContext().language).value!.trim().isNotEmpty) + Align( + //alignment: Alignment.center, + child: HtmlWidget( + sectionSelected!.description!.firstWhere((translation) => translation.language == appContext.getContext().language).value!, + textStyle: new TextStyle(fontSize: kIsWeb? kWebSectionDescriptionDetailSize : kSectionDescriptionDetailSize, color: textColor, fontFamily: 'Roboto'), + ) + ) + ], + ), + ), + Padding( + padding: const EdgeInsets.only(right: 15.0), + child: Container( + height: size.height *0.08, + width: size.width *0.08, + child: FittedBox( + child: FloatingActionButton.extended( + backgroundColor: kBackgroundColor, + focusColor: kBackgroundColor, + splashColor: kBackgroundColor, + onPressed: () { + setState(() { + sectionSelected = null; + }); + }, + icon: Icon(Icons.arrow_back, color: Colors.grey), + label: Text(TranslationHelper.getFromLocale("menu", appContext.getContext()), style: TextStyle(color: Colors.black)) + ), + ), + ), + ) ], ), - ) - ], - ), - ), - Padding( - padding: sectionSelected!.type != SectionType.slider ? const EdgeInsets.only(left: 15.0, right: 15.0, top: 15.0) : const EdgeInsets.only(top: 15.0), - child: Container( - width: size.width, - height: size.height * 0.85, - decoration: sectionSelected!.type != SectionType.video && sectionSelected!.type != SectionType.web && sectionSelected!.type != SectionType.slider && sectionSelected!.type != SectionType.map ? BoxDecoration( - color: kBackgroundLight, - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(30.0), - boxShadow: [ - BoxShadow( - color: kBackgroundSecondGrey, - spreadRadius: 0.5, - blurRadius: 5, - offset: Offset(0, 1.5), // changes position of shadow + ), + ), + Expanded( + flex: 9, + child: Padding( + padding: sectionSelected!.type != SectionType.Slider ? const EdgeInsets.only(left: 15.0, right: 15.0, top: 10.0) : const EdgeInsets.only(top: 10.0), + child: Container( + width: size.width, + //height: size.height * 0.9, + /*decoration: sectionSelected!.type != SectionType.Video && sectionSelected!.type != SectionType.Web && sectionSelected!.type != SectionType.Slider && sectionSelected!.type != SectionType.Map ? BoxDecoration( + //color: kBackgroundLight, + shape: BoxShape.rectangle, + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 30.0), + /*boxShadow: [ + BoxShadow( + color: kBackgroundSecondGrey, + spreadRadius: 0.5, + blurRadius: 5, + offset: Offset(0, 1.5), // changes position of shadow + ), + ],*/ + ) :null,*/ + child: Padding( + padding: const EdgeInsets.only(bottom: 8.0), + child: elementToShow), ), - ], - ) : null, - child: Padding( - padding: const EdgeInsets.all(0.0), - child: elementToShow), - ), - ) - ], + ), + ) + ], + ), + ), ), ), ), - floatingActionButtonLocation: FloatingActionButtonLocation.endTop, + /*floatingActionButtonLocation: FloatingActionButtonLocation.endTop, floatingActionButton: Padding( - padding: const EdgeInsets.only(top: kIsWeb ? 16.0 : 16.0), + padding: const EdgeInsets.only(top: 10.0), child: Container( - height: kIsWeb ? size.height *0.08 : size.height *0.08, - width: kIsWeb ? size.width *0.08: size.width *0.08, + height: size.height *0.08, + width: size.width *0.08, child: FittedBox( child: FloatingActionButton.extended( backgroundColor: kBackgroundColor, @@ -254,7 +324,7 @@ class _MainViewWidget extends State { ), ), ), - ), + ),*/ ); } else { return Scaffold( @@ -301,7 +371,7 @@ class _MainViewWidget extends State { LanguageSelection(size: size), Center( child: Container( - height: kIsWeb ? size.height : size.height * 0.85, + height: configurationDTO.screenPercentageSectionsMainPage != null ? size.height * (configurationDTO.screenPercentageSectionsMainPage! / 100) : size.height * 0.85, width: size.width * 0.9, child: isInit ? FutureBuilder( future: getSections(size, appContext), @@ -327,7 +397,7 @@ class _MainViewWidget extends State { ) : getGridSections(appContext), ), ), - if(configurationDTO.weatherCity != null && configurationDTO.weatherCity!.length > 2 && configurationDTO.weatherResult != null) + /*if(configurationDTO.weatherCity != null && configurationDTO.weatherCity!.length > 2 && configurationDTO.weatherResult != null) Positioned( bottom: 0, left: 0, @@ -341,7 +411,7 @@ class _MainViewWidget extends State { return WeatherView(weatherData: weatherDataResult); } ), - )) + ))*/ ]), ), ); @@ -393,7 +463,7 @@ class _MainViewWidget extends State { var result = await showDialog( builder: (BuildContext dialogContext) => AlertDialog( shape: RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(20.0)) + borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)) ), content: Container( width: 400, @@ -438,50 +508,84 @@ class _MainViewWidget extends State { } getGridSections(AppContext appContext) { + TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext; + if(sectionsLocal != null) { var isPortrait = MediaQuery.of(context).orientation == Orientation.portrait; return Center( - child: GridView.builder( - shrinkWrap: true, - gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: rowCount), - itemCount: sectionsLocal!.length, - itemBuilder: (BuildContext context, int index) { - return InkWell( - onTap: () { - setState(() { - sectionSelected = sectionsLocal![index]; - }); - }, - child: Container( - decoration: boxDecoration(appContext, sectionsLocal![index], false), - padding: const EdgeInsets.all(18), - margin: EdgeInsets.symmetric(vertical: 25, horizontal: 25), - child: Align( - alignment: Alignment.bottomRight, - child: FractionallySizedBox( - heightFactor: 0.5, - child: Container( - //color: Colors.green, - child: SizedBox( - width: double.infinity, - child: Align( - alignment: Alignment.centerRight, + child: Container( + //color: Colors.greenAccent, + child: GridView.builder( + shrinkWrap: true, + gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: rowCount), + itemCount: sectionsLocal!.length, + itemBuilder: (BuildContext context, int index) { + return InkWell( + onTap: () { + setState(() { + sectionSelected = sectionsLocal![index]; + }); + }, + child: Container( + decoration: isImageBackground ? boxDecoration(appContext, sectionsLocal![index], false) : null, + //color: Colors.yellow, + padding: EdgeInsets.all(isImageBackground ? 18 : 5), + margin: EdgeInsets.symmetric(vertical: isImageBackground ? 25 : 10, horizontal: 25), + child: isImageBackground ? Align( + alignment: Alignment.bottomRight, + child: FractionallySizedBox( + heightFactor: 0.5, + child: Container( + //color: Colors.green, + child: SizedBox( + width: double.infinity, + child: Align( + alignment: Alignment.centerRight, + child: HtmlWidget( + sectionsLocal![index].title!.firstWhere((translation) => translation.language == appContext.getContext().language).value ?? "", + customStylesBuilder: (element) { + return {'text-align': 'right'}; + }, + textStyle: TextStyle(fontSize: isPortrait ? 10 : 25),//calculateFontSize(constraints.maxWidth, constraints.maxHeight, kIsWeb ? kWebMenuTitleDetailSize : kMenuTitleDetailSize)), + ), + ), + ), + ) + ), + ) : Column( + children: [ + Expanded( + flex: 8, + child: Container( + decoration: BoxDecoration( + color: sectionsLocal![index].imageSource == null ? kBackgroundLight : null, // default color if no image + shape: BoxShape.rectangle, + image: sectionsLocal![index].imageSource != null ? new DecorationImage( + fit: BoxFit.cover, + image: ImageCustomProvider.getImageProvider(appContext, sectionsLocal![index].imageId!, sectionsLocal![index].imageSource!), + ): null, + ), + ) + ), + Expanded( + flex: 2, + child: Center( child: HtmlWidget( sectionsLocal![index].title!.firstWhere((translation) => translation.language == appContext.getContext().language).value ?? "", customStylesBuilder: (element) { - return {'text-align': 'right'}; + return {'text-align': 'center', 'font-family': "Roboto"}; }, textStyle: TextStyle(fontSize: isPortrait ? 10 : 25),//calculateFontSize(constraints.maxWidth, constraints.maxHeight, kIsWeb ? kWebMenuTitleDetailSize : kMenuTitleDetailSize)), ), - ), - ), + ) ) - ), + ], + ) ), - ), - ); - } + ); + } + ), ), ); } else { @@ -509,10 +613,11 @@ double calculateFontSize(double parentWidth, double parentHeight, double baseSiz } boxDecoration(AppContext appContext, SectionDTO section, bool isSelected) { + TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext; return BoxDecoration( - color: kBackgroundLight, + color: !isSelected ? kBackgroundLight : section.imageSource == null ? kBackgroundLight : null, shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(30.0), + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 30.0), image: section.imageSource != null ? new DecorationImage( fit: BoxFit.cover, colorFilter: !isSelected? new ColorFilter.mode(kBackgroundLight.withOpacity(0.2), BlendMode.dstATop) : null, diff --git a/lib/Screens/MainView/weather_view.dart b/lib/Screens/MainView/weather_view.dart deleted file mode 100644 index 070242b..0000000 --- a/lib/Screens/MainView/weather_view.dart +++ /dev/null @@ -1,403 +0,0 @@ -import 'package:auto_size_text/auto_size_text.dart'; -import 'package:cached_network_image/cached_network_image.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; -import 'package:provider/provider.dart'; -import 'package:tablet_app/Helpers/translationHelper.dart'; -import 'package:tablet_app/Models/WeatherData.dart'; -import 'package:tablet_app/Models/tabletContext.dart'; -import 'package:tablet_app/app_context.dart'; -import 'package:tablet_app/constants.dart'; -import 'package:intl/intl.dart'; - -class WeatherView extends StatelessWidget { - final WeatherData weatherData; - WeatherView({required this.weatherData}); - - int nbrNextHours = 5; - - String formatTimestamp(int timestamp, AppContext appContext, bool isHourOnly, bool isDateOnly) { - - DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(timestamp * 1000); - - // Determine the date format based on the application language - String dateFormat = appContext.getContext().language.toString().toUpperCase() == "EN" ? - 'MM/dd/yyyy HH:mm' - : 'dd/MM/yyyy HH:mm'; - - if(isHourOnly) { - dateFormat = 'HH:mm'; - } - - if(isDateOnly) { - dateFormat = dateFormat.replaceAll('/yyyy HH:mm', ''); - } - - String formattedDate = DateFormat(dateFormat).format(dateTime); - - return formattedDate; - } - - String getTranslatedDayOfWeek(int timestamp, AppContext appContext, bool isDate) { - DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(timestamp * 1000); - - String dayToPrint = ""; - - print("dateTime.weekday"); - print(dateTime.weekday); - - switch(dateTime.weekday) { - case 1: - dayToPrint = TranslationHelper.getFromLocale("monday", appContext.getContext()); - break; - case 2: - dayToPrint = TranslationHelper.getFromLocale("tuesday", appContext.getContext()); - break; - case 3: - dayToPrint = TranslationHelper.getFromLocale("wednesday", appContext.getContext()); - break; - case 4: - dayToPrint = TranslationHelper.getFromLocale("thursday", appContext.getContext()); - break; - case 5: - dayToPrint = TranslationHelper.getFromLocale("friday", appContext.getContext()); - break; - case 6: - dayToPrint = TranslationHelper.getFromLocale("saturday", appContext.getContext()); - break; - case 7: - dayToPrint = TranslationHelper.getFromLocale("sunday", appContext.getContext()); - break; - } - - return isDate ? "${dayToPrint} ${formatTimestamp(timestamp, appContext, false, true)}" : dayToPrint; - } - - List getNextFiveDaysForecast(List allForecasts) { - List nextFiveDaysForecast = []; - DateTime today = DateTime.now(); - - List nextDay1All = allForecasts.where((af) => (DateTime.fromMillisecondsSinceEpoch(af.dt! * 1000)).day == (today.add(Duration(days: 1))).day).toList(); - List nextDay2All = allForecasts.where((af) => (DateTime.fromMillisecondsSinceEpoch(af.dt! * 1000)).day == (today.add(Duration(days: 2))).day).toList(); - List nextDay3All = allForecasts.where((af) => (DateTime.fromMillisecondsSinceEpoch(af.dt! * 1000)).day == (today.add(Duration(days: 3))).day).toList(); - List nextDay4All = allForecasts.where((af) => (DateTime.fromMillisecondsSinceEpoch(af.dt! * 1000)).day == (today.add(Duration(days: 4))).day).toList(); - List nextDay5All = allForecasts.where((af) => (DateTime.fromMillisecondsSinceEpoch(af.dt! * 1000)).day == (today.add(Duration(days: 5))).day).toList(); - - var nextDay1MiddayTest = nextDay1All.where((nd) => (DateTime.fromMillisecondsSinceEpoch(nd.dt! * 1000)).hour == 12).firstOrNull; - if(nextDay1All.isNotEmpty) { - WeatherForecast nextDay1AllSummary = nextDay1MiddayTest != null ? nextDay1MiddayTest : nextDay1All.last; - nextFiveDaysForecast.add(nextDay1AllSummary); - } - - var nextDay2MiddayTest = nextDay2All.where((nd) => (DateTime.fromMillisecondsSinceEpoch(nd.dt! * 1000)).hour == 12).firstOrNull; - if(nextDay2All.isNotEmpty) { - WeatherForecast nextDay2Midday = nextDay2MiddayTest != null ? nextDay2MiddayTest : nextDay2All.last; - nextFiveDaysForecast.add(nextDay2Midday); - } - - var nextDay3MiddayTest = nextDay3All.where((nd) => (DateTime.fromMillisecondsSinceEpoch(nd.dt! * 1000)).hour == 12).firstOrNull; - if(nextDay3All.isNotEmpty) { - WeatherForecast nextDay3Midday = nextDay3MiddayTest != null ? nextDay3MiddayTest : nextDay3All.last; - nextFiveDaysForecast.add(nextDay3Midday); - } - - var nextDay4MiddayTest = nextDay4All.where((nd) => (DateTime.fromMillisecondsSinceEpoch(nd.dt! * 1000)).hour == 12).firstOrNull; - if(nextDay4All.isNotEmpty) { - WeatherForecast nextDay4Midday = nextDay4MiddayTest != null ? nextDay4MiddayTest : nextDay4All.last; - nextFiveDaysForecast.add(nextDay4Midday); - } - - var nextDay5MiddayTest = nextDay5All.where((nd) => (DateTime.fromMillisecondsSinceEpoch(nd.dt! * 1000)).hour == 12).firstOrNull; - if(nextDay5All.isNotEmpty) { - WeatherForecast nextDay5Midday = nextDay5MiddayTest != null ? nextDay5MiddayTest : nextDay5All.last; - nextFiveDaysForecast.add(nextDay5Midday); - } - - return nextFiveDaysForecast; - } - - @override - Widget build(BuildContext context) { - Size size = MediaQuery.of(context).size; - final appContext = Provider.of(context); - TabletAppContext tabletAppContext = appContext.getContext(); - - return InkWell( - onTap: () { - - /*print(weatherData.list!.first.weather!.first.main); - print(weatherData.list!.first.weather!.first.description); - print(weatherData.list!.first.weather!.first.icon!); - print(weatherData.list!.first.dtTxt); - print(weatherData.list!.first.dt);*/ - - //String formattedDate = formatTimestamp(weatherData.list!.first.dt!, appContext, false, false); - //getNextFiveDaysForecast(weatherData.list!); - - showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(20.0)) - ), - contentPadding: EdgeInsets.zero, - // title: Text(eventAgenda.name!), - content: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(20.0)), - gradient: LinearGradient( - begin: Alignment.topRight, - end: Alignment.bottomLeft, - stops: [ - 0.2, - 0.5, - 0.9, - 0.95 - ], - colors: [ - Colors.blue[50]!, - Colors.blue[100]!, - Colors.blue[200]!, - Colors.blue[300]! - ] - ) - ), - height: size.height * 0.9, - width: size.width * 0.8, - child: Stack( - children: [ - Positioned( - right: 5, - top: 5, - child: InkWell( - onTap: () { - Navigator.of(context).pop(); - }, - child: Container( - width: 50, - height: 50, - child: Icon( - Icons.close, - size: 25, - color: Colors.black54, - ), - ), - ), - ), - SizedBox( - //height: 300, - //width: 300, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.all(10.0), - child: Center(child: Text(tabletAppContext.configuration!.weatherCity!, style: TextStyle(fontSize: kSectionTitleDetailSize, fontWeight: FontWeight.w500, color: Colors.black54))), - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Text("${weatherData.list!.first.main!.temp!.round().toString()}°", style: TextStyle(fontSize: 55.0, fontWeight: FontWeight.w400, color: Colors.black54)), - ), - Container( - //color: Colors.red, - height: size.height * 0.2, - width: size.width * 0.2, - child: Center( - child: CachedNetworkImage(imageUrl: "https://openweathermap.org/img/wn/${weatherData.list!.first.weather!.first.icon!}@4x.png") - ) - ), - Container( - // color: Colors.green, - width: size.width * 0.1, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - children: [ - Icon(Icons.water_drop_outlined, color: kTestSecondColor), - Text("${weatherData.list!.first.pop!.round().toString()}%", style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.w400, color: Colors.black54)), - ], - ), - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - children: [ - Icon(Icons.air, color: kTestSecondColor), - Text("${(weatherData.list!.first.wind!.speed! * 3.6).toStringAsFixed(1)}km/h", style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.w400, color: Colors.black54)), - ], - ), - ), - ], - ), - ), - ]), - Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - height: size.height * 0.25, - width: size.width * 0.6, - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(20.0)), - //color: Colors.grey, - ), - child: Column( - children: [ - Padding( - padding: const EdgeInsets.only(left: 15, bottom: 10), - child: Align(alignment: Alignment.centerLeft, child: Text(TranslationHelper.getFromLocale("weather.hourly", appContext.getContext()), style: TextStyle(fontSize: 22, fontWeight: FontWeight.w400, color: Colors.black54))), - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.center, - children: List.generate( - nbrNextHours, - (index) { - final weatherForecast = weatherData.list!.sublist(1)[index]; - return Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - height: size.height * 0.15, - width: size.width * 0.1, - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(20.0)), - color: Colors.lightBlueAccent, - boxShadow: [ - BoxShadow( - color: kBackgroundGrey.withOpacity(0.6), - spreadRadius: 0.75, - blurRadius: 3.1, - offset: Offset(0, 2.5), // changes position of shadow - ), - ], - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text('${formatTimestamp(weatherForecast.dt!, appContext, true, false)}', style: TextStyle(fontSize: 12.0, fontWeight: FontWeight.w400, color: Colors.white)), - Center(child: CachedNetworkImage(imageUrl: "https://openweathermap.org/img/wn/${weatherForecast.weather!.first.icon!}.png")), - Text('${weatherForecast.main!.temp!.round().toString()}°', style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w600, color: Colors.white)), - ], - ), - ), - ); - }, - ), - ), - ], - ), - ), - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - height: size.height * 0.3, - width: size.width * 0.75, - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(20.0)), - //color: Colors.amber, - ), - child: Column( - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Align(alignment: Alignment.centerLeft, child: Text(TranslationHelper.getFromLocale("weather.nextdays", appContext.getContext()), style: TextStyle(fontSize: 20, fontWeight: FontWeight.w400, color: Colors.black54))), - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.center, - children: List.generate( - getNextFiveDaysForecast(weatherData.list!).length, // nbrNextHours - (index) { - final weatherForecastNextDay = getNextFiveDaysForecast(weatherData.list!)[index]; - return Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - height: size.height * 0.22, - width: size.width * 0.125, - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(20.0)), - color: Colors.lightBlue, - boxShadow: [ - BoxShadow( - color: kBackgroundGrey.withOpacity(0.5), - spreadRadius: 0.75, - blurRadius: 3.1, - offset: Offset(0, 2.5), // changes position of shadow - ), - ], - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Center(child: CachedNetworkImage(imageUrl: "https://openweathermap.org/img/wn/${weatherForecastNextDay.weather!.first.icon!}@2x.png")), - Text('${weatherForecastNextDay.main!.temp!.round().toString()}°', style: TextStyle(fontSize: 25.0, fontWeight: FontWeight.w600, color: Colors.white)), - Text('${getTranslatedDayOfWeek(weatherForecastNextDay.dt!, appContext, true)}', style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.w400, color: Colors.white)), - ], - ), - ), - ); - }, - ), - ), - ], - ), - ), - ) - ], - ), - ), - ], - ), - ), - ); - }, - ); - }, - child: Container( - //color: Colors.amber, - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(10.0)), - gradient: LinearGradient( - begin: Alignment.topRight, - end: Alignment.bottomLeft, - stops: [ - 0.2, - 0.5, - 1.0, - 1.0 - ], - colors: [ - Colors.blue[50]!, - Colors.blue[100]!, - Colors.blue[200]!, - Colors.blue[300]! - ] - ) - ), - width: 70, - child: Column( - children: [ - CachedNetworkImage(imageUrl: "https://openweathermap.org/img/wn/${weatherData.list!.first.weather!.first.icon!}.png"), - Container(child: AutoSizeText("${weatherData.list!.first.main!.temp!.round().toString()}°")), - //AutoSizeText(weatherData.city!.name!), - ], - ), - ), - ); - } -} - -//_webView \ No newline at end of file diff --git a/lib/Screens/Map/marker_view.dart b/lib/Screens/Map/marker_view.dart index 8a376de..66e59f6 100644 --- a/lib/Screens/Map/marker_view.dart +++ b/lib/Screens/Map/marker_view.dart @@ -9,6 +9,7 @@ import 'package:provider/provider.dart'; import 'package:tablet_app/Components/show_element_for_resource.dart'; import 'package:tablet_app/Helpers/ImageCustomProvider.dart'; import 'package:tablet_app/Models/map-marker.dart'; +import 'package:tablet_app/Models/tabletContext.dart'; import 'package:tablet_app/Screens/Quizz/quizz_view.dart'; import 'package:tablet_app/app_context.dart'; @@ -43,6 +44,8 @@ class _MarkerInfoWidget extends State { Widget build(BuildContext context) { Size size = MediaQuery.of(context).size; final mapContext = Provider.of(context); + final appContext = Provider.of(context); + TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext; Size sizeMarker = Size(size.width * 0.42, size.height * 0.8); return new AnimatedPositioned( @@ -59,7 +62,7 @@ class _MarkerInfoWidget extends State { decoration: BoxDecoration( color: kBackgroundLight, // Colors.amberAccent //kBackgroundLight, shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(10.0), + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 10.0), boxShadow: [ BoxShadow( color: kBackgroundSecondGrey, @@ -188,7 +191,7 @@ class _MarkerInfoWidget extends State { decoration: BoxDecoration( color: kBackgroundColor, shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(10.0), + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 10.0), boxShadow: [ BoxShadow( color: kBackgroundSecondGrey, @@ -258,6 +261,8 @@ class _MarkerInfoWidget extends State { getElementForResource(BuildContext context, AppContext appContext, ContentGeoPoint i) { var widgetToInclude; + final appContext = Provider.of(context); + TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext; switch(i.resourceType) { case ResourceType.Image: @@ -272,7 +277,7 @@ getElementForResource(BuildContext context, AppContext appContext, ContentGeoPoi backgroundDecoration: BoxDecoration( color: kBackgroundSecondGrey, shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(15.0), + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0), ), ) : Center(child: Text('No data')), ), @@ -285,7 +290,7 @@ getElementForResource(BuildContext context, AppContext appContext, ContentGeoPoi decoration: BoxDecoration( color: kBackgroundSecondGrey, shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(15.0), + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0), ), child: showElementForResource(ResourceDTO(id: i.resourceId, url: i.resourceUrl, type: i.resourceType), appContext, false, true), ); diff --git a/lib/Screens/Menu/menu_view.dart b/lib/Screens/Menu/menu_view.dart index 951a74b..2332517 100644 --- a/lib/Screens/Menu/menu_view.dart +++ b/lib/Screens/Menu/menu_view.dart @@ -22,8 +22,9 @@ import 'package:tablet_app/app_context.dart'; import 'package:tablet_app/constants.dart'; class MenuView extends StatefulWidget { - final SectionDTO? section; - MenuView({this.section}); + final SectionDTO section; + final bool isImageBackground; + MenuView({required this.section, required this.isImageBackground}); @override _MenuView createState() => _MenuView(); @@ -32,10 +33,11 @@ class MenuView extends StatefulWidget { class _MenuView extends State { MenuDTO menuDTO = MenuDTO(); SectionDTO? selectedSection; + @override void initState() { - print(widget.section!.data); - menuDTO = MenuDTO.fromJson(jsonDecode(widget.section!.data!))!; + print(widget.section.data); + menuDTO = MenuDTO.fromJson(jsonDecode(widget.section.data!))!; print(menuDTO); super.initState(); @@ -50,11 +52,12 @@ class _MenuView extends State { Widget build(BuildContext context) { final appContext = Provider.of(context); Size size = MediaQuery.of(context).size; + TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext; if (selectedSection != null) { var elementToShow; switch (selectedSection!.type) { - case SectionType.map : + case SectionType.Map : elementToShow = ChangeNotifierProvider( create: (_) => MapContext(new MapMarker( @@ -69,25 +72,25 @@ class _MenuView extends State { : CircularProgressIndicator()),*/ ); break; - case SectionType.web : // WEB + case SectionType.Web : // WEB elementToShow = WebView(section: selectedSection); break; - case SectionType.video : // Video + case SectionType.Video : // Video elementToShow = VideoView(section: selectedSection); break; - case SectionType.slider : // Slider + case SectionType.Slider : // Slider elementToShow = SliderView(section: selectedSection); break; - case SectionType.quizz : // Quizz + case SectionType.Quizz : // Quizz elementToShow = QuizzView(section: selectedSection); break; - case SectionType.pdf : // Pdf + case SectionType.Pdf : // Pdf elementToShow = PDFViewWidget(section: selectedSection); break; - case SectionType.puzzle : // Puzzle + case SectionType.Puzzle : // Puzzle elementToShow = PuzzleView(section: selectedSection); break; - case SectionType.agenda : // Agenda + case SectionType.Agenda : // Agenda elementToShow = AgendaView(section: selectedSection); break; /*case SectionType.article : // Article @@ -101,13 +104,13 @@ class _MenuView extends State { children: [ Center( child: Padding( - padding: selectedSection!.type == SectionType.video || selectedSection!.type == SectionType.web ? EdgeInsets.all(8.0) : EdgeInsets.all(0.0), + padding: selectedSection!.type == SectionType.Video || selectedSection!.type == SectionType.Web ? EdgeInsets.all(8.0) : EdgeInsets.all(0.0), child: Container( width: size.width, - decoration: selectedSection!.type != SectionType.video && selectedSection!.type != SectionType.web && selectedSection!.type != SectionType.slider && selectedSection!.type != SectionType.map ? BoxDecoration( + decoration: selectedSection!.type != SectionType.Video && selectedSection!.type != SectionType.Web && selectedSection!.type != SectionType.Slider && selectedSection!.type != SectionType.Map ? BoxDecoration( color: kBackgroundLight, shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(30.0), + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0), boxShadow: [ BoxShadow( color: kBackgroundSecondGrey, @@ -137,7 +140,7 @@ class _MenuView extends State { decoration: BoxDecoration( color: appContext.getContext().configuration == null ? kBackgroundGrey : appContext.getContext().configuration.secondaryColor != null ? new Color(int.parse(appContext.getContext().configuration.secondaryColor.split('(0x')[1].split(')')[0], radix: 16)): kBackgroundGrey, shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(30.0), + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0), boxShadow: [ BoxShadow( color: kBackgroundSecondGrey, @@ -180,7 +183,7 @@ class _MenuView extends State { child: Align( alignment: Alignment.bottomRight, child: FractionallySizedBox( - heightFactor: 0.45, + heightFactor: 0.5, child: Column( children: [ Align( @@ -193,7 +196,7 @@ class _MenuView extends State { textStyle: new TextStyle(fontSize: kIsWeb? kWebMenuTitleDetailSize : kMenuTitleDetailSize), ), ), - Align( + /*Align( alignment: Alignment.centerRight, child: HtmlWidget( menuDTO.sections![index].description!.firstWhere((translation) => translation.language == appContext.getContext().language).value!, @@ -202,7 +205,7 @@ class _MenuView extends State { }, textStyle: new TextStyle(fontSize: kIsWeb? kWebSectionDescriptionDetailSize: kSectionDescriptionDetailSize, fontFamily: ""), ), - ), + ),*/ ], ) ), @@ -217,10 +220,12 @@ class _MenuView extends State { } boxDecoration(AppContext appContext, SectionDTO section, bool isSelected) { + TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext; + return BoxDecoration( color: kBackgroundLight, shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(30.0), + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0), image: section.imageSource != null ? new DecorationImage( fit: BoxFit.cover, colorFilter: !isSelected? new ColorFilter.mode(kBackgroundLight.withOpacity(0.2), BlendMode.dstATop) : null, diff --git a/lib/Screens/PDF/pdf_filter.dart b/lib/Screens/PDF/pdf_filter.dart index b62ce21..013601d 100644 --- a/lib/Screens/PDF/pdf_filter.dart +++ b/lib/Screens/PDF/pdf_filter.dart @@ -27,6 +27,8 @@ class _PdfFilterState extends State { TabletAppContext tabletAppContext = appContext.getContext(); var currentLanguage = tabletAppContext.language; + var primaryColor = tabletAppContext.configuration != null ? tabletAppContext.configuration!.primaryColor != null ? new Color(int.parse(tabletAppContext.configuration!.primaryColor!.split('(0x')[1].split(')')[0], radix: 16)) : kTestSecondColor : kTestSecondColor; + return ListView.builder( itemCount: widget.pdfsList.length, itemBuilder: (context, index) { @@ -37,7 +39,7 @@ class _PdfFilterState extends State { textStyle: TextStyle( fontSize: 15.0, fontWeight: _selectedOrderPdf == widget.pdfsList[index].order ? FontWeight.bold : FontWeight.normal, - color: _selectedOrderPdf == widget.pdfsList[index].order ? kTestSecondColor : null, + color: _selectedOrderPdf == widget.pdfsList[index].order ? primaryColor : null, ), ), /*Text( @@ -54,7 +56,7 @@ class _PdfFilterState extends State { }); widget.onPDFSelected(_selectedOrderPdf); }, - tileColor: _selectedOrderPdf == widget.pdfsList[index].order ? kTestSecondColor : null, + tileColor: _selectedOrderPdf == widget.pdfsList[index].order ? primaryColor : null, ); } else { // Si nbrEvents est 0, ne retourne pas de widget diff --git a/lib/Screens/PDF/pdf_view.dart b/lib/Screens/PDF/pdf_view.dart index 588bb84..c5a515f 100644 --- a/lib/Screens/PDF/pdf_view.dart +++ b/lib/Screens/PDF/pdf_view.dart @@ -100,6 +100,8 @@ class _PDFViewWidget extends State { final appContext = Provider.of(context); TabletAppContext tabletAppContext = appContext.getContext(); + var primaryColor = tabletAppContext.configuration != null ? tabletAppContext.configuration!.primaryColor != null ? new Color(int.parse(tabletAppContext.configuration!.primaryColor!.split('(0x')[1].split(')')[0], radix: 16)) : kTestSecondColor : kTestSecondColor; + pdfDTO.pdfs!.sort((a, b) => a.order!.compareTo(b.order!)); return pdfDTO.pdfs != null && pdfDTO.pdfs!.length > 0 ? @@ -112,10 +114,7 @@ class _PDFViewWidget extends State { child: Container( decoration: BoxDecoration( color: kBackgroundColor, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(30.0), - bottomLeft: Radius.circular(30.0), - ), + borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)), ), child: Padding( padding: const EdgeInsets.all(8.0), @@ -183,8 +182,8 @@ class _PDFViewWidget extends State { builder: (context, value, _) { return Container( decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(30.0)), - color: kTestSecondColor + borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)), + color: primaryColor ), child: Padding( padding: const EdgeInsets.all(6.0), diff --git a/lib/Screens/Previous/previous_view.dart b/lib/Screens/Previous/previous_view.dart index e616a80..6df18f0 100644 --- a/lib/Screens/Previous/previous_view.dart +++ b/lib/Screens/Previous/previous_view.dart @@ -170,7 +170,7 @@ class _PreviousViewWidget extends State with TickerProviderS child: Container( decoration: BoxDecoration( borderRadius: new BorderRadius.only( - topRight: const Radius.circular(20.0), + topRight: Radius.circular(20.0), ), color: kSecondRed ), @@ -198,7 +198,7 @@ class _PreviousViewWidget extends State with TickerProviderS child: Container( decoration: BoxDecoration( borderRadius: new BorderRadius.only( - bottomRight: const Radius.circular(20.0), + bottomRight: Radius.circular(20.0), ), color: kSecondRed ), diff --git a/lib/Screens/Puzzle/message_dialog.dart b/lib/Screens/Puzzle/message_dialog.dart index 775d3f4..61d86a6 100644 --- a/lib/Screens/Puzzle/message_dialog.dart +++ b/lib/Screens/Puzzle/message_dialog.dart @@ -2,16 +2,20 @@ import 'package:flutter/material.dart'; import 'package:flutter_widget_from_html/flutter_widget_from_html.dart'; import 'package:manager_api/api.dart'; import 'package:tablet_app/Components/show_element_for_resource.dart'; +import 'package:tablet_app/Models/tabletContext.dart'; import 'package:tablet_app/app_context.dart'; import 'package:tablet_app/constants.dart'; void showMessage(TranslationAndResourceDTO translationAndResourceDTO, AppContext appContext, BuildContext context, Size size) { print("translationAndResourceDTO"); print(translationAndResourceDTO); + + TabletAppContext tabletAppContext = appContext.getContext(); + showDialog( builder: (BuildContext context) => AlertDialog( shape: RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(20.0)) + borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)) ), content: SingleChildScrollView( child: Column( @@ -26,7 +30,7 @@ void showMessage(TranslationAndResourceDTO translationAndResourceDTO, AppContext child: Center( child: Container( decoration: BoxDecoration( - borderRadius: BorderRadius.circular(30), + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 30), //border: Border.all(width: 3, color: Colors.black) ), child: showElementForResource(ResourceDTO(id: translationAndResourceDTO.resourceId, type: translationAndResourceDTO.resourceType, url: translationAndResourceDTO.resourceUrl), appContext, true, false), diff --git a/lib/Screens/Puzzle/puzzle_piece.dart b/lib/Screens/Puzzle/puzzle_piece.dart index 844e8fe..c464f4e 100644 --- a/lib/Screens/Puzzle/puzzle_piece.dart +++ b/lib/Screens/Puzzle/puzzle_piece.dart @@ -82,8 +82,8 @@ class _PuzzlePieceState extends State { var isPortrait = MediaQuery.of(context).orientation == Orientation.portrait; - var imageHeight = isPortrait ? widget.imageSize.width/1.5 : widget.imageSize.width; - var imageWidth = isPortrait ? widget.imageSize.width/1.5: widget.imageSize.height; + var imageHeight = isPortrait ? widget.imageSize.width/1.55 : widget.imageSize.width; + var imageWidth = isPortrait ? widget.imageSize.width/1.55 : widget.imageSize.height; final pieceWidth = imageWidth / widget.maxCol; final pieceHeight = imageHeight / widget.maxRow; diff --git a/lib/Screens/Puzzle/puzzle_view.dart b/lib/Screens/Puzzle/puzzle_view.dart index d2e9da4..bef436d 100644 --- a/lib/Screens/Puzzle/puzzle_view.dart +++ b/lib/Screens/Puzzle/puzzle_view.dart @@ -205,24 +205,27 @@ class _PuzzleView extends State { final appContext = Provider.of(context); TabletAppContext tabletAppContext = appContext.getContext(); - return Padding( - key: _widgetKey, - padding: const EdgeInsets.all(10.0), - child: isSplittingImage ? Center(child: LoadingCommon()) : - puzzleDTO.image == null || puzzleDTO.image!.resourceUrl == null || realWidgetSize == null - ? Center(child: Text("Aucune image à afficher", style: TextStyle(fontSize: kNoneInfoOrIncorrect))) - : Center( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - width: tabletAppContext.puzzleSize != null && tabletAppContext.puzzleSize!.width > 0 ? tabletAppContext.puzzleSize!.width : realWidgetSize!.width * 0.8, - height: tabletAppContext.puzzleSize != null && tabletAppContext.puzzleSize!.height > 0 ? tabletAppContext.puzzleSize!.height +1.5 : realWidgetSize!.height * 0.85, - child: Stack( - children: pieces, + return Container( + //color: Colors.green, + child: Padding( + key: _widgetKey, + padding: const EdgeInsets.all(0.0), + child: isSplittingImage ? Center(child: LoadingCommon()) : + puzzleDTO.image == null || puzzleDTO.image!.resourceUrl == null || realWidgetSize == null + ? Center(child: Text("Aucune image à afficher", style: TextStyle(fontSize: kNoneInfoOrIncorrect))) + : Center( + child: Padding( + padding: const EdgeInsets.all(0.0), + child: Container( + width: tabletAppContext.puzzleSize != null && tabletAppContext.puzzleSize!.width > 0 ? tabletAppContext.puzzleSize!.width : realWidgetSize!.width * 0.8, + height: tabletAppContext.puzzleSize != null && tabletAppContext.puzzleSize!.height > 0 ? tabletAppContext.puzzleSize!.height +1.5 : realWidgetSize!.height * 0.85, + child: Stack( + children: pieces, + ), ), ), ), - ), + ), ); } } \ No newline at end of file diff --git a/lib/Screens/Quizz/quizz_view.dart b/lib/Screens/Quizz/quizz_view.dart index 308fa8c..58f8cb7 100644 --- a/lib/Screens/Quizz/quizz_view.dart +++ b/lib/Screens/Quizz/quizz_view.dart @@ -13,7 +13,9 @@ import 'package:provider/provider.dart'; import 'package:tablet_app/Components/Buttons/rounded_button.dart'; import 'package:tablet_app/Components/show_element_for_resource.dart'; import 'package:tablet_app/Helpers/ImageCustomProvider.dart'; +import 'package:tablet_app/Helpers/translationHelper.dart'; import 'package:tablet_app/Models/ResponseSubDTO.dart'; +import 'package:tablet_app/Models/tabletContext.dart'; import 'package:tablet_app/Screens/Quizz/showResponses.dart'; import 'package:tablet_app/Screens/Slider/slider_view.dart'; import 'package:tablet_app/app_context.dart'; @@ -70,6 +72,9 @@ class _QuizzView extends State { Widget build(BuildContext context) { Size size = MediaQuery.of(context).size; final appContext = Provider.of(context); + TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext; + + var primaryColor = tabletAppContext.configuration != null ? tabletAppContext.configuration!.primaryColor != null ? new Color(int.parse(tabletAppContext.configuration!.primaryColor!.split('(0x')[1].split(')')[0], radix: 16)) : kTestSecondColor : kTestSecondColor; if(showResult) { @@ -104,11 +109,11 @@ class _QuizzView extends State { numberOfParticles: 2, blastDirectionality: BlastDirectionality.explosive, shouldLoop: false, // start again as soon as the animation is finished - colors: const [ + colors: [ Colors.red, Colors.blueGrey, Colors.green, - kTestSecondColor + primaryColor //Colors.pink, //Colors.orange, //Colors.purple @@ -128,11 +133,11 @@ class _QuizzView extends State { alignment: Alignment.center, child : getElementForResource(context, appContext, levelToShow.label!.firstWhere((translation) => translation.language == appContext.getContext().language), true), ), - Container( - height: 90, - //color: Colors.orange, - child: Text('$goodResponses/${quizzDTO.questions!.length}', textAlign: TextAlign.center, style: TextStyle(fontSize: kIsWeb ? (showResponses ? 60 : 100) : (showResponses ? 60 : 70), color: kBackgroundSecondGrey)), - ), + Container( + height: showResponses ? 60 : 90, + //color: Colors.orange, + child: Text('$goodResponses/${quizzDTO.questions!.length}', textAlign: TextAlign.center, style: TextStyle(fontSize: kIsWeb ? (showResponses ? 40 : 100) : (showResponses ? 40 : 70), color: kBackgroundSecondGrey)), + ), if(!showResponses) Container( child: Padding( @@ -143,7 +148,7 @@ class _QuizzView extends State { decoration: BoxDecoration( color: kBackgroundLight, shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(10.0), + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 10.0), boxShadow: [ BoxShadow( color: kBackgroundSecondGrey, @@ -177,12 +182,12 @@ class _QuizzView extends State { ), if(showResponses) Container( - width: MediaQuery.of(context).size.width *0.75, - height: kIsWeb ? MediaQuery.of(context).size.height *0.35 : MediaQuery.of(context).size.height *0.5, //MediaQuery.of(context).size.height *0.55 + width: MediaQuery.of(context).size.width *0.9, + height: kIsWeb ? MediaQuery.of(context).size.height *0.35 : MediaQuery.of(context).size.height *0.6, //MediaQuery.of(context).size.height *0.55 decoration: BoxDecoration( color: kBackgroundLight, shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(10.0), + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 10.0), boxShadow: [ BoxShadow( color: kBackgroundSecondGrey, @@ -206,10 +211,10 @@ class _QuizzView extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( - height: kIsWeb ? 50 : 50, //85 + height: 50, //85 child: RoundedButton( - text: "Recommencer", - color: kBackgroundSecondGrey, + text: TranslationHelper.getFromLocale("quiz.restart", appContext.getContext()), + color: primaryColor, textColor: kBackgroundLight, icon: Icons.undo, press: () { @@ -227,10 +232,10 @@ class _QuizzView extends State { ), if(!showResponses) Container( - height: kIsWeb ? 50 : 50, //85 + height: 50, //85 child: RoundedButton( - text: "Voir les réponses", - color: kBackgroundSecondGrey, + text: TranslationHelper.getFromLocale("quiz.seeResponses", appContext.getContext()), + color: primaryColor, textColor: kBackgroundLight, icon: Icons.assignment_turned_in, press: () { @@ -282,7 +287,7 @@ class _QuizzView extends State { decoration: BoxDecoration( color: kBackgroundLight, shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(20.0), + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0), image: i.resourceUrl != null ? new DecorationImage( fit: BoxFit.cover, opacity: 0.35, @@ -314,7 +319,7 @@ class _QuizzView extends State { decoration: BoxDecoration( color: kBackgroundLight, // Colors.orange,// kBackgroundLight, shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(10.0), + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 10.0), boxShadow: [ BoxShadow( color: kBackgroundSecondGrey, @@ -431,9 +436,9 @@ class _QuizzView extends State { ], ), decoration: BoxDecoration( - color: i.chosen == index ? kTestSecondColor : kBackgroundLight, + color: i.chosen == index ? primaryColor : kBackgroundLight, shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(10.0), + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 10.0), boxShadow: [ BoxShadow( color: kBackgroundSecondGrey, @@ -483,7 +488,7 @@ class _QuizzView extends State { child: Icon( Icons.chevron_right, size: kIsWeb ? 100 : 100, // 95 - color: kTestSecondColor, + color: primaryColor, ), ) ), @@ -499,7 +504,7 @@ class _QuizzView extends State { child: Icon( Icons.chevron_left, size: kIsWeb ? 100 : 100, //95 - color: kTestSecondColor, + color: primaryColor, ), ) ), @@ -526,6 +531,7 @@ class _QuizzView extends State { getElementForResource(BuildContext context, AppContext appContext, TranslationAndResourceDTO i, bool addFullScreen) { var widgetToInclude; Size size = MediaQuery.of(context).size; + TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext; switch(i.resourceType) { case ResourceType.Image: @@ -537,14 +543,14 @@ getElementForResource(BuildContext context, AppContext appContext, TranslationAn context: context, builder: (BuildContext context) { return AlertDialog( - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(20.0)) + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)) ), contentPadding: EdgeInsets.zero, // title: Text(eventAgenda.name!), content: Container( decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(20.0)), + borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)), color: kBackgroundColor, ), height: size.height * 0.8, @@ -552,7 +558,7 @@ getElementForResource(BuildContext context, AppContext appContext, TranslationAn child: Container( decoration: BoxDecoration( color: const Color(0xff7c94b6), - borderRadius: BorderRadius.all(Radius.circular(15.0)), + borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0)), ), child: PhotoView( imageProvider: ImageCustomProvider.getImageProvider(appContext, i.resourceId!, i.resourceUrl!), @@ -561,7 +567,7 @@ getElementForResource(BuildContext context, AppContext appContext, TranslationAn backgroundDecoration: BoxDecoration( color: kBackgroundSecondGrey, shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(15.0), + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0), ), ), ), @@ -573,16 +579,16 @@ getElementForResource(BuildContext context, AppContext appContext, TranslationAn }, child: Container( decoration: BoxDecoration( - color: const Color(0xff7c94b6), + //color: kBackgroundLight, image: DecorationImage( image: ImageCustomProvider.getImageProvider(appContext, i.resourceId!, i.resourceUrl!), fit: BoxFit.cover, ), - borderRadius: BorderRadius.all(Radius.circular(15.0)), - border: Border.all( + borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0)), + /*border: Border.all( color: kBackgroundGrey, width: 1.0, - ), + ),*/ ), ), ); @@ -598,14 +604,14 @@ getElementForResource(BuildContext context, AppContext appContext, TranslationAn context: context, builder: (BuildContext context) { return AlertDialog( - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(20.0)) + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)) ), contentPadding: EdgeInsets.zero, // title: Text(eventAgenda.name!), content: Container( decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(20.0)), + borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)), color: kBackgroundColor, ), height: size.height * 0.8, @@ -621,9 +627,9 @@ getElementForResource(BuildContext context, AppContext appContext, TranslationAn ignoring: i.resourceType != ResourceType.Audio, child: Container( decoration: BoxDecoration( - color: kBackgroundSecondGrey, + //color: kBackgroundSecondGrey, shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(15.0), + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0), ), child: showElementForResource(ResourceDTO(id: i.resourceId, url: i.resourceUrl, type: i.resourceType), appContext, false, true), ), diff --git a/lib/Screens/Quizz/showResponses.dart b/lib/Screens/Quizz/showResponses.dart index 90f08ae..c05f598 100644 --- a/lib/Screens/Quizz/showResponses.dart +++ b/lib/Screens/Quizz/showResponses.dart @@ -10,6 +10,7 @@ import 'package:manager_api/api.dart'; import 'package:provider/provider.dart'; import 'package:tablet_app/Helpers/ImageCustomProvider.dart'; import 'package:tablet_app/Models/ResponseSubDTO.dart'; +import 'package:tablet_app/Models/tabletContext.dart'; import 'package:tablet_app/app_context.dart'; import 'package:tablet_app/constants.dart'; @@ -46,8 +47,11 @@ class _ShowReponsesWidget extends State { Widget build(BuildContext context) { Size sizeAll = MediaQuery.of(context).size; - Size size = Size(sizeAll.width * 0.65, kIsWeb ? sizeAll.height * 0.5 : sizeAll.height * 0.5); //sizeAll.height * 0.32 + Size size = Size(sizeAll.width * 0.65, sizeAll.height * 0.55); final appContext = Provider.of(context); + TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext; + + var primaryColor = tabletAppContext.configuration != null ? tabletAppContext.configuration!.primaryColor != null ? new Color(int.parse(tabletAppContext.configuration!.primaryColor!.split('(0x')[1].split(')')[0], radix: 16)) : kTestSecondColor : kTestSecondColor; return Stack( children: [ @@ -77,7 +81,7 @@ class _ShowReponsesWidget extends State { decoration: BoxDecoration( color: kBackgroundLight, shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(20.0), + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0), image: i.resourceUrl != null ? new DecorationImage( fit: BoxFit.contain, opacity: 0.35, @@ -101,7 +105,7 @@ class _ShowReponsesWidget extends State { child: Container( //width: MediaQuery.of(context).size.width *0.65, //color: Colors.pink, - height: kIsWeb ? size.height *0.25 : size.height *0.25, + height: size.height *0.25, child: Stack( children: [ Center( @@ -109,7 +113,7 @@ class _ShowReponsesWidget extends State { decoration: BoxDecoration( color: kBackgroundLight, shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(10.0), + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 10.0), boxShadow: [ BoxShadow( color: kBackgroundSecondGrey, @@ -153,8 +157,8 @@ class _ShowReponsesWidget extends State { child: GridView.builder( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, - mainAxisExtent: kIsWeb ? 65 : 65, // TODO depends on percentage 125 - mainAxisSpacing: kIsWeb ? 10 : 10, // TODO depends on percentage 15 + mainAxisExtent: 65, + mainAxisSpacing: 10, crossAxisSpacing: 5, ), itemCount: i.responsesSubDTO!.length, @@ -173,7 +177,7 @@ class _ShowReponsesWidget extends State { decoration: BoxDecoration( color: i.responsesSubDTO![index].isGood! ? kGreen : i.chosen == index ? kMainRed : kBackgroundLight, shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(10.0), + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 10.0), boxShadow: [ BoxShadow( color: kBackgroundSecondGrey, @@ -200,8 +204,8 @@ class _ShowReponsesWidget extends State { ), if(_questionsSubDTO != null && _questionsSubDTO.length > 1 && currentIndex != _questionsSubDTO.length && _questionsSubDTO[currentIndex-1].chosen != null && widget.questionsSubDTO!.length > 0) Positioned( - top: kIsWeb ? size.height * 0.3 : size.height * 0.3, // size.height * 0.35 // TODO depends on screen' percentage - right: kIsWeb ? 45 : 45, // 60TODO depends on screen' percentage + top: size.height * 0.35, + right: 35, child: InkWell( onTap: () { if(_questionsSubDTO[currentIndex-1].chosen != null && widget.questionsSubDTO!.length > 0) { @@ -219,15 +223,15 @@ class _ShowReponsesWidget extends State { }, child: Icon( Icons.chevron_right, - size: kIsWeb ? 100 : 100, // 150 TODO depends on screen' percentage - color: kMainRed, + size: 90, + color: primaryColor, ), ) ), if(_questionsSubDTO != null && _questionsSubDTO.length > 1 && currentIndex != 1) Positioned( - top: kIsWeb ? size.height * 0.3 : size.height * 0.3, // size.height * 0.35 TODO depends on screen' percentage - left: kIsWeb ? 45 : 45, // 60 TODO depends on screen' percentage + top: size.height * 0.35, + left: 35, child: InkWell( onTap: () { if(currentIndex > 1) @@ -235,8 +239,8 @@ class _ShowReponsesWidget extends State { }, child: Icon( Icons.chevron_left, - size: kIsWeb ? 100 : 100, // 150 TODO depends on screen' percentage - color: kMainRed, + size: 90, + color: primaryColor, ), ) ), diff --git a/lib/Screens/Slider/slider_view.dart b/lib/Screens/Slider/slider_view.dart index b0d4ca6..c333cd0 100644 --- a/lib/Screens/Slider/slider_view.dart +++ b/lib/Screens/Slider/slider_view.dart @@ -52,6 +52,8 @@ class _SliderView extends State { Widget build(BuildContext context) { Size size = MediaQuery.of(context).size; final appContext = Provider.of(context); + TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext; + Color? primaryColor = tabletAppContext.configuration!.primaryColor != null ? new Color(int.parse(tabletAppContext.configuration!.primaryColor!.split('(0x')[1].split(')')[0], radix: 16)) : null; configurationDTO = appContext.getContext().configuration; @@ -76,8 +78,8 @@ class _SliderView extends State { height: MediaQuery.of(context).size.height, margin: EdgeInsets.symmetric(horizontal: 5.0), decoration: BoxDecoration( - color: configurationDTO.imageId == null ? configurationDTO.secondaryColor != null ? new Color(int.parse(configurationDTO.secondaryColor!.split('(0x')[1].split(')')[0], radix: 16)): kBackgroundGrey : null, - borderRadius: BorderRadius.circular(10.0), + //color: configurationDTO.imageId == null ? configurationDTO.secondaryColor != null ? new Color(int.parse(configurationDTO.secondaryColor!.split('(0x')[1].split(')')[0], radix: 16)): kBackgroundGrey : null, + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 10.0), //border: Border.all(width: 0.3, color: kSecondGrey), ), child: Column( @@ -130,12 +132,12 @@ class _SliderView extends State { child: Padding( padding: const EdgeInsets.only(bottom: 10), child: Container( - width: MediaQuery.of(context).size.width *0.65, height: MediaQuery.of(context).size.height *0.25, + width: MediaQuery.of(context).size.width *0.7, decoration: BoxDecoration( color: kBackgroundLight, shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(10.0), + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 10.0), boxShadow: [ BoxShadow( color: kBackgroundSecondGrey, @@ -179,7 +181,7 @@ class _SliderView extends State { child: Icon( Icons.chevron_right, size: 90, - color: Colors.white, + color: primaryColor ?? kTestSecondColor, ), ) ), @@ -195,7 +197,7 @@ class _SliderView extends State { child: Icon( Icons.chevron_left, size: 90, - color: Colors.white, + color: primaryColor ?? kTestSecondColor, ), ) ), @@ -252,6 +254,7 @@ class _SliderView extends State { getElementForResource(AppContext appContext, ContentDTO i) { var widgetToInclude; + TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext; switch(i.resourceType) { case ResourceType.Image: @@ -262,7 +265,7 @@ class _SliderView extends State { backgroundDecoration: BoxDecoration( color: kBackgroundSecondGrey, shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(15.0), + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0), ), ); break; @@ -274,7 +277,7 @@ class _SliderView extends State { backgroundDecoration: BoxDecoration( color: kBackgroundSecondGrey, shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(15.0), + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0), ), ); break; @@ -283,9 +286,9 @@ class _SliderView extends State { case ResourceType.Audio: widgetToInclude = Container( decoration: BoxDecoration( - color: kBackgroundSecondGrey, - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(15.0), + //color: kBackgroundSecondGrey, + //shape: BoxShape.rectangle, + borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0), ), child: showElementForResource(ResourceDTO(id: i.resourceId, url: i.resourceUrl, type: i.resourceType), appContext, false, true), ); diff --git a/lib/Screens/Weather/weather_view.dart b/lib/Screens/Weather/weather_view.dart new file mode 100644 index 0000000..c0a736f --- /dev/null +++ b/lib/Screens/Weather/weather_view.dart @@ -0,0 +1,609 @@ +import 'dart:convert'; + +import 'package:auto_size_text/auto_size_text.dart'; +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; +import 'package:manager_api/api.dart'; +import 'package:provider/provider.dart'; +import 'package:tablet_app/Helpers/translationHelper.dart'; +import 'package:tablet_app/Models/WeatherData.dart'; +import 'package:tablet_app/Models/tabletContext.dart'; +import 'package:tablet_app/app_context.dart'; +import 'package:tablet_app/constants.dart'; +import 'package:intl/intl.dart'; + +class WeatherView extends StatefulWidget { + final SectionDTO? section; + WeatherView({required this.section}); + + @override + State createState() => _WeatherViewState(); +} + +class _WeatherViewState extends State { + WeatherDTO weatherDTO = WeatherDTO(); + WeatherData? weatherData = null; + int nbrNextHours = 5; + + @override + void initState() { + print(widget.section!.data); + weatherDTO = WeatherDTO.fromJson(jsonDecode(widget.section!.data!))!; + print(weatherDTO); + if(weatherDTO.result != null) { + Map weatherResultInJson = jsonDecode(weatherDTO.result!); + weatherData = WeatherData.fromJson(weatherResultInJson); + } + + super.initState(); + } + + String formatTimestamp(int timestamp, AppContext appContext, bool isHourOnly, bool isDateOnly) { + + DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(timestamp * 1000); + + // Determine the date format based on the application language + String dateFormat = appContext.getContext().language.toString().toUpperCase() == "EN" ? + 'MM/dd/yyyy HH:mm' + : 'dd/MM/yyyy HH:mm'; + + if(isHourOnly) { + dateFormat = 'HH:mm'; + } + + if(isDateOnly) { + dateFormat = dateFormat.replaceAll('/yyyy HH:mm', ''); + } + + String formattedDate = DateFormat(dateFormat).format(dateTime); + + return formattedDate; + } + + String getTranslatedDayOfWeek(int timestamp, AppContext appContext, bool isDate) { + DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(timestamp * 1000); + + String dayToPrint = ""; + + print("dateTime.weekday"); + print(dateTime.weekday); + + switch(dateTime.weekday) { + case 1: + dayToPrint = TranslationHelper.getFromLocale("monday", appContext.getContext()); + break; + case 2: + dayToPrint = TranslationHelper.getFromLocale("tuesday", appContext.getContext()); + break; + case 3: + dayToPrint = TranslationHelper.getFromLocale("wednesday", appContext.getContext()); + break; + case 4: + dayToPrint = TranslationHelper.getFromLocale("thursday", appContext.getContext()); + break; + case 5: + dayToPrint = TranslationHelper.getFromLocale("friday", appContext.getContext()); + break; + case 6: + dayToPrint = TranslationHelper.getFromLocale("saturday", appContext.getContext()); + break; + case 7: + dayToPrint = TranslationHelper.getFromLocale("sunday", appContext.getContext()); + break; + } + + return isDate ? "${dayToPrint} ${formatTimestamp(timestamp, appContext, false, true)}" : dayToPrint; + } + + List getNextFiveDaysForecast(List allForecasts) { + List nextFiveDaysForecast = []; + DateTime today = DateTime.now(); + + List nextDay1All = allForecasts.where((af) => (DateTime.fromMillisecondsSinceEpoch(af.dt! * 1000)).day == (today.add(Duration(days: 1))).day).toList(); + List nextDay2All = allForecasts.where((af) => (DateTime.fromMillisecondsSinceEpoch(af.dt! * 1000)).day == (today.add(Duration(days: 2))).day).toList(); + List nextDay3All = allForecasts.where((af) => (DateTime.fromMillisecondsSinceEpoch(af.dt! * 1000)).day == (today.add(Duration(days: 3))).day).toList(); + List nextDay4All = allForecasts.where((af) => (DateTime.fromMillisecondsSinceEpoch(af.dt! * 1000)).day == (today.add(Duration(days: 4))).day).toList(); + List nextDay5All = allForecasts.where((af) => (DateTime.fromMillisecondsSinceEpoch(af.dt! * 1000)).day == (today.add(Duration(days: 5))).day).toList(); + + var nextDay1MiddayTest = nextDay1All.where((nd) => (DateTime.fromMillisecondsSinceEpoch(nd.dt! * 1000)).hour == 12).firstOrNull; + if(nextDay1All.isNotEmpty) { + WeatherForecast nextDay1AllSummary = nextDay1MiddayTest != null ? nextDay1MiddayTest : nextDay1All.last; + nextFiveDaysForecast.add(nextDay1AllSummary); + } + + var nextDay2MiddayTest = nextDay2All.where((nd) => (DateTime.fromMillisecondsSinceEpoch(nd.dt! * 1000)).hour == 12).firstOrNull; + if(nextDay2All.isNotEmpty) { + WeatherForecast nextDay2Midday = nextDay2MiddayTest != null ? nextDay2MiddayTest : nextDay2All.last; + nextFiveDaysForecast.add(nextDay2Midday); + } + + var nextDay3MiddayTest = nextDay3All.where((nd) => (DateTime.fromMillisecondsSinceEpoch(nd.dt! * 1000)).hour == 12).firstOrNull; + if(nextDay3All.isNotEmpty) { + WeatherForecast nextDay3Midday = nextDay3MiddayTest != null ? nextDay3MiddayTest : nextDay3All.last; + nextFiveDaysForecast.add(nextDay3Midday); + } + + var nextDay4MiddayTest = nextDay4All.where((nd) => (DateTime.fromMillisecondsSinceEpoch(nd.dt! * 1000)).hour == 12).firstOrNull; + if(nextDay4All.isNotEmpty) { + WeatherForecast nextDay4Midday = nextDay4MiddayTest != null ? nextDay4MiddayTest : nextDay4All.last; + nextFiveDaysForecast.add(nextDay4Midday); + } + + var nextDay5MiddayTest = nextDay5All.where((nd) => (DateTime.fromMillisecondsSinceEpoch(nd.dt! * 1000)).hour == 12).firstOrNull; + if(nextDay5All.isNotEmpty) { + WeatherForecast nextDay5Midday = nextDay5MiddayTest != null ? nextDay5MiddayTest : nextDay5All.last; + nextFiveDaysForecast.add(nextDay5Midday); + } + + return nextFiveDaysForecast; + } + + @override + Widget build(BuildContext context) { + Size size = MediaQuery.of(context).size; + final appContext = Provider.of(context); + TabletAppContext tabletAppContext = appContext.getContext(); + + return weatherData == null ? Center(child: Text("Aucune donnée à afficher")) : Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)), + gradient: LinearGradient( + begin: Alignment.topRight, + end: Alignment.bottomLeft, + stops: [ + 0.2, + 0.5, + 0.9, + 0.95 + ], + colors: [ + Colors.blue[50]!, + Colors.blue[100]!, + Colors.blue[200]!, + Colors.blue[300]! + ] + ) + ), + //color: Colors.yellow, + //height: 300, + //width: 300, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(10.0), + child: Center(child: Text(weatherDTO.city!, style: TextStyle(fontSize: kSectionTitleDetailSize, fontWeight: FontWeight.w500, color: Colors.black54, fontFamily: "Roboto"))), + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Text("${weatherData!.list!.first.main!.temp!.round().toString()}°", style: TextStyle(fontSize: 55.0, fontWeight: FontWeight.w400, color: Colors.black54, fontFamily: "Roboto")), + ), + Container( + //color: Colors.red, + height: size.height * 0.2, + width: size.width * 0.2, + child: Center( + child: CachedNetworkImage(imageUrl: "https://openweathermap.org/img/wn/${weatherData!.list!.first.weather!.first.icon!}@4x.png") + ) + ), + Container( + // color: Colors.green, + width: size.width * 0.1, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + children: [ + Icon(Icons.water_drop_outlined, color: kTestSecondColor), + Text("${weatherData!.list!.first.pop!.round().toString()}%", style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.w400, color: Colors.black54, fontFamily: "Roboto")), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + children: [ + Icon(Icons.air, color: kTestSecondColor), + Text("${(weatherData!.list!.first.wind!.speed! * 3.6).toStringAsFixed(1)}km/h", style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.w400, color: Colors.black54, fontFamily: "Roboto")), + ], + ), + ), + ], + ), + ), + ]), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + height: size.height * 0.25, + width: size.width * 0.6, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)), + //color: Colors.grey, + ), + child: Column( + children: [ + Padding( + padding: const EdgeInsets.only(left: 15, bottom: 10), + child: Align(alignment: Alignment.centerLeft, child: Text(TranslationHelper.getFromLocale("weather.hourly", appContext.getContext()), style: TextStyle(fontSize: 22, fontWeight: FontWeight.w400, color: Colors.black54, fontFamily: "Roboto"))), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.center, + children: List.generate( + nbrNextHours, + (index) { + final weatherForecast = weatherData!.list!.sublist(1)[index]; + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + height: size.height * 0.15, + width: size.width * 0.1, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)), + color: Colors.lightBlueAccent, + boxShadow: [ + BoxShadow( + color: kBackgroundGrey.withOpacity(0.6), + spreadRadius: 0.75, + blurRadius: 3.1, + offset: Offset(0, 2.5), // changes position of shadow + ), + ], + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text('${formatTimestamp(weatherForecast.dt!, appContext, true, false)}', style: TextStyle(fontSize: 12.0, fontWeight: FontWeight.w400, color: Colors.white, fontFamily: "Roboto")), + Center(child: CachedNetworkImage(imageUrl: "https://openweathermap.org/img/wn/${weatherForecast.weather!.first.icon!}.png")), + Text('${weatherForecast.main!.temp!.round().toString()}°', style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w600, color: Colors.white, fontFamily: "Roboto")), + ], + ), + ), + ); + }, + ), + ), + ], + ), + ), + ), + Padding( + padding: const EdgeInsets.all(0.0), + child: Container( + height: size.height * 0.3, + width: size.width * 0.75, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)), + //color: Colors.amber, + ), + child: Column( + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Align(alignment: Alignment.centerLeft, child: Text(TranslationHelper.getFromLocale("weather.nextdays", appContext.getContext()), style: TextStyle(fontSize: 20, fontWeight: FontWeight.w400, color: Colors.black54, fontFamily: "Roboto"))), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.center, + children: List.generate( + getNextFiveDaysForecast(weatherData!.list!).length, // nbrNextHours + (index) { + final weatherForecastNextDay = getNextFiveDaysForecast(weatherData!.list!)[index]; + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + height: size.height * 0.22, + width: size.width * 0.125, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)), + color: Colors.lightBlue, + boxShadow: [ + BoxShadow( + color: kBackgroundGrey.withOpacity(0.5), + spreadRadius: 0.75, + blurRadius: 3.1, + offset: Offset(0, 2.5), // changes position of shadow + ), + ], + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Center(child: CachedNetworkImage(imageUrl: "https://openweathermap.org/img/wn/${weatherForecastNextDay.weather!.first.icon!}@2x.png")), + Text('${weatherForecastNextDay.main!.temp!.round().toString()}°', style: TextStyle(fontSize: 25.0, fontWeight: FontWeight.w600, color: Colors.white, fontFamily: "Roboto")), + Text('${getTranslatedDayOfWeek(weatherForecastNextDay.dt!, appContext, true)}', style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.w400, color: Colors.white, fontFamily: "Roboto")), + ], + ), + ), + ); + }, + ), + ), + ], + ), + ), + ) + ], + ), + ); + /*return InkWell( + onTap: () { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(20.0)) + ), + contentPadding: EdgeInsets.zero, + // title: Text(eventAgenda.name!), + content: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(20.0)), + gradient: LinearGradient( + begin: Alignment.topRight, + end: Alignment.bottomLeft, + stops: [ + 0.2, + 0.5, + 0.9, + 0.95 + ], + colors: [ + Colors.blue[50]!, + Colors.blue[100]!, + Colors.blue[200]!, + Colors.blue[300]! + ] + ) + ), + height: size.height * 0.9, + width: size.width * 0.8, + child: Stack( + children: [ + Positioned( + right: 5, + top: 5, + child: InkWell( + onTap: () { + Navigator.of(context).pop(); + }, + child: Container( + width: 50, + height: 50, + child: Icon( + Icons.close, + size: 25, + color: Colors.black54, + ), + ), + ), + ), + SizedBox( + //height: 300, + //width: 300, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(10.0), + child: Center(child: Text(tabletAppContext.configuration!.weatherCity!, style: TextStyle(fontSize: kSectionTitleDetailSize, fontWeight: FontWeight.w500, color: Colors.black54))), + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Text("${weatherData.list!.first.main!.temp!.round().toString()}°", style: TextStyle(fontSize: 55.0, fontWeight: FontWeight.w400, color: Colors.black54)), + ), + Container( + //color: Colors.red, + height: size.height * 0.2, + width: size.width * 0.2, + child: Center( + child: CachedNetworkImage(imageUrl: "https://openweathermap.org/img/wn/${weatherData.list!.first.weather!.first.icon!}@4x.png") + ) + ), + Container( + // color: Colors.green, + width: size.width * 0.1, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + children: [ + Icon(Icons.water_drop_outlined, color: kTestSecondColor), + Text("${weatherData.list!.first.pop!.round().toString()}%", style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.w400, color: Colors.black54)), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + children: [ + Icon(Icons.air, color: kTestSecondColor), + Text("${(weatherData.list!.first.wind!.speed! * 3.6).toStringAsFixed(1)}km/h", style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.w400, color: Colors.black54)), + ], + ), + ), + ], + ), + ), + ]), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + height: size.height * 0.25, + width: size.width * 0.6, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(20.0)), + //color: Colors.grey, + ), + child: Column( + children: [ + Padding( + padding: const EdgeInsets.only(left: 15, bottom: 10), + child: Align(alignment: Alignment.centerLeft, child: Text(TranslationHelper.getFromLocale("weather.hourly", appContext.getContext()), style: TextStyle(fontSize: 22, fontWeight: FontWeight.w400, color: Colors.black54))), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.center, + children: List.generate( + nbrNextHours, + (index) { + final weatherForecast = weatherData.list!.sublist(1)[index]; + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + height: size.height * 0.15, + width: size.width * 0.1, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(20.0)), + color: Colors.lightBlueAccent, + boxShadow: [ + BoxShadow( + color: kBackgroundGrey.withOpacity(0.6), + spreadRadius: 0.75, + blurRadius: 3.1, + offset: Offset(0, 2.5), // changes position of shadow + ), + ], + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text('${formatTimestamp(weatherForecast.dt!, appContext, true, false)}', style: TextStyle(fontSize: 12.0, fontWeight: FontWeight.w400, color: Colors.white)), + Center(child: CachedNetworkImage(imageUrl: "https://openweathermap.org/img/wn/${weatherForecast.weather!.first.icon!}.png")), + Text('${weatherForecast.main!.temp!.round().toString()}°', style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w600, color: Colors.white)), + ], + ), + ), + ); + }, + ), + ), + ], + ), + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + height: size.height * 0.3, + width: size.width * 0.75, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(20.0)), + //color: Colors.amber, + ), + child: Column( + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Align(alignment: Alignment.centerLeft, child: Text(TranslationHelper.getFromLocale("weather.nextdays", appContext.getContext()), style: TextStyle(fontSize: 20, fontWeight: FontWeight.w400, color: Colors.black54))), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.center, + children: List.generate( + getNextFiveDaysForecast(weatherData.list!).length, // nbrNextHours + (index) { + final weatherForecastNextDay = getNextFiveDaysForecast(weatherData.list!)[index]; + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + height: size.height * 0.22, + width: size.width * 0.125, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(20.0)), + color: Colors.lightBlue, + boxShadow: [ + BoxShadow( + color: kBackgroundGrey.withOpacity(0.5), + spreadRadius: 0.75, + blurRadius: 3.1, + offset: Offset(0, 2.5), // changes position of shadow + ), + ], + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Center(child: CachedNetworkImage(imageUrl: "https://openweathermap.org/img/wn/${weatherForecastNextDay.weather!.first.icon!}@2x.png")), + Text('${weatherForecastNextDay.main!.temp!.round().toString()}°', style: TextStyle(fontSize: 25.0, fontWeight: FontWeight.w600, color: Colors.white)), + Text('${getTranslatedDayOfWeek(weatherForecastNextDay.dt!, appContext, true)}', style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.w400, color: Colors.white)), + ], + ), + ), + ); + }, + ), + ), + ], + ), + ), + ) + ], + ), + ), + ], + ), + ) + ); + }, + ); + }, + child: Container( + //color: Colors.amber, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(10.0)), + gradient: LinearGradient( + begin: Alignment.topRight, + end: Alignment.bottomLeft, + stops: [ + 0.2, + 0.5, + 1.0, + 1.0 + ], + colors: [ + Colors.blue[50]!, + Colors.blue[100]!, + Colors.blue[200]!, + Colors.blue[300]! + ] + ) + ), + width: 70, + child: Column( + children: [ + CachedNetworkImage(imageUrl: "https://openweathermap.org/img/wn/${weatherData.list!.first.weather!.first.icon!}.png"), + Container(child: AutoSizeText("${weatherData.list!.first.main!.temp!.round().toString()}°")), + //AutoSizeText(weatherData.city!.name!), + ], + ), + ), + );*/ + } +} + +//_webView \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 052accd..004df98 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -15,6 +15,7 @@ import 'Screens/MainView/main_view.dart'; import 'Screens/Previous/previous_view.dart'; import 'app_context.dart'; import 'constants.dart'; +import 'package:flutter/services.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); @@ -99,6 +100,13 @@ class _MyAppState extends State { @override Widget build(BuildContext context) { + + // Block screen orientation in landscape mode only // TO TEST + SystemChrome.setPreferredOrientations([ + DeviceOrientation.landscapeLeft, + DeviceOrientation.landscapeRight, + ]); + return ChangeNotifierProvider( create: (_) => AppContext(widget.tabletAppContext), child: MaterialApp( @@ -113,8 +121,8 @@ class _MyAppState extends State { primaryColor: widget.tabletAppContext != null ? widget.tabletAppContext!.configuration != null ? widget.tabletAppContext!.configuration!.primaryColor != null ? new Color(int.parse(widget.tabletAppContext!.configuration!.secondaryColor!.split('(0x')[1].split(')')[0], radix: 16)): kTestSecondColor : kTestSecondColor : kTestSecondColor, primarySwatch: Colors.grey, scaffoldBackgroundColor: widget.tabletAppContext != null ? widget.tabletAppContext!.configuration != null ? widget.tabletAppContext!.configuration!.secondaryColor != null ? new Color(int.parse(widget.tabletAppContext!.configuration!.secondaryColor!.split('(0x')[1].split(')')[0], radix: 16)): kBackgroundGrey : kBackgroundGrey : kBackgroundGrey, - //fontFamily: "Vollkorn", - textTheme: TextTheme(bodyLarge: TextStyle(color: kMainRed)), + fontFamily: "Roboto", + textTheme: TextTheme(bodyLarge: TextStyle(color: kTestSecondColor)), visualDensity: VisualDensity.adaptivePlatformDensity, ), routes: { diff --git a/macos/Flutter/ephemeral/Flutter-Generated.xcconfig b/macos/Flutter/ephemeral/Flutter-Generated.xcconfig new file mode 100644 index 0000000..d2f3d74 --- /dev/null +++ b/macos/Flutter/ephemeral/Flutter-Generated.xcconfig @@ -0,0 +1,11 @@ +// This is a generated file; do not edit or check into version control. +FLUTTER_ROOT=C:\PROJ\flutter +FLUTTER_APPLICATION_PATH=C:\Users\ThomasFransolet\Documents\Documents\Perso\MuseeDeLaFraise\tablet-app +COCOAPODS_PARALLEL_CODE_SIGN=true +FLUTTER_BUILD_DIR=build +FLUTTER_BUILD_NAME=2.0.6 +FLUTTER_BUILD_NUMBER=12 +DART_OBFUSCATION=false +TRACK_WIDGET_CREATION=true +TREE_SHAKE_ICONS=false +PACKAGE_CONFIG=.dart_tool/package_config.json diff --git a/macos/Flutter/ephemeral/flutter_export_environment.sh b/macos/Flutter/ephemeral/flutter_export_environment.sh new file mode 100644 index 0000000..dfd6748 --- /dev/null +++ b/macos/Flutter/ephemeral/flutter_export_environment.sh @@ -0,0 +1,12 @@ +#!/bin/sh +# This is a generated file; do not edit or check into version control. +export "FLUTTER_ROOT=C:\PROJ\flutter" +export "FLUTTER_APPLICATION_PATH=C:\Users\ThomasFransolet\Documents\Documents\Perso\MuseeDeLaFraise\tablet-app" +export "COCOAPODS_PARALLEL_CODE_SIGN=true" +export "FLUTTER_BUILD_DIR=build" +export "FLUTTER_BUILD_NAME=2.0.6" +export "FLUTTER_BUILD_NUMBER=12" +export "DART_OBFUSCATION=false" +export "TRACK_WIDGET_CREATION=true" +export "TREE_SHAKE_ICONS=false" +export "PACKAGE_CONFIG=.dart_tool/package_config.json" diff --git a/pubspec.yaml b/pubspec.yaml index 9bbc82f..b978051 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -64,6 +64,7 @@ dependencies: just_audio_cache: ^0.1.2 path_provider: ^2.1.2 permission_handler: ^11.2.0 + google_fonts: ^6.2.1 openapi_generator_cli: ^4.13.1 openapi_generator: ^4.13.1