From 61b08f80b3c90e3a6a976a51df0682736efb310d Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Mon, 5 Aug 2024 17:35:59 +0200 Subject: [PATCH 01/34] Build with Material 3 --- lib/extensions/theme_extension.dart | 109 +--------------------------- lib/main.dart | 4 +- 2 files changed, 5 insertions(+), 108 deletions(-) diff --git a/lib/extensions/theme_extension.dart b/lib/extensions/theme_extension.dart index a6fe5e1..070f5ff 100644 --- a/lib/extensions/theme_extension.dart +++ b/lib/extensions/theme_extension.dart @@ -5,65 +5,7 @@ class AppTheme { return ThemeData( brightness: Brightness.light, fontFamily: 'Montserrat', - iconTheme: const IconThemeData(color: Colors.black87), - inputDecorationTheme: InputDecorationTheme( - prefixIconColor: Colors.grey[600], - suffixIconColor: Colors.grey[600], - border: const OutlineInputBorder(), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide( - color: Colors.grey[800]!, - ) - ), - labelStyle: const TextStyle( - color: Colors.black26, - ), - isDense: true, - contentPadding: const EdgeInsets.all(10), - disabledBorder: const OutlineInputBorder( - borderSide: BorderSide( - color: Colors.black12, - ) - ) - ), - appBarTheme: const AppBarTheme( - titleTextStyle: TextStyle( - color: Colors.black87 - ), - toolbarTextStyle: TextStyle( - color: Colors.black87 - ), - iconTheme: IconThemeData( - color: Colors.black87, - ), - ), - textButtonTheme: TextButtonThemeData( - style: TextButton.styleFrom( - foregroundColor: Colors.black87 - ) - ), - buttonTheme: const ButtonThemeData( - textTheme: ButtonTextTheme.primary - ), - primaryTextTheme: TextTheme( - bodyMedium: const TextStyle( - color: Colors.black87 - ), - bodySmall: TextStyle( - color: Colors.grey[600] - ), - labelMedium: TextStyle( - color: Colors.grey[300] - ), - ), - snackBarTheme: const SnackBarThemeData( - behavior: SnackBarBehavior.floating - ), - checkboxTheme: CheckboxThemeData( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(3) - ) - ) + colorScheme: ColorScheme.fromSeed(seedColor: Colors.grey), ); } @@ -71,52 +13,7 @@ class AppTheme { return ThemeData( brightness: Brightness.dark, fontFamily: 'Montserrat', - iconTheme: IconThemeData(color: Colors.grey[50]), - inputDecorationTheme: InputDecorationTheme( - prefixIconColor: Colors.grey[400], - suffixIconColor: Colors.grey[400], - border: const OutlineInputBorder(), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide( - color: Colors.grey[300]!, - ) - ), - labelStyle: TextStyle( - color: Colors.grey[600], - ), - isDense: true, - contentPadding: const EdgeInsets.all(10), - disabledBorder: OutlineInputBorder( - borderSide: BorderSide( - color: Colors.grey[700]!, - ) - ) - ), - textButtonTheme: TextButtonThemeData( - style: TextButton.styleFrom( - foregroundColor: Colors.white - ) - ), - buttonTheme: const ButtonThemeData( - textTheme: ButtonTextTheme.primary - ), - primaryTextTheme: TextTheme( - bodySmall: TextStyle( - color: Colors.grey[300] - ), - labelMedium: TextStyle( - color: Colors.grey[600] - ) - ), - snackBarTheme: SnackBarThemeData( - behavior: SnackBarBehavior.floating, - backgroundColor: Colors.grey[300] - ), - checkboxTheme: CheckboxThemeData( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(3) - ) - ) + colorScheme: ColorScheme.fromSeed(seedColor: Colors.grey, brightness: Brightness.dark), ); } -} \ No newline at end of file +} diff --git a/lib/main.dart b/lib/main.dart index e2ffde4..15faf08 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -178,8 +178,8 @@ class Tare extends StatelessWidget { ], debugShowCheckedModeBanner: false, title: 'UnTaRe App', - theme: AppTheme.lightTheme.copyWith(primaryColor: Color(settingsCubit.state.materialHexColor), useMaterial3: false), - darkTheme: AppTheme.darkTheme.copyWith(primaryColor: Color(settingsCubit.state.materialHexColor), useMaterial3: false), + theme: AppTheme.lightTheme.copyWith(primaryColor: Color(settingsCubit.state.materialHexColor)), + darkTheme: AppTheme.darkTheme.copyWith(primaryColor: Color(settingsCubit.state.materialHexColor)), themeMode: themeMode, home: (state is AuthenticationAuthenticated) ? const TarePage() From fdd4298e44e171889a62df01471474fb82987948 Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Mon, 5 Aug 2024 17:36:07 +0200 Subject: [PATCH 02/34] Migrate bottomsheet to Material 3 --- lib/main.dart | 39 +++++++++------------------------------ 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 15faf08..f5216ea 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -342,36 +342,15 @@ class TarePageState extends State with SingleTickerProviderStateMixin index: _selectedScreenIndex, children: _pages ), - bottomNavigationBar: Container( - decoration: BoxDecoration( - boxShadow:[ - BoxShadow( - color: Colors.black12.withOpacity(0.4), //color of shadow - spreadRadius: 0.5, //spread radius - blurRadius: 1, // blur radius - offset: const Offset(0, 0) - ), - ], - ), - child: SizeTransition( - sizeFactor: _animationController, - axisAlignment: -1.0, - child: BottomNavigationBar( - type: BottomNavigationBarType.fixed, - currentIndex: _selectedScreenIndex, - selectedItemColor: Theme.of(context).primaryColor, - unselectedItemColor: Colors.grey, - showSelectedLabels: true, - showUnselectedLabels: false, - onTap: _selectScreen, - items: [ - BottomNavigationBarItem(icon: const Icon(Icons.restaurant_menu_outlined), label: AppLocalizations.of(context)!.recipesTitle), - BottomNavigationBarItem(icon: const Icon(Icons.calendar_today_outlined), label: AppLocalizations.of(context)!.mealPlanTitle), - BottomNavigationBarItem(icon: const Icon(Icons.shopping_cart_outlined), label: AppLocalizations.of(context)!.shoppingListTitle), - BottomNavigationBarItem(icon: const Icon(Icons.settings), label: AppLocalizations.of(context)!.settingsTitle), - ], - ) - ), + bottomNavigationBar: NavigationBar( + selectedIndex: _selectedScreenIndex, + onDestinationSelected: _selectScreen, + destinations: [ + NavigationDestination(icon: const Icon(Icons.restaurant_menu_outlined), label: AppLocalizations.of(context)!.recipesTitle), + NavigationDestination(icon: const Icon(Icons.calendar_today_outlined), label: AppLocalizations.of(context)!.mealPlanTitle), + NavigationDestination(icon: const Icon(Icons.shopping_cart_outlined), label: AppLocalizations.of(context)!.shoppingListTitle), + NavigationDestination(icon: const Icon(Icons.settings), label: AppLocalizations.of(context)!.settingsTitle), + ], ) ) ); From b1be386caa3ef74a9dff0e7ec39cf30854f655cd Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Mon, 5 Aug 2024 21:44:17 +0200 Subject: [PATCH 03/34] Update bottom sheet styling --- .../meal_plan_entry_more_bottom_sheet_component.dart | 2 -- .../bottom_sheets/meal_plan_more_bottom_sheet_component.dart | 2 -- .../bottom_sheets/recipe_more_bottom_sheet_component.dart | 2 -- .../recipe_shopping_list_bottom_sheet_component.dart | 2 -- .../bottom_sheets/recipes_more_bottom_sheet_component.dart | 2 -- .../settings_default_page_bottom_sheet_component.dart | 2 -- .../bottom_sheets/settings_layout_bottom_sheet_component.dart | 2 -- .../bottom_sheets/settings_theme_bottom_sheet_component.dart | 2 -- .../shopping_list_more_bottom_sheet_component.dart | 2 -- lib/components/bottom_sheets/sort_bottom_sheet_component.dart | 2 -- 10 files changed, 20 deletions(-) diff --git a/lib/components/bottom_sheets/meal_plan_entry_more_bottom_sheet_component.dart b/lib/components/bottom_sheets/meal_plan_entry_more_bottom_sheet_component.dart index 15f603e..dda5ac7 100644 --- a/lib/components/bottom_sheets/meal_plan_entry_more_bottom_sheet_component.dart +++ b/lib/components/bottom_sheets/meal_plan_entry_more_bottom_sheet_component.dart @@ -20,7 +20,6 @@ Future mealPlanEntryMoreBottomSheet(BuildContext context, MealPlanEntry mealPlan color: Theme.of(context).scaffoldBackgroundColor, borderRadius: const BorderRadius.all(Radius.circular(10)) ), - margin: const EdgeInsets.all(12), child: Wrap( children: [ Container( @@ -28,7 +27,6 @@ Future mealPlanEntryMoreBottomSheet(BuildContext context, MealPlanEntry mealPlan alignment: Alignment.center, decoration: BoxDecoration( borderRadius: const BorderRadius.vertical(top: Radius.circular(10)), - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[300] : Colors.grey[700] ), child: Text( (mealPlan.recipe != null) ? mealPlan.recipe!.name : mealPlan.title, diff --git a/lib/components/bottom_sheets/meal_plan_more_bottom_sheet_component.dart b/lib/components/bottom_sheets/meal_plan_more_bottom_sheet_component.dart index e61c995..f781d36 100644 --- a/lib/components/bottom_sheets/meal_plan_more_bottom_sheet_component.dart +++ b/lib/components/bottom_sheets/meal_plan_more_bottom_sheet_component.dart @@ -13,7 +13,6 @@ Future mealPlanMoreBottomSheet(BuildContext context) { color: Theme.of(context).scaffoldBackgroundColor, borderRadius: const BorderRadius.all(Radius.circular(10)) ), - margin: const EdgeInsets.all(12), child: Wrap( spacing: 15, children: [ @@ -22,7 +21,6 @@ Future mealPlanMoreBottomSheet(BuildContext context) { alignment: Alignment.center, decoration: BoxDecoration( borderRadius: const BorderRadius.vertical(top: Radius.circular(10)), - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[300] : Colors.grey[700] ), child: Text( AppLocalizations.of(context)!.mealPlanTitle, diff --git a/lib/components/bottom_sheets/recipe_more_bottom_sheet_component.dart b/lib/components/bottom_sheets/recipe_more_bottom_sheet_component.dart index ad158a5..fb135f0 100644 --- a/lib/components/bottom_sheets/recipe_more_bottom_sheet_component.dart +++ b/lib/components/bottom_sheets/recipe_more_bottom_sheet_component.dart @@ -12,7 +12,6 @@ Future recipeMoreBottomSheet(BuildContext context, Recipe recipe) { color: Theme.of(context).scaffoldBackgroundColor, borderRadius: const BorderRadius.all(Radius.circular(10)) ), - margin: const EdgeInsets.all(12), child: Wrap( spacing: 15, children: [ @@ -21,7 +20,6 @@ Future recipeMoreBottomSheet(BuildContext context, Recipe recipe) { alignment: Alignment.center, decoration: BoxDecoration( borderRadius: const BorderRadius.vertical(top: Radius.circular(10)), - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[300] : Colors.grey[700] ), child: Text( recipe.name, diff --git a/lib/components/bottom_sheets/recipe_shopping_list_bottom_sheet_component.dart b/lib/components/bottom_sheets/recipe_shopping_list_bottom_sheet_component.dart index 6c72dc2..79db107 100644 --- a/lib/components/bottom_sheets/recipe_shopping_list_bottom_sheet_component.dart +++ b/lib/components/bottom_sheets/recipe_shopping_list_bottom_sheet_component.dart @@ -14,7 +14,6 @@ Future recipeShoppingListBottomSheet(BuildContext context, Recipe recipe) { color: Theme.of(context).scaffoldBackgroundColor, borderRadius: const BorderRadius.all(Radius.circular(10)) ), - margin: const EdgeInsets.all(12), child: Wrap( children: [ Container( @@ -22,7 +21,6 @@ Future recipeShoppingListBottomSheet(BuildContext context, Recipe recipe) { alignment: Alignment.center, decoration: BoxDecoration( borderRadius: const BorderRadius.vertical(top: Radius.circular(10)), - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[300] : Colors.grey[700] ), child: Text( recipe.name, diff --git a/lib/components/bottom_sheets/recipes_more_bottom_sheet_component.dart b/lib/components/bottom_sheets/recipes_more_bottom_sheet_component.dart index 92096cf..a7ebf90 100644 --- a/lib/components/bottom_sheets/recipes_more_bottom_sheet_component.dart +++ b/lib/components/bottom_sheets/recipes_more_bottom_sheet_component.dart @@ -13,7 +13,6 @@ Future recipesBottomSheet(BuildContext context) { color: Theme.of(context).scaffoldBackgroundColor, borderRadius: const BorderRadius.all(Radius.circular(10)) ), - margin: const EdgeInsets.all(12), child: Wrap( children: [ Container( @@ -21,7 +20,6 @@ Future recipesBottomSheet(BuildContext context) { alignment: Alignment.center, decoration: BoxDecoration( borderRadius: const BorderRadius.vertical(top: Radius.circular(10)), - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[300] : Colors.grey[700] ), child: Text( AppLocalizations.of(context)!.recipesTitle, diff --git a/lib/components/bottom_sheets/settings_default_page_bottom_sheet_component.dart b/lib/components/bottom_sheets/settings_default_page_bottom_sheet_component.dart index 45b9098..552703e 100644 --- a/lib/components/bottom_sheets/settings_default_page_bottom_sheet_component.dart +++ b/lib/components/bottom_sheets/settings_default_page_bottom_sheet_component.dart @@ -13,7 +13,6 @@ Future settingsDefaultPageBottomSheet(BuildContext context) { color: Theme.of(context).scaffoldBackgroundColor, borderRadius: const BorderRadius.all(Radius.circular(10)) ), - margin: const EdgeInsets.all(12), child: Wrap( children: [ Container( @@ -21,7 +20,6 @@ Future settingsDefaultPageBottomSheet(BuildContext context) { alignment: Alignment.center, decoration: BoxDecoration( borderRadius: const BorderRadius.vertical(top: Radius.circular(10)), - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[300] : Colors.grey[700] ), child: Text( AppLocalizations.of(context)!.settingsDefaultPage, diff --git a/lib/components/bottom_sheets/settings_layout_bottom_sheet_component.dart b/lib/components/bottom_sheets/settings_layout_bottom_sheet_component.dart index 76fb322..8198909 100644 --- a/lib/components/bottom_sheets/settings_layout_bottom_sheet_component.dart +++ b/lib/components/bottom_sheets/settings_layout_bottom_sheet_component.dart @@ -13,7 +13,6 @@ Future settingsLayoutBottomSheet(BuildContext context) { color: Theme.of(context).scaffoldBackgroundColor, borderRadius: const BorderRadius.all(Radius.circular(10)) ), - margin: const EdgeInsets.all(12), child: Wrap( children: [ Container( @@ -21,7 +20,6 @@ Future settingsLayoutBottomSheet(BuildContext context) { alignment: Alignment.center, decoration: BoxDecoration( borderRadius: const BorderRadius.vertical(top: Radius.circular(10)), - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[300] : Colors.grey[700] ), child: Text( AppLocalizations.of(context)!.settingsRecipeLayout, diff --git a/lib/components/bottom_sheets/settings_theme_bottom_sheet_component.dart b/lib/components/bottom_sheets/settings_theme_bottom_sheet_component.dart index 2eb39b4..6636604 100644 --- a/lib/components/bottom_sheets/settings_theme_bottom_sheet_component.dart +++ b/lib/components/bottom_sheets/settings_theme_bottom_sheet_component.dart @@ -13,7 +13,6 @@ Future settingsThemeBottomSheet(BuildContext context) { color: Theme.of(context).scaffoldBackgroundColor, borderRadius: const BorderRadius.all(Radius.circular(10)) ), - margin: const EdgeInsets.all(12), child: Wrap( children: [ Container( @@ -21,7 +20,6 @@ Future settingsThemeBottomSheet(BuildContext context) { alignment: Alignment.center, decoration: BoxDecoration( borderRadius: const BorderRadius.vertical(top: Radius.circular(10)), - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[300] : Colors.grey[700] ), child: Text( AppLocalizations.of(context)!.settingsThemeMode, diff --git a/lib/components/bottom_sheets/shopping_list_more_bottom_sheet_component.dart b/lib/components/bottom_sheets/shopping_list_more_bottom_sheet_component.dart index baf620c..28c2e87 100644 --- a/lib/components/bottom_sheets/shopping_list_more_bottom_sheet_component.dart +++ b/lib/components/bottom_sheets/shopping_list_more_bottom_sheet_component.dart @@ -12,7 +12,6 @@ Future shoppingListMoreBottomSheet(BuildContext context) { color: Theme.of(context).scaffoldBackgroundColor, borderRadius: const BorderRadius.all(Radius.circular(10)) ), - margin: const EdgeInsets.all(12), child: Wrap( spacing: 15, children: [ @@ -21,7 +20,6 @@ Future shoppingListMoreBottomSheet(BuildContext context) { alignment: Alignment.center, decoration: BoxDecoration( borderRadius: const BorderRadius.vertical(top: Radius.circular(10)), - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[300] : Colors.grey[700] ), child: Text( AppLocalizations.of(context)!.shoppingListTitle, diff --git a/lib/components/bottom_sheets/sort_bottom_sheet_component.dart b/lib/components/bottom_sheets/sort_bottom_sheet_component.dart index 42491b9..aa0d2d9 100644 --- a/lib/components/bottom_sheets/sort_bottom_sheet_component.dart +++ b/lib/components/bottom_sheets/sort_bottom_sheet_component.dart @@ -12,7 +12,6 @@ Future sortBottomSheet(BuildContext context, Function(String, bool) sortButtonPr color: Theme.of(context).scaffoldBackgroundColor, borderRadius: const BorderRadius.all(Radius.circular(10)) ), - margin: const EdgeInsets.all(12), child: Wrap( spacing: 15, children: [ @@ -21,7 +20,6 @@ Future sortBottomSheet(BuildContext context, Function(String, bool) sortButtonPr alignment: Alignment.center, decoration: BoxDecoration( borderRadius: const BorderRadius.vertical(top: Radius.circular(10)), - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[300] : Colors.grey[700] ), child: Text( AppLocalizations.of(context)!.sortBy, From bfd714cae4040dcd56f5e406d9edf6e755f73392 Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Mon, 5 Aug 2024 21:44:29 +0200 Subject: [PATCH 04/34] Fix accent color usage for ThemeData --- lib/extensions/theme_extension.dart | 8 ++++---- lib/main.dart | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/extensions/theme_extension.dart b/lib/extensions/theme_extension.dart index 070f5ff..64b5f8d 100644 --- a/lib/extensions/theme_extension.dart +++ b/lib/extensions/theme_extension.dart @@ -1,19 +1,19 @@ import 'package:flutter/material.dart'; class AppTheme { - static ThemeData get lightTheme { + static ThemeData lightTheme(Color color) { return ThemeData( brightness: Brightness.light, fontFamily: 'Montserrat', - colorScheme: ColorScheme.fromSeed(seedColor: Colors.grey), + colorScheme: ColorScheme.fromSeed(seedColor: color), ); } - static ThemeData get darkTheme { + static ThemeData darkTheme(Color color) { return ThemeData( brightness: Brightness.dark, fontFamily: 'Montserrat', - colorScheme: ColorScheme.fromSeed(seedColor: Colors.grey, brightness: Brightness.dark), + colorScheme: ColorScheme.fromSeed(seedColor: color, brightness: Brightness.dark), ); } } diff --git a/lib/main.dart b/lib/main.dart index f5216ea..556aa28 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -178,8 +178,8 @@ class Tare extends StatelessWidget { ], debugShowCheckedModeBanner: false, title: 'UnTaRe App', - theme: AppTheme.lightTheme.copyWith(primaryColor: Color(settingsCubit.state.materialHexColor)), - darkTheme: AppTheme.darkTheme.copyWith(primaryColor: Color(settingsCubit.state.materialHexColor)), + theme: AppTheme.lightTheme(Color(settingsCubit.state.materialHexColor)), + darkTheme: AppTheme.darkTheme(Color(settingsCubit.state.materialHexColor)), themeMode: themeMode, home: (state is AuthenticationAuthenticated) ? const TarePage() From 5df850f85a7b58e8698b2b404fc0d18b80cc46da Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 07:38:22 +0200 Subject: [PATCH 05/34] Replace custom search widget by SearchBar --- lib/pages/recipes_page.dart | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/lib/pages/recipes_page.dart b/lib/pages/recipes_page.dart index f86ba5d..1f6313c 100644 --- a/lib/pages/recipes_page.dart +++ b/lib/pages/recipes_page.dart @@ -263,32 +263,8 @@ Widget sliverAppBarWidget(BuildContext context, bool innerBoxIsScrolled, TextEdi child: Row( children: [ Flexible( - child: TextField( + child: SearchBar( controller: searchTextController, - cursorColor: Theme.of(context).primaryColor, - decoration: InputDecoration( - hintText: AppLocalizations.of(context)!.search, - contentPadding: const EdgeInsets.only(top: 10), - prefixIcon: const Icon(Icons.search_outlined), - suffixIcon: showSearchClear ? IconButton( - splashRadius: 1, - padding: const EdgeInsets.fromLTRB(8, 7, 8, 8), - icon: const Icon(Icons.clear_outlined), - onPressed: () { - searchTextController.clear(); - }, - ) : null, - fillColor: (Theme.of(context).brightness.name == 'light') ? Colors.grey[200] : Colors.grey[700], - focusedBorder: const OutlineInputBorder( - borderSide: BorderSide(color: Colors.transparent, width: 0.0), - borderRadius: BorderRadius.all(Radius.circular(30.0)), - ), - filled: true, - enabledBorder: const OutlineInputBorder( - borderSide: BorderSide(color: Colors.transparent, width: 0.0), - borderRadius: BorderRadius.all(Radius.circular(30.0)), - ), - ), ), ), IconButton( From 4587c50665f93eb4cc2417d969d1e404e94b3951 Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 07:45:02 +0200 Subject: [PATCH 06/34] Migrate recipe view colors --- .../recipes/recipe_image_component.dart | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/components/recipes/recipe_image_component.dart b/lib/components/recipes/recipe_image_component.dart index 71cc1d8..8f2b727 100644 --- a/lib/components/recipes/recipe_image_component.dart +++ b/lib/components/recipes/recipe_image_component.dart @@ -16,7 +16,7 @@ Widget buildRecipeImage(Recipe recipe, BorderRadius borderRadius, double height, height: height, width: double.maxFinite, decoration: BoxDecoration( - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[100]! : Colors.grey[700], + color: Theme.of(context).colorScheme.secondary, borderRadius: borderRadius, boxShadow: [ if (boxShadow != null) boxShadow @@ -29,13 +29,13 @@ Widget buildRecipeImage(Recipe recipe, BorderRadius borderRadius, double height, ), placeholder: (context, url) => Shimmer.fromColors( enabled: true, - baseColor: (Theme.of(context).brightness.name == 'light') ? Colors.grey[100]! : Colors.grey[700]!, - highlightColor: (Theme.of(context).brightness.name == 'light') ? Colors.grey[200]! : Colors.grey[600]!, + baseColor: Theme.of(context).colorScheme.secondary, + highlightColor: Theme.of(context).colorScheme.onSecondary, child: Container( height: height, width: double.maxFinite, decoration: BoxDecoration( - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[100] : Colors.grey[700], + color: Theme.of(context).colorScheme.secondary, borderRadius: borderRadius, ), ), @@ -45,13 +45,13 @@ Widget buildRecipeImage(Recipe recipe, BorderRadius borderRadius, double height, height: height, width: double.maxFinite, decoration: BoxDecoration( - color: (Theme.of(context).brightness.name == 'light') ? Colors.black12 : Colors.grey[700], + color: Theme.of(context).colorScheme.secondary, borderRadius: borderRadius, ), child: Center( child: Icon( Icons.restaurant_menu_outlined, - color: (Theme.of(context).brightness.name == 'light') ? Colors.black38 : Colors.grey[400], + color: Theme.of(context).colorScheme.onSecondary, ), ), ); @@ -65,14 +65,14 @@ Widget buildRecipeImage(Recipe recipe, BorderRadius borderRadius, double height, height: height, width: double.maxFinite, decoration: BoxDecoration( - color: (Theme.of(context).brightness.name == 'light') ? Colors.black12 : Colors.grey[700], + color: Theme.of(context).colorScheme.secondary, borderRadius: borderRadius, ), child: Container( alignment: Alignment.center, child: Icon( Icons.restaurant_menu_outlined, - color: (Theme.of(context).brightness.name == 'light') ? Colors.black38 : Colors.grey[400], + color: Theme.of(context).colorScheme.onSecondary, ), ), ); From 6ae61e95631e05b30ce31555ae061af799ff9689 Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 08:00:22 +0200 Subject: [PATCH 07/34] Refactor bottom sheets --- ...lan_entry_more_bottom_sheet_component.dart | 93 +++++++------------ ...meal_plan_more_bottom_sheet_component.dart | 89 +++++++----------- .../recipe_more_bottom_sheet_component.dart | 50 +++++----- ..._shopping_list_bottom_sheet_component.dart | 48 +++++----- .../recipes_more_bottom_sheet_component.dart | 76 ++++++--------- ...s_default_page_bottom_sheet_component.dart | 84 +++++++---------- ...ettings_layout_bottom_sheet_component.dart | 70 +++++--------- ...settings_theme_bottom_sheet_component.dart | 84 +++++++---------- ...ping_list_more_bottom_sheet_component.dart | 36 ++----- .../sort_bottom_sheet_component.dart | 44 ++++----- 10 files changed, 255 insertions(+), 419 deletions(-) diff --git a/lib/components/bottom_sheets/meal_plan_entry_more_bottom_sheet_component.dart b/lib/components/bottom_sheets/meal_plan_entry_more_bottom_sheet_component.dart index dda5ac7..45ad624 100644 --- a/lib/components/bottom_sheets/meal_plan_entry_more_bottom_sheet_component.dart +++ b/lib/components/bottom_sheets/meal_plan_entry_more_bottom_sheet_component.dart @@ -12,72 +12,49 @@ Future mealPlanEntryMoreBottomSheet(BuildContext context, MealPlanEntry mealPlan MealPlanBloc mealPlanBloc = BlocProvider.of(context); return showModalBottomSheet( - backgroundColor: Colors.transparent, + showDragHandle: true, useRootNavigator: true, context: context, - builder: (btsContext) => Container( - decoration: BoxDecoration( - color: Theme.of(context).scaffoldBackgroundColor, - borderRadius: const BorderRadius.all(Radius.circular(10)) - ), - child: Wrap( - children: [ - Container( - height: 44, + builder: (btsContext) => Wrap( + children: [ + Container( alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: const BorderRadius.vertical(top: Radius.circular(10)), - ), - child: Text( - (mealPlan.recipe != null) ? mealPlan.recipe!.name : mealPlan.title, - textAlign: TextAlign.center, - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18, - ), - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - ), - Container( - alignment: Alignment.center, - padding: const EdgeInsets.only(left: 12, right: 12, bottom: 6), - child: Column( - children: [ + padding: const EdgeInsets.only(left: 12, right: 12, bottom: 6), + child: Column( + children: [ + ListTile( + onTap: () { + Navigator.pop(btsContext); + upsertMealPlanEntryDialog(context, mealPlan: mealPlan, referer: 'edit'); + }, + leading: const Icon(Icons.edit_outlined), + title: Text(AppLocalizations.of(context)!.edit) + ), + if (mealPlan.recipe != null) ListTile( onTap: () { Navigator.pop(btsContext); - upsertMealPlanEntryDialog(context, mealPlan: mealPlan, referer: 'edit'); + recipeShoppingListBottomSheet(context, mealPlan.recipe!); }, - leading: const Icon(Icons.edit_outlined), - title: Text(AppLocalizations.of(context)!.edit) + leading: const Icon(Icons.add_shopping_cart_outlined), + title: Text(AppLocalizations.of(context)!.addToShoppingList) ), - if (mealPlan.recipe != null) - ListTile( - onTap: () { - Navigator.pop(btsContext); - recipeShoppingListBottomSheet(context, mealPlan.recipe!); - }, - leading: const Icon(Icons.add_shopping_cart_outlined), - title: Text(AppLocalizations.of(context)!.addToShoppingList) - ), - const Divider(), - ListTile( - onTap: () { - Navigator.pop(btsContext); - mealPlanBloc.add(DeleteMealPlan(mealPlan: mealPlan)); - }, - leading: const Icon(Icons.delete_outline, color: Colors.redAccent), - title: Text( - AppLocalizations.of(context)!.mealPlanRemove, - style: const TextStyle(color: Colors.redAccent) - ) + const Divider(), + ListTile( + onTap: () { + Navigator.pop(btsContext); + mealPlanBloc.add(DeleteMealPlan(mealPlan: mealPlan)); + }, + leading: const Icon(Icons.delete_outline, color: Colors.redAccent), + title: Text( + AppLocalizations.of(context)!.mealPlanRemove, + style: const TextStyle(color: Colors.redAccent) ) - ] - ) - ) - ], - ), - ) + ) + ] + ) + ) + ], + ), ); } \ No newline at end of file diff --git a/lib/components/bottom_sheets/meal_plan_more_bottom_sheet_component.dart b/lib/components/bottom_sheets/meal_plan_more_bottom_sheet_component.dart index f781d36..52d9eb3 100644 --- a/lib/components/bottom_sheets/meal_plan_more_bottom_sheet_component.dart +++ b/lib/components/bottom_sheets/meal_plan_more_bottom_sheet_component.dart @@ -5,64 +5,43 @@ import 'package:untare/components/dialogs/edit_meal_type_dialog.dart'; Future mealPlanMoreBottomSheet(BuildContext context) { return showModalBottomSheet( - backgroundColor: Colors.transparent, + showDragHandle: true, useRootNavigator: true, context: context, - builder: (btsContext) => Container( - decoration: BoxDecoration( - color: Theme.of(context).scaffoldBackgroundColor, - borderRadius: const BorderRadius.all(Radius.circular(10)) - ), - child: Wrap( - spacing: 15, - children: [ - Container( - height: 44, + builder: (btsContext) => Wrap( + spacing: 15, + children: [ + Container( alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: const BorderRadius.vertical(top: Radius.circular(10)), - ), - child: Text( - AppLocalizations.of(context)!.mealPlanTitle, - textAlign: TextAlign.center, - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18 - ), - ), - ), - Container( - alignment: Alignment.center, - padding: const EdgeInsets.only(left: 12, right: 12, bottom: 6), - child: Column( - children: [ - ListTile( - minLeadingWidth: 35, - onTap: () { - Navigator.pop(btsContext); - editMealTypeDialog(context); - }, - leading: const Icon(Icons.edit_outlined), - title: Text(AppLocalizations.of(context)!.editMealType), - ), - const Divider(), - ListTile( - minLeadingWidth: 35, - onTap: () { - Navigator.pop(btsContext); - deleteMealTypeDialog(context); - }, - leading: const Icon(Icons.delete_outline, color: Colors.redAccent), - title: Text( - AppLocalizations.of(context)!.removeMealType, - style: const TextStyle(color: Colors.redAccent), - ) + padding: const EdgeInsets.only(left: 12, right: 12, bottom: 6), + child: Column( + children: [ + ListTile( + minLeadingWidth: 35, + onTap: () { + Navigator.pop(btsContext); + editMealTypeDialog(context); + }, + leading: const Icon(Icons.edit_outlined), + title: Text(AppLocalizations.of(context)!.editMealType), + ), + const Divider(), + ListTile( + minLeadingWidth: 35, + onTap: () { + Navigator.pop(btsContext); + deleteMealTypeDialog(context); + }, + leading: const Icon(Icons.delete_outline, color: Colors.redAccent), + title: Text( + AppLocalizations.of(context)!.removeMealType, + style: const TextStyle(color: Colors.redAccent), ) - ] - ) - ) - ], - ), - ) + ) + ] + ) + ) + ], + ), ); } \ No newline at end of file diff --git a/lib/components/bottom_sheets/recipe_more_bottom_sheet_component.dart b/lib/components/bottom_sheets/recipe_more_bottom_sheet_component.dart index fb135f0..dd6f675 100644 --- a/lib/components/bottom_sheets/recipe_more_bottom_sheet_component.dart +++ b/lib/components/bottom_sheets/recipe_more_bottom_sheet_component.dart @@ -4,37 +4,31 @@ import 'package:untare/models/recipe.dart'; Future recipeMoreBottomSheet(BuildContext context, Recipe recipe) { return showModalBottomSheet( - backgroundColor: Colors.transparent, + showDragHandle: true, useRootNavigator: true, context: context, - builder: (btsContext) => Container( - decoration: BoxDecoration( - color: Theme.of(context).scaffoldBackgroundColor, - borderRadius: const BorderRadius.all(Radius.circular(10)) - ), - child: Wrap( - spacing: 15, - children: [ - Container( - height: 44, - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: const BorderRadius.vertical(top: Radius.circular(10)), - ), - child: Text( - recipe.name, - textAlign: TextAlign.center, - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18 - ), - maxLines: 1, - overflow: TextOverflow.ellipsis, + builder: (btsContext) => Wrap( + spacing: 15, + children: [ + Container( + height: 44, + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: const BorderRadius.vertical(top: Radius.circular(10)), + ), + child: Text( + recipe.name, + textAlign: TextAlign.center, + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18 ), + maxLines: 1, + overflow: TextOverflow.ellipsis, ), - buildRecipeMore(context, btsContext, recipe) - ], - ), - ) + ), + buildRecipeMore(context, btsContext, recipe) + ], + ), ); } \ No newline at end of file diff --git a/lib/components/bottom_sheets/recipe_shopping_list_bottom_sheet_component.dart b/lib/components/bottom_sheets/recipe_shopping_list_bottom_sheet_component.dart index 79db107..27858b1 100644 --- a/lib/components/bottom_sheets/recipe_shopping_list_bottom_sheet_component.dart +++ b/lib/components/bottom_sheets/recipe_shopping_list_bottom_sheet_component.dart @@ -6,36 +6,30 @@ import 'package:untare/models/recipe.dart'; Future recipeShoppingListBottomSheet(BuildContext context, Recipe recipe) { return showModalBottomSheet( isScrollControlled: true, - backgroundColor: Colors.transparent, + showDragHandle: true, useRootNavigator: true, context: context, - builder: (btsContext) => Container( - decoration: BoxDecoration( - color: Theme.of(context).scaffoldBackgroundColor, - borderRadius: const BorderRadius.all(Radius.circular(10)) - ), - child: Wrap( - children: [ - Container( - height: 44, - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: const BorderRadius.vertical(top: Radius.circular(10)), - ), - child: Text( - recipe.name, - textAlign: TextAlign.center, - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18 - ), - maxLines: 1, - overflow: TextOverflow.ellipsis, + builder: (btsContext) => Wrap( + children: [ + Container( + height: 44, + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: const BorderRadius.vertical(top: Radius.circular(10)), + ), + child: Text( + recipe.name, + textAlign: TextAlign.center, + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18 ), + maxLines: 1, + overflow: TextOverflow.ellipsis, ), - SizedBox(height: 600,child: RecipeShoppingListWidget(recipe: recipe, btsContext: btsContext)) - ], - ), - ) + ), + SizedBox(height: 600,child: RecipeShoppingListWidget(recipe: recipe, btsContext: btsContext)) + ], + ), ); } \ No newline at end of file diff --git a/lib/components/bottom_sheets/recipes_more_bottom_sheet_component.dart b/lib/components/bottom_sheets/recipes_more_bottom_sheet_component.dart index a7ebf90..cb72af6 100644 --- a/lib/components/bottom_sheets/recipes_more_bottom_sheet_component.dart +++ b/lib/components/bottom_sheets/recipes_more_bottom_sheet_component.dart @@ -5,64 +5,44 @@ import 'package:untare/pages/units_page.dart'; Future recipesBottomSheet(BuildContext context) { return showModalBottomSheet( - backgroundColor: Colors.transparent, + showDragHandle: true, useRootNavigator: true, context: context, - builder: (btsContext) => Container( - decoration: BoxDecoration( - color: Theme.of(context).scaffoldBackgroundColor, - borderRadius: const BorderRadius.all(Radius.circular(10)) - ), - child: Wrap( - children: [ - Container( - height: 44, - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: const BorderRadius.vertical(top: Radius.circular(10)), - ), - child: Text( - AppLocalizations.of(context)!.recipesTitle, - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18 + builder: (btsContext) => Wrap( + children: [ + Container( + alignment: Alignment.center, + padding: const EdgeInsets.only(left: 12, right: 12), + child: Column( + children: [ + ListTile( + minLeadingWidth: 35, + onTap: () { + Navigator.pop(btsContext); + Navigator.push( + context, + MaterialPageRoute(builder: (context) => const FoodsPage()), + ); + }, + leading: const Icon(Icons.edit_note_outlined), + title: Text(AppLocalizations.of(context)!.manageFoods), ), - ), - ), - Container( - alignment: Alignment.center, - padding: const EdgeInsets.only(left: 12, right: 12), - child: Column( - children: [ - ListTile( + ListTile( minLeadingWidth: 35, onTap: () { Navigator.pop(btsContext); Navigator.push( context, - MaterialPageRoute(builder: (context) => const FoodsPage()), + MaterialPageRoute(builder: (context) => const UnitsPage()), ); }, leading: const Icon(Icons.edit_note_outlined), - title: Text(AppLocalizations.of(context)!.manageFoods), - ), - ListTile( - minLeadingWidth: 35, - onTap: () { - Navigator.pop(btsContext); - Navigator.push( - context, - MaterialPageRoute(builder: (context) => const UnitsPage()), - ); - }, - leading: const Icon(Icons.edit_note_outlined), - title: Text(AppLocalizations.of(context)!.manageUnits) - ) - ], - ), - ) - ], - ), - ) + title: Text(AppLocalizations.of(context)!.manageUnits) + ) + ], + ), + ) + ], + ), ); } \ No newline at end of file diff --git a/lib/components/bottom_sheets/settings_default_page_bottom_sheet_component.dart b/lib/components/bottom_sheets/settings_default_page_bottom_sheet_component.dart index 552703e..eef5324 100644 --- a/lib/components/bottom_sheets/settings_default_page_bottom_sheet_component.dart +++ b/lib/components/bottom_sheets/settings_default_page_bottom_sheet_component.dart @@ -5,61 +5,41 @@ import 'package:untare/cubits/settings_cubit.dart'; Future settingsDefaultPageBottomSheet(BuildContext context) { return showModalBottomSheet( - backgroundColor: Colors.transparent, + showDragHandle: true, useRootNavigator: true, context: context, - builder: (btsContext) => Container( - decoration: BoxDecoration( - color: Theme.of(context).scaffoldBackgroundColor, - borderRadius: const BorderRadius.all(Radius.circular(10)) - ), - child: Wrap( - children: [ - Container( - height: 44, - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: const BorderRadius.vertical(top: Radius.circular(10)), - ), - child: Text( - AppLocalizations.of(context)!.settingsDefaultPage, - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18 + builder: (btsContext) => Wrap( + children: [ + Container( + alignment: Alignment.center, + padding: const EdgeInsets.only(left: 12, right: 12), + child: Column( + children: [ + ListTile( + onTap: () { + context.read().changeDefaultPageTo('plan'); + Navigator.pop(btsContext); + }, + title: Text(AppLocalizations.of(context)!.mealPlanTitle), ), - ), + ListTile( + onTap: () { + context.read().changeDefaultPageTo('recipes'); + Navigator.pop(btsContext); + }, + title: Text(AppLocalizations.of(context)!.recipesTitle), + ), + ListTile( + onTap: () { + context.read().changeDefaultPageTo('shopping'); + Navigator.pop(btsContext); + }, + title: Text(AppLocalizations.of(context)!.shoppingListTitle), + ) + ], ), - Container( - alignment: Alignment.center, - padding: const EdgeInsets.only(left: 12, right: 12), - child: Column( - children: [ - ListTile( - onTap: () { - context.read().changeDefaultPageTo('plan'); - Navigator.pop(btsContext); - }, - title: Text(AppLocalizations.of(context)!.mealPlanTitle), - ), - ListTile( - onTap: () { - context.read().changeDefaultPageTo('recipes'); - Navigator.pop(btsContext); - }, - title: Text(AppLocalizations.of(context)!.recipesTitle), - ), - ListTile( - onTap: () { - context.read().changeDefaultPageTo('shopping'); - Navigator.pop(btsContext); - }, - title: Text(AppLocalizations.of(context)!.shoppingListTitle), - ) - ], - ), - ) - ], - ), - ) + ) + ], + ), ); } \ No newline at end of file diff --git a/lib/components/bottom_sheets/settings_layout_bottom_sheet_component.dart b/lib/components/bottom_sheets/settings_layout_bottom_sheet_component.dart index 8198909..3abc004 100644 --- a/lib/components/bottom_sheets/settings_layout_bottom_sheet_component.dart +++ b/lib/components/bottom_sheets/settings_layout_bottom_sheet_component.dart @@ -5,54 +5,34 @@ import 'package:untare/cubits/settings_cubit.dart'; Future settingsLayoutBottomSheet(BuildContext context) { return showModalBottomSheet( - backgroundColor: Colors.transparent, + showDragHandle: true, useRootNavigator: true, context: context, - builder: (btsContext) => Container( - decoration: BoxDecoration( - color: Theme.of(context).scaffoldBackgroundColor, - borderRadius: const BorderRadius.all(Radius.circular(10)) - ), - child: Wrap( - children: [ - Container( - height: 44, - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: const BorderRadius.vertical(top: Radius.circular(10)), - ), - child: Text( - AppLocalizations.of(context)!.settingsRecipeLayout, - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18 + builder: (btsContext) => Wrap( + children: [ + Container( + alignment: Alignment.center, + padding: const EdgeInsets.only(left: 12, right: 12), + child: Column( + children: [ + ListTile( + onTap: () { + context.read().changeLayoutTo('card'); + Navigator.pop(btsContext); + }, + title: Text(AppLocalizations.of(context)!.settingRecipeLayoutCard), ), - ), + ListTile( + onTap: () { + context.read().changeLayoutTo('list'); + Navigator.pop(btsContext); + }, + title: Text(AppLocalizations.of(context)!.settingRecipeLayoutList), + ) + ], ), - Container( - alignment: Alignment.center, - padding: const EdgeInsets.only(left: 12, right: 12), - child: Column( - children: [ - ListTile( - onTap: () { - context.read().changeLayoutTo('card'); - Navigator.pop(btsContext); - }, - title: Text(AppLocalizations.of(context)!.settingRecipeLayoutCard), - ), - ListTile( - onTap: () { - context.read().changeLayoutTo('list'); - Navigator.pop(btsContext); - }, - title: Text(AppLocalizations.of(context)!.settingRecipeLayoutList), - ) - ], - ), - ) - ], - ), - ) + ) + ], + ), ); } \ No newline at end of file diff --git a/lib/components/bottom_sheets/settings_theme_bottom_sheet_component.dart b/lib/components/bottom_sheets/settings_theme_bottom_sheet_component.dart index 6636604..4f833fb 100644 --- a/lib/components/bottom_sheets/settings_theme_bottom_sheet_component.dart +++ b/lib/components/bottom_sheets/settings_theme_bottom_sheet_component.dart @@ -5,61 +5,41 @@ import 'package:untare/cubits/settings_cubit.dart'; Future settingsThemeBottomSheet(BuildContext context) { return showModalBottomSheet( - backgroundColor: Colors.transparent, + showDragHandle: true, useRootNavigator: true, context: context, - builder: (btsContext) => Container( - decoration: BoxDecoration( - color: Theme.of(context).scaffoldBackgroundColor, - borderRadius: const BorderRadius.all(Radius.circular(10)) - ), - child: Wrap( - children: [ - Container( - height: 44, - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: const BorderRadius.vertical(top: Radius.circular(10)), - ), - child: Text( - AppLocalizations.of(context)!.settingsThemeMode, - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18 + builder: (btsContext) => Wrap( + children: [ + Container( + alignment: Alignment.center, + padding: const EdgeInsets.only(left: 12, right: 12), + child: Column( + children: [ + ListTile( + onTap: () { + context.read().changeThemeTo('dark'); + Navigator.pop(btsContext); + }, + title: Text(AppLocalizations.of(context)!.settingsDarkMode), ), - ), + ListTile( + onTap: () { + context.read().changeThemeTo('light'); + Navigator.pop(btsContext); + }, + title: Text(AppLocalizations.of(context)!.settingsLightMode), + ), + ListTile( + onTap: () { + context.read().changeThemeTo('system'); + Navigator.pop(btsContext); + }, + title: Text(AppLocalizations.of(context)!.settingsSystemMode), + ) + ], ), - Container( - alignment: Alignment.center, - padding: const EdgeInsets.only(left: 12, right: 12), - child: Column( - children: [ - ListTile( - onTap: () { - context.read().changeThemeTo('dark'); - Navigator.pop(btsContext); - }, - title: Text(AppLocalizations.of(context)!.settingsDarkMode), - ), - ListTile( - onTap: () { - context.read().changeThemeTo('light'); - Navigator.pop(btsContext); - }, - title: Text(AppLocalizations.of(context)!.settingsLightMode), - ), - ListTile( - onTap: () { - context.read().changeThemeTo('system'); - Navigator.pop(btsContext); - }, - title: Text(AppLocalizations.of(context)!.settingsSystemMode), - ) - ], - ), - ) - ], - ), - ) + ) + ], + ), ); } \ No newline at end of file diff --git a/lib/components/bottom_sheets/shopping_list_more_bottom_sheet_component.dart b/lib/components/bottom_sheets/shopping_list_more_bottom_sheet_component.dart index 28c2e87..7c66ff5 100644 --- a/lib/components/bottom_sheets/shopping_list_more_bottom_sheet_component.dart +++ b/lib/components/bottom_sheets/shopping_list_more_bottom_sheet_component.dart @@ -1,38 +1,16 @@ import 'package:flutter/material.dart'; import 'package:untare/components/widgets/bottom_sheets/shopping_list_more_component.dart'; -import 'package:flutter_gen/gen_l10n/app_locales.dart'; Future shoppingListMoreBottomSheet(BuildContext context) { return showModalBottomSheet( - backgroundColor: Colors.transparent, + showDragHandle: true, useRootNavigator: true, context: context, - builder: (btsContext) => Container( - decoration: BoxDecoration( - color: Theme.of(context).scaffoldBackgroundColor, - borderRadius: const BorderRadius.all(Radius.circular(10)) - ), - child: Wrap( - spacing: 15, - children: [ - Container( - height: 44, - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: const BorderRadius.vertical(top: Radius.circular(10)), - ), - child: Text( - AppLocalizations.of(context)!.shoppingListTitle, - textAlign: TextAlign.center, - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18 - ), - ), - ), - buildShoppingListMore(context, btsContext) - ], - ), - ) + builder: (btsContext) => Wrap( + spacing: 15, + children: [ + buildShoppingListMore(context, btsContext) + ], + ), ); } \ No newline at end of file diff --git a/lib/components/bottom_sheets/sort_bottom_sheet_component.dart b/lib/components/bottom_sheets/sort_bottom_sheet_component.dart index aa0d2d9..2595285 100644 --- a/lib/components/bottom_sheets/sort_bottom_sheet_component.dart +++ b/lib/components/bottom_sheets/sort_bottom_sheet_component.dart @@ -4,34 +4,28 @@ import 'package:flutter_gen/gen_l10n/app_locales.dart'; Future sortBottomSheet(BuildContext context, Function(String, bool) sortButtonPressed, Map sortMap) { return showModalBottomSheet( - backgroundColor: Colors.transparent, + showDragHandle: true, useRootNavigator: true, context: context, - builder: (context) => Container( - decoration: BoxDecoration( - color: Theme.of(context).scaffoldBackgroundColor, - borderRadius: const BorderRadius.all(Radius.circular(10)) - ), - child: Wrap( - spacing: 15, - children: [ - Container( - height: 44, - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: const BorderRadius.vertical(top: Radius.circular(10)), - ), - child: Text( - AppLocalizations.of(context)!.sortBy, - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18 - ), + builder: (context) => Wrap( + spacing: 15, + children: [ + Container( + height: 44, + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: const BorderRadius.vertical(top: Radius.circular(10)), + ), + child: Text( + AppLocalizations.of(context)!.sortBy, + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18 ), ), - buildSort(context, sortButtonPressed, sortMap) - ], - ), - ) + ), + buildSort(context, sortButtonPressed, sortMap) + ], + ), ); } \ No newline at end of file From cd5ce30108dbc433f5d7ca452490c0286df43213 Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 08:10:20 +0200 Subject: [PATCH 08/34] Refactor recipe grid components --- lib/components/recipes/recipe_grid_component.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/components/recipes/recipe_grid_component.dart b/lib/components/recipes/recipe_grid_component.dart index f883a75..932aa3d 100644 --- a/lib/components/recipes/recipe_grid_component.dart +++ b/lib/components/recipes/recipe_grid_component.dart @@ -11,7 +11,7 @@ import 'package:untare/pages/recipe_detail_page.dart'; Widget recipeGridComponent(Recipe recipe, BuildContext context, {String? referer, MealPlanEntry? mealPlan, bool? disabled}) { BoxDecoration recipeTimeDecoration = BoxDecoration( - color: (Theme.of(context).brightness.name == 'light') ? Colors.white.withOpacity(0.8) : Colors.grey[800]!.withOpacity(0.8), + color: Theme.of(context).colorScheme.tertiaryContainer, borderRadius: BorderRadius.circular(30) ); @@ -28,7 +28,7 @@ Widget recipeGridComponent(Recipe recipe, BuildContext context, {String? referer } if (mealPlan != null) { widgets.add( - Flexible(child: Text(mealPlan.mealType.name, style: const TextStyle(fontSize: 11))) + Flexible(child: Text(mealPlan.mealType.name, style: TextStyle(fontSize: 11, color: Theme.of(context).colorScheme.onTertiaryContainer))) ); } @@ -88,7 +88,7 @@ Widget recipeGridComponent(Recipe recipe, BuildContext context, {String? referer padding: const EdgeInsets.fromLTRB(5, 3, 5, 3), margin: const EdgeInsets.all(5), decoration: BoxDecoration( - color: (Theme.of(context).brightness.name == 'light') ? Colors.white.withOpacity(0.8) : Colors.grey[800]!.withOpacity(0.8), + color: Theme.of(context).colorScheme.tertiaryContainer, borderRadius: BorderRadius.circular(30) ), child: Row( From bb092da75841934e6b5bce2f8c10907960ed0932 Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 08:12:37 +0200 Subject: [PATCH 09/34] Remove bottom sheet name --- .../recipe_more_bottom_sheet_component.dart | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/lib/components/bottom_sheets/recipe_more_bottom_sheet_component.dart b/lib/components/bottom_sheets/recipe_more_bottom_sheet_component.dart index dd6f675..3a147ff 100644 --- a/lib/components/bottom_sheets/recipe_more_bottom_sheet_component.dart +++ b/lib/components/bottom_sheets/recipe_more_bottom_sheet_component.dart @@ -10,23 +10,6 @@ Future recipeMoreBottomSheet(BuildContext context, Recipe recipe) { builder: (btsContext) => Wrap( spacing: 15, children: [ - Container( - height: 44, - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: const BorderRadius.vertical(top: Radius.circular(10)), - ), - child: Text( - recipe.name, - textAlign: TextAlign.center, - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18 - ), - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - ), buildRecipeMore(context, btsContext, recipe) ], ), From a08a38140dcfc782eac179a4f450eb589e9914b3 Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 08:25:22 +0200 Subject: [PATCH 10/34] Update recipe detail tabbar widget --- .../widgets/recipe_detail_tabbar_widget.dart | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/lib/components/widgets/recipe_detail_tabbar_widget.dart b/lib/components/widgets/recipe_detail_tabbar_widget.dart index f464cf4..544eeb7 100644 --- a/lib/components/widgets/recipe_detail_tabbar_widget.dart +++ b/lib/components/widgets/recipe_detail_tabbar_widget.dart @@ -88,9 +88,8 @@ class RecipeDetailTabBarWidgetState extends State { onPressed: () => { decrement() }, - icon: Icon( + icon: const Icon( Icons.remove_circle_outline, - color: Theme.of(context).primaryColor, ), ), Text(newServings.toString()), @@ -98,9 +97,8 @@ class RecipeDetailTabBarWidgetState extends State { onPressed: () => { increment() }, - icon: Icon( + icon: const Icon( Icons.add_circle_outline_outlined, - color: Theme.of(context).primaryColor, ) ) ], @@ -154,9 +152,9 @@ class RecipeDetailTabBarWidgetState extends State { ), title: Text( recipe.steps[i].stepRecipeData!.name, - style: TextStyle(color: Theme.of(context).primaryColor, fontWeight: FontWeight.w600), + style: const TextStyle(fontWeight: FontWeight.w600), ), - trailing: Icon(Icons.arrow_forward_outlined, color: Theme.of(context).primaryColor), + trailing: const Icon(Icons.arrow_forward_outlined), ), ) ); @@ -234,9 +232,9 @@ class RecipeDetailTabBarWidgetState extends State { alignment: Alignment.center, decoration: BoxDecoration( shape: BoxShape.circle, - border: Border.all(color: Theme.of(context).primaryColor, width: 2), + border: Border.all(color: Theme.of(context).colorScheme.secondary, width: 2), ), - child:Text((stepNumber).toString(), style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Theme.of(context).primaryColor)), + child: Text((stepNumber).toString(), style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold)), ) ), if (stepName != null && stepName != '') @@ -254,11 +252,7 @@ class RecipeDetailTabBarWidgetState extends State { Icon(Icons.timer_outlined, size: 15.5, color: (Theme.of(context).brightness.name == 'light') ? Colors.black45 : Colors.grey[600]!), Text( ' $stepTime min', - style: TextStyle( - fontStyle: FontStyle.italic, - color: (Theme.of(context).brightness.name == 'light') ? Colors.black45 : Colors.grey[600]!, - fontSize: 15.5 - ) + style: const TextStyle(fontStyle: FontStyle.italic, fontSize: 15.5) ) ], ) @@ -266,7 +260,7 @@ class RecipeDetailTabBarWidgetState extends State { ), IconButton( icon: const Icon(Icons.check), - color: (collapsed) ? Theme.of(context).primaryColor : ((Theme.of(context).brightness.name == 'light') ? Colors.black45 : Colors.grey[600]!), + color: (collapsed) ? Theme.of(context).colorScheme.secondary.withOpacity(0.5) : Theme.of(context).colorScheme.secondary, onPressed: () { setState(() { collapsed = !collapsed; @@ -280,7 +274,7 @@ class RecipeDetailTabBarWidgetState extends State { decoration: BoxDecoration( border: Border( left: BorderSide( - color: Theme.of(context).primaryColor, + color: Theme.of(context).colorScheme.secondary, width: 1 ) ) @@ -356,7 +350,7 @@ class RecipeDetailTabBarWidgetState extends State { ), child: Text( food, - style: TextStyle(color: Theme.of(context).primaryColor, fontWeight: FontWeight.w600), + style: const TextStyle(fontWeight: FontWeight.w600), ), ), if (recipe == null) From 6f9244b73ebe96d6f4c062e9ee8aad784a8098a4 Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 09:02:53 +0200 Subject: [PATCH 11/34] Migrate MaterialButtons --- .../dialogs/add_shopping_list_entry_dialog.dart | 3 +-- .../dialogs/delete_meal_type_dialog.dart | 3 +-- lib/components/dialogs/delete_recipe_dialog.dart | 7 +++---- .../delete_supermarket_category_dialog.dart | 3 +-- lib/components/dialogs/edit_food_dialog.dart | 3 +-- .../dialogs/edit_meal_type_dialog.dart | 3 +-- lib/components/dialogs/edit_share_dialog.dart | 3 +-- .../dialogs/edit_shopping_list_entry_dialog.dart | 3 +-- .../edit_shopping_list_recent_days_dialog.dart | 3 +-- .../edit_shopping_list_refresh_dialog.dart | 3 +-- .../edit_supermarket_category_dialog.dart | 3 +-- lib/components/dialogs/edit_unit_dialog.dart | 3 +-- .../dialogs/import_recipe_website_dialog.dart | 3 +-- .../dialogs/upsert_meal_plan_entry_dialog.dart | 3 +-- .../dialogs/upsert_recipe_ingredient_dialog.dart | 3 +-- .../dialogs/upsert_recipe_step_time_dialog.dart | 3 +-- .../recipe_shopping_list_stateful_widget.dart | 4 +--- lib/pages/starting_page.dart | 16 +++------------- 18 files changed, 22 insertions(+), 50 deletions(-) diff --git a/lib/components/dialogs/add_shopping_list_entry_dialog.dart b/lib/components/dialogs/add_shopping_list_entry_dialog.dart index a504c1a..6c1bbf1 100644 --- a/lib/components/dialogs/add_shopping_list_entry_dialog.dart +++ b/lib/components/dialogs/add_shopping_list_entry_dialog.dart @@ -72,8 +72,7 @@ Future addShoppingListEntryDialog(BuildContext context) { ) ), const SizedBox(height: 15), - MaterialButton( - color: Theme.of(context).primaryColor, + ElevatedButton( child: Text(AppLocalizations.of(context)!.add), onPressed: () { formBuilderKey.currentState!.save(); diff --git a/lib/components/dialogs/delete_meal_type_dialog.dart b/lib/components/dialogs/delete_meal_type_dialog.dart index ee50eb6..d4419b6 100644 --- a/lib/components/dialogs/delete_meal_type_dialog.dart +++ b/lib/components/dialogs/delete_meal_type_dialog.dart @@ -50,8 +50,7 @@ Future deleteMealTypeDialog(BuildContext context) async { const SizedBox(height: 15), Container( alignment: Alignment.bottomRight, - child: MaterialButton( - color: Theme.of(context).primaryColor, + child: ElevatedButton( onPressed: () { formBuilderKey.currentState!.save(); diff --git a/lib/components/dialogs/delete_recipe_dialog.dart b/lib/components/dialogs/delete_recipe_dialog.dart index 7c108e2..35b305c 100644 --- a/lib/components/dialogs/delete_recipe_dialog.dart +++ b/lib/components/dialogs/delete_recipe_dialog.dart @@ -24,16 +24,15 @@ Future deleteRecipeDialog(BuildContext context, Recipe recipe) async { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - MaterialButton( - color: Colors.redAccent, + ElevatedButton( + style: ElevatedButton.styleFrom(backgroundColor: Colors.redAccent, foregroundColor: Colors.white), onPressed: () { recipeBloc.add(DeleteRecipe(recipe: recipe)); Navigator.pop(dContext); }, child: Text(AppLocalizations.of(context)!.remove) ), - MaterialButton( - color: Theme.of(context).primaryColor, + ElevatedButton( onPressed: () { Navigator.pop(dContext); }, diff --git a/lib/components/dialogs/delete_supermarket_category_dialog.dart b/lib/components/dialogs/delete_supermarket_category_dialog.dart index 3d379ea..b4a02fb 100644 --- a/lib/components/dialogs/delete_supermarket_category_dialog.dart +++ b/lib/components/dialogs/delete_supermarket_category_dialog.dart @@ -49,8 +49,7 @@ Future deleteSupermarketCategoryDialog(BuildContext context) async { const SizedBox(height: 15), Container( alignment: Alignment.bottomRight, - child: MaterialButton( - color: Theme.of(context).primaryColor, + child: ElevatedButton( onPressed: () { formBuilderKey.currentState!.save(); diff --git a/lib/components/dialogs/edit_food_dialog.dart b/lib/components/dialogs/edit_food_dialog.dart index b5e78c7..ad6cd0c 100644 --- a/lib/components/dialogs/edit_food_dialog.dart +++ b/lib/components/dialogs/edit_food_dialog.dart @@ -50,8 +50,7 @@ Future editFoodDialog(BuildContext context, Food food) { const SizedBox(height: 15), Container( alignment: Alignment.bottomRight, - child: MaterialButton( - color: Theme.of(context).primaryColor, + child: ElevatedButton( onPressed: () { formBuilderKey.currentState!.save(); if (formBuilderKey.currentState!.validate()) { diff --git a/lib/components/dialogs/edit_meal_type_dialog.dart b/lib/components/dialogs/edit_meal_type_dialog.dart index aa96aa9..47d9b16 100644 --- a/lib/components/dialogs/edit_meal_type_dialog.dart +++ b/lib/components/dialogs/edit_meal_type_dialog.dart @@ -76,8 +76,7 @@ Future editMealTypeDialog(BuildContext context) async { const SizedBox(height: 15), Container( alignment: Alignment.bottomRight, - child: MaterialButton( - color: Theme.of(context).primaryColor, + child: ElevatedButton( onPressed: isVisible ? () { formBuilderKey.currentState!.save(); diff --git a/lib/components/dialogs/edit_share_dialog.dart b/lib/components/dialogs/edit_share_dialog.dart index fba7b35..9c31b08 100644 --- a/lib/components/dialogs/edit_share_dialog.dart +++ b/lib/components/dialogs/edit_share_dialog.dart @@ -60,8 +60,7 @@ Future editShareDialog(BuildContext context, UserSetting userSetting, String ref const SizedBox(height: 15), Container( alignment: Alignment.bottomRight, - child: MaterialButton( - color: Theme.of(context).primaryColor, + child: ElevatedButton( onPressed: () { formBuilderKey.currentState!.save(); diff --git a/lib/components/dialogs/edit_shopping_list_entry_dialog.dart b/lib/components/dialogs/edit_shopping_list_entry_dialog.dart index 2d5c746..b07d40f 100644 --- a/lib/components/dialogs/edit_shopping_list_entry_dialog.dart +++ b/lib/components/dialogs/edit_shopping_list_entry_dialog.dart @@ -51,8 +51,7 @@ Future editShoppingListEntryDialog(BuildContext context, ShoppingListEntry shopp const SizedBox(height: 15), Container( alignment: Alignment.bottomRight, - child: MaterialButton( - color: Theme.of(context).primaryColor, + child: ElevatedButton( onPressed: () { formBuilderKey.currentState!.save(); if (formBuilderKey.currentState!.validate()) { diff --git a/lib/components/dialogs/edit_shopping_list_recent_days_dialog.dart b/lib/components/dialogs/edit_shopping_list_recent_days_dialog.dart index 08c322b..e003df5 100644 --- a/lib/components/dialogs/edit_shopping_list_recent_days_dialog.dart +++ b/lib/components/dialogs/edit_shopping_list_recent_days_dialog.dart @@ -45,8 +45,7 @@ Future editShoppingListRecentDaysDialog(BuildContext context, UserSetting userSe const SizedBox(height: 15), Container( alignment: Alignment.bottomRight, - child: MaterialButton( - color: Theme.of(context).primaryColor, + child: ElevatedButton( onPressed: () { formBuilderKey.currentState!.save(); diff --git a/lib/components/dialogs/edit_shopping_list_refresh_dialog.dart b/lib/components/dialogs/edit_shopping_list_refresh_dialog.dart index fb1212e..dd8ed07 100644 --- a/lib/components/dialogs/edit_shopping_list_refresh_dialog.dart +++ b/lib/components/dialogs/edit_shopping_list_refresh_dialog.dart @@ -45,8 +45,7 @@ Future editShoppingListRefreshDialog(BuildContext context, UserSetting userSetti const SizedBox(height: 15), Container( alignment: Alignment.bottomRight, - child: MaterialButton( - color: Theme.of(context).primaryColor, + child: ElevatedButton( onPressed: () { formBuilderKey.currentState!.save(); diff --git a/lib/components/dialogs/edit_supermarket_category_dialog.dart b/lib/components/dialogs/edit_supermarket_category_dialog.dart index f8950a5..4e62cf9 100644 --- a/lib/components/dialogs/edit_supermarket_category_dialog.dart +++ b/lib/components/dialogs/edit_supermarket_category_dialog.dart @@ -76,8 +76,7 @@ Future editSupermarketCategoryDialog(BuildContext context) async { const SizedBox(height: 15), Container( alignment: Alignment.bottomRight, - child: MaterialButton( - color: Theme.of(context).primaryColor, + child: ElevatedButton( onPressed: isVisible ? () { formBuilderKey.currentState!.save(); diff --git a/lib/components/dialogs/edit_unit_dialog.dart b/lib/components/dialogs/edit_unit_dialog.dart index 7913e9d..2833fbb 100644 --- a/lib/components/dialogs/edit_unit_dialog.dart +++ b/lib/components/dialogs/edit_unit_dialog.dart @@ -50,8 +50,7 @@ Future editUnitDialog(BuildContext context, Unit unit) { const SizedBox(height: 15), Container( alignment: Alignment.bottomRight, - child: MaterialButton( - color: Theme.of(context).primaryColor, + child: ElevatedButton( onPressed: () { formBuilderKey.currentState!.save(); if (formBuilderKey.currentState!.validate()) { diff --git a/lib/components/dialogs/import_recipe_website_dialog.dart b/lib/components/dialogs/import_recipe_website_dialog.dart index e051215..9c071dd 100644 --- a/lib/components/dialogs/import_recipe_website_dialog.dart +++ b/lib/components/dialogs/import_recipe_website_dialog.dart @@ -55,8 +55,7 @@ Future importRecipeWebsiteDialog(BuildContext context) { ), Container( alignment: Alignment.bottomRight, - child: MaterialButton( - color: Theme.of(context).primaryColor, + child: ElevatedButton( onPressed: () { formBuilderKey.currentState!.save(); diff --git a/lib/components/dialogs/upsert_meal_plan_entry_dialog.dart b/lib/components/dialogs/upsert_meal_plan_entry_dialog.dart index ffa1390..e458f39 100644 --- a/lib/components/dialogs/upsert_meal_plan_entry_dialog.dart +++ b/lib/components/dialogs/upsert_meal_plan_entry_dialog.dart @@ -136,8 +136,7 @@ Future upsertMealPlanEntryDialog(BuildContext context, {MealPlanEntry? mealPlan, const SizedBox(height: 15), Container( alignment: Alignment.bottomRight, - child: MaterialButton( - color: Theme.of(context).primaryColor, + child: ElevatedButton( onPressed: () { formBuilderKey.currentState!.save(); if (formBuilderKey.currentState!.validate()) { diff --git a/lib/components/dialogs/upsert_recipe_ingredient_dialog.dart b/lib/components/dialogs/upsert_recipe_ingredient_dialog.dart index b2784df..3002d7e 100644 --- a/lib/components/dialogs/upsert_recipe_ingredient_dialog.dart +++ b/lib/components/dialogs/upsert_recipe_ingredient_dialog.dart @@ -48,8 +48,7 @@ Future upsertRecipeIngredientDialog(BuildContext context, int stepIndex, int ing const SizedBox(height: 10), Container( alignment: Alignment.bottomRight, - child: MaterialButton( - color: Theme.of(context).primaryColor, + child: ElevatedButton( child: Text((ingredient != null) ? AppLocalizations.of(context)!.edit : AppLocalizations.of(context)!.add), onPressed: () { diff --git a/lib/components/dialogs/upsert_recipe_step_time_dialog.dart b/lib/components/dialogs/upsert_recipe_step_time_dialog.dart index 2a12ff7..ea7df7f 100644 --- a/lib/components/dialogs/upsert_recipe_step_time_dialog.dart +++ b/lib/components/dialogs/upsert_recipe_step_time_dialog.dart @@ -36,8 +36,7 @@ Future upsertRecipeStepTimeDialog(BuildContext context, int stepIndex, Function( const SizedBox(height: 15), Container( alignment: Alignment.bottomRight, - child: MaterialButton( - color: Theme.of(context).primaryColor, + child: ElevatedButton( onPressed: () { formKey.currentState!.setInternalFieldValue('stepIndex', stepIndex); formKey.currentState!.save(); diff --git a/lib/components/widgets/recipe_shopping_list_stateful_widget.dart b/lib/components/widgets/recipe_shopping_list_stateful_widget.dart index 5c8b3f0..4db84bd 100644 --- a/lib/components/widgets/recipe_shopping_list_stateful_widget.dart +++ b/lib/components/widgets/recipe_shopping_list_stateful_widget.dart @@ -193,9 +193,7 @@ class RecipeShoppingListWidgetState extends State { ) ) ), - child: MaterialButton( - color: Theme.of(context).primaryColor, - minWidth: double.maxFinite, + child: ElevatedButton( child: Text(AppLocalizations.of(context)!.add), onPressed: () { recipeBloc.add(AddIngredientsToShoppingList( diff --git a/lib/pages/starting_page.dart b/lib/pages/starting_page.dart index 8998142..e032542 100644 --- a/lib/pages/starting_page.dart +++ b/lib/pages/starting_page.dart @@ -167,24 +167,17 @@ class __SignInFormState extends State<_SignInForm> { ])), )), const SizedBox(width: 10), - SizedBox( - width: 80, - child: MaterialButton( - color: Theme.of(context).primaryColor, - minWidth: double.maxFinite, - padding: const EdgeInsets.fromLTRB( - 8, 4.5, 8, 4.5), + ElevatedButton( child: Text( AppLocalizations.of(context)! .officialServer, style: const TextStyle(fontSize: 13), - textAlign: TextAlign.center), + ), onPressed: () { _urlController.text = 'https://app.tandoor.dev'; }, ), - ) ], ), const SizedBox(height: 15), @@ -226,10 +219,7 @@ class __SignInFormState extends State<_SignInForm> { ), ), const SizedBox(height: 15), - MaterialButton( - color: Theme.of(context).primaryColor, - minWidth: double.maxFinite, - padding: const EdgeInsets.fromLTRB(8, 5, 8, 5), + ElevatedButton( onPressed: onLoginButtonPressed, child: const Text('LOGIN'), ), From 67186e21917d5da8edbb538b16c734dacfb2b3aa Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 09:17:56 +0200 Subject: [PATCH 12/34] Migrate recipe_shopping_list_stateful_widget --- .../recipe_shopping_list_stateful_widget.dart | 26 +++++-------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/lib/components/widgets/recipe_shopping_list_stateful_widget.dart b/lib/components/widgets/recipe_shopping_list_stateful_widget.dart index 4db84bd..b7de3c3 100644 --- a/lib/components/widgets/recipe_shopping_list_stateful_widget.dart +++ b/lib/components/widgets/recipe_shopping_list_stateful_widget.dart @@ -146,9 +146,8 @@ class RecipeShoppingListWidgetState extends State { onPressed: () => { decrement() }, - icon: Icon( + icon: const Icon( Icons.remove_circle_outline, - color: Theme.of(context).primaryColor, ), ), Text(newServings.toString()), @@ -156,9 +155,8 @@ class RecipeShoppingListWidgetState extends State { onPressed: () => { increment() }, - icon: Icon( + icon: const Icon( Icons.add_circle_outline_outlined, - color: Theme.of(context).primaryColor, ) ) ], @@ -185,14 +183,6 @@ class RecipeShoppingListWidgetState extends State { ), child: Container( padding: const EdgeInsets.fromLTRB(20, 30, 20, 20), - decoration: BoxDecoration( - border: Border( - top: BorderSide( - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[300]! : Colors.grey[700]!, - width: 1 - ) - ) - ), child: ElevatedButton( child: Text(AppLocalizations.of(context)!.add), onPressed: () { @@ -257,7 +247,7 @@ class RecipeShoppingListWidgetState extends State { decoration: BoxDecoration( border: Border( bottom: BorderSide( - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[300]! : Colors.grey[700]!, + color: Theme.of(context).colorScheme.secondary.withOpacity(0.5), width: 0.8 ) ) @@ -268,12 +258,8 @@ class RecipeShoppingListWidgetState extends State { visualDensity: const VisualDensity(horizontal: 0, vertical: -3), contentPadding: const EdgeInsets.fromLTRB(0, 0, 0, 0), leading: Transform.scale( - scale: 1.2, - child: Checkbox( - activeColor: Theme.of(context).primaryColor, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(3) - ), + scale: 1.2, + child: Checkbox( onChanged: (bool? value) { setState(() { checkBoxValue = value; @@ -328,7 +314,7 @@ class RecipeShoppingListWidgetState extends State { icon: Icon( Icons.home_outlined, size: 21, - color: (ingredient.food != null && ingredient.food!.onHand!) ? Theme.of(context).primaryColor : null, + color: (ingredient.food != null && ingredient.food!.onHand!) ? Theme.of(context).colorScheme.secondary.withOpacity(0.5) : Theme.of(context).colorScheme.secondary, ) ), ], From a737d0de78ab708a64ffb34fea835f88ed96c564 Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 09:24:09 +0200 Subject: [PATCH 13/34] Align recipe view chips with other chips --- lib/pages/recipe_detail_page.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pages/recipe_detail_page.dart b/lib/pages/recipe_detail_page.dart index 6fcd9a6..43d7c43 100644 --- a/lib/pages/recipe_detail_page.dart +++ b/lib/pages/recipe_detail_page.dart @@ -398,10 +398,10 @@ Widget? getKeywordWidget(BuildContext context, Keyword keyword) { padding: const EdgeInsets.fromLTRB(5, 3, 5, 3), margin: const EdgeInsets.fromLTRB(5, 5, 0, 5), decoration: BoxDecoration( - color: (Theme.of(context).brightness.name == 'light') ? Colors.white.withOpacity(0.8) : Colors.grey[800]!.withOpacity(0.8), + color: Theme.of(context).colorScheme.tertiaryContainer, borderRadius: BorderRadius.circular(30) ), - child: Text(text, style: const TextStyle(fontSize: 11)) + child: Text(text, style: TextStyle(fontSize: 11, color: Theme.of(context).colorScheme.onTertiaryContainer)) ); } From 277ceb2aa73cd43c378bdc6940e424c09bf9dbdc Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 09:33:17 +0200 Subject: [PATCH 14/34] Update shopping list page --- lib/pages/shopping_list_page.dart | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/pages/shopping_list_page.dart b/lib/pages/shopping_list_page.dart index ebe0565..e635ecb 100644 --- a/lib/pages/shopping_list_page.dart +++ b/lib/pages/shopping_list_page.dart @@ -269,7 +269,7 @@ class ShoppingListPageState extends State with TickerProviderS groupSeparatorBuilder: (String groupByValue) { return Padding( padding: const EdgeInsets.fromLTRB(15, 25, 15, 5), - child: Text(groupByValue.toUpperCase(), style: const TextStyle(color: Colors.grey, fontWeight: FontWeight.bold)), + child: Text(groupByValue.toUpperCase(), style: TextStyle(color: Theme.of(context).colorScheme.secondary, fontWeight: FontWeight.bold)), ); }, itemComparator: (item1, item2) { @@ -311,7 +311,7 @@ class ShoppingListPageState extends State with TickerProviderS scale: 1.2, child: Checkbox( value: checkBoxValue, - activeColor: Theme.of(context).primaryColor, + activeColor: Theme.of(context).colorScheme.secondary, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(3) ), @@ -333,7 +333,7 @@ class ShoppingListPageState extends State with TickerProviderS title: Text( groupedList.first.food!.name, style: (checkBoxValue) - ? TextStyle(color: (Theme.of(context).brightness.name == 'light') ? Colors.black45 : Colors.grey[600]!, fontWeight: FontWeight.bold, decoration: TextDecoration.lineThrough) + ? const TextStyle(fontWeight: FontWeight.bold, decoration: TextDecoration.lineThrough) : const TextStyle(fontWeight: FontWeight.bold) ), leading: const Icon(Icons.keyboard_arrow_up), @@ -345,7 +345,7 @@ class ShoppingListPageState extends State with TickerProviderS decoration: BoxDecoration( border: Border( bottom: BorderSide( - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[300]! : Colors.grey[700]!, + color: Theme.of(context).colorScheme.secondary.withOpacity(0.5), width: 0.8 ) ) @@ -358,7 +358,7 @@ class ShoppingListPageState extends State with TickerProviderS scale: 1.2, child: Checkbox( value: checkBoxValue, - activeColor: Theme.of(context).primaryColor, + activeColor: Theme.of(context).colorScheme.secondary, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(3) ), @@ -380,7 +380,7 @@ class ShoppingListPageState extends State with TickerProviderS title: Text( groupedList.first.food!.name, style: (checkBoxValue) - ? TextStyle(color: (Theme.of(context).brightness.name == 'light') ? Colors.black45 : Colors.grey[600]!, fontWeight: FontWeight.bold, decoration: TextDecoration.lineThrough) + ? const TextStyle(fontWeight: FontWeight.bold, decoration: TextDecoration.lineThrough) : const TextStyle(fontWeight: FontWeight.bold) ), leading: const Icon(Icons.keyboard_arrow_down), @@ -460,7 +460,7 @@ class ShoppingListPageState extends State with TickerProviderS decoration: BoxDecoration( border: Border( bottom: BorderSide( - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[300]! : Colors.grey[700]!, + color: Theme.of(context).colorScheme.secondary.withOpacity(0.5), width: 0.8 ) ) @@ -480,19 +480,19 @@ class ShoppingListPageState extends State with TickerProviderS TextSpan(text: food, style: TextStyle(color: Theme.of(context).primaryTextTheme.bodyMedium!.color, fontWeight: (shoppingListEntry.food != null && shoppingListEntry.food!.recipe != null) ? FontWeight.bold : FontWeight.w400)), ], style: (checkBoxValue) - ? TextStyle(color: (Theme.of(context).brightness.name == 'light') ? Colors.black45 : Colors.grey[600]!, decoration: TextDecoration.lineThrough) + ? const TextStyle(decoration: TextDecoration.lineThrough) : null ) ) ] ), subtitle: (shoppingListEntry.recipeMealPlan != null) - ? Padding(padding: const EdgeInsets.only(top: 4), child: Text(shoppingListEntry.recipeMealPlan!.name, style: TextStyle(color: Colors.grey[600]!))) + ? Padding(padding: const EdgeInsets.only(top: 4), child: Text(shoppingListEntry.recipeMealPlan!.name)) : null, trailing: Transform.scale( scale: 1.2, child: Checkbox( - activeColor: Theme.of(context).primaryColor, + activeColor: Theme.of(context).colorScheme.secondary, value: checkBoxValue, onChanged: (bool? value) { setState(() { From 21628a6d3ab1b16c21f42a13d74112b4d294a843 Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 09:34:32 +0200 Subject: [PATCH 15/34] Update spaces page --- lib/pages/spaces_page.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pages/spaces_page.dart b/lib/pages/spaces_page.dart index 6df202d..59823de 100644 --- a/lib/pages/spaces_page.dart +++ b/lib/pages/spaces_page.dart @@ -41,7 +41,7 @@ class SpacesPageState extends State { onChanged: (bool? changed) { }, - activeColor: Theme.of(context).primaryColor, + activeColor: Theme.of(context).colorScheme.secondary, title: Wrap(children: [Text(spaces[index].name)]), subtitle: Wrap(direction: Axis.horizontal,children: [ Icon(Icons.restaurant_menu_outlined, size: 15, color: Theme.of(context).inputDecorationTheme.prefixIconColor), @@ -58,7 +58,7 @@ class SpacesPageState extends State { ],), ), separatorBuilder: (context, index) => Divider( - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[300]! : Colors.grey[700]!, + color: Theme.of(context).colorScheme.secondary.withOpacity(0.5), ), itemCount: context.watch().state.length ), From 000fed5a6a2ea329b0fc43d9f47bdb3ef59d3856 Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 09:37:14 +0200 Subject: [PATCH 16/34] Fix invisible switch states --- lib/components/dialogs/add_shopping_list_entry_dialog.dart | 1 - lib/components/dialogs/import_recipe_website_dialog.dart | 1 - lib/pages/settings_page.dart | 2 -- 3 files changed, 4 deletions(-) diff --git a/lib/components/dialogs/add_shopping_list_entry_dialog.dart b/lib/components/dialogs/add_shopping_list_entry_dialog.dart index 6c1bbf1..62531aa 100644 --- a/lib/components/dialogs/add_shopping_list_entry_dialog.dart +++ b/lib/components/dialogs/add_shopping_list_entry_dialog.dart @@ -44,7 +44,6 @@ Future addShoppingListEntryDialog(BuildContext context) { }); }, initialValue: simpleMode, - activeColor: Theme.of(context).primaryColor, decoration: const InputDecoration( border: InputBorder.none ), diff --git a/lib/components/dialogs/import_recipe_website_dialog.dart b/lib/components/dialogs/import_recipe_website_dialog.dart index 9c071dd..a1d42da 100644 --- a/lib/components/dialogs/import_recipe_website_dialog.dart +++ b/lib/components/dialogs/import_recipe_website_dialog.dart @@ -48,7 +48,6 @@ Future importRecipeWebsiteDialog(BuildContext context) { }); }, initialValue: splitInstructions, - activeColor: Theme.of(context).primaryColor, decoration: const InputDecoration( border: InputBorder.none ), diff --git a/lib/pages/settings_page.dart b/lib/pages/settings_page.dart index f8e6ed8..dd4e852 100644 --- a/lib/pages/settings_page.dart +++ b/lib/pages/settings_page.dart @@ -180,7 +180,6 @@ class SettingsPageState extends State { onToggle: (bool value) { }, - activeSwitchColor: Theme.of(context).primaryColor, initialValue: setting.userServerSetting!.mealPlanAutoAddShopping, title: Text('Auto add meal plan'), description: Text('Automatically add meal plan ingredients to shopping list'), @@ -227,7 +226,6 @@ class SettingsPageState extends State { newUserSetting = setting.userServerSetting!.copyWith(useFractions: value); settingsCubit.updateServerSetting(newUserSetting); }, - activeSwitchColor: Theme.of(context).primaryColor, initialValue: useFraction, title: Text(AppLocalizations.of(context)!.useFractions), ), From dc59713bb37e3a53f73fe152d27eb141e6319c0c Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 09:39:25 +0200 Subject: [PATCH 17/34] Migrate recipes list --- lib/components/recipes/recipes_list_component.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/components/recipes/recipes_list_component.dart b/lib/components/recipes/recipes_list_component.dart index b42d6d9..615f4b1 100644 --- a/lib/components/recipes/recipes_list_component.dart +++ b/lib/components/recipes/recipes_list_component.dart @@ -12,7 +12,7 @@ Widget buildRecipesList(List recipesWidgetList) { padding: const EdgeInsets.only(left: 10, right: 10), child: Divider( thickness: 0.5, - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[300]! : Colors.grey[700]!, + color: Theme.of(context).colorScheme.secondary.withOpacity(0.5), ), ), ], From 62a75864c99ce8746db99700172dc2f025bdcead Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 09:54:45 +0200 Subject: [PATCH 18/34] Migrate meal plan list --- lib/components/recipes/recipe_list_component.dart | 2 +- lib/pages/meal_plan_page.dart | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/components/recipes/recipe_list_component.dart b/lib/components/recipes/recipe_list_component.dart index 641b283..5299fe1 100644 --- a/lib/components/recipes/recipe_list_component.dart +++ b/lib/components/recipes/recipe_list_component.dart @@ -50,7 +50,7 @@ Widget recipeListComponent(Recipe recipe, BuildContext context, {String? referer rating(recipe, context), if (mealPlan != null) Flexible( - child: Text(mealPlan.mealType.name, style: TextStyle(color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[600] : Colors.grey, fontSize: 12)) + child: Text(mealPlan.mealType.name, style: TextStyle(color: Theme.of(context).colorScheme.secondary.withOpacity(0.8), fontSize: 12)) ) ], ) : null, diff --git a/lib/pages/meal_plan_page.dart b/lib/pages/meal_plan_page.dart index 2c6b529..7b94d69 100644 --- a/lib/pages/meal_plan_page.dart +++ b/lib/pages/meal_plan_page.dart @@ -353,10 +353,10 @@ Widget buildDayLayout(BuildContext context, List mealPlanList, Da Container( padding: const EdgeInsets.fromLTRB(10, 0, 12, 0), decoration: BoxDecoration( - color: (Theme.of(context).brightness.name == 'light') ? Colors.white : Colors.grey[800], + color: Theme.of(context).colorScheme.surfaceContainer, border: Border( bottom: BorderSide( - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[100]! : Colors.grey[700]!, + color: Theme.of(context).colorScheme.surfaceContainerHigh, width: 1 ) ) @@ -385,10 +385,10 @@ Widget buildDayLayout(BuildContext context, List mealPlanList, Da child: Container( padding: const EdgeInsets.fromLTRB(10, 0, 12, 0), decoration: BoxDecoration( - color: (Theme.of(context).brightness.name == 'light') ? Colors.white : Colors.grey[800], + color: Theme.of(context).colorScheme.surfaceContainer, border: Border( bottom: BorderSide( - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[100]! : Colors.grey[700]!, + color: Theme.of(context).colorScheme.surfaceContainerHigh, width: 1 ) ) @@ -405,13 +405,13 @@ Widget buildDayLayout(BuildContext context, List mealPlanList, Da height: 100, width: double.maxFinite, decoration: BoxDecoration( - color: (Theme.of(context).brightness.name == 'light') ? Colors.black12 : Colors.grey[700], + color: Theme.of(context).colorScheme.secondary, borderRadius: const BorderRadius.all(Radius.circular(10)), ), child: Center( child: Icon( Icons.restaurant_menu_outlined, - color: (Theme.of(context).brightness.name == 'light') ? Colors.black38 : Colors.grey[400], + color: Theme.of(context).colorScheme.onSecondary, ), ), ), @@ -420,7 +420,7 @@ Widget buildDayLayout(BuildContext context, List mealPlanList, Da subtitle: Row( children: [ Flexible( - child: Text(mealPlan.mealType.name, style: TextStyle(color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[600] : Colors.grey, fontSize: 12)) + child: Text(mealPlan.mealType.name, style: TextStyle(color: Theme.of(context).colorScheme.secondary.withOpacity(0.8), fontSize: 12)) ) ], ), From 4b03a601486cd698ecedea9c640d32ccfb99fea7 Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 09:56:46 +0200 Subject: [PATCH 19/34] Migrate meal plan grid --- lib/pages/meal_plan_page.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pages/meal_plan_page.dart b/lib/pages/meal_plan_page.dart index 7b94d69..8ac917f 100644 --- a/lib/pages/meal_plan_page.dart +++ b/lib/pages/meal_plan_page.dart @@ -449,13 +449,13 @@ Widget buildDayLayout(BuildContext context, List mealPlanList, Da height: 140, width: double.maxFinite, decoration: BoxDecoration( - color: (Theme.of(context).brightness.name == 'light') ? Colors.black12 : Colors.grey[700], + color: Theme.of(context).colorScheme.secondary, borderRadius: const BorderRadius.vertical(top: Radius.circular(10)), ), child: Center( child: Icon( Icons.restaurant_menu_outlined, - color: (Theme.of(context).brightness.name == 'light') ? Colors.black38 : Colors.grey[400], + color: Theme.of(context).colorScheme.onSecondary, ), ), ), @@ -468,14 +468,14 @@ Widget buildDayLayout(BuildContext context, List mealPlanList, Da padding: const EdgeInsets.fromLTRB(5, 3, 5, 3), margin: const EdgeInsets.all(5), decoration: BoxDecoration( - color: (Theme.of(context).brightness.name == 'light') ? Colors.white.withOpacity(0.8) : Colors.grey[800]!.withOpacity(0.8), + color: Theme.of(context).colorScheme.tertiaryContainer, borderRadius: BorderRadius.circular(30) ), child: Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, - children: [Flexible(child: Text(mealPlan.mealType.name, style: const TextStyle(fontSize: 11)))], + children: [Flexible(child: Text(mealPlan.mealType.name, style: TextStyle(color: Theme.of(context).colorScheme.onTertiaryContainer, fontSize: 11)))], ), ), ) From 04169fe0c396f9f8c1d430c286ef3baef162ecd8 Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 10:06:54 +0200 Subject: [PATCH 20/34] Migrate recipe details widget --- .../widgets/recipe_detail_tabbar_widget.dart | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/components/widgets/recipe_detail_tabbar_widget.dart b/lib/components/widgets/recipe_detail_tabbar_widget.dart index 544eeb7..d813076 100644 --- a/lib/components/widgets/recipe_detail_tabbar_widget.dart +++ b/lib/components/widgets/recipe_detail_tabbar_widget.dart @@ -240,16 +240,15 @@ class RecipeDetailTabBarWidgetState extends State { if (stepName != null && stepName != '') Text( '$stepName ', - style: TextStyle( + style: const TextStyle( fontStyle: FontStyle.italic, - color: (Theme.of(context).brightness.name == 'light') ? Colors.black45 : Colors.grey[600]!, fontSize: 15.5 ) ), if (stepTime != null && stepTime != 0) Row( children: [ - Icon(Icons.timer_outlined, size: 15.5, color: (Theme.of(context).brightness.name == 'light') ? Colors.black45 : Colors.grey[600]!), + Icon(Icons.timer_outlined, size: 15.5, color: Theme.of(context).colorScheme.secondary), Text( ' $stepTime min', style: const TextStyle(fontStyle: FontStyle.italic, fontSize: 15.5) @@ -329,7 +328,7 @@ class RecipeDetailTabBarWidgetState extends State { decoration: BoxDecoration( border: Border( bottom: BorderSide( - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[300]! : Colors.grey[700]!, + color: Theme.of(context).colorScheme.secondary.withOpacity(0.5), width: 0.8 ) ) @@ -358,7 +357,7 @@ class RecipeDetailTabBarWidgetState extends State { Text( note, style: TextStyle( - color: (Theme.of(context).brightness.name == 'light') ? Colors.black45 : Colors.grey[600]!, + color: Theme.of(context).colorScheme.secondary.withOpacity(0.5), fontStyle: FontStyle.italic, fontSize: 15 ) @@ -378,7 +377,7 @@ class RecipeDetailTabBarWidgetState extends State { decoration: BoxDecoration( border: Border( bottom: BorderSide( - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[300]! : Colors.grey[700]!, + color: Theme.of(context).colorScheme.secondary.withOpacity(0.5), width: 0.8 ) ) @@ -421,7 +420,7 @@ class RecipeDetailTabBarWidgetState extends State { decoration: BoxDecoration( border: Border( bottom: BorderSide( - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[300]! : Colors.grey[700]!, + color: Theme.of(context).colorScheme.secondary.withOpacity(0.5), width: 0.8 ) ) From a2c701997c344d1efc2869202cbbbd9ba5d78bd3 Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 10:07:37 +0200 Subject: [PATCH 21/34] Migrate units page --- lib/pages/units_page.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pages/units_page.dart b/lib/pages/units_page.dart index a893316..e98e277 100644 --- a/lib/pages/units_page.dart +++ b/lib/pages/units_page.dart @@ -145,7 +145,7 @@ class UnitsPageState extends State { ), ), separatorBuilder: (context, index) => Divider( - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[300]! : Colors.grey[700]!, + color: Theme.of(context).colorScheme.secondary.withOpacity(0.5), height: 4, ), itemCount: units.length From 1b91d16382dacf7a8c058002ade6dc3b6cde5004 Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 10:08:25 +0200 Subject: [PATCH 22/34] Migrate foods page --- lib/pages/foods_page.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pages/foods_page.dart b/lib/pages/foods_page.dart index 894b90c..736728b 100644 --- a/lib/pages/foods_page.dart +++ b/lib/pages/foods_page.dart @@ -151,7 +151,7 @@ class FoodsPageState extends State { ), ), separatorBuilder: (context, index) => Divider( - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[300]! : Colors.grey[700]!, + color: Theme.of(context).colorScheme.secondary.withOpacity(0.5), height: 4, ), itemCount: foods.length From cf08695f324fce3b1d525e26288fba232b25daf8 Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 10:13:16 +0200 Subject: [PATCH 23/34] Migrate recipe upsert page --- lib/pages/recipe_upsert_page.dart | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/pages/recipe_upsert_page.dart b/lib/pages/recipe_upsert_page.dart index 989831a..85ca477 100644 --- a/lib/pages/recipe_upsert_page.dart +++ b/lib/pages/recipe_upsert_page.dart @@ -675,19 +675,19 @@ class RecipeUpsertPageState extends State { '${step.name} ', style: TextStyle( fontStyle: FontStyle.italic, - color: (Theme.of(context).brightness.name == 'light') ? Colors.black45 : Colors.grey[600]!, + color: Theme.of(context).colorScheme.secondary.withOpacity(0.5), fontSize: 15.5 ) ), if (step.time != null && step.time != 0) Row( children: [ - Icon(Icons.timer_outlined, size: 15.5, color: (Theme.of(context).brightness.name == 'light') ? Colors.black45 : Colors.grey[600]!), + Icon(Icons.timer_outlined, size: 15.5, color: Theme.of(context).colorScheme.secondary.withOpacity(0.5)), Text( ' ${step.time} min', style: TextStyle( fontStyle: FontStyle.italic, - color: (Theme.of(context).brightness.name == 'light') ? Colors.black45 : Colors.grey[600]!, + color: Theme.of(context).colorScheme.secondary.withOpacity(0.5), fontSize: 15.5 ) ) @@ -840,7 +840,7 @@ class RecipeUpsertPageState extends State { decoration: BoxDecoration( border: Border( bottom: BorderSide( - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[300]! : Colors.grey[700]!, + color: Theme.of(context).colorScheme.secondary.withOpacity(0.5), width: 0.8 ) ) @@ -859,7 +859,7 @@ class RecipeUpsertPageState extends State { TextSpan( text: note, style: TextStyle( - color: (Theme.of(context).brightness.name == 'light') ? Colors.black45 : Colors.grey[600]!, + color: Theme.of(context).colorScheme.secondary.withOpacity(0.5), fontStyle: FontStyle.italic ) ) From ea047332bfd36fcc25f430dd9b9c598f1237210a Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 10:19:26 +0200 Subject: [PATCH 24/34] Replace hardcoded colors on detail page --- lib/pages/recipe_detail_page.dart | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/pages/recipe_detail_page.dart b/lib/pages/recipe_detail_page.dart index 43d7c43..41ba6d2 100644 --- a/lib/pages/recipe_detail_page.dart +++ b/lib/pages/recipe_detail_page.dart @@ -239,9 +239,9 @@ class RecipeDetailPageState extends State with WidgetsBindingO const SizedBox(height: 3), Text( AppLocalizations.of(context)!.lastCooked, - style: const TextStyle( + style: TextStyle( fontSize: 10, - color: Colors.grey + color: Theme.of(context).colorScheme.secondary.withOpacity(0.8) ), ) ], @@ -266,9 +266,9 @@ class RecipeDetailPageState extends State with WidgetsBindingO const SizedBox(height: 3), Text( AppLocalizations.of(context)!.rating, - style: const TextStyle( + style: TextStyle( fontSize: 10, - color: Colors.grey + color: Theme.of(context).colorScheme.secondary.withOpacity(0.8) ), ) ], @@ -292,9 +292,9 @@ class RecipeDetailPageState extends State with WidgetsBindingO const SizedBox(height: 3), Text( AppLocalizations.of(context)!.prepTime, - style: const TextStyle( + style: TextStyle( fontSize: 10, - color: Colors.grey + color: Theme.of(context).colorScheme.secondary.withOpacity(0.8) ), ) ], @@ -320,9 +320,9 @@ class RecipeDetailPageState extends State with WidgetsBindingO const SizedBox(height: 3), Text( AppLocalizations.of(context)!.waitingTime, - style: const TextStyle( + style: TextStyle( fontSize: 10, - color: Colors.grey + color: Theme.of(context).colorScheme.secondary.withOpacity(0.8) ), ) ], @@ -336,9 +336,6 @@ class RecipeDetailPageState extends State with WidgetsBindingO SliverPersistentHeader( delegate: _SliverAppBarDelegate( TabBar( - indicatorColor: Theme.of(context).primaryColor, - unselectedLabelColor: Colors.grey, - labelColor: (Theme.of(context).brightness.name == 'dark') ? Colors.white : Colors.black, tabs: [ Tab(text: AppLocalizations.of(context)!.ingredients), Tab(text: AppLocalizations.of(context)!.directions), From d7650dbb6a8ef2400a556a3668e836d0ca92d90c Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 11:01:31 +0200 Subject: [PATCH 25/34] Add dynamic color support --- lib/cubits/settings_cubit.dart | 6 ++++++ lib/extensions/theme_extension.dart | 12 ++++++------ lib/l10n/app_en.arb | 1 + lib/l10n/app_fr.arb | 1 + lib/main.dart | 12 ++++++++---- lib/models/app_setting.dart | 11 ++++++++--- lib/pages/settings_page.dart | 11 ++++++++++- linux/flutter/generated_plugin_registrant.cc | 4 ++++ linux/flutter/generated_plugins.cmake | 1 + macos/Flutter/GeneratedPluginRegistrant.swift | 2 ++ pubspec.lock | 8 ++++++++ pubspec.yaml | 1 + windows/flutter/generated_plugin_registrant.cc | 3 +++ windows/flutter/generated_plugins.cmake | 1 + 14 files changed, 60 insertions(+), 14 deletions(-) diff --git a/lib/cubits/settings_cubit.dart b/lib/cubits/settings_cubit.dart index c60e5c4..0e93743 100644 --- a/lib/cubits/settings_cubit.dart +++ b/lib/cubits/settings_cubit.dart @@ -16,6 +16,12 @@ class SettingsCubit extends Cubit { SettingsCubit({required this.apiUser, required this.cacheUserService}) : super(AppSetting(layout: 'card', defaultPage: 'recipes', materialHexColor: 0xffceb27c)); + void changeDynamicColorTo(bool dynamicColor) { + AppSetting newState = state.copyWith(dynamicColor: dynamicColor); + emit(newState); + box.put('settings', newState); + } + void changeLayoutTo(String? layout) { if (['list', 'card'].contains(layout)) { AppSetting newState = state.copyWith(layout: layout); diff --git a/lib/extensions/theme_extension.dart b/lib/extensions/theme_extension.dart index 64b5f8d..62adb9d 100644 --- a/lib/extensions/theme_extension.dart +++ b/lib/extensions/theme_extension.dart @@ -1,19 +1,19 @@ import 'package:flutter/material.dart'; class AppTheme { - static ThemeData lightTheme(Color color) { + static ThemeData fromColor(Color color, Brightness brightness) { return ThemeData( - brightness: Brightness.light, + brightness: brightness, fontFamily: 'Montserrat', - colorScheme: ColorScheme.fromSeed(seedColor: color), + colorScheme: ColorScheme.fromSeed(seedColor: color, brightness: brightness), ); } - static ThemeData darkTheme(Color color) { + static ThemeData fromScheme(ColorScheme colorScheme) { return ThemeData( - brightness: Brightness.dark, + brightness: colorScheme.brightness, fontFamily: 'Montserrat', - colorScheme: ColorScheme.fromSeed(seedColor: color, brightness: Brightness.dark), + colorScheme: colorScheme, ); } } diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 7b9e758..02dbe9e 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -120,6 +120,7 @@ "settingsRecentDays": "Recent days", "settingsRecentDaysDescription": "Displays the last %s days of the shopping list", "settingsLogout": "Logout", + "dynamicColor": "Dynamic color", "accentColor": "Accent color", "pickColor": "Pick a color", diff --git a/lib/l10n/app_fr.arb b/lib/l10n/app_fr.arb index cfebbcd..7e78e55 100644 --- a/lib/l10n/app_fr.arb +++ b/lib/l10n/app_fr.arb @@ -229,6 +229,7 @@ "@settingsRecentDaysDescription": {}, "settingsLogout": "Déconnexion", "@settingsLogout": {}, + "dynamicColor": "Couleurs dynamiques", "accentColor": "Palette de couleur", "@accentColor": {}, "pickColor": "Choisir une couleur", diff --git a/lib/main.dart b/lib/main.dart index 556aa28..237400b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,3 +1,5 @@ +import 'package:dynamic_color/dynamic_color.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -160,7 +162,8 @@ class Tare extends StatelessWidget { themeMode = ThemeMode.system; } - return MaterialApp( + return DynamicColorBuilder(builder: (lightColorScheme, darkColorScheme) { + return MaterialApp( localizationsDelegates: const [ AppLocalizations.delegate, GlobalMaterialLocalizations.delegate, @@ -178,13 +181,14 @@ class Tare extends StatelessWidget { ], debugShowCheckedModeBanner: false, title: 'UnTaRe App', - theme: AppTheme.lightTheme(Color(settingsCubit.state.materialHexColor)), - darkTheme: AppTheme.darkTheme(Color(settingsCubit.state.materialHexColor)), + theme: settingsCubit.state.dynamicColor && lightColorScheme != null ? AppTheme.fromScheme(lightColorScheme) : AppTheme.fromColor(Color(settingsCubit.state.materialHexColor), Brightness.light), + darkTheme: settingsCubit.state.dynamicColor && darkColorScheme != null ? AppTheme.fromScheme(darkColorScheme) : AppTheme.fromColor(Color(settingsCubit.state.materialHexColor), Brightness.dark), themeMode: themeMode, home: (state is AuthenticationAuthenticated) ? const TarePage() : const StartingPage() - ); + ); + }); }, ) ); diff --git a/lib/models/app_setting.dart b/lib/models/app_setting.dart index 2b16e55..681d606 100644 --- a/lib/models/app_setting.dart +++ b/lib/models/app_setting.dart @@ -16,13 +16,16 @@ class AppSetting { final int materialHexColor; @HiveField(4) final UserSetting? userServerSetting; + @HiveField(5) + final bool dynamicColor; AppSetting({ required this.layout, this.theme, required this.defaultPage, required this.materialHexColor, - this.userServerSetting + this.userServerSetting, + this.dynamicColor = false }); AppSetting copyWith({ @@ -30,14 +33,16 @@ class AppSetting { String? theme, String? defaultPage, int? materialHexColor, - UserSetting? userServerSetting + UserSetting? userServerSetting, + bool? dynamicColor }) { return AppSetting( layout: layout ?? this.layout, theme: theme ?? this.theme, defaultPage: defaultPage ?? this.defaultPage, materialHexColor: materialHexColor ?? this.materialHexColor, - userServerSetting: userServerSetting ?? this.userServerSetting + userServerSetting: userServerSetting ?? this.userServerSetting, + dynamicColor: dynamicColor ?? this.dynamicColor ); } } \ No newline at end of file diff --git a/lib/pages/settings_page.dart b/lib/pages/settings_page.dart index dd4e852..854512b 100644 --- a/lib/pages/settings_page.dart +++ b/lib/pages/settings_page.dart @@ -97,7 +97,16 @@ class SettingsPageState extends State { title: Text(AppLocalizations.of(context)!.settingsThemeMode), value: Text((setting.theme != 'system') ? ((setting.theme == 'light') ? AppLocalizations.of(context)!.settingsLightMode : AppLocalizations.of(context)!.settingsDarkMode) : AppLocalizations.of(context)!.settingsSystemMode), ), + SettingsTile.switchTile( + leading: const Icon(Icons.style_outlined), + onToggle: (bool value) { + settingsCubit.changeDynamicColorTo(value); + }, + initialValue: setting.dynamicColor, + title: Text(AppLocalizations.of(context)!.dynamicColor), + ), SettingsTile.navigation( + enabled: !setting.dynamicColor, onPressed: (context) { Color pickedColor = Color(setting.materialHexColor); showDialog(context: context, builder: (BuildContext dContext) { @@ -148,7 +157,7 @@ class SettingsPageState extends State { }, leading: const Icon(Icons.color_lens_outlined), title: Text(AppLocalizations.of(context)!.accentColor), - trailing: Icon(Icons.circle, color: Color(setting.materialHexColor)) + trailing: Icon(Icons.circle, color: Color(setting.materialHexColor).withOpacity(setting.dynamicColor ? 0.5 : 1.0)) ) ] ), diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index 7299b5c..36af2d7 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -6,10 +6,14 @@ #include "generated_plugin_registrant.h" +#include #include #include void fl_register_plugins(FlPluginRegistry* registry) { + g_autoptr(FlPluginRegistrar) dynamic_color_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "DynamicColorPlugin"); + dynamic_color_plugin_register_with_registrar(dynamic_color_registrar); g_autoptr(FlPluginRegistrar) file_selector_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin"); file_selector_plugin_register_with_registrar(file_selector_linux_registrar); diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 786ff5c..f308ccc 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + dynamic_color file_selector_linux url_launcher_linux ) diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index ebc5fd9..46df04e 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,6 +5,7 @@ import FlutterMacOS import Foundation +import dynamic_color import file_selector_macos import path_provider_foundation import share_plus @@ -13,6 +14,7 @@ import url_launcher_macos import wakelock_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + DynamicColorPlugin.register(with: registry.registrar(forPlugin: "DynamicColorPlugin")) FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin")) diff --git a/pubspec.lock b/pubspec.lock index 89ff56e..0f47ab5 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -265,6 +265,14 @@ packages: url: "https://pub.dev" source: hosted version: "5.0.6" + dynamic_color: + dependency: "direct main" + description: + name: dynamic_color + sha256: eae98052fa6e2826bdac3dd2e921c6ce2903be15c6b7f8b6d8a5d49b5086298d + url: "https://pub.dev" + source: hosted + version: "1.7.0" equatable: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 8acd89e..1c5054f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -60,6 +60,7 @@ dependencies: flutter_markdown: ^0.7.3 url_launcher: ^6.2.2 receive_sharing_intent: ^1.7.0 + dynamic_color: ^1.7.0 dependency_overrides: flutter_chips_input: diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 5e62361..9fa615d 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -6,11 +6,14 @@ #include "generated_plugin_registrant.h" +#include #include #include #include void RegisterPlugins(flutter::PluginRegistry* registry) { + DynamicColorPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("DynamicColorPluginCApi")); FileSelectorWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("FileSelectorWindows")); SharePlusWindowsPluginCApiRegisterWithRegistrar( diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 281df51..ea66676 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + dynamic_color file_selector_windows share_plus url_launcher_windows From aca200b9c4939bbb5a2625fcd079a75dcb56d22a Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 11:09:43 +0200 Subject: [PATCH 26/34] Fix colors on meal plan text --- lib/pages/meal_plan_page.dart | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/pages/meal_plan_page.dart b/lib/pages/meal_plan_page.dart index 8ac917f..4eba2c7 100644 --- a/lib/pages/meal_plan_page.dart +++ b/lib/pages/meal_plan_page.dart @@ -166,7 +166,7 @@ class MealPlanPageState extends State with WidgetsBindingObserver }, icon: Icon( Icons.more_vert_outlined, - color: Theme.of(context).primaryTextTheme.bodyMedium!.color, + color: Theme.of(context).textTheme.bodyMedium!.color, ) ) ], @@ -198,7 +198,7 @@ class MealPlanPageState extends State with WidgetsBindingObserver textAlign: TextAlign.center, style: TextStyle( fontSize: 18, - color: Theme.of(context).primaryTextTheme.bodyMedium!.color, + color: Theme.of(context).textTheme.bodyMedium!.color, ), ), ), @@ -308,7 +308,7 @@ Widget buildDayLayout(BuildContext context, List mealPlanList, Da decoration: BoxDecoration( border: Border( bottom: BorderSide( - color: Theme.of(context).primaryTextTheme.labelMedium!.color!, + color: Theme.of(context).textTheme.labelMedium!.color!, width: 0.8 ) ) @@ -323,13 +323,13 @@ Widget buildDayLayout(BuildContext context, List mealPlanList, Da DateFormat('EEEE', Platform.localeName).format(day), style: TextStyle( fontWeight: (dailyMealPlanList.isNotEmpty) ? FontWeight.bold : FontWeight.normal, - color: (dailyMealPlanList.isNotEmpty) ? Theme.of(context).primaryTextTheme.bodyMedium!.color : Theme.of(context).primaryTextTheme.bodySmall!.color + color: (dailyMealPlanList.isNotEmpty) ? Theme.of(context).textTheme.bodyMedium!.color : Theme.of(context).textTheme.bodySmall!.color ) ), const SizedBox(width: 8), (isToday) ? Text(AppLocalizations.of(context)!.mealPlanToday.toLowerCase(), style: TextStyle(color: Theme.of(context).primaryColor)) - : Text(DateFormat('d. MMM', Platform.localeName).format(day), style: TextStyle(color: Theme.of(context).primaryTextTheme.bodySmall!.color)) + : Text(DateFormat('d. MMM', Platform.localeName).format(day), style: TextStyle(color: Theme.of(context).textTheme.bodySmall!.color)) ], ), trailing: IconButton( From 15bca9a72e1a1d7b7e5bc301a605a939477f2fd4 Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 11:27:41 +0200 Subject: [PATCH 27/34] Improve search bar styling --- lib/pages/recipes_page.dart | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/lib/pages/recipes_page.dart b/lib/pages/recipes_page.dart index 1f6313c..775e2a4 100644 --- a/lib/pages/recipes_page.dart +++ b/lib/pages/recipes_page.dart @@ -250,25 +250,21 @@ Widget sliverAppBarWidget(BuildContext context, bool innerBoxIsScrolled, TextEdi ), ), ), - backgroundColor: Theme.of(context).scaffoldBackgroundColor, pinned: true, stretch: true, forceElevated: innerBoxIsScrolled, elevation: 1.5, bottom: PreferredSize( - preferredSize: const Size(double.maxFinite, 42), + preferredSize: const Size(double.maxFinite, 50), child: Container( - height: 42, - padding: const EdgeInsets.fromLTRB(40, 0, 30, 10), - child: Row( - children: [ - Flexible( - child: SearchBar( - controller: searchTextController, - ), - ), - IconButton( - padding: const EdgeInsets.fromLTRB(8, 4, 8, 8), + height: 50, + padding: const EdgeInsets.fromLTRB(20, 0, 20, 10), + child: SearchBar( + controller: searchTextController, + elevation: WidgetStateProperty.all(0), + leading: Icon(Icons.search_rounded, color: Theme.of(context).colorScheme.secondary), + trailing: [ + IconButton( tooltip: AppLocalizations.of(context)!.sort, splashRadius: 20, onPressed: () { @@ -280,7 +276,7 @@ Widget sliverAppBarWidget(BuildContext context, bool innerBoxIsScrolled, TextEdi ) ) ], - ) + ), ), ), actions: [ From 9878a89c1e8ba36ea365781dd60cfad1624dc92e Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 11:35:41 +0200 Subject: [PATCH 28/34] Remove explicit app bar background color setting --- lib/pages/foods_page.dart | 1 - lib/pages/meal_plan_page.dart | 1 - lib/pages/recipe_detail_page.dart | 1 - lib/pages/settings_page.dart | 1 - lib/pages/shopping_list_page.dart | 1 - lib/pages/spaces_page.dart | 1 - lib/pages/units_page.dart | 1 - 7 files changed, 7 deletions(-) diff --git a/lib/pages/foods_page.dart b/lib/pages/foods_page.dart index 736728b..405c5f4 100644 --- a/lib/pages/foods_page.dart +++ b/lib/pages/foods_page.dart @@ -48,7 +48,6 @@ class FoodsPageState extends State { return Scaffold( appBar: AppBar( title: Text(AppLocalizations.of(context)!.foods), - backgroundColor: Theme.of(context).scaffoldBackgroundColor, elevation: 1.5, ), body: BlocProvider( diff --git a/lib/pages/meal_plan_page.dart b/lib/pages/meal_plan_page.dart index 4eba2c7..c06337a 100644 --- a/lib/pages/meal_plan_page.dart +++ b/lib/pages/meal_plan_page.dart @@ -171,7 +171,6 @@ class MealPlanPageState extends State with WidgetsBindingObserver ) ], elevation: (scrolled) ? 1.5 : 0, - backgroundColor: Theme.of(context).scaffoldBackgroundColor, pinned: true, forceElevated: true, bottom: PreferredSize( diff --git a/lib/pages/recipe_detail_page.dart b/lib/pages/recipe_detail_page.dart index 41ba6d2..0f29c09 100644 --- a/lib/pages/recipe_detail_page.dart +++ b/lib/pages/recipe_detail_page.dart @@ -187,7 +187,6 @@ class RecipeDetailPageState extends State with WidgetsBindingO ) ], elevation: (scrolled) ? 1.5 : 0, - backgroundColor: Theme.of(context).scaffoldBackgroundColor, pinned: true, ); }); diff --git a/lib/pages/settings_page.dart b/lib/pages/settings_page.dart index 854512b..74c1e27 100644 --- a/lib/pages/settings_page.dart +++ b/lib/pages/settings_page.dart @@ -58,7 +58,6 @@ class SettingsPageState extends State { ), ), elevation: 1.5, - backgroundColor: Theme.of(context).scaffoldBackgroundColor, pinned: true, ) ]; diff --git a/lib/pages/shopping_list_page.dart b/lib/pages/shopping_list_page.dart index e635ecb..d2c426a 100644 --- a/lib/pages/shopping_list_page.dart +++ b/lib/pages/shopping_list_page.dart @@ -155,7 +155,6 @@ class ShoppingListPageState extends State with TickerProviderS ) ], elevation: (scrolled) ? 1.5 : 0, - backgroundColor: Theme.of(context).scaffoldBackgroundColor, pinned: true, forceElevated: true, ); diff --git a/lib/pages/spaces_page.dart b/lib/pages/spaces_page.dart index 59823de..32872b8 100644 --- a/lib/pages/spaces_page.dart +++ b/lib/pages/spaces_page.dart @@ -32,7 +32,6 @@ class SpacesPageState extends State { return Scaffold( appBar: AppBar( title: Text(AppLocalizations.of(context)!.spaces), - backgroundColor: Theme.of(context).scaffoldBackgroundColor, elevation: 1.5, ), body: ListView.separated( diff --git a/lib/pages/units_page.dart b/lib/pages/units_page.dart index e98e277..be94e17 100644 --- a/lib/pages/units_page.dart +++ b/lib/pages/units_page.dart @@ -46,7 +46,6 @@ class UnitsPageState extends State { return Scaffold( appBar: AppBar( title: Text(AppLocalizations.of(context)!.units), - backgroundColor: Theme.of(context).scaffoldBackgroundColor, elevation: 1.5, ), body: BlocProvider( From 9f176d292cb4b59e1e7337e4d59e0f184e16d100 Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 11:52:12 +0200 Subject: [PATCH 29/34] Fix color of SearchBar --- lib/pages/recipes_page.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pages/recipes_page.dart b/lib/pages/recipes_page.dart index 775e2a4..708c404 100644 --- a/lib/pages/recipes_page.dart +++ b/lib/pages/recipes_page.dart @@ -260,6 +260,7 @@ Widget sliverAppBarWidget(BuildContext context, bool innerBoxIsScrolled, TextEdi height: 50, padding: const EdgeInsets.fromLTRB(20, 0, 20, 10), child: SearchBar( + backgroundColor: WidgetStateProperty.all(Theme.of(context).colorScheme.surfaceContainer), controller: searchTextController, elevation: WidgetStateProperty.all(0), leading: Icon(Icons.search_rounded, color: Theme.of(context).colorScheme.secondary), From 7f6e0748373558d4ac5badb412ef1435dcf1a085 Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 11:54:07 +0200 Subject: [PATCH 30/34] Replace hardcoded colors on recipes list page --- lib/components/recipes/recipe_list_component.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/components/recipes/recipe_list_component.dart b/lib/components/recipes/recipe_list_component.dart index 5299fe1..0297c91 100644 --- a/lib/components/recipes/recipe_list_component.dart +++ b/lib/components/recipes/recipe_list_component.dart @@ -65,12 +65,12 @@ Widget lastCooked(Recipe recipe, BuildContext context) { Icon( Icons.restaurant_outlined, size: 12, - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[600] : Colors.grey + color: Theme.of(context).colorScheme.secondary.withOpacity(0.8) ), const SizedBox(width: 2), Text( DateFormat('dd.MM.yy').format(DateTime.parse(recipe.lastCooked!).toLocal()), - style: TextStyle(color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[600] : Colors.grey, fontSize: 12) + style: TextStyle(color: Theme.of(context).colorScheme.secondary.withOpacity(0.8), fontSize: 12) ), const SizedBox(width: 8) ], @@ -87,7 +87,7 @@ Widget rating (Recipe recipe, BuildContext context) { recipe.rating.toString(), style: TextStyle( fontSize: 12, - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[600] : Colors.grey + color: Theme.of(context).colorScheme.secondary.withOpacity(0.8) ) ), const SizedBox(width: 2), From dd42df09b556e50719d5e54e54768717f2a3746e Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 11:54:54 +0200 Subject: [PATCH 31/34] Replace hardcoded colors on upsert steps page --- .../widgets/recipe_upsert_steps_stateful_widget.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/components/widgets/recipe_upsert_steps_stateful_widget.dart b/lib/components/widgets/recipe_upsert_steps_stateful_widget.dart index 1b0ec08..b9273ea 100644 --- a/lib/components/widgets/recipe_upsert_steps_stateful_widget.dart +++ b/lib/components/widgets/recipe_upsert_steps_stateful_widget.dart @@ -294,7 +294,7 @@ class RecipeUpsertStepsWidgetState extends State { decoration: BoxDecoration( border: Border( bottom: BorderSide( - color: (Theme.of(context).brightness.name == 'light') ? Colors.grey[300]! : Colors.grey[700]!, + color: Theme.of(context).colorScheme.secondary.withOpacity(0.5), width: 0.8 ) ) @@ -310,7 +310,7 @@ class RecipeUpsertStepsWidgetState extends State { Text( note, style: TextStyle( - color: (Theme.of(context).brightness.name == 'light') ? Colors.black45 : Colors.grey[600]!, + color: Theme.of(context).colorScheme.secondary.withOpacity(0.8), fontStyle: FontStyle.italic, fontSize: 15 ) From ac666707ba88cc6e8abf679209fd35429e7f5928 Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 11:59:57 +0200 Subject: [PATCH 32/34] Fix textTheme usage --- lib/pages/recipe_upsert_page.dart | 2 +- lib/pages/shopping_list_page.dart | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pages/recipe_upsert_page.dart b/lib/pages/recipe_upsert_page.dart index 85ca477..0c8d890 100644 --- a/lib/pages/recipe_upsert_page.dart +++ b/lib/pages/recipe_upsert_page.dart @@ -851,7 +851,7 @@ class RecipeUpsertPageState extends State { title: RichText( overflow: TextOverflow.ellipsis, text: TextSpan( - style: TextStyle(fontSize: 15, color: Theme.of(context).primaryTextTheme.bodyMedium!.color), + style: TextStyle(fontSize: 15, color: Theme.of(context).textTheme.bodyMedium!.color), children: [ TextSpan(text: amount, style: const TextStyle(fontWeight: FontWeight.bold)), TextSpan(text: unit, style: const TextStyle(fontWeight: FontWeight.bold)), diff --git a/lib/pages/shopping_list_page.dart b/lib/pages/shopping_list_page.dart index d2c426a..6a75568 100644 --- a/lib/pages/shopping_list_page.dart +++ b/lib/pages/shopping_list_page.dart @@ -474,9 +474,9 @@ class ShoppingListPageState extends State with TickerProviderS RichText( text: TextSpan( children: [ - TextSpan(text: amount, style: TextStyle(color: Theme.of(context).primaryTextTheme.bodyMedium!.color, fontWeight: FontWeight.bold)), - TextSpan(text: unit, style: TextStyle(color: Theme.of(context).primaryTextTheme.bodyMedium!.color, fontWeight: FontWeight.bold)), - TextSpan(text: food, style: TextStyle(color: Theme.of(context).primaryTextTheme.bodyMedium!.color, fontWeight: (shoppingListEntry.food != null && shoppingListEntry.food!.recipe != null) ? FontWeight.bold : FontWeight.w400)), + TextSpan(text: amount, style: TextStyle(color: Theme.of(context).textTheme.bodyMedium!.color, fontWeight: FontWeight.bold)), + TextSpan(text: unit, style: TextStyle(color: Theme.of(context).textTheme.bodyMedium!.color, fontWeight: FontWeight.bold)), + TextSpan(text: food, style: TextStyle(color: Theme.of(context).textTheme.bodyMedium!.color, fontWeight: (shoppingListEntry.food != null && shoppingListEntry.food!.recipe != null) ? FontWeight.bold : FontWeight.w400)), ], style: (checkBoxValue) ? const TextStyle(decoration: TextDecoration.lineThrough) From c33ea44654b3fa20ed2fa9916161e7d7b7207b82 Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 12:00:49 +0200 Subject: [PATCH 33/34] Fix usage of color without scheme --- lib/components/dialogs/edit_share_dialog.dart | 2 +- .../dialogs/upsert_meal_plan_entry_dialog.dart | 2 +- lib/components/loading_component.dart | 2 +- .../recipe_upsert_steps_stateful_widget.dart | 14 +++++++------- lib/pages/meal_plan_page.dart | 2 +- lib/pages/recipe_upsert_page.dart | 14 +++++++------- lib/pages/settings_page.dart | 8 ++++---- lib/pages/starting_page.dart | 4 ++-- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/components/dialogs/edit_share_dialog.dart b/lib/components/dialogs/edit_share_dialog.dart index 9c31b08..fbf819d 100644 --- a/lib/components/dialogs/edit_share_dialog.dart +++ b/lib/components/dialogs/edit_share_dialog.dart @@ -48,7 +48,7 @@ Future editShareDialog(BuildContext context, UserSetting userSetting, String ref ), FormBuilderFilterChip ( name: 'share', - checkmarkColor: Theme.of(context).primaryColor, + checkmarkColor: Theme.of(context).colorScheme.primary, initialValue: (referer == 'shopping') ? userSetting.shoppingShare.map((user) => user.id).toList() : userSetting.planShare.map((user) => user.id).toList(), decoration: InputDecoration( labelText: AppLocalizations.of(context)!.shareWith, diff --git a/lib/components/dialogs/upsert_meal_plan_entry_dialog.dart b/lib/components/dialogs/upsert_meal_plan_entry_dialog.dart index e458f39..880bff1 100644 --- a/lib/components/dialogs/upsert_meal_plan_entry_dialog.dart +++ b/lib/components/dialogs/upsert_meal_plan_entry_dialog.dart @@ -124,7 +124,7 @@ Future upsertMealPlanEntryDialog(BuildContext context, {MealPlanEntry? mealPlan, const SizedBox(height: 15), FormBuilderFilterChip ( name: 'share', - checkmarkColor: Theme.of(context).primaryColor, + checkmarkColor: Theme.of(context).colorScheme.primary, initialValue: sharedUsers.map((user) => user.id).toList(), decoration: InputDecoration( labelText: AppLocalizations.of(context)!.shareWith, diff --git a/lib/components/loading_component.dart b/lib/components/loading_component.dart index 9ebad48..82e0b64 100644 --- a/lib/components/loading_component.dart +++ b/lib/components/loading_component.dart @@ -9,7 +9,7 @@ Widget buildLoading() { child: Center( child: CircularProgressIndicator( strokeWidth: 2, - color: Theme.of(context).primaryColor + color: Theme.of(context).colorScheme.primary ), ) ); diff --git a/lib/components/widgets/recipe_upsert_steps_stateful_widget.dart b/lib/components/widgets/recipe_upsert_steps_stateful_widget.dart index b9273ea..93613ad 100644 --- a/lib/components/widgets/recipe_upsert_steps_stateful_widget.dart +++ b/lib/components/widgets/recipe_upsert_steps_stateful_widget.dart @@ -146,7 +146,7 @@ class RecipeUpsertStepsWidgetState extends State { alignment: Alignment.center, decoration: BoxDecoration( shape: BoxShape.circle, - border: Border.all(color: Theme.of(context).primaryColor, width: 2), + border: Border.all(color: Theme.of(context).colorScheme.primary, width: 2), ), child: IconButton( padding: const EdgeInsets.all(0), @@ -154,7 +154,7 @@ class RecipeUpsertStepsWidgetState extends State { visualDensity: const VisualDensity(horizontal: -4, vertical: -4), icon: Icon( Icons.add, - color: Theme.of(context).primaryColor, + color: Theme.of(context).colorScheme.primary, ), onPressed: () => _addStep(), ), @@ -203,9 +203,9 @@ class RecipeUpsertStepsWidgetState extends State { alignment: Alignment.center, decoration: BoxDecoration( shape: BoxShape.circle, - border: Border.all(color: Theme.of(context).primaryColor, width: 2), + border: Border.all(color: Theme.of(context).colorScheme.primary, width: 2), ), - child: Text((stepIndex+1).toString(), style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Theme.of(context).primaryColor)), + child: Text((stepIndex+1).toString(), style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Theme.of(context).colorScheme.primary)), ) ), Container( @@ -213,7 +213,7 @@ class RecipeUpsertStepsWidgetState extends State { decoration: BoxDecoration( border: Border( left: BorderSide( - color: Theme.of(context).primaryColor, + color: Theme.of(context).colorScheme.primary, width: 1 ) ) @@ -226,7 +226,7 @@ class RecipeUpsertStepsWidgetState extends State { splashRadius: 20, icon: Icon( Icons.add, - color: Theme.of(context).primaryColor, + color: Theme.of(context).colorScheme.primary, ), onPressed: () { upsertRecipeIngredientDialog(context, stepIndex, ingredients.length, _upsertIngredient); @@ -243,7 +243,7 @@ class RecipeUpsertStepsWidgetState extends State { decoration: BoxDecoration( border: Border( left: BorderSide( - color: Theme.of(context).primaryColor, + color: Theme.of(context).colorScheme.primary, width: 1 ) ) diff --git a/lib/pages/meal_plan_page.dart b/lib/pages/meal_plan_page.dart index c06337a..55b24dc 100644 --- a/lib/pages/meal_plan_page.dart +++ b/lib/pages/meal_plan_page.dart @@ -327,7 +327,7 @@ Widget buildDayLayout(BuildContext context, List mealPlanList, Da ), const SizedBox(width: 8), (isToday) - ? Text(AppLocalizations.of(context)!.mealPlanToday.toLowerCase(), style: TextStyle(color: Theme.of(context).primaryColor)) + ? Text(AppLocalizations.of(context)!.mealPlanToday.toLowerCase(), style: TextStyle(color: Theme.of(context).colorScheme.primary)) : Text(DateFormat('d. MMM', Platform.localeName).format(day), style: TextStyle(color: Theme.of(context).textTheme.bodySmall!.color)) ], ), diff --git a/lib/pages/recipe_upsert_page.dart b/lib/pages/recipe_upsert_page.dart index 0c8d890..9a6ac99 100644 --- a/lib/pages/recipe_upsert_page.dart +++ b/lib/pages/recipe_upsert_page.dart @@ -599,7 +599,7 @@ class RecipeUpsertPageState extends State { alignment: Alignment.center, decoration: BoxDecoration( shape: BoxShape.circle, - border: Border.all(color: Theme.of(context).primaryColor, width: 2), + border: Border.all(color: Theme.of(context).colorScheme.primary, width: 2), ), child: IconButton( padding: const EdgeInsets.all(0), @@ -607,7 +607,7 @@ class RecipeUpsertPageState extends State { visualDensity: const VisualDensity(horizontal: -4, vertical: -4), icon: Icon( Icons.add, - color: Theme.of(context).primaryColor, + color: Theme.of(context).colorScheme.primary, ), onPressed: () { FocusManager.instance.primaryFocus?.unfocus(); @@ -665,9 +665,9 @@ class RecipeUpsertPageState extends State { alignment: Alignment.center, decoration: BoxDecoration( shape: BoxShape.circle, - border: Border.all(color: Theme.of(context).primaryColor, width: 2), + border: Border.all(color: Theme.of(context).colorScheme.primary, width: 2), ), - child: Text((stepIndex+1).toString(), style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Theme.of(context).primaryColor)), + child: Text((stepIndex+1).toString(), style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Theme.of(context).colorScheme.primary)), ) ), if (step.name != null && step.name != '') @@ -757,7 +757,7 @@ class RecipeUpsertPageState extends State { decoration: BoxDecoration( border: Border( left: BorderSide( - color: Theme.of(context).primaryColor, + color: Theme.of(context).colorScheme.primary, width: 1 ) ) @@ -770,7 +770,7 @@ class RecipeUpsertPageState extends State { splashRadius: 20, icon: Icon( Icons.add, - color: Theme.of(context).primaryColor, + color: Theme.of(context).colorScheme.primary, ), onPressed: () { FocusManager.instance.primaryFocus?.unfocus(); @@ -788,7 +788,7 @@ class RecipeUpsertPageState extends State { decoration: BoxDecoration( border: Border( left: BorderSide( - color: Theme.of(context).primaryColor, + color: Theme.of(context).colorScheme.primary, width: 1 ) ) diff --git a/lib/pages/settings_page.dart b/lib/pages/settings_page.dart index 74c1e27..c9ac870 100644 --- a/lib/pages/settings_page.dart +++ b/lib/pages/settings_page.dart @@ -277,13 +277,13 @@ class SettingsPageState extends State { ], physics: const BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics()), lightTheme: SettingsThemeData( - tileHighlightColor: Theme.of(context).primaryColor, - titleTextColor: Theme.of(context).primaryColor, + tileHighlightColor: Theme.of(context).colorScheme.primary, + titleTextColor: Theme.of(context).colorScheme.primary, settingsListBackground: Theme.of(context).scaffoldBackgroundColor ), darkTheme: SettingsThemeData( - tileHighlightColor: Theme.of(context).primaryColor, - titleTextColor: Theme.of(context).primaryColor, + tileHighlightColor: Theme.of(context).colorScheme.primary, + titleTextColor: Theme.of(context).colorScheme.primary, settingsListBackground: Theme.of(context).scaffoldBackgroundColor ), ); diff --git a/lib/pages/starting_page.dart b/lib/pages/starting_page.dart index e032542..808047c 100644 --- a/lib/pages/starting_page.dart +++ b/lib/pages/starting_page.dart @@ -49,7 +49,7 @@ class StartingPage extends StatelessWidget { return Center( child: CircularProgressIndicator( strokeWidth: 2, - color: Theme.of(context).primaryColor, + color: Theme.of(context).colorScheme.primary, ), ); }, @@ -116,7 +116,7 @@ class __SignInFormState extends State<_SignInForm> { return Center( child: CircularProgressIndicator( strokeWidth: 2, - color: Theme.of(context).primaryColor, + color: Theme.of(context).colorScheme.primary, ), ); } From 55792ecbd182c519e21c6bf0b9d63736ba11e4ee Mon Sep 17 00:00:00 2001 From: Alexander Linder Date: Tue, 6 Aug 2024 12:02:26 +0200 Subject: [PATCH 34/34] Enable dynamic color by default --- lib/models/app_setting.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/models/app_setting.dart b/lib/models/app_setting.dart index 681d606..f419e20 100644 --- a/lib/models/app_setting.dart +++ b/lib/models/app_setting.dart @@ -25,7 +25,7 @@ class AppSetting { required this.defaultPage, required this.materialHexColor, this.userServerSetting, - this.dynamicColor = false + this.dynamicColor = true }); AppSetting copyWith({