From 1e890708d2439b8b120c77825a73b3f9c974b44f Mon Sep 17 00:00:00 2001 From: Alberto Ponces Date: Wed, 7 Sep 2022 12:01:04 +0100 Subject: [PATCH] fix: Further improvements on app theming --- assets/i18n/en.json | 2 +- lib/theme.dart | 30 ++++++++----- lib/ui/theme/dynamic_theme_builder.dart | 15 +++++-- lib/ui/views/installer/installer_view.dart | 2 +- lib/ui/views/navigation/navigation_view.dart | 20 +++++---- lib/ui/views/settings/settings_viewmodel.dart | 2 +- .../appInfoView/app_info_viewmodel.dart | 6 +-- .../homeView/available_updates_card.dart | 10 ++++- .../widgets/homeView/installed_apps_card.dart | 10 ++++- .../widgets/homeView/latest_commit_card.dart | 45 ++++++++++++++----- lib/ui/widgets/shared/search_bar.dart | 2 +- 11 files changed, 98 insertions(+), 46 deletions(-) diff --git a/assets/i18n/en.json b/assets/i18n/en.json index 02de88c8..b4f7ca68 100644 --- a/assets/i18n/en.json +++ b/assets/i18n/en.json @@ -5,7 +5,7 @@ "disabledLabel": "Disabled", "yesLabel": "Yes", "noLabel": "No", - "main": { + "navigationView": { "dashboardTab": "Dashboard", "patcherTab": "Patcher", "settingsTab": "Settings" diff --git a/lib/theme.dart b/lib/theme.dart index 923cb0b7..6995996b 100644 --- a/lib/theme.dart +++ b/lib/theme.dart @@ -1,15 +1,18 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; +var lightCustomColorScheme = ColorScheme.fromSeed( + seedColor: Colors.blue, + brightness: Brightness.light, +); + var lightCustomTheme = ThemeData( useMaterial3: true, - colorScheme: ColorScheme.fromSeed( - seedColor: Colors.blue, - brightness: Brightness.light, - ), + colorScheme: lightCustomColorScheme, navigationBarTheme: NavigationBarThemeData( labelTextStyle: MaterialStateProperty.all( - const TextStyle( + TextStyle( + color: lightCustomColorScheme.secondary, fontWeight: FontWeight.w500, ), ), @@ -17,17 +20,20 @@ var lightCustomTheme = ThemeData( textTheme: GoogleFonts.robotoTextTheme(ThemeData.light().textTheme), ); +var darkCustomColorScheme = ColorScheme.fromSeed( + seedColor: Colors.blue, + brightness: Brightness.dark, + primary: const Color(0xff7792BA), + surface: const Color(0xff0A0D11), +); + var darkCustomTheme = ThemeData( useMaterial3: true, - colorScheme: ColorScheme.fromSeed( - seedColor: Colors.blue, - brightness: Brightness.dark, - primary: const Color(0xff7792BA), - surface: const Color(0xff0A0D11), - ), + colorScheme: darkCustomColorScheme, navigationBarTheme: NavigationBarThemeData( labelTextStyle: MaterialStateProperty.all( - const TextStyle( + TextStyle( + color: darkCustomColorScheme.secondary, fontWeight: FontWeight.w500, ), ), diff --git a/lib/ui/theme/dynamic_theme_builder.dart b/lib/ui/theme/dynamic_theme_builder.dart index c48879fb..c6255a1f 100644 --- a/lib/ui/theme/dynamic_theme_builder.dart +++ b/lib/ui/theme/dynamic_theme_builder.dart @@ -29,10 +29,16 @@ class DynamicThemeBuilder extends StatelessWidget { backgroundColor: lightColorScheme?.background, indicatorColor: lightColorScheme?.primary.withAlpha(150), labelTextStyle: MaterialStateProperty.all( - const TextStyle( + GoogleFonts.roboto( + color: lightColorScheme?.secondary, fontWeight: FontWeight.w500, ), ), + iconTheme: MaterialStateProperty.all( + IconThemeData( + color: lightColorScheme?.secondary, + ), + ), ), scaffoldBackgroundColor: lightColorScheme?.background, colorScheme: lightColorScheme?.harmonized(), @@ -46,13 +52,14 @@ class DynamicThemeBuilder extends StatelessWidget { backgroundColor: darkColorScheme?.background, indicatorColor: darkColorScheme?.primary.withOpacity(0.4), labelTextStyle: MaterialStateProperty.all( - const TextStyle( + GoogleFonts.roboto( + color: darkColorScheme?.secondary, fontWeight: FontWeight.w500, ), ), iconTheme: MaterialStateProperty.all( - const IconThemeData( - color: Colors.white, + IconThemeData( + color: darkColorScheme?.secondary, ), ), ), diff --git a/lib/ui/views/installer/installer_view.dart b/lib/ui/views/installer/installer_view.dart index 8c875b11..2e851d4e 100644 --- a/lib/ui/views/installer/installer_view.dart +++ b/lib/ui/views/installer/installer_view.dart @@ -60,7 +60,7 @@ class InstallerView extends StatelessWidget { preferredSize: const Size(double.infinity, 1.0), child: LinearProgressIndicator( color: Theme.of(context).colorScheme.primary, - backgroundColor: Colors.white, + backgroundColor: Theme.of(context).colorScheme.secondary, value: model.progress, ), ), diff --git a/lib/ui/views/navigation/navigation_view.dart b/lib/ui/views/navigation/navigation_view.dart index 597201f3..ccf12616 100644 --- a/lib/ui/views/navigation/navigation_view.dart +++ b/lib/ui/views/navigation/navigation_view.dart @@ -34,26 +34,30 @@ class NavigationView extends StatelessWidget { selectedIndex: model.currentIndex, destinations: [ NavigationDestination( - icon: const Icon( - Icons.dashboard_outlined, - ), + icon: model.isIndexSelected(0) + ? const Icon(Icons.dashboard) + : const Icon(Icons.dashboard_outlined), label: FlutterI18n.translate( context, - 'main.dashboardTab', + 'navigationView.dashboardTab', ), ), NavigationDestination( - icon: const Icon(Icons.build_outlined), + icon: model.isIndexSelected(1) + ? const Icon(Icons.build) + : const Icon(Icons.build_outlined), label: FlutterI18n.translate( context, - 'main.patcherTab', + 'navigationView.patcherTab', ), ), NavigationDestination( - icon: const Icon(Icons.settings_outlined), + icon: model.isIndexSelected(2) + ? const Icon(Icons.settings) + : const Icon(Icons.settings_outlined), label: FlutterI18n.translate( context, - 'main.settingsTab', + 'navigationView.settingsTab', ), ), ], diff --git a/lib/ui/views/settings/settings_viewmodel.dart b/lib/ui/views/settings/settings_viewmodel.dart index 464611af..ca041e9b 100644 --- a/lib/ui/views/settings/settings_viewmodel.dart +++ b/lib/ui/views/settings/settings_viewmodel.dart @@ -70,7 +70,7 @@ class SettingsViewModel extends BaseViewModel { context: context, builder: (context) => SimpleDialog( title: I18nText('settingsView.languageLabel'), - backgroundColor: Theme.of(context).colorScheme.surface, + backgroundColor: Theme.of(context).colorScheme.secondaryContainer, children: [ RadioListTile( title: I18nText('settingsView.englishOption'), diff --git a/lib/ui/widgets/appInfoView/app_info_viewmodel.dart b/lib/ui/widgets/appInfoView/app_info_viewmodel.dart index 0ae8172a..0f845e30 100644 --- a/lib/ui/widgets/appInfoView/app_info_viewmodel.dart +++ b/lib/ui/widgets/appInfoView/app_info_viewmodel.dart @@ -46,6 +46,7 @@ class AppInfoViewModel extends BaseViewModel { context: context, builder: (context) => AlertDialog( title: I18nText('appInfoView.alertDialogTitle'), + backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: I18nText('appInfoView.errorDialogText'), actions: [ CustomMaterialButton( @@ -53,7 +54,6 @@ class AppInfoViewModel extends BaseViewModel { onPressed: () => Navigator.of(context).pop(), ) ], - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, ), ); } else { @@ -61,6 +61,7 @@ class AppInfoViewModel extends BaseViewModel { context: context, builder: (context) => AlertDialog( title: I18nText('appInfoView.alertDialogTitle'), + backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: I18nText('appInfoView.alertDialogText'), actions: [ CustomMaterialButton( @@ -78,7 +79,6 @@ class AppInfoViewModel extends BaseViewModel { }, ) ], - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, ), ); } @@ -102,6 +102,7 @@ class AppInfoViewModel extends BaseViewModel { context: context, builder: (context) => AlertDialog( title: I18nText('appInfoView.appliedPatchesLabel'), + backgroundColor: Theme.of(context).colorScheme.secondaryContainer, content: Text(getAppliedPatchesString(app.appliedPatches)), actions: [ CustomMaterialButton( @@ -109,7 +110,6 @@ class AppInfoViewModel extends BaseViewModel { onPressed: () => Navigator.of(context).pop(), ) ], - backgroundColor: Theme.of(context).colorScheme.secondaryContainer, ), ); } diff --git a/lib/ui/widgets/homeView/available_updates_card.dart b/lib/ui/widgets/homeView/available_updates_card.dart index 48cb42cc..0ade6486 100644 --- a/lib/ui/widgets/homeView/available_updates_card.dart +++ b/lib/ui/widgets/homeView/available_updates_card.dart @@ -19,14 +19,20 @@ class AvailableUpdatesCard extends StatelessWidget { child: Center( child: Column( children: [ - const Icon(Icons.update_disabled, size: 40), + Icon( + size: 40, + Icons.update_disabled, + color: Theme.of(context).colorScheme.secondary, + ), const SizedBox(height: 16), I18nText( 'homeView.noUpdates', child: Text( '', textAlign: TextAlign.center, - style: Theme.of(context).textTheme.subtitle1!, + style: Theme.of(context).textTheme.subtitle1!.copyWith( + color: Theme.of(context).colorScheme.secondary, + ), ), ) ], diff --git a/lib/ui/widgets/homeView/installed_apps_card.dart b/lib/ui/widgets/homeView/installed_apps_card.dart index 2be557e4..81917d5b 100644 --- a/lib/ui/widgets/homeView/installed_apps_card.dart +++ b/lib/ui/widgets/homeView/installed_apps_card.dart @@ -19,14 +19,20 @@ class InstalledAppsCard extends StatelessWidget { child: Center( child: Column( children: [ - const Icon(Icons.file_download_off, size: 40), + Icon( + size: 40, + Icons.file_download_off, + color: Theme.of(context).colorScheme.secondary, + ), const SizedBox(height: 16), I18nText( 'homeView.noInstallations', child: Text( '', textAlign: TextAlign.center, - style: Theme.of(context).textTheme.subtitle1!, + style: Theme.of(context).textTheme.subtitle1!.copyWith( + color: Theme.of(context).colorScheme.secondary, + ), ), ) ], diff --git a/lib/ui/widgets/homeView/latest_commit_card.dart b/lib/ui/widgets/homeView/latest_commit_card.dart index 57f4cb52..ceaa2cb5 100644 --- a/lib/ui/widgets/homeView/latest_commit_card.dart +++ b/lib/ui/widgets/homeView/latest_commit_card.dart @@ -36,9 +36,12 @@ class _LatestCommitCardState extends State { children: [ I18nText( 'latestCommitCard.patcherLabel', - child: const Text( + child: Text( '', - style: TextStyle(fontWeight: FontWeight.bold), + style: TextStyle( + fontWeight: FontWeight.bold, + color: Theme.of(context).colorScheme.secondary, + ), ), ), FutureBuilder( @@ -56,6 +59,9 @@ class _LatestCommitCardState extends State { context, 'latestCommitCard.loadingLabel', ), + style: TextStyle( + color: Theme.of(context).colorScheme.secondary, + ), ), ), ], @@ -65,22 +71,39 @@ class _LatestCommitCardState extends State { children: [ I18nText( 'latestCommitCard.managerLabel', - child: const Text( + child: Text( '', - style: TextStyle(fontWeight: FontWeight.bold), + style: TextStyle( + fontWeight: FontWeight.bold, + color: Theme.of(context).colorScheme.secondary, + ), ), ), FutureBuilder( future: _githubAPI.latestCommitTime( _managerAPI.getManagerRepo(), ), - builder: (context, snapshot) => - snapshot.hasData && snapshot.data!.isNotEmpty - ? I18nText( - 'latestCommitCard.timeagoLabel', - translationParams: {'time': snapshot.data!}, - ) - : I18nText('latestCommitCard.loadingLabel'), + builder: (context, snapshot) => snapshot.hasData && + snapshot.data!.isNotEmpty + ? I18nText( + 'latestCommitCard.timeagoLabel', + translationParams: {'time': snapshot.data!}, + child: Text( + '', + style: TextStyle( + color: Theme.of(context).colorScheme.secondary, + ), + ), + ) + : I18nText( + 'latestCommitCard.loadingLabel', + child: Text( + '', + style: TextStyle( + color: Theme.of(context).colorScheme.secondary, + ), + ), + ), ), ], ), diff --git a/lib/ui/widgets/shared/search_bar.dart b/lib/ui/widgets/shared/search_bar.dart index 8bb2f3d0..2e8b8a00 100644 --- a/lib/ui/widgets/shared/search_bar.dart +++ b/lib/ui/widgets/shared/search_bar.dart @@ -43,7 +43,7 @@ class _SearchBarState extends State { hintText: widget.hintText, prefixIcon: Icon( Icons.search, - color: Theme.of(context).iconTheme.color, + color: Theme.of(context).colorScheme.secondary, ), suffixIcon: _textController.text.isNotEmpty ? IconButton(