From 6ede91eed7aa7606d93b1a33538f83c017fb56d1 Mon Sep 17 00:00:00 2001 From: Thomas Fransolet Date: Wed, 25 Aug 2021 17:22:38 +0200 Subject: [PATCH] Add background color from service + real local db update --- lib/Helpers/DatabaseHelper.dart | 2 +- lib/Screens/MainView/main_view.dart | 150 +++++++++++++++------------- lib/Screens/Menu/menu_view.dart | 2 +- lib/Screens/Slider/slider_view.dart | 2 +- lib/main.dart | 2 +- 5 files changed, 82 insertions(+), 76 deletions(-) diff --git a/lib/Helpers/DatabaseHelper.dart b/lib/Helpers/DatabaseHelper.dart index 10a0667..0ed24e5 100644 --- a/lib/Helpers/DatabaseHelper.dart +++ b/lib/Helpers/DatabaseHelper.dart @@ -61,7 +61,7 @@ class DatabaseHelper { 'tabletAppContext', tabletAppContext.toMap(), where: "id = ?", - whereArgs: ["1234"], // + whereArgs: [tabletAppContext.id], ); } diff --git a/lib/Screens/MainView/main_view.dart b/lib/Screens/MainView/main_view.dart index 6633221..a2673fb 100644 --- a/lib/Screens/MainView/main_view.dart +++ b/lib/Screens/MainView/main_view.dart @@ -78,83 +78,89 @@ class _MainViewWidget extends State { } return Scaffold( body: SingleChildScrollView( - child: Column( - children: [ - Container( - width: size.width, - height: size.height * 0.12, - child: Row( - children: [ - Padding( - padding: const EdgeInsets.only(left: 15.0, top: 10.0), - child: AspectRatio( - aspectRatio: 4 / 4, - child: Container( - /*width: 125, - height: 125,*/ - decoration: boxDecoration(sectionSelected, true), + child: Container( + height: size.height, + width: size.width, + 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, + + child: Column( + children: [ + Container( + width: size.width, + height: size.height * 0.12, + child: Row( + children: [ + Padding( + padding: const EdgeInsets.only(left: 15.0, top: 10.0), + child: AspectRatio( + aspectRatio: 4 / 4, + child: Container( + /*width: 125, + height: 125,*/ + decoration: boxDecoration(sectionSelected, true), + ), ), ), - ), - SizedBox( - width: 25, - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: Align( - alignment: Alignment.centerLeft, - child: AutoSizeText( - sectionSelected.title.firstWhere((translation) => translation.language == appContext.getContext().language).value, - style: new TextStyle(fontSize: 25), - maxLines: 1, - ), - ) - ), - Expanded( - child: Align( - alignment: Alignment.centerLeft, - child: AutoSizeText( - sectionSelected.description.firstWhere((translation) => translation.language == appContext.getContext().language).value, - style: new TextStyle(fontSize: 20), - maxLines: 2, - ), - ) - ) - ], - ), - ) - ], - ), - ), - Padding( - padding: sectionSelected.type != SectionType.slider ? const EdgeInsets.only(left: 15.0, right: 15.0, top: 15.0) : const EdgeInsets.only(top: 15.0), - child: Container( - width: size.width, - height: size.height * 0.85, - decoration: sectionSelected.type != SectionType.video && sectionSelected.type != SectionType.web && sectionSelected.type != SectionType.slider && sectionSelected.type != SectionType.map ? BoxDecoration( - color: kBackgroundLight, - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(30.0), - boxShadow: [ - BoxShadow( - color: kBackgroundSecondGrey, - spreadRadius: 0.5, - blurRadius: 5, - offset: Offset(0, 1.5), // changes position of shadow + SizedBox( + width: 25, ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Align( + alignment: Alignment.centerLeft, + child: AutoSizeText( + sectionSelected.title.firstWhere((translation) => translation.language == appContext.getContext().language).value, + style: new TextStyle(fontSize: 25), + maxLines: 1, + ), + ) + ), + Expanded( + child: Align( + alignment: Alignment.centerLeft, + child: AutoSizeText( + sectionSelected.description.firstWhere((translation) => translation.language == appContext.getContext().language).value, + style: new TextStyle(fontSize: 20), + maxLines: 2, + ), + ) + ) + ], + ), + ) ], - ) : null, - child: Padding( - padding: const EdgeInsets.all(0.0), - child: elementToShow), + ), ), - ) - ], + Padding( + padding: sectionSelected.type != SectionType.slider ? const EdgeInsets.only(left: 15.0, right: 15.0, top: 15.0) : const EdgeInsets.only(top: 15.0), + child: Container( + width: size.width, + height: size.height * 0.85, + decoration: sectionSelected.type != SectionType.video && sectionSelected.type != SectionType.web && sectionSelected.type != SectionType.slider && sectionSelected.type != SectionType.map ? BoxDecoration( + color: kBackgroundLight, + shape: BoxShape.rectangle, + borderRadius: BorderRadius.circular(30.0), + boxShadow: [ + BoxShadow( + color: kBackgroundSecondGrey, + spreadRadius: 0.5, + blurRadius: 5, + offset: Offset(0, 1.5), // changes position of shadow + ), + ], + ) : null, + child: Padding( + padding: const EdgeInsets.all(0.0), + child: elementToShow), + ), + ) + ], + ), ), ), floatingActionButtonLocation: FloatingActionButtonLocation.endTop, diff --git a/lib/Screens/Menu/menu_view.dart b/lib/Screens/Menu/menu_view.dart index 109cfb4..9f211f5 100644 --- a/lib/Screens/Menu/menu_view.dart +++ b/lib/Screens/Menu/menu_view.dart @@ -109,7 +109,7 @@ class _MenuViewWidget extends State { }, child: Container( decoration: BoxDecoration( - color: 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, borderRadius: BorderRadius.circular(30.0), boxShadow: [ diff --git a/lib/Screens/Slider/slider_view.dart b/lib/Screens/Slider/slider_view.dart index 60c8b90..1e48b76 100644 --- a/lib/Screens/Slider/slider_view.dart +++ b/lib/Screens/Slider/slider_view.dart @@ -68,7 +68,7 @@ class _SliderViewWidget extends State { height: MediaQuery.of(context).size.height, margin: EdgeInsets.symmetric(horizontal: 5.0), decoration: BoxDecoration( - color: 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, borderRadius: BorderRadius.circular(10.0), //border: Border.all(width: 0.3, color: kSecondGrey), ), diff --git a/lib/main.dart b/lib/main.dart index 5dcb90b..fb47c9e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -76,7 +76,7 @@ class _MyAppState extends State { ],*/ theme: ThemeData( primarySwatch: Colors.grey, - scaffoldBackgroundColor: 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", textTheme: TextTheme(bodyText1: TextStyle(color: kMainRed)), visualDensity: VisualDensity.adaptivePlatformDensity,