Layout update + use primary color (wip?)

This commit is contained in:
Thomas Fransolet 2024-04-12 17:10:25 +02:00
parent 341cc077e8
commit 59618c84e0
26 changed files with 1102 additions and 686 deletions

View File

@ -1,4 +1,7 @@
import 'package:flutter/material.dart'; 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'; import 'package:tablet_app/constants.dart';
class RoundedButton extends StatelessWidget { class RoundedButton extends StatelessWidget {
@ -24,6 +27,9 @@ class RoundedButton extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final appContext = Provider.of<AppContext>(context);
TabletAppContext tabletAppContext = appContext.getContext();
//Size size = MediaQuery.of(context).size; //Size size = MediaQuery.of(context).size;
return TextButton( return TextButton(
style: ButtonStyle( style: ButtonStyle(
@ -31,7 +37,7 @@ class RoundedButton extends StatelessWidget {
backgroundColor: MaterialStateColor.resolveWith((states) => color!), backgroundColor: MaterialStateColor.resolveWith((states) => color!),
shape: MaterialStateProperty.all<RoundedRectangleBorder>( shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder( RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0),
) )
) )
), ),

View File

@ -12,6 +12,9 @@ List<Translation> translations = [
"friday": "Vendredi", "friday": "Vendredi",
"saturday": "Samedi", "saturday": "Samedi",
"sunday": "Dimanche", "sunday": "Dimanche",
"menu": "Menu",
"quiz.seeResponses": "Voir les réponses",
"quiz.restart": "Recommencer"
}), }),
Translation(language: "EN", data: { Translation(language: "EN", data: {
"weather.hourly": "Hourly", "weather.hourly": "Hourly",
@ -23,7 +26,10 @@ List<Translation> translations = [
"thursday": "Thursday", "thursday": "Thursday",
"friday": "Friday", "friday": "Friday",
"saturday": "Saturday", "saturday": "Saturday",
"sunday": "Sunday" "sunday": "Sunday",
"menu": "Menu",
"quiz.seeResponses": "See the answers",
"quiz.restart": "Restart"
}), }),
Translation(language: "DE", data: { Translation(language: "DE", data: {
"weather.hourly": "Nächste Stunden", "weather.hourly": "Nächste Stunden",
@ -35,7 +41,10 @@ List<Translation> translations = [
"thursday": "Donnerstag", "thursday": "Donnerstag",
"friday": "Freitag", "friday": "Freitag",
"saturday": "Samstag", "saturday": "Samstag",
"sunday": "Sonntag" "sunday": "Sonntag",
"menu": "Speisekarte",
"quiz.seeResponses": "Sehen Sie sich die Antworten an",
"quiz.restart": "Neu starten"
}), }),
Translation(language: "NL", data: { Translation(language: "NL", data: {
"weather.hourly": "Volgende uren", "weather.hourly": "Volgende uren",
@ -47,7 +56,10 @@ List<Translation> translations = [
"thursday": "Donderdag", "thursday": "Donderdag",
"friday": "Vrijdag", "friday": "Vrijdag",
"saturday": "Zaterdag", "saturday": "Zaterdag",
"sunday": "Zondag" "sunday": "Zondag",
"menu": "Menu",
"quiz.seeResponses": "Zie de antwoorden",
"quiz.restart": "Herstarten"
}), }),
Translation(language: "IT", data: { Translation(language: "IT", data: {
"weather.hourly": "Le prossime ore", "weather.hourly": "Le prossime ore",
@ -59,7 +71,10 @@ List<Translation> translations = [
"thursday": "Giovedì", "thursday": "Giovedì",
"friday": "Venerdì", "friday": "Venerdì",
"saturday": "Sabato", "saturday": "Sabato",
"sunday": "Domenica" "sunday": "Domenica",
"menu": "Menù",
"quiz.seeResponses": "Vedi le risposte",
"quiz.restart": "Ricomincia"
}), }),
Translation(language: "ES", data: { Translation(language: "ES", data: {
"weather.hourly": "Próximas horas", "weather.hourly": "Próximas horas",
@ -71,7 +86,10 @@ List<Translation> translations = [
"thursday": "Jueves", "thursday": "Jueves",
"friday": "Viernes", "friday": "Viernes",
"saturday": "Sábado", "saturday": "Sábado",
"sunday": "Domingo" "sunday": "Domingo",
"menu": "Menú",
"quiz.seeResponses": "Ver las respuestas",
"quiz.restart": "Reanudar"
}), }),
Translation(language: "PL", data: { Translation(language: "PL", data: {
"weather.hourly": "Następne godziny", "weather.hourly": "Następne godziny",
@ -83,7 +101,10 @@ List<Translation> translations = [
"thursday": "Czwartek", "thursday": "Czwartek",
"friday": "Piątek", "friday": "Piątek",
"saturday": "Sobota", "saturday": "Sobota",
"sunday": "Niedziela" "sunday": "Niedziela",
"menu": "Menu",
"quiz.seeResponses": "Zobacz odpowiedzi",
"quiz.restart": "Uruchom ponownie"
}), }),
Translation(language: "CN", data: { Translation(language: "CN", data: {
"weather.hourly": "接下来的几个小时", "weather.hourly": "接下来的几个小时",
@ -95,7 +116,10 @@ List<Translation> translations = [
"thursday": "星期四", "thursday": "星期四",
"friday": "星期五", "friday": "星期五",
"saturday": "星期六", "saturday": "星期六",
"sunday": "星期日" "sunday": "星期日",
"menu": "菜单",
"quiz.seeResponses": "查看答案",
"quiz.restart": "重新开始"
}), }),
Translation(language: "UK", data: { Translation(language: "UK", data: {
"weather.hourly": "Наступні години", "weather.hourly": "Наступні години",
@ -107,7 +131,10 @@ List<Translation> translations = [
"thursday": "Четвер", "thursday": "Четвер",
"friday": "П'ятниця", "friday": "П'ятниця",
"saturday": "Субота", "saturday": "Субота",
"sunday": "Неділя" "sunday": "Неділя",
"menu": "Меню",
"quiz.seeResponses": "Подивіться відповіді",
"quiz.restart": "Перезапустіть"
}), }),
Translation(language: "AR", data: { Translation(language: "AR", data: {
"weather.hourly": "الساعات القادمة", "weather.hourly": "الساعات القادمة",
@ -119,6 +146,9 @@ List<Translation> translations = [
"thursday": "الخميس", "thursday": "الخميس",
"friday": "الجمعة", "friday": "الجمعة",
"saturday": "السبت", "saturday": "السبت",
"sunday": "الأحد" "sunday": "الأحد",
"menu": "القائمة",
"quiz.seeResponses": "انظر الإجابات",
"quiz.restart": "إعادة تشغيل"
}), }),
]; ];

View File

@ -111,10 +111,7 @@ class _AgendaView extends State<AgendaView> {
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: kBackgroundColor, color: kBackgroundColor,
borderRadius: BorderRadius.only( borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 30.0)),
topLeft: Radius.circular(30.0),
bottomLeft: Radius.circular(30.0),
),
), ),
child: Padding( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
@ -132,7 +129,7 @@ class _AgendaView extends State<AgendaView> {
Expanded( Expanded(
flex: 4, flex: 4,
child: Padding( 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: Container(
child: ValueListenableBuilder<List<EventAgenda>>( child: ValueListenableBuilder<List<EventAgenda>>(
valueListenable: filteredAgenda, valueListenable: filteredAgenda,

View File

@ -32,7 +32,7 @@ class EventListItem extends StatelessWidget {
return Container( return Container(
margin: const EdgeInsets.all(10.0), margin: const EdgeInsets.all(10.0),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0),
//color: Colors.red, //color: Colors.red,
boxShadow: const [ boxShadow: const [
BoxShadow( BoxShadow(
@ -53,7 +53,7 @@ class EventListItem extends StatelessWidget {
child: Stack( child: Stack(
children: [ children: [
eventAgenda.image != null ? ClipRRect( 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( child: Container(
//color: Colors.green, //color: Colors.green,
//constraints: const BoxConstraints(maxHeight: 175), //constraints: const BoxConstraints(maxHeight: 175),
@ -79,10 +79,10 @@ class EventListItem extends StatelessWidget {
right: 0.0, right: 0.0,
bottom: 0.0, bottom: 0.0,
child: Container( child: Container(
decoration: const BoxDecoration( decoration: BoxDecoration(
color: kTestSecondColor, // TODO color: primaryColor,
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(
topLeft: Radius.circular(20.0), topLeft: Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0),
), ),
), ),
child: Padding( child: Padding(
@ -125,9 +125,9 @@ class EventListItem extends StatelessWidget {
constraints: BoxConstraints(maxHeight: 120),*/ constraints: BoxConstraints(maxHeight: 120),*/
child: Container( child: Container(
width: size.width, width: size.width,
decoration: const BoxDecoration( decoration: BoxDecoration(
color: Colors.white, 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)) border: Border(top: BorderSide(width: 0.1, color: kMainGrey))
), ),
child: Padding( child: Padding(

View File

@ -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:google_maps_flutter/google_maps_flutter.dart';
import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart' as mapBox; import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart' as mapBox;
import 'package:manager_api/api.dart'; import 'package:manager_api/api.dart';
import 'package:provider/provider.dart';
import 'package:qr_flutter/qr_flutter.dart'; import 'package:qr_flutter/qr_flutter.dart';
import 'package:tablet_app/Components/loading_common.dart'; import 'package:tablet_app/Components/loading_common.dart';
import 'package:tablet_app/Components/video_viewer_youtube.dart'; import 'package:tablet_app/Components/video_viewer_youtube.dart';
import 'package:tablet_app/Models/agenda.dart'; import 'package:tablet_app/Models/agenda.dart';
import 'package:intl/intl.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'; import 'package:tablet_app/constants.dart';
class EventPopup extends StatefulWidget { class EventPopup extends StatefulWidget {
@ -90,6 +93,8 @@ class _EventPopupState extends State<EventPopup> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final appContext = Provider.of<AppContext>(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!)}"; 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; Size size = MediaQuery.of(context).size;
@ -101,14 +106,14 @@ class _EventPopupState extends State<EventPopup> {
} }
return AlertDialog( return AlertDialog(
shape: const RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20.0)) borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0))
), ),
contentPadding: EdgeInsets.zero, contentPadding: EdgeInsets.zero,
// title: Text(eventAgenda.name!), // title: Text(eventAgenda.name!),
content: Container( content: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(20.0)), borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)),
color: kBackgroundColor, color: kBackgroundColor,
), ),
height: size.height * 0.85, height: size.height * 0.85,
@ -125,11 +130,11 @@ class _EventPopupState extends State<EventPopup> {
width: 50, width: 50,
height: 50, height: 50,
decoration: BoxDecoration( decoration: BoxDecoration(
color: kMainGrey, color: kBackgroundGrey,
shape: BoxShape.circle, shape: BoxShape.circle,
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: kMainGrey, color: kBackgroundGrey,
spreadRadius: 0.5, spreadRadius: 0.5,
blurRadius: 1.1, blurRadius: 1.1,
offset: Offset(0, 1.1), // changes position of shadow offset: Offset(0, 1.1), // changes position of shadow
@ -147,7 +152,7 @@ class _EventPopupState extends State<EventPopup> {
Row( Row(
children: [ children: [
widget.eventAgenda.image != null ? ClipRRect( 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: Container(
child: Center( child: Center(
child: Container( child: Container(
@ -225,7 +230,7 @@ class _EventPopupState extends State<EventPopup> {
width: size.width * 0.38, width: size.width * 0.38,
decoration: BoxDecoration( decoration: BoxDecoration(
color: kBackgroundLight, color: kBackgroundLight,
borderRadius: BorderRadius.all(Radius.circular(20.0)) borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0))
), ),
child: Padding( child: Padding(
padding: const EdgeInsets.only(left: 20, right: 10, bottom: 10, top: 15), padding: const EdgeInsets.only(left: 20, right: 10, bottom: 10, top: 15),

View File

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:tablet_app/Helpers/translationHelper.dart'; import 'package:tablet_app/Helpers/translationHelper.dart';
import 'package:tablet_app/Models/agenda.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/app_context.dart';
import 'package:tablet_app/constants.dart'; import 'package:tablet_app/constants.dart';
@ -30,11 +31,14 @@ class _MonthFilterState extends State<MonthFilter> {
List<Map<String, dynamic>> sortedMonths = _getSortedMonths(); List<Map<String, dynamic>> sortedMonths = _getSortedMonths();
final appContext = Provider.of<AppContext>(context); final appContext = Provider.of<AppContext>(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( return ListView.builder(
itemCount: sortedMonths.length + 1, // +1 for "Tout (nbr total events)" itemCount: sortedMonths.length + 1, // +1 for "Tout (nbr total events)"
itemBuilder: (context, index) { itemBuilder: (context, index) {
if (index == 0) { if (index == 0) {
return _buildAllItem(appContext); return _buildAllItem(appContext, primaryColor);
} else { } else {
final monthYear = sortedMonths[index - 1]['monthYear']; final monthYear = sortedMonths[index - 1]['monthYear'];
@ -54,7 +58,7 @@ class _MonthFilterState extends State<MonthFilter> {
style: TextStyle( style: TextStyle(
fontSize: 15.0, fontSize: 15.0,
fontWeight: _selectedMonth == monthYear ? FontWeight.bold : FontWeight.normal, fontWeight: _selectedMonth == monthYear ? FontWeight.bold : FontWeight.normal,
color: _selectedMonth == monthYear ? kTestSecondColor : null, color: _selectedMonth == monthYear ? primaryColor : null,
), ),
), ),
onTap: () { onTap: () {
@ -63,7 +67,7 @@ class _MonthFilterState extends State<MonthFilter> {
}); });
widget.onMonthSelected(filteredEvents); widget.onMonthSelected(filteredEvents);
}, },
tileColor: _selectedMonth == monthYear ? kTestSecondColor : null, tileColor: _selectedMonth == monthYear ? primaryColor : null,
); );
} else { } else {
// Si nbrEvents est 0, ne retourne pas de widget // Si nbrEvents est 0, ne retourne pas de widget
@ -82,7 +86,7 @@ class _MonthFilterState extends State<MonthFilter> {
return translatedMonthName; return translatedMonthName;
} }
Widget _buildAllItem(AppContext appContext) { Widget _buildAllItem(AppContext appContext, Color primaryColor) {
int totalEvents = widget.events.length; int totalEvents = widget.events.length;
return ListTile( return ListTile(
title: Text( title: Text(
@ -90,7 +94,7 @@ class _MonthFilterState extends State<MonthFilter> {
style: TextStyle( style: TextStyle(
fontSize: 15.0, fontSize: 15.0,
fontWeight: _selectedMonth == null ? FontWeight.bold : FontWeight.normal, fontWeight: _selectedMonth == null ? FontWeight.bold : FontWeight.normal,
color: _selectedMonth == null ? kTestSecondColor : null, color: _selectedMonth == null ? primaryColor : null,
), ),
), ),
onTap: () { onTap: () {
@ -99,7 +103,7 @@ class _MonthFilterState extends State<MonthFilter> {
}); });
widget.onMonthSelected(widget.events); widget.onMonthSelected(widget.events);
}, },
tileColor: _selectedMonth == null ? kTestSecondColor : null, tileColor: _selectedMonth == null ? primaryColor : null,
); );
} }

View File

@ -33,7 +33,7 @@ class _DropDownConfigState extends State<DropDownConfig> {
style: const TextStyle(color: kMainGrey), style: const TextStyle(color: kMainGrey),
underline: Container( underline: Container(
height: 2, height: 2,
color: kMainRed, // TODO CHANGEEEEE color: kTestSecondColor,
), ),
onChanged: (ConfigurationDTO? newValue) { onChanged: (ConfigurationDTO? newValue) {
setState(() { setState(() {

View File

@ -64,7 +64,7 @@ class _LanguageSelection extends State<LanguageSelection> with TickerProviderSta
top: 0, top: 0,
right: 0, right: 0,
child: Padding( child: Padding(
padding: const EdgeInsets.only(right: 0.0, top: 25.0), padding: const EdgeInsets.only(right: 0.0, top: 10.0),
child: InkWell( child: InkWell(
onTap: () { onTap: () {
minimizedAnimation(size); minimizedAnimation(size);
@ -85,7 +85,7 @@ class _LanguageSelection extends State<LanguageSelection> with TickerProviderSta
right: _rightLanguage, right: _rightLanguage,
bottom: _bottomLanguage, bottom: _bottomLanguage,
child: Padding( child: Padding(
padding: const EdgeInsets.only(top: 25.0), padding: const EdgeInsets.only(top: 10.0),
child: ListView( child: ListView(
children: [ children: [
if(minimized) ... [ if(minimized) ... [

View File

@ -4,10 +4,12 @@ import 'dart:io';
import 'dart:math'; import 'dart:math';
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart'; import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
import 'package:manager_api/api.dart'; import 'package:manager_api/api.dart';
import 'package:provider/provider.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/DatabaseHelper.dart';
import 'package:tablet_app/Helpers/ImageCustomProvider.dart'; import 'package:tablet_app/Helpers/ImageCustomProvider.dart';
import 'package:tablet_app/Helpers/MQTTHelper.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/Models/WeatherData.dart';
import 'package:tablet_app/Screens/Agenda/agenda_view.dart'; import 'package:tablet_app/Screens/Agenda/agenda_view.dart';
import 'package:tablet_app/Screens/Article/article_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/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_context.dart';
import 'package:tablet_app/Screens/Map/map_view.dart'; import 'package:tablet_app/Screens/Map/map_view.dart';
import 'package:tablet_app/Models/map-marker.dart'; import 'package:tablet_app/Models/map-marker.dart';
@ -54,6 +57,8 @@ class _MainViewWidget extends State<MainViewWidget> {
late Color backgroundColor; late Color backgroundColor;
int rowCount = 4; int rowCount = 4;
bool isImageBackground = false;
List<SectionDTO>? sectionsLocal; List<SectionDTO>? sectionsLocal;
bool isInit = true; // Use to make it faster and to load resource at init bool isInit = true; // Use to make it faster and to load resource at init
bool isDialogOpen = false; bool isDialogOpen = false;
@ -65,7 +70,9 @@ class _MainViewWidget extends State<MainViewWidget> {
if(configurationDTO.isHour != null && configurationDTO.isHour!) { if(configurationDTO.isHour != null && configurationDTO.isHour!) {
Timer.periodic(Duration(seconds: 1), (Timer t) => _getTime(currentHourDate)); Timer.periodic(Duration(seconds: 1), (Timer t) => _getTime(currentHourDate));
} }
print("Init state helloowww");
isImageBackground = configurationDTO.isSectionImageBackground ?? true;
super.initState(); super.initState();
} }
@ -75,7 +82,7 @@ class _MainViewWidget extends State<MainViewWidget> {
//setState(() { //setState(() {
//_timeString = formattedDateTime; //_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<MainViewWidget> {
backgroundColor = appContext.getContext().configuration != null ? new Color(int.parse(appContext.getContext().configuration.secondaryColor.split('(0x')[1].split(')')[0], radix: 16)) : Colors.white; 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; Color textColor = backgroundColor.computeLuminance() > 0.5 ? Colors.black : Colors.white;
TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext;
// TODO REMOVE // TODO REMOVE
/*if (!MQTTHelper.instance.isInstantiated) /*if (!MQTTHelper.instance.isInstantiated)
MQTTHelper.instance.connect(appContext);*/ MQTTHelper.instance.connect(appContext);*/
if(sectionSelected != null) { if(sectionSelected != null) {
var elementToShow; var elementToShow;
print(sectionSelected!.type);
switch (sectionSelected!.type) { switch (sectionSelected!.type) {
case SectionType.map : // MAP case SectionType.Map : // MAP
elementToShow = ChangeNotifierProvider<MapContext>( elementToShow = ChangeNotifierProvider<MapContext>(
create: (_) => create: (_) =>
MapContext(new MapMarker( MapContext(new MapMarker(
@ -110,33 +119,36 @@ class _MainViewWidget extends State<MainViewWidget> {
: CircularProgressIndicator()),*/ : CircularProgressIndicator()),*/
); );
break; break;
case SectionType.web : // WEB case SectionType.Web : // WEB
elementToShow = WebView(section: sectionSelected); elementToShow = WebView(section: sectionSelected);
break; break;
case SectionType.video : // Video case SectionType.Video : // Video
elementToShow = VideoView(section: sectionSelected); elementToShow = VideoView(section: sectionSelected);
break; break;
case SectionType.slider : case SectionType.Slider :
elementToShow = SliderView(section: sectionSelected); elementToShow = SliderView(section: sectionSelected);
break; break;
case SectionType.menu : case SectionType.Menu :
elementToShow = MenuView(section: sectionSelected!); elementToShow = MenuView(section: sectionSelected!, isImageBackground: isImageBackground);
break; break;
case SectionType.quizz : case SectionType.Quizz :
elementToShow = QuizzView(section: sectionSelected); elementToShow = QuizzView(section: sectionSelected);
break; break;
case SectionType.pdf : case SectionType.Pdf :
elementToShow = PDFViewWidget(section: sectionSelected); elementToShow = PDFViewWidget(section: sectionSelected);
break; break;
case SectionType.puzzle : case SectionType.Puzzle :
elementToShow = PuzzleView(section: sectionSelected); elementToShow = PuzzleView(section: sectionSelected);
break; break;
case SectionType.agenda : case SectionType.Agenda :
elementToShow = AgendaView(section: sectionSelected); elementToShow = AgendaView(section: sectionSelected);
break; break;
/*case SectionType.article : // TODO /*case SectionType.article : // TODO
elementToShow = ArticleView(section: sectionSelected); elementToShow = ArticleView(section: sectionSelected);
break;*/ break;*/
case SectionType.Weather :
elementToShow = WeatherView(section: sectionSelected);
break;
default: default:
elementToShow = Text("Ce type n'est pas supporté"); elementToShow = Text("Ce type n'est pas supporté");
break; break;
@ -154,91 +166,149 @@ class _MainViewWidget extends State<MainViewWidget> {
image: ImageCustomProvider.getImageProvider(appContext, configurationDTO.imageId!, configurationDTO.imageSource!), image: ImageCustomProvider.getImageProvider(appContext, configurationDTO.imageId!, configurationDTO.imageSource!),
), ),
) : null, ) : null,
child: Column( child: Padding(
children: [ padding: const EdgeInsets.all(8.0),
Container( child: Container(
width: size.width, decoration : BoxDecoration(
height: size.height * 0.12, color: kBackgroundLight,
child: Row( shape: BoxShape.rectangle,
children: [ borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 30.0),
Padding( boxShadow: [
padding: const EdgeInsets.only(left: 15.0, top: 10.0), BoxShadow(
child: AspectRatio( color: kBackgroundSecondGrey,
aspectRatio: 4 / 4, spreadRadius: 0.5,
child: Container( blurRadius: 5,
/*width: 125, offset: Offset(0, 1.5), // changes position of shadow
height: 125,*/ ),
decoration: boxDecoration(appContext, sectionSelected!, true), ],
), ),
), child: Column(
), children: [
SizedBox( Expanded(
width: 25, flex: 1,
), //height: size.height * 0.1,
Padding( child: Container(
padding: const EdgeInsets.all(8.0), //color: Colors.greenAccent,
child: Column( width: size.width,
mainAxisAlignment: MainAxisAlignment.spaceEvenly, child: Row(
crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Expanded( Container(
child: Align( //color: Colors.grey,
alignment: Alignment.centerLeft, //width: size.width * 0.8,
child: HtmlWidget( child: Padding(
sectionSelected!.title!.firstWhere((translation) => translation.language == appContext.getContext().language).value!, padding: const EdgeInsets.only(left: 15.0, top: 10.0, bottom: 10.0),
textStyle: new TextStyle(fontSize: kIsWeb ? kWebSectionTitleDetailSize : kSectionTitleDetailSize, color: textColor), 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) Container(
Expanded( //width: size.width,
child: Align( //color: Colors.green,
alignment: Alignment.centerLeft, child: Column(
child: HtmlWidget( mainAxisAlignment: MainAxisAlignment.center,
sectionSelected!.description!.firstWhere((translation) => translation.language == appContext.getContext().language).value!, crossAxisAlignment: CrossAxisAlignment.center,
textStyle: new TextStyle(fontSize: kIsWeb? kWebSectionDescriptionDetailSize : kSectionDescriptionDetailSize, color: textColor), 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))
),
),
),
)
], ],
), ),
) ),
], ),
), Expanded(
), flex: 9,
Padding( child: Padding(
padding: sectionSelected!.type != SectionType.slider ? const EdgeInsets.only(left: 15.0, right: 15.0, top: 15.0) : const EdgeInsets.only(top: 15.0), 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( child: Container(
width: size.width, width: size.width,
height: size.height * 0.85, //height: size.height * 0.9,
decoration: sectionSelected!.type != SectionType.video && sectionSelected!.type != SectionType.web && sectionSelected!.type != SectionType.slider && sectionSelected!.type != SectionType.map ? BoxDecoration( /*decoration: sectionSelected!.type != SectionType.Video && sectionSelected!.type != SectionType.Web && sectionSelected!.type != SectionType.Slider && sectionSelected!.type != SectionType.Map ? BoxDecoration(
color: kBackgroundLight, //color: kBackgroundLight,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(30.0), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 30.0),
boxShadow: [ /*boxShadow: [
BoxShadow( BoxShadow(
color: kBackgroundSecondGrey, color: kBackgroundSecondGrey,
spreadRadius: 0.5, spreadRadius: 0.5,
blurRadius: 5, blurRadius: 5,
offset: Offset(0, 1.5), // changes position of shadow 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( floatingActionButton: Padding(
padding: const EdgeInsets.only(top: kIsWeb ? 16.0 : 16.0), padding: const EdgeInsets.only(top: 10.0),
child: Container( child: Container(
height: kIsWeb ? size.height *0.08 : size.height *0.08, height: size.height *0.08,
width: kIsWeb ? size.width *0.08: size.width *0.08, width: size.width *0.08,
child: FittedBox( child: FittedBox(
child: FloatingActionButton.extended( child: FloatingActionButton.extended(
backgroundColor: kBackgroundColor, backgroundColor: kBackgroundColor,
@ -254,7 +324,7 @@ class _MainViewWidget extends State<MainViewWidget> {
), ),
), ),
), ),
), ),*/
); );
} else { } else {
return Scaffold( return Scaffold(
@ -301,7 +371,7 @@ class _MainViewWidget extends State<MainViewWidget> {
LanguageSelection(size: size), LanguageSelection(size: size),
Center( Center(
child: Container( 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, width: size.width * 0.9,
child: isInit ? FutureBuilder( child: isInit ? FutureBuilder(
future: getSections(size, appContext), future: getSections(size, appContext),
@ -327,7 +397,7 @@ class _MainViewWidget extends State<MainViewWidget> {
) : getGridSections(appContext), ) : 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( Positioned(
bottom: 0, bottom: 0,
left: 0, left: 0,
@ -341,7 +411,7 @@ class _MainViewWidget extends State<MainViewWidget> {
return WeatherView(weatherData: weatherDataResult); return WeatherView(weatherData: weatherDataResult);
} }
), ),
)) ))*/
]), ]),
), ),
); );
@ -393,7 +463,7 @@ class _MainViewWidget extends State<MainViewWidget> {
var result = await showDialog( var result = await showDialog(
builder: (BuildContext dialogContext) => AlertDialog( builder: (BuildContext dialogContext) => AlertDialog(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20.0)) borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0))
), ),
content: Container( content: Container(
width: 400, width: 400,
@ -438,50 +508,84 @@ class _MainViewWidget extends State<MainViewWidget> {
} }
getGridSections(AppContext appContext) { getGridSections(AppContext appContext) {
TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext;
if(sectionsLocal != null) { if(sectionsLocal != null) {
var isPortrait = MediaQuery.of(context).orientation == Orientation.portrait; var isPortrait = MediaQuery.of(context).orientation == Orientation.portrait;
return Center( return Center(
child: GridView.builder( child: Container(
shrinkWrap: true, //color: Colors.greenAccent,
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: rowCount), child: GridView.builder(
itemCount: sectionsLocal!.length, shrinkWrap: true,
itemBuilder: (BuildContext context, int index) { gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: rowCount),
return InkWell( itemCount: sectionsLocal!.length,
onTap: () { itemBuilder: (BuildContext context, int index) {
setState(() { return InkWell(
sectionSelected = sectionsLocal![index]; onTap: () {
}); setState(() {
}, sectionSelected = sectionsLocal![index];
child: Container( });
decoration: boxDecoration(appContext, sectionsLocal![index], false), },
padding: const EdgeInsets.all(18), child: Container(
margin: EdgeInsets.symmetric(vertical: 25, horizontal: 25), decoration: isImageBackground ? boxDecoration(appContext, sectionsLocal![index], false) : null,
child: Align( //color: Colors.yellow,
alignment: Alignment.bottomRight, padding: EdgeInsets.all(isImageBackground ? 18 : 5),
child: FractionallySizedBox( margin: EdgeInsets.symmetric(vertical: isImageBackground ? 25 : 10, horizontal: 25),
heightFactor: 0.5, child: isImageBackground ? Align(
child: Container( alignment: Alignment.bottomRight,
//color: Colors.green, child: FractionallySizedBox(
child: SizedBox( heightFactor: 0.5,
width: double.infinity, child: Container(
child: Align( //color: Colors.green,
alignment: Alignment.centerRight, 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( child: HtmlWidget(
sectionsLocal![index].title!.firstWhere((translation) => translation.language == appContext.getContext().language).value ?? "", sectionsLocal![index].title!.firstWhere((translation) => translation.language == appContext.getContext().language).value ?? "",
customStylesBuilder: (element) { 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)), textStyle: TextStyle(fontSize: isPortrait ? 10 : 25),//calculateFontSize(constraints.maxWidth, constraints.maxHeight, kIsWeb ? kWebMenuTitleDetailSize : kMenuTitleDetailSize)),
), ),
), )
),
) )
), ],
)
), ),
), );
); }
} ),
), ),
); );
} else { } else {
@ -509,10 +613,11 @@ double calculateFontSize(double parentWidth, double parentHeight, double baseSiz
} }
boxDecoration(AppContext appContext, SectionDTO section, bool isSelected) { boxDecoration(AppContext appContext, SectionDTO section, bool isSelected) {
TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext;
return BoxDecoration( return BoxDecoration(
color: kBackgroundLight, color: !isSelected ? kBackgroundLight : section.imageSource == null ? kBackgroundLight : null,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(30.0), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 30.0),
image: section.imageSource != null ? new DecorationImage( image: section.imageSource != null ? new DecorationImage(
fit: BoxFit.cover, fit: BoxFit.cover,
colorFilter: !isSelected? new ColorFilter.mode(kBackgroundLight.withOpacity(0.2), BlendMode.dstATop) : null, colorFilter: !isSelected? new ColorFilter.mode(kBackgroundLight.withOpacity(0.2), BlendMode.dstATop) : null,

View File

@ -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<WeatherForecast> getNextFiveDaysForecast(List<WeatherForecast> allForecasts) {
List<WeatherForecast> nextFiveDaysForecast = [];
DateTime today = DateTime.now();
List<WeatherForecast> nextDay1All = allForecasts.where((af) => (DateTime.fromMillisecondsSinceEpoch(af.dt! * 1000)).day == (today.add(Duration(days: 1))).day).toList();
List<WeatherForecast> nextDay2All = allForecasts.where((af) => (DateTime.fromMillisecondsSinceEpoch(af.dt! * 1000)).day == (today.add(Duration(days: 2))).day).toList();
List<WeatherForecast> nextDay3All = allForecasts.where((af) => (DateTime.fromMillisecondsSinceEpoch(af.dt! * 1000)).day == (today.add(Duration(days: 3))).day).toList();
List<WeatherForecast> nextDay4All = allForecasts.where((af) => (DateTime.fromMillisecondsSinceEpoch(af.dt! * 1000)).day == (today.add(Duration(days: 4))).day).toList();
List<WeatherForecast> 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<AppContext>(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

View File

@ -9,6 +9,7 @@ import 'package:provider/provider.dart';
import 'package:tablet_app/Components/show_element_for_resource.dart'; import 'package:tablet_app/Components/show_element_for_resource.dart';
import 'package:tablet_app/Helpers/ImageCustomProvider.dart'; import 'package:tablet_app/Helpers/ImageCustomProvider.dart';
import 'package:tablet_app/Models/map-marker.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/Screens/Quizz/quizz_view.dart';
import 'package:tablet_app/app_context.dart'; import 'package:tablet_app/app_context.dart';
@ -43,6 +44,8 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size; Size size = MediaQuery.of(context).size;
final mapContext = Provider.of<MapContext>(context); final mapContext = Provider.of<MapContext>(context);
final appContext = Provider.of<AppContext>(context);
TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext;
Size sizeMarker = Size(size.width * 0.42, size.height * 0.8); Size sizeMarker = Size(size.width * 0.42, size.height * 0.8);
return new AnimatedPositioned( return new AnimatedPositioned(
@ -59,7 +62,7 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
decoration: BoxDecoration( decoration: BoxDecoration(
color: kBackgroundLight, // Colors.amberAccent //kBackgroundLight, color: kBackgroundLight, // Colors.amberAccent //kBackgroundLight,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(10.0), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 10.0),
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: kBackgroundSecondGrey, color: kBackgroundSecondGrey,
@ -188,7 +191,7 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
decoration: BoxDecoration( decoration: BoxDecoration(
color: kBackgroundColor, color: kBackgroundColor,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(10.0), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 10.0),
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: kBackgroundSecondGrey, color: kBackgroundSecondGrey,
@ -258,6 +261,8 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
getElementForResource(BuildContext context, AppContext appContext, ContentGeoPoint i) { getElementForResource(BuildContext context, AppContext appContext, ContentGeoPoint i) {
var widgetToInclude; var widgetToInclude;
final appContext = Provider.of<AppContext>(context);
TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext;
switch(i.resourceType) { switch(i.resourceType) {
case ResourceType.Image: case ResourceType.Image:
@ -272,7 +277,7 @@ getElementForResource(BuildContext context, AppContext appContext, ContentGeoPoi
backgroundDecoration: BoxDecoration( backgroundDecoration: BoxDecoration(
color: kBackgroundSecondGrey, color: kBackgroundSecondGrey,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(15.0), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0),
), ),
) : Center(child: Text('No data')), ) : Center(child: Text('No data')),
), ),
@ -285,7 +290,7 @@ getElementForResource(BuildContext context, AppContext appContext, ContentGeoPoi
decoration: BoxDecoration( decoration: BoxDecoration(
color: kBackgroundSecondGrey, color: kBackgroundSecondGrey,
shape: BoxShape.rectangle, 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), child: showElementForResource(ResourceDTO(id: i.resourceId, url: i.resourceUrl, type: i.resourceType), appContext, false, true),
); );

View File

@ -22,8 +22,9 @@ import 'package:tablet_app/app_context.dart';
import 'package:tablet_app/constants.dart'; import 'package:tablet_app/constants.dart';
class MenuView extends StatefulWidget { class MenuView extends StatefulWidget {
final SectionDTO? section; final SectionDTO section;
MenuView({this.section}); final bool isImageBackground;
MenuView({required this.section, required this.isImageBackground});
@override @override
_MenuView createState() => _MenuView(); _MenuView createState() => _MenuView();
@ -32,10 +33,11 @@ class MenuView extends StatefulWidget {
class _MenuView extends State<MenuView> { class _MenuView extends State<MenuView> {
MenuDTO menuDTO = MenuDTO(); MenuDTO menuDTO = MenuDTO();
SectionDTO? selectedSection; SectionDTO? selectedSection;
@override @override
void initState() { void initState() {
print(widget.section!.data); print(widget.section.data);
menuDTO = MenuDTO.fromJson(jsonDecode(widget.section!.data!))!; menuDTO = MenuDTO.fromJson(jsonDecode(widget.section.data!))!;
print(menuDTO); print(menuDTO);
super.initState(); super.initState();
@ -50,11 +52,12 @@ class _MenuView extends State<MenuView> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final appContext = Provider.of<AppContext>(context); final appContext = Provider.of<AppContext>(context);
Size size = MediaQuery.of(context).size; Size size = MediaQuery.of(context).size;
TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext;
if (selectedSection != null) { if (selectedSection != null) {
var elementToShow; var elementToShow;
switch (selectedSection!.type) { switch (selectedSection!.type) {
case SectionType.map : case SectionType.Map :
elementToShow = ChangeNotifierProvider<MapContext>( elementToShow = ChangeNotifierProvider<MapContext>(
create: (_) => create: (_) =>
MapContext(new MapMarker( MapContext(new MapMarker(
@ -69,25 +72,25 @@ class _MenuView extends State<MenuView> {
: CircularProgressIndicator()),*/ : CircularProgressIndicator()),*/
); );
break; break;
case SectionType.web : // WEB case SectionType.Web : // WEB
elementToShow = WebView(section: selectedSection); elementToShow = WebView(section: selectedSection);
break; break;
case SectionType.video : // Video case SectionType.Video : // Video
elementToShow = VideoView(section: selectedSection); elementToShow = VideoView(section: selectedSection);
break; break;
case SectionType.slider : // Slider case SectionType.Slider : // Slider
elementToShow = SliderView(section: selectedSection); elementToShow = SliderView(section: selectedSection);
break; break;
case SectionType.quizz : // Quizz case SectionType.Quizz : // Quizz
elementToShow = QuizzView(section: selectedSection); elementToShow = QuizzView(section: selectedSection);
break; break;
case SectionType.pdf : // Pdf case SectionType.Pdf : // Pdf
elementToShow = PDFViewWidget(section: selectedSection); elementToShow = PDFViewWidget(section: selectedSection);
break; break;
case SectionType.puzzle : // Puzzle case SectionType.Puzzle : // Puzzle
elementToShow = PuzzleView(section: selectedSection); elementToShow = PuzzleView(section: selectedSection);
break; break;
case SectionType.agenda : // Agenda case SectionType.Agenda : // Agenda
elementToShow = AgendaView(section: selectedSection); elementToShow = AgendaView(section: selectedSection);
break; break;
/*case SectionType.article : // Article /*case SectionType.article : // Article
@ -101,13 +104,13 @@ class _MenuView extends State<MenuView> {
children: [ children: [
Center( Center(
child: Padding( 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( child: Container(
width: size.width, 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, color: kBackgroundLight,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(30.0), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0),
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: kBackgroundSecondGrey, color: kBackgroundSecondGrey,
@ -137,7 +140,7 @@ class _MenuView extends State<MenuView> {
decoration: BoxDecoration( 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, 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, shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(30.0), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0),
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: kBackgroundSecondGrey, color: kBackgroundSecondGrey,
@ -180,7 +183,7 @@ class _MenuView extends State<MenuView> {
child: Align( child: Align(
alignment: Alignment.bottomRight, alignment: Alignment.bottomRight,
child: FractionallySizedBox( child: FractionallySizedBox(
heightFactor: 0.45, heightFactor: 0.5,
child: Column( child: Column(
children: [ children: [
Align( Align(
@ -193,7 +196,7 @@ class _MenuView extends State<MenuView> {
textStyle: new TextStyle(fontSize: kIsWeb? kWebMenuTitleDetailSize : kMenuTitleDetailSize), textStyle: new TextStyle(fontSize: kIsWeb? kWebMenuTitleDetailSize : kMenuTitleDetailSize),
), ),
), ),
Align( /*Align(
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: HtmlWidget( child: HtmlWidget(
menuDTO.sections![index].description!.firstWhere((translation) => translation.language == appContext.getContext().language).value!, menuDTO.sections![index].description!.firstWhere((translation) => translation.language == appContext.getContext().language).value!,
@ -202,7 +205,7 @@ class _MenuView extends State<MenuView> {
}, },
textStyle: new TextStyle(fontSize: kIsWeb? kWebSectionDescriptionDetailSize: kSectionDescriptionDetailSize, fontFamily: ""), textStyle: new TextStyle(fontSize: kIsWeb? kWebSectionDescriptionDetailSize: kSectionDescriptionDetailSize, fontFamily: ""),
), ),
), ),*/
], ],
) )
), ),
@ -217,10 +220,12 @@ class _MenuView extends State<MenuView> {
} }
boxDecoration(AppContext appContext, SectionDTO section, bool isSelected) { boxDecoration(AppContext appContext, SectionDTO section, bool isSelected) {
TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext;
return BoxDecoration( return BoxDecoration(
color: kBackgroundLight, color: kBackgroundLight,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(30.0), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0),
image: section.imageSource != null ? new DecorationImage( image: section.imageSource != null ? new DecorationImage(
fit: BoxFit.cover, fit: BoxFit.cover,
colorFilter: !isSelected? new ColorFilter.mode(kBackgroundLight.withOpacity(0.2), BlendMode.dstATop) : null, colorFilter: !isSelected? new ColorFilter.mode(kBackgroundLight.withOpacity(0.2), BlendMode.dstATop) : null,

View File

@ -27,6 +27,8 @@ class _PdfFilterState extends State<PdfFilter> {
TabletAppContext tabletAppContext = appContext.getContext(); TabletAppContext tabletAppContext = appContext.getContext();
var currentLanguage = tabletAppContext.language; 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( return ListView.builder(
itemCount: widget.pdfsList.length, itemCount: widget.pdfsList.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
@ -37,7 +39,7 @@ class _PdfFilterState extends State<PdfFilter> {
textStyle: TextStyle( textStyle: TextStyle(
fontSize: 15.0, fontSize: 15.0,
fontWeight: _selectedOrderPdf == widget.pdfsList[index].order ? FontWeight.bold : FontWeight.normal, 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( /*Text(
@ -54,7 +56,7 @@ class _PdfFilterState extends State<PdfFilter> {
}); });
widget.onPDFSelected(_selectedOrderPdf); widget.onPDFSelected(_selectedOrderPdf);
}, },
tileColor: _selectedOrderPdf == widget.pdfsList[index].order ? kTestSecondColor : null, tileColor: _selectedOrderPdf == widget.pdfsList[index].order ? primaryColor : null,
); );
} else { } else {
// Si nbrEvents est 0, ne retourne pas de widget // Si nbrEvents est 0, ne retourne pas de widget

View File

@ -100,6 +100,8 @@ class _PDFViewWidget extends State<PDFViewWidget> {
final appContext = Provider.of<AppContext>(context); final appContext = Provider.of<AppContext>(context);
TabletAppContext tabletAppContext = appContext.getContext(); 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!)); pdfDTO.pdfs!.sort((a, b) => a.order!.compareTo(b.order!));
return pdfDTO.pdfs != null && pdfDTO.pdfs!.length > 0 ? return pdfDTO.pdfs != null && pdfDTO.pdfs!.length > 0 ?
@ -112,10 +114,7 @@ class _PDFViewWidget extends State<PDFViewWidget> {
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: kBackgroundColor, color: kBackgroundColor,
borderRadius: BorderRadius.only( borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)),
topLeft: Radius.circular(30.0),
bottomLeft: Radius.circular(30.0),
),
), ),
child: Padding( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
@ -183,8 +182,8 @@ class _PDFViewWidget extends State<PDFViewWidget> {
builder: (context, value, _) { builder: (context, value, _) {
return Container( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(30.0)), borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)),
color: kTestSecondColor color: primaryColor
), ),
child: Padding( child: Padding(
padding: const EdgeInsets.all(6.0), padding: const EdgeInsets.all(6.0),

View File

@ -170,7 +170,7 @@ class _PreviousViewWidget extends State<PreviousViewWidget> with TickerProviderS
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: new BorderRadius.only( borderRadius: new BorderRadius.only(
topRight: const Radius.circular(20.0), topRight: Radius.circular(20.0),
), ),
color: kSecondRed color: kSecondRed
), ),
@ -198,7 +198,7 @@ class _PreviousViewWidget extends State<PreviousViewWidget> with TickerProviderS
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: new BorderRadius.only( borderRadius: new BorderRadius.only(
bottomRight: const Radius.circular(20.0), bottomRight: Radius.circular(20.0),
), ),
color: kSecondRed color: kSecondRed
), ),

View File

@ -2,16 +2,20 @@ import 'package:flutter/material.dart';
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart'; import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
import 'package:manager_api/api.dart'; import 'package:manager_api/api.dart';
import 'package:tablet_app/Components/show_element_for_resource.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/app_context.dart';
import 'package:tablet_app/constants.dart'; import 'package:tablet_app/constants.dart';
void showMessage(TranslationAndResourceDTO translationAndResourceDTO, AppContext appContext, BuildContext context, Size size) { void showMessage(TranslationAndResourceDTO translationAndResourceDTO, AppContext appContext, BuildContext context, Size size) {
print("translationAndResourceDTO"); print("translationAndResourceDTO");
print(translationAndResourceDTO); print(translationAndResourceDTO);
TabletAppContext tabletAppContext = appContext.getContext();
showDialog( showDialog(
builder: (BuildContext context) => AlertDialog( builder: (BuildContext context) => AlertDialog(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20.0)) borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0))
), ),
content: SingleChildScrollView( content: SingleChildScrollView(
child: Column( child: Column(
@ -26,7 +30,7 @@ void showMessage(TranslationAndResourceDTO translationAndResourceDTO, AppContext
child: Center( child: Center(
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 30),
//border: Border.all(width: 3, color: Colors.black) //border: Border.all(width: 3, color: Colors.black)
), ),
child: showElementForResource(ResourceDTO(id: translationAndResourceDTO.resourceId, type: translationAndResourceDTO.resourceType, url: translationAndResourceDTO.resourceUrl), appContext, true, false), child: showElementForResource(ResourceDTO(id: translationAndResourceDTO.resourceId, type: translationAndResourceDTO.resourceType, url: translationAndResourceDTO.resourceUrl), appContext, true, false),

View File

@ -82,8 +82,8 @@ class _PuzzlePieceState extends State<PuzzlePiece> {
var isPortrait = MediaQuery.of(context).orientation == Orientation.portrait; var isPortrait = MediaQuery.of(context).orientation == Orientation.portrait;
var imageHeight = isPortrait ? widget.imageSize.width/1.5 : widget.imageSize.width; var imageHeight = isPortrait ? widget.imageSize.width/1.55 : widget.imageSize.width;
var imageWidth = isPortrait ? widget.imageSize.width/1.5: widget.imageSize.height; var imageWidth = isPortrait ? widget.imageSize.width/1.55 : widget.imageSize.height;
final pieceWidth = imageWidth / widget.maxCol; final pieceWidth = imageWidth / widget.maxCol;
final pieceHeight = imageHeight / widget.maxRow; final pieceHeight = imageHeight / widget.maxRow;

View File

@ -205,24 +205,27 @@ class _PuzzleView extends State<PuzzleView> {
final appContext = Provider.of<AppContext>(context); final appContext = Provider.of<AppContext>(context);
TabletAppContext tabletAppContext = appContext.getContext(); TabletAppContext tabletAppContext = appContext.getContext();
return Padding( return Container(
key: _widgetKey, //color: Colors.green,
padding: const EdgeInsets.all(10.0), child: Padding(
child: isSplittingImage ? Center(child: LoadingCommon()) : key: _widgetKey,
puzzleDTO.image == null || puzzleDTO.image!.resourceUrl == null || realWidgetSize == null padding: const EdgeInsets.all(0.0),
? Center(child: Text("Aucune image à afficher", style: TextStyle(fontSize: kNoneInfoOrIncorrect))) child: isSplittingImage ? Center(child: LoadingCommon()) :
: Center( puzzleDTO.image == null || puzzleDTO.image!.resourceUrl == null || realWidgetSize == null
child: Padding( ? Center(child: Text("Aucune image à afficher", style: TextStyle(fontSize: kNoneInfoOrIncorrect)))
padding: const EdgeInsets.all(8.0), : Center(
child: Container( child: Padding(
width: tabletAppContext.puzzleSize != null && tabletAppContext.puzzleSize!.width > 0 ? tabletAppContext.puzzleSize!.width : realWidgetSize!.width * 0.8, padding: const EdgeInsets.all(0.0),
height: tabletAppContext.puzzleSize != null && tabletAppContext.puzzleSize!.height > 0 ? tabletAppContext.puzzleSize!.height +1.5 : realWidgetSize!.height * 0.85, child: Container(
child: Stack( width: tabletAppContext.puzzleSize != null && tabletAppContext.puzzleSize!.width > 0 ? tabletAppContext.puzzleSize!.width : realWidgetSize!.width * 0.8,
children: pieces, height: tabletAppContext.puzzleSize != null && tabletAppContext.puzzleSize!.height > 0 ? tabletAppContext.puzzleSize!.height +1.5 : realWidgetSize!.height * 0.85,
child: Stack(
children: pieces,
),
), ),
), ),
), ),
), ),
); );
} }
} }

View File

@ -13,7 +13,9 @@ import 'package:provider/provider.dart';
import 'package:tablet_app/Components/Buttons/rounded_button.dart'; import 'package:tablet_app/Components/Buttons/rounded_button.dart';
import 'package:tablet_app/Components/show_element_for_resource.dart'; import 'package:tablet_app/Components/show_element_for_resource.dart';
import 'package:tablet_app/Helpers/ImageCustomProvider.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/ResponseSubDTO.dart';
import 'package:tablet_app/Models/tabletContext.dart';
import 'package:tablet_app/Screens/Quizz/showResponses.dart'; import 'package:tablet_app/Screens/Quizz/showResponses.dart';
import 'package:tablet_app/Screens/Slider/slider_view.dart'; import 'package:tablet_app/Screens/Slider/slider_view.dart';
import 'package:tablet_app/app_context.dart'; import 'package:tablet_app/app_context.dart';
@ -70,6 +72,9 @@ class _QuizzView extends State<QuizzView> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size; Size size = MediaQuery.of(context).size;
final appContext = Provider.of<AppContext>(context); final appContext = Provider.of<AppContext>(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) if(showResult)
{ {
@ -104,11 +109,11 @@ class _QuizzView extends State<QuizzView> {
numberOfParticles: 2, numberOfParticles: 2,
blastDirectionality: BlastDirectionality.explosive, blastDirectionality: BlastDirectionality.explosive,
shouldLoop: false, // start again as soon as the animation is finished shouldLoop: false, // start again as soon as the animation is finished
colors: const [ colors: [
Colors.red, Colors.red,
Colors.blueGrey, Colors.blueGrey,
Colors.green, Colors.green,
kTestSecondColor primaryColor
//Colors.pink, //Colors.pink,
//Colors.orange, //Colors.orange,
//Colors.purple //Colors.purple
@ -128,11 +133,11 @@ class _QuizzView extends State<QuizzView> {
alignment: Alignment.center, alignment: Alignment.center,
child : getElementForResource(context, appContext, levelToShow.label!.firstWhere((translation) => translation.language == appContext.getContext().language), true), child : getElementForResource(context, appContext, levelToShow.label!.firstWhere((translation) => translation.language == appContext.getContext().language), true),
), ),
Container( Container(
height: 90, height: showResponses ? 60 : 90,
//color: Colors.orange, //color: Colors.orange,
child: Text('$goodResponses/${quizzDTO.questions!.length}', textAlign: TextAlign.center, style: TextStyle(fontSize: kIsWeb ? (showResponses ? 60 : 100) : (showResponses ? 60 : 70), color: kBackgroundSecondGrey)), child: Text('$goodResponses/${quizzDTO.questions!.length}', textAlign: TextAlign.center, style: TextStyle(fontSize: kIsWeb ? (showResponses ? 40 : 100) : (showResponses ? 40 : 70), color: kBackgroundSecondGrey)),
), ),
if(!showResponses) if(!showResponses)
Container( Container(
child: Padding( child: Padding(
@ -143,7 +148,7 @@ class _QuizzView extends State<QuizzView> {
decoration: BoxDecoration( decoration: BoxDecoration(
color: kBackgroundLight, color: kBackgroundLight,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(10.0), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 10.0),
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: kBackgroundSecondGrey, color: kBackgroundSecondGrey,
@ -177,12 +182,12 @@ class _QuizzView extends State<QuizzView> {
), ),
if(showResponses) if(showResponses)
Container( Container(
width: MediaQuery.of(context).size.width *0.75, width: MediaQuery.of(context).size.width *0.9,
height: kIsWeb ? MediaQuery.of(context).size.height *0.35 : MediaQuery.of(context).size.height *0.5, //MediaQuery.of(context).size.height *0.55 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( decoration: BoxDecoration(
color: kBackgroundLight, color: kBackgroundLight,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(10.0), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 10.0),
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: kBackgroundSecondGrey, color: kBackgroundSecondGrey,
@ -206,10 +211,10 @@ class _QuizzView extends State<QuizzView> {
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Container( Container(
height: kIsWeb ? 50 : 50, //85 height: 50, //85
child: RoundedButton( child: RoundedButton(
text: "Recommencer", text: TranslationHelper.getFromLocale("quiz.restart", appContext.getContext()),
color: kBackgroundSecondGrey, color: primaryColor,
textColor: kBackgroundLight, textColor: kBackgroundLight,
icon: Icons.undo, icon: Icons.undo,
press: () { press: () {
@ -227,10 +232,10 @@ class _QuizzView extends State<QuizzView> {
), ),
if(!showResponses) if(!showResponses)
Container( Container(
height: kIsWeb ? 50 : 50, //85 height: 50, //85
child: RoundedButton( child: RoundedButton(
text: "Voir les réponses", text: TranslationHelper.getFromLocale("quiz.seeResponses", appContext.getContext()),
color: kBackgroundSecondGrey, color: primaryColor,
textColor: kBackgroundLight, textColor: kBackgroundLight,
icon: Icons.assignment_turned_in, icon: Icons.assignment_turned_in,
press: () { press: () {
@ -282,7 +287,7 @@ class _QuizzView extends State<QuizzView> {
decoration: BoxDecoration( decoration: BoxDecoration(
color: kBackgroundLight, color: kBackgroundLight,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(20.0), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0),
image: i.resourceUrl != null ? new DecorationImage( image: i.resourceUrl != null ? new DecorationImage(
fit: BoxFit.cover, fit: BoxFit.cover,
opacity: 0.35, opacity: 0.35,
@ -314,7 +319,7 @@ class _QuizzView extends State<QuizzView> {
decoration: BoxDecoration( decoration: BoxDecoration(
color: kBackgroundLight, // Colors.orange,// kBackgroundLight, color: kBackgroundLight, // Colors.orange,// kBackgroundLight,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(10.0), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 10.0),
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: kBackgroundSecondGrey, color: kBackgroundSecondGrey,
@ -431,9 +436,9 @@ class _QuizzView extends State<QuizzView> {
], ],
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
color: i.chosen == index ? kTestSecondColor : kBackgroundLight, color: i.chosen == index ? primaryColor : kBackgroundLight,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(10.0), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 10.0),
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: kBackgroundSecondGrey, color: kBackgroundSecondGrey,
@ -483,7 +488,7 @@ class _QuizzView extends State<QuizzView> {
child: Icon( child: Icon(
Icons.chevron_right, Icons.chevron_right,
size: kIsWeb ? 100 : 100, // 95 size: kIsWeb ? 100 : 100, // 95
color: kTestSecondColor, color: primaryColor,
), ),
) )
), ),
@ -499,7 +504,7 @@ class _QuizzView extends State<QuizzView> {
child: Icon( child: Icon(
Icons.chevron_left, Icons.chevron_left,
size: kIsWeb ? 100 : 100, //95 size: kIsWeb ? 100 : 100, //95
color: kTestSecondColor, color: primaryColor,
), ),
) )
), ),
@ -526,6 +531,7 @@ class _QuizzView extends State<QuizzView> {
getElementForResource(BuildContext context, AppContext appContext, TranslationAndResourceDTO i, bool addFullScreen) { getElementForResource(BuildContext context, AppContext appContext, TranslationAndResourceDTO i, bool addFullScreen) {
var widgetToInclude; var widgetToInclude;
Size size = MediaQuery.of(context).size; Size size = MediaQuery.of(context).size;
TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext;
switch(i.resourceType) { switch(i.resourceType) {
case ResourceType.Image: case ResourceType.Image:
@ -537,14 +543,14 @@ getElementForResource(BuildContext context, AppContext appContext, TranslationAn
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return AlertDialog( return AlertDialog(
shape: const RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20.0)) borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0))
), ),
contentPadding: EdgeInsets.zero, contentPadding: EdgeInsets.zero,
// title: Text(eventAgenda.name!), // title: Text(eventAgenda.name!),
content: Container( content: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(20.0)), borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)),
color: kBackgroundColor, color: kBackgroundColor,
), ),
height: size.height * 0.8, height: size.height * 0.8,
@ -552,7 +558,7 @@ getElementForResource(BuildContext context, AppContext appContext, TranslationAn
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color(0xff7c94b6), color: const Color(0xff7c94b6),
borderRadius: BorderRadius.all(Radius.circular(15.0)), borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0)),
), ),
child: PhotoView( child: PhotoView(
imageProvider: ImageCustomProvider.getImageProvider(appContext, i.resourceId!, i.resourceUrl!), imageProvider: ImageCustomProvider.getImageProvider(appContext, i.resourceId!, i.resourceUrl!),
@ -561,7 +567,7 @@ getElementForResource(BuildContext context, AppContext appContext, TranslationAn
backgroundDecoration: BoxDecoration( backgroundDecoration: BoxDecoration(
color: kBackgroundSecondGrey, color: kBackgroundSecondGrey,
shape: BoxShape.rectangle, 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( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color(0xff7c94b6), //color: kBackgroundLight,
image: DecorationImage( image: DecorationImage(
image: ImageCustomProvider.getImageProvider(appContext, i.resourceId!, i.resourceUrl!), image: ImageCustomProvider.getImageProvider(appContext, i.resourceId!, i.resourceUrl!),
fit: BoxFit.cover, fit: BoxFit.cover,
), ),
borderRadius: BorderRadius.all(Radius.circular(15.0)), borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0)),
border: Border.all( /*border: Border.all(
color: kBackgroundGrey, color: kBackgroundGrey,
width: 1.0, width: 1.0,
), ),*/
), ),
), ),
); );
@ -598,14 +604,14 @@ getElementForResource(BuildContext context, AppContext appContext, TranslationAn
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return AlertDialog( return AlertDialog(
shape: const RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20.0)) borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0))
), ),
contentPadding: EdgeInsets.zero, contentPadding: EdgeInsets.zero,
// title: Text(eventAgenda.name!), // title: Text(eventAgenda.name!),
content: Container( content: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(20.0)), borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)),
color: kBackgroundColor, color: kBackgroundColor,
), ),
height: size.height * 0.8, height: size.height * 0.8,
@ -621,9 +627,9 @@ getElementForResource(BuildContext context, AppContext appContext, TranslationAn
ignoring: i.resourceType != ResourceType.Audio, ignoring: i.resourceType != ResourceType.Audio,
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: kBackgroundSecondGrey, //color: kBackgroundSecondGrey,
shape: BoxShape.rectangle, 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), child: showElementForResource(ResourceDTO(id: i.resourceId, url: i.resourceUrl, type: i.resourceType), appContext, false, true),
), ),

View File

@ -10,6 +10,7 @@ import 'package:manager_api/api.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:tablet_app/Helpers/ImageCustomProvider.dart'; import 'package:tablet_app/Helpers/ImageCustomProvider.dart';
import 'package:tablet_app/Models/ResponseSubDTO.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/app_context.dart';
import 'package:tablet_app/constants.dart'; import 'package:tablet_app/constants.dart';
@ -46,8 +47,11 @@ class _ShowReponsesWidget extends State<ShowReponsesWidget> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
Size sizeAll = MediaQuery.of(context).size; 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<AppContext>(context); final appContext = Provider.of<AppContext>(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( return Stack(
children: [ children: [
@ -77,7 +81,7 @@ class _ShowReponsesWidget extends State<ShowReponsesWidget> {
decoration: BoxDecoration( decoration: BoxDecoration(
color: kBackgroundLight, color: kBackgroundLight,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(20.0), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0),
image: i.resourceUrl != null ? new DecorationImage( image: i.resourceUrl != null ? new DecorationImage(
fit: BoxFit.contain, fit: BoxFit.contain,
opacity: 0.35, opacity: 0.35,
@ -101,7 +105,7 @@ class _ShowReponsesWidget extends State<ShowReponsesWidget> {
child: Container( child: Container(
//width: MediaQuery.of(context).size.width *0.65, //width: MediaQuery.of(context).size.width *0.65,
//color: Colors.pink, //color: Colors.pink,
height: kIsWeb ? size.height *0.25 : size.height *0.25, height: size.height *0.25,
child: Stack( child: Stack(
children: [ children: [
Center( Center(
@ -109,7 +113,7 @@ class _ShowReponsesWidget extends State<ShowReponsesWidget> {
decoration: BoxDecoration( decoration: BoxDecoration(
color: kBackgroundLight, color: kBackgroundLight,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(10.0), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 10.0),
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: kBackgroundSecondGrey, color: kBackgroundSecondGrey,
@ -153,8 +157,8 @@ class _ShowReponsesWidget extends State<ShowReponsesWidget> {
child: GridView.builder( child: GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2, crossAxisCount: 2,
mainAxisExtent: kIsWeb ? 65 : 65, // TODO depends on percentage 125 mainAxisExtent: 65,
mainAxisSpacing: kIsWeb ? 10 : 10, // TODO depends on percentage 15 mainAxisSpacing: 10,
crossAxisSpacing: 5, crossAxisSpacing: 5,
), ),
itemCount: i.responsesSubDTO!.length, itemCount: i.responsesSubDTO!.length,
@ -173,7 +177,7 @@ class _ShowReponsesWidget extends State<ShowReponsesWidget> {
decoration: BoxDecoration( decoration: BoxDecoration(
color: i.responsesSubDTO![index].isGood! ? kGreen : i.chosen == index ? kMainRed : kBackgroundLight, color: i.responsesSubDTO![index].isGood! ? kGreen : i.chosen == index ? kMainRed : kBackgroundLight,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(10.0), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 10.0),
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: kBackgroundSecondGrey, color: kBackgroundSecondGrey,
@ -200,8 +204,8 @@ class _ShowReponsesWidget extends State<ShowReponsesWidget> {
), ),
if(_questionsSubDTO != null && _questionsSubDTO.length > 1 && currentIndex != _questionsSubDTO.length && _questionsSubDTO[currentIndex-1].chosen != null && widget.questionsSubDTO!.length > 0) if(_questionsSubDTO != null && _questionsSubDTO.length > 1 && currentIndex != _questionsSubDTO.length && _questionsSubDTO[currentIndex-1].chosen != null && widget.questionsSubDTO!.length > 0)
Positioned( Positioned(
top: kIsWeb ? size.height * 0.3 : size.height * 0.3, // size.height * 0.35 // TODO depends on screen' percentage top: size.height * 0.35,
right: kIsWeb ? 45 : 45, // 60TODO depends on screen' percentage right: 35,
child: InkWell( child: InkWell(
onTap: () { onTap: () {
if(_questionsSubDTO[currentIndex-1].chosen != null && widget.questionsSubDTO!.length > 0) { if(_questionsSubDTO[currentIndex-1].chosen != null && widget.questionsSubDTO!.length > 0) {
@ -219,15 +223,15 @@ class _ShowReponsesWidget extends State<ShowReponsesWidget> {
}, },
child: Icon( child: Icon(
Icons.chevron_right, Icons.chevron_right,
size: kIsWeb ? 100 : 100, // 150 TODO depends on screen' percentage size: 90,
color: kMainRed, color: primaryColor,
), ),
) )
), ),
if(_questionsSubDTO != null && _questionsSubDTO.length > 1 && currentIndex != 1) if(_questionsSubDTO != null && _questionsSubDTO.length > 1 && currentIndex != 1)
Positioned( Positioned(
top: kIsWeb ? size.height * 0.3 : size.height * 0.3, // size.height * 0.35 TODO depends on screen' percentage top: size.height * 0.35,
left: kIsWeb ? 45 : 45, // 60 TODO depends on screen' percentage left: 35,
child: InkWell( child: InkWell(
onTap: () { onTap: () {
if(currentIndex > 1) if(currentIndex > 1)
@ -235,8 +239,8 @@ class _ShowReponsesWidget extends State<ShowReponsesWidget> {
}, },
child: Icon( child: Icon(
Icons.chevron_left, Icons.chevron_left,
size: kIsWeb ? 100 : 100, // 150 TODO depends on screen' percentage size: 90,
color: kMainRed, color: primaryColor,
), ),
) )
), ),

View File

@ -52,6 +52,8 @@ class _SliderView extends State<SliderView> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size; Size size = MediaQuery.of(context).size;
final appContext = Provider.of<AppContext>(context); final appContext = Provider.of<AppContext>(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; configurationDTO = appContext.getContext().configuration;
@ -76,8 +78,8 @@ class _SliderView extends State<SliderView> {
height: MediaQuery.of(context).size.height, height: MediaQuery.of(context).size.height,
margin: EdgeInsets.symmetric(horizontal: 5.0), margin: EdgeInsets.symmetric(horizontal: 5.0),
decoration: BoxDecoration( decoration: BoxDecoration(
color: configurationDTO.imageId == null ? configurationDTO.secondaryColor != null ? new Color(int.parse(configurationDTO.secondaryColor!.split('(0x')[1].split(')')[0], radix: 16)): kBackgroundGrey : null, //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), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 10.0),
//border: Border.all(width: 0.3, color: kSecondGrey), //border: Border.all(width: 0.3, color: kSecondGrey),
), ),
child: Column( child: Column(
@ -130,12 +132,12 @@ class _SliderView extends State<SliderView> {
child: Padding( child: Padding(
padding: const EdgeInsets.only(bottom: 10), padding: const EdgeInsets.only(bottom: 10),
child: Container( child: Container(
width: MediaQuery.of(context).size.width *0.65,
height: MediaQuery.of(context).size.height *0.25, height: MediaQuery.of(context).size.height *0.25,
width: MediaQuery.of(context).size.width *0.7,
decoration: BoxDecoration( decoration: BoxDecoration(
color: kBackgroundLight, color: kBackgroundLight,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(10.0), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 10.0),
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: kBackgroundSecondGrey, color: kBackgroundSecondGrey,
@ -179,7 +181,7 @@ class _SliderView extends State<SliderView> {
child: Icon( child: Icon(
Icons.chevron_right, Icons.chevron_right,
size: 90, size: 90,
color: Colors.white, color: primaryColor ?? kTestSecondColor,
), ),
) )
), ),
@ -195,7 +197,7 @@ class _SliderView extends State<SliderView> {
child: Icon( child: Icon(
Icons.chevron_left, Icons.chevron_left,
size: 90, size: 90,
color: Colors.white, color: primaryColor ?? kTestSecondColor,
), ),
) )
), ),
@ -252,6 +254,7 @@ class _SliderView extends State<SliderView> {
getElementForResource(AppContext appContext, ContentDTO i) { getElementForResource(AppContext appContext, ContentDTO i) {
var widgetToInclude; var widgetToInclude;
TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext;
switch(i.resourceType) { switch(i.resourceType) {
case ResourceType.Image: case ResourceType.Image:
@ -262,7 +265,7 @@ class _SliderView extends State<SliderView> {
backgroundDecoration: BoxDecoration( backgroundDecoration: BoxDecoration(
color: kBackgroundSecondGrey, color: kBackgroundSecondGrey,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(15.0), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0),
), ),
); );
break; break;
@ -274,7 +277,7 @@ class _SliderView extends State<SliderView> {
backgroundDecoration: BoxDecoration( backgroundDecoration: BoxDecoration(
color: kBackgroundSecondGrey, color: kBackgroundSecondGrey,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(15.0), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0),
), ),
); );
break; break;
@ -283,9 +286,9 @@ class _SliderView extends State<SliderView> {
case ResourceType.Audio: case ResourceType.Audio:
widgetToInclude = Container( widgetToInclude = Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: kBackgroundSecondGrey, //color: kBackgroundSecondGrey,
shape: BoxShape.rectangle, //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), child: showElementForResource(ResourceDTO(id: i.resourceId, url: i.resourceUrl, type: i.resourceType), appContext, false, true),
); );

View File

@ -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<WeatherView> createState() => _WeatherViewState();
}
class _WeatherViewState extends State<WeatherView> {
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<String, dynamic> 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<WeatherForecast> getNextFiveDaysForecast(List<WeatherForecast> allForecasts) {
List<WeatherForecast> nextFiveDaysForecast = [];
DateTime today = DateTime.now();
List<WeatherForecast> nextDay1All = allForecasts.where((af) => (DateTime.fromMillisecondsSinceEpoch(af.dt! * 1000)).day == (today.add(Duration(days: 1))).day).toList();
List<WeatherForecast> nextDay2All = allForecasts.where((af) => (DateTime.fromMillisecondsSinceEpoch(af.dt! * 1000)).day == (today.add(Duration(days: 2))).day).toList();
List<WeatherForecast> nextDay3All = allForecasts.where((af) => (DateTime.fromMillisecondsSinceEpoch(af.dt! * 1000)).day == (today.add(Duration(days: 3))).day).toList();
List<WeatherForecast> nextDay4All = allForecasts.where((af) => (DateTime.fromMillisecondsSinceEpoch(af.dt! * 1000)).day == (today.add(Duration(days: 4))).day).toList();
List<WeatherForecast> 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<AppContext>(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

View File

@ -15,6 +15,7 @@ import 'Screens/MainView/main_view.dart';
import 'Screens/Previous/previous_view.dart'; import 'Screens/Previous/previous_view.dart';
import 'app_context.dart'; import 'app_context.dart';
import 'constants.dart'; import 'constants.dart';
import 'package:flutter/services.dart';
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
@ -99,6 +100,13 @@ class _MyAppState extends State<MyApp> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// Block screen orientation in landscape mode only // TO TEST
SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeLeft,
DeviceOrientation.landscapeRight,
]);
return ChangeNotifierProvider<AppContext>( return ChangeNotifierProvider<AppContext>(
create: (_) => AppContext(widget.tabletAppContext), create: (_) => AppContext(widget.tabletAppContext),
child: MaterialApp( child: MaterialApp(
@ -113,8 +121,8 @@ class _MyAppState extends State<MyApp> {
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, 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, 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, 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", fontFamily: "Roboto",
textTheme: TextTheme(bodyLarge: TextStyle(color: kMainRed)), textTheme: TextTheme(bodyLarge: TextStyle(color: kTestSecondColor)),
visualDensity: VisualDensity.adaptivePlatformDensity, visualDensity: VisualDensity.adaptivePlatformDensity,
), ),
routes: { routes: {

View File

@ -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

View File

@ -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"

View File

@ -64,6 +64,7 @@ dependencies:
just_audio_cache: ^0.1.2 just_audio_cache: ^0.1.2
path_provider: ^2.1.2 path_provider: ^2.1.2
permission_handler: ^11.2.0 permission_handler: ^11.2.0
google_fonts: ^6.2.1
openapi_generator_cli: ^4.13.1 openapi_generator_cli: ^4.13.1
openapi_generator: ^4.13.1 openapi_generator: ^4.13.1