From 7eb2d5cb1f3b4b969d8952c6506cd1f5d346ca5f Mon Sep 17 00:00:00 2001 From: Tom BARITEAU-PETER Date: Wed, 1 Nov 2023 17:32:38 +0100 Subject: [PATCH] feat(front/mobile): apply theme on Services page --- .../components/editor/cards/action_card.dart | 1 - .../lib/components/services/service_card.dart | 9 +- frontend/mobile/lib/main.dart | 3 +- frontend/mobile/lib/pages/landing.dart | 14 +- frontend/mobile/lib/pages/services.dart | 7 +- frontend/mobile/lib/pages/user.dart | 221 +++++++++--------- frontend/mobile/lib/storage/index.dart | 1 - 7 files changed, 132 insertions(+), 124 deletions(-) diff --git a/frontend/mobile/lib/components/editor/cards/action_card.dart b/frontend/mobile/lib/components/editor/cards/action_card.dart index f6488098..61c48f9d 100644 --- a/frontend/mobile/lib/components/editor/cards/action_card.dart +++ b/frontend/mobile/lib/components/editor/cards/action_card.dart @@ -1,4 +1,3 @@ -import 'package:area_mobile/colors.dart'; import 'package:area_mobile/components/editor/steps/action/select_action_event.dart'; import 'package:area_mobile/components/editor/steps/action/select_action_service.dart'; import 'package:area_mobile/components/editor/steps/select_area_params.dart'; diff --git a/frontend/mobile/lib/components/services/service_card.dart b/frontend/mobile/lib/components/services/service_card.dart index dffbd7c3..a8fadbc4 100644 --- a/frontend/mobile/lib/components/services/service_card.dart +++ b/frontend/mobile/lib/components/services/service_card.dart @@ -1,4 +1,3 @@ -import 'package:area_mobile/colors.dart'; import 'package:area_mobile/types/services.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; @@ -15,16 +14,20 @@ class ServiceCard extends StatelessWidget { @override Widget build(BuildContext context) { return Card( + color: Theme.of(context).colorScheme.primary, elevation: 8, child: ListTile( selected: selected, - selectedTileColor: secondaryColor, + selectedTileColor: Theme.of(context).colorScheme.secondary, leading: SvgPicture.network( service.imageUrl, width: 32, height: 32, ), - title: Text(service.id), + title: Text(service.id, + style: TextStyle( + color: Theme.of(context).colorScheme.onPrimary, + )), onTap: onTap, ), ); diff --git a/frontend/mobile/lib/main.dart b/frontend/mobile/lib/main.dart index 27161898..84456b82 100644 --- a/frontend/mobile/lib/main.dart +++ b/frontend/mobile/lib/main.dart @@ -23,8 +23,7 @@ ThemeData _buildDarkTheme() { final ThemeData base = ThemeData.dark(); return base.copyWith( colorScheme: base.colorScheme.copyWith( - primary: const Color( - 0xFF516079), // Personnalisez les couleurs selon vos besoins + primary: const Color(0xFF516079), secondary: const Color(0xFFF1895C), onPrimary: const Color(0xFFC5C6C6), onSecondary: const Color(0xFF2E3244)), diff --git a/frontend/mobile/lib/pages/landing.dart b/frontend/mobile/lib/pages/landing.dart index e3703f67..1a7ec42a 100644 --- a/frontend/mobile/lib/pages/landing.dart +++ b/frontend/mobile/lib/pages/landing.dart @@ -22,7 +22,7 @@ class _LandingPageState extends State { bool isLoggedIn = false; int _selectedIndex = 2; int libraryKey = 0; - String language = "en"; + String locale = "en"; String theme = "light"; @override @@ -33,14 +33,14 @@ class _LandingPageState extends State { } void _checkSettings() async { - final storageLanguage = await storage.getLocale(); + final storageLocale = await storage.getLocale(); final storageTheme = await storage.getTheme(); - if (storageLanguage == null) { - storage.setLocale(language); + if (storageLocale == null) { + storage.setLocale(locale); } else { setState(() { - language = storageLanguage; + locale = storageLocale; }); } @@ -59,7 +59,7 @@ class _LandingPageState extends State { storage.setTheme(newTheme); setState(() { - language = newLocale; + locale = newLocale; theme = newTheme; }); widget.updateTheme(newTheme); @@ -89,7 +89,7 @@ class _LandingPageState extends State { Widget build(BuildContext context) { return Localizations.override( context: context, - locale: Locale(language), + locale: Locale(locale), child: Builder( builder: (context) { if (!isLoggedIn) { diff --git a/frontend/mobile/lib/pages/services.dart b/frontend/mobile/lib/pages/services.dart index 4c412d04..eea4da89 100644 --- a/frontend/mobile/lib/pages/services.dart +++ b/frontend/mobile/lib/pages/services.dart @@ -12,11 +12,12 @@ class Services extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( + backgroundColor: Theme.of(context).colorScheme.primary, title: Text(AppLocalizations.of(context)!.servicesTitle), automaticallyImplyLeading: false), body: Container( constraints: const BoxConstraints(maxWidth: 450, maxHeight: 800), - color: const Color(0xFFC5C6C6), + color: Theme.of(context).colorScheme.onSecondary, child: Padding( padding: const EdgeInsets.all(16.0), child: FutureBuilder>>( @@ -94,7 +95,9 @@ class _ServiceDetailsState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text(widget.service.id), automaticallyImplyLeading: false), + backgroundColor: Theme.of(context).colorScheme.primary, + title: Text(widget.service.id), + ), body: Padding( padding: const EdgeInsets.all(16.0), child: SingleChildScrollView( diff --git a/frontend/mobile/lib/pages/user.dart b/frontend/mobile/lib/pages/user.dart index 5d534781..d50bec8b 100644 --- a/frontend/mobile/lib/pages/user.dart +++ b/frontend/mobile/lib/pages/user.dart @@ -32,120 +32,125 @@ class _UserHero extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - backgroundColor: Theme.of(context).colorScheme.primary, - actions: [ - IconButton( - onPressed: () { - widget.onDisconnect(); - }, - icon: const Icon(Icons.logout), - ), - ], - title: Text(AppLocalizations.of(context)!.userTitle), - automaticallyImplyLeading: false), - body: Container( - color: Theme.of(context).colorScheme.onSecondary, - child: Padding( - padding: const EdgeInsets.all(16.0), - child: FutureBuilder>( - future: future, - builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { - return const CircularProgressIndicator(); - } else { - final UserMe? user = snapshot.data?.data; - if (user != null) { - newLocale = user.settings.language; - newTheme = user.settings.theme; - newEmail = user.email; - } - - if (user == null) { - return Column( - children: [ - ElevatedButton( - onPressed: () { - widget.onDisconnect(); - }, - child: Text(AppLocalizations.of(context)!.logout), - ), - ], - ); - } + appBar: AppBar( + backgroundColor: Theme.of(context).colorScheme.primary, + actions: [ + IconButton( + onPressed: () { + widget.onDisconnect(); + }, + icon: const Icon(Icons.logout), + ), + ], + title: Text(AppLocalizations.of(context)!.userTitle), + automaticallyImplyLeading: false), + body: Container( + color: Theme.of(context).colorScheme.onSecondary, + child: Padding( + padding: const EdgeInsets.all(16.0), + child: FutureBuilder>( + future: future, + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const CircularProgressIndicator(); + } else { + final UserMe? user = snapshot.data?.data; + if (user != null) { + newLocale = user.settings.language; + newTheme = user.settings.theme; + newEmail = user.email; + } - return Column( - children: [ - const UserTile(), - Form( - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - TextFormField( - decoration: InputDecoration( - labelText: AppLocalizations.of(context)!.email), - initialValue: user.email, - onChanged: ((value) => newEmail = value), - ), - const SizedBox(height: 16.0), - DropdownButtonFormField( - value: newLocale, - items: [ - InterfaceLanguage(id: "en", text: "🇺🇸 English"), - InterfaceLanguage(id: "fr", text: "🇫🇷 Francais"), - InterfaceLanguage(id: "is", text: "🇮🇸 Íslenskur"), - ].map((InterfaceLanguage locale) { - return DropdownMenuItem( - value: locale.id, - child: Text(locale.text), - ); - }).toList(), - onChanged: (value) { - if (value == null) return; - newLocale = value; - }, - decoration: InputDecoration( - labelText: - AppLocalizations.of(context)!.language), - ), - DropdownButtonFormField( - value: newTheme, - items: [ - 'auto', - 'dark', - 'light', - ].map((String theme) { - return DropdownMenuItem( - value: theme, - child: Text(theme), - ); - }).toList(), - onChanged: (value) { - if (value == null) return; - newTheme = value; - }, - decoration: InputDecoration( - labelText: AppLocalizations.of(context)!.theme), - ), - const SizedBox(height: 16.0), + if (user == null) { + return Column( + children: [ ElevatedButton( onPressed: () { - widget.updateSettings(newLocale, newTheme); - services.user - .updateProfile(newEmail, newLocale, newTheme); + widget.onDisconnect(); }, - child: Text(AppLocalizations.of(context)!.save), + child: Text(AppLocalizations.of(context)!.logout), ), ], - ), - ) - ], - ); - } - }, - ), - ), - ); + ); + } + + return Column( + children: [ + const UserTile(), + Form( + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + TextFormField( + decoration: InputDecoration( + labelText: + AppLocalizations.of(context)!.email), + initialValue: user.email, + onChanged: ((value) => newEmail = value), + ), + const SizedBox(height: 16.0), + DropdownButtonFormField( + value: newLocale, + items: [ + InterfaceLanguage( + id: "en", text: "🇺🇸 English"), + InterfaceLanguage( + id: "fr", text: "🇫🇷 Francais"), + InterfaceLanguage( + id: "is", text: "🇮🇸 Íslenskur"), + ].map((InterfaceLanguage locale) { + return DropdownMenuItem( + value: locale.id, + child: Text(locale.text), + ); + }).toList(), + onChanged: (value) { + if (value == null) return; + newLocale = value; + }, + decoration: InputDecoration( + labelText: + AppLocalizations.of(context)!.language), + ), + DropdownButtonFormField( + value: newTheme, + items: [ + 'auto', + 'dark', + 'light', + ].map((String theme) { + return DropdownMenuItem( + value: theme, + child: Text(theme), + ); + }).toList(), + onChanged: (value) { + if (value == null) return; + newTheme = value; + }, + decoration: InputDecoration( + labelText: + AppLocalizations.of(context)!.theme), + ), + const SizedBox(height: 16.0), + ElevatedButton( + onPressed: () { + widget.updateSettings(newLocale, newTheme); + services.user.updateProfile( + newEmail, newLocale, newTheme); + }, + child: Text(AppLocalizations.of(context)!.save), + ), + ], + ), + ) + ], + ); + } + }, + ), + ), + )); } } diff --git a/frontend/mobile/lib/storage/index.dart b/frontend/mobile/lib/storage/index.dart index 7c348eaa..2d8d1e7f 100644 --- a/frontend/mobile/lib/storage/index.dart +++ b/frontend/mobile/lib/storage/index.dart @@ -1,4 +1,3 @@ -import 'package:flutter/material.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; class Storage {