diff --git a/assets/images/pipe.png b/assets/images/pipe_day.png similarity index 100% rename from assets/images/pipe.png rename to assets/images/pipe_day.png diff --git a/assets/images/pipe_night.png b/assets/images/pipe_night.png new file mode 100644 index 0000000000..479ea24448 Binary files /dev/null and b/assets/images/pipe_night.png differ diff --git a/lib/admin/ui/admin.dart b/lib/admin/ui/admin.dart index 4d40551181..20e3eb3e83 100644 --- a/lib/admin/ui/admin.dart +++ b/lib/admin/ui/admin.dart @@ -15,7 +15,7 @@ class AdminTemplate extends HookConsumerWidget { final meNotifier = ref.watch(asyncUserProvider.notifier); return Scaffold( body: Container( - decoration: const BoxDecoration(color: Colors.white), + decoration: const BoxDecoration(), child: SafeArea( child: Column( mainAxisAlignment: MainAxisAlignment.start, diff --git a/lib/admin/ui/components/admin_button.dart b/lib/admin/ui/components/admin_button.dart index 307c4887f7..8b5c97c9e0 100644 --- a/lib/admin/ui/components/admin_button.dart +++ b/lib/admin/ui/components/admin_button.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:titan/tools/constants.dart'; class AdminButton extends StatelessWidget { final Widget child; @@ -13,12 +12,17 @@ class AdminButton extends StatelessWidget { padding: const EdgeInsets.symmetric(vertical: 15), alignment: Alignment.center, decoration: BoxDecoration( - gradient: const LinearGradient( - colors: [ColorConstants.gradient1, ColorConstants.gradient2], + gradient: LinearGradient( + colors: [ + Theme.of(context).colorScheme.primaryContainer, + Theme.of(context).colorScheme.primaryFixed, + ], ), boxShadow: [ BoxShadow( - color: ColorConstants.gradient2.withValues(alpha: 0.5), + color: Theme.of( + context, + ).colorScheme.primaryFixed.withValues(alpha: 0.5), blurRadius: 5, offset: const Offset(2, 2), spreadRadius: 2, diff --git a/lib/admin/ui/components/item_card_ui.dart b/lib/admin/ui/components/item_card_ui.dart index 9adf51fb06..96db1d7721 100644 --- a/lib/admin/ui/components/item_card_ui.dart +++ b/lib/admin/ui/components/item_card_ui.dart @@ -10,11 +10,11 @@ class ItemCardUi extends StatelessWidget { margin: const EdgeInsets.symmetric(vertical: 10), padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10), decoration: BoxDecoration( - color: Colors.white, + color: Theme.of(context).colorScheme.primary, borderRadius: BorderRadius.circular(10), boxShadow: [ BoxShadow( - color: Colors.grey.withValues(alpha: 0.2), + color: Theme.of(context).shadowColor, blurRadius: 5, spreadRadius: 2, ), diff --git a/lib/admin/ui/components/text_editing.dart b/lib/admin/ui/components/text_editing.dart index 99c9f8c63e..c512f7841d 100644 --- a/lib/admin/ui/components/text_editing.dart +++ b/lib/admin/ui/components/text_editing.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/ui/widgets/align_left_text.dart'; import 'package:titan/tools/ui/widgets/text_entry.dart'; @@ -21,12 +20,12 @@ class TextEditing extends StatelessWidget { label, fontSize: 14, fontWeight: FontWeight.w400, - color: Colors.grey.shade500, + color: Theme.of(context).colorScheme.secondaryFixed, ), TextEntry( label: label, controller: controller, - color: ColorConstants.gradient1, + color: Theme.of(context).colorScheme.primaryContainer, ), ], ), diff --git a/lib/admin/ui/components/user_ui.dart b/lib/admin/ui/components/user_ui.dart index d7ca60174d..3aa8c9e97f 100644 --- a/lib/admin/ui/components/user_ui.dart +++ b/lib/admin/ui/components/user_ui.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:heroicons/heroicons.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/user/class/simple_users.dart'; class UserUi extends HookConsumerWidget { @@ -29,24 +28,29 @@ class UserUi extends HookConsumerWidget { child: Container( padding: const EdgeInsets.all(7), decoration: BoxDecoration( - gradient: const LinearGradient( - colors: [ColorConstants.background2, Colors.black], + gradient: LinearGradient( + colors: [ + Theme.of(context).colorScheme.secondaryContainer, + Theme.of(context).colorScheme.secondary, + ], begin: Alignment.topLeft, end: Alignment.bottomRight, ), boxShadow: [ BoxShadow( - color: ColorConstants.background2.withValues(alpha: 0.4), + color: Theme.of( + context, + ).colorScheme.secondaryContainer.withValues(alpha: 0.4), offset: const Offset(2, 3), blurRadius: 5, ), ], borderRadius: const BorderRadius.all(Radius.circular(10)), ), - child: const HeroIcon( + child: HeroIcon( HeroIcons.trash, size: 20, - color: Colors.white, + color: Theme.of(context).colorScheme.onSecondary, ), ), ), diff --git a/lib/admin/ui/pages/groups/add_group_page/add_group_page.dart b/lib/admin/ui/pages/groups/add_group_page/add_group_page.dart index a42957311a..f4ba0988ba 100644 --- a/lib/admin/ui/pages/groups/add_group_page/add_group_page.dart +++ b/lib/admin/ui/pages/groups/add_group_page/add_group_page.dart @@ -69,12 +69,12 @@ class AddGroupPage extends HookConsumerWidget { }); }, builder: (child) => AdminButton(child: child), - child: const Text( + child: Text( AdminTextConstants.add, style: TextStyle( fontSize: 18, fontWeight: FontWeight.w600, - color: Colors.white, + color: Theme.of(context).colorScheme.onPrimaryContainer, ), ), ), diff --git a/lib/admin/ui/pages/groups/add_loaner_page/add_loaner_page.dart b/lib/admin/ui/pages/groups/add_loaner_page/add_loaner_page.dart index 058a9e6216..27b63d12d8 100644 --- a/lib/admin/ui/pages/groups/add_loaner_page/add_loaner_page.dart +++ b/lib/admin/ui/pages/groups/add_loaner_page/add_loaner_page.dart @@ -90,10 +90,12 @@ class AddLoanerPage extends HookConsumerWidget { fontWeight: FontWeight.w500, ), ), - const HeroIcon( + HeroIcon( HeroIcons.plus, size: 25, - color: Colors.black, + color: Theme.of( + context, + ).colorScheme.onPrimary, ), ], ), diff --git a/lib/admin/ui/pages/groups/edit_group_page/edit_group_page.dart b/lib/admin/ui/pages/groups/edit_group_page/edit_group_page.dart index a906c41534..cc690f941c 100644 --- a/lib/admin/ui/pages/groups/edit_group_page/edit_group_page.dart +++ b/lib/admin/ui/pages/groups/edit_group_page/edit_group_page.dart @@ -11,7 +11,6 @@ import 'package:titan/admin/tools/constants.dart'; import 'package:titan/admin/ui/admin.dart'; import 'package:titan/admin/ui/components/admin_button.dart'; import 'package:titan/admin/ui/pages/groups/edit_group_page/search_user.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/functions.dart'; import 'package:titan/tools/token_expire_wrapper.dart'; import 'package:titan/tools/ui/builders/auto_loader_child.dart'; @@ -60,10 +59,10 @@ class EditGroupPage extends HookConsumerWidget { description.text = group.description; return Column( children: [ - const AlignLeftText( + AlignLeftText( AdminTextConstants.edit, fontSize: 20, - color: ColorConstants.gradient1, + color: Theme.of(context).colorScheme.primaryContainer, ), const SizedBox(height: 20), Form( @@ -75,7 +74,9 @@ class EditGroupPage extends HookConsumerWidget { alignment: Alignment.centerLeft, child: TextEntry( controller: name, - color: ColorConstants.gradient1, + color: Theme.of( + context, + ).colorScheme.primaryContainer, label: AdminTextConstants.name, suffixIcon: const HeroIcon(HeroIcons.pencil), enabledColor: Colors.transparent, @@ -86,7 +87,9 @@ class EditGroupPage extends HookConsumerWidget { alignment: Alignment.centerLeft, child: TextEntry( controller: description, - color: ColorConstants.gradient1, + color: Theme.of( + context, + ).colorScheme.primaryContainer, label: AdminTextConstants.description, suffixIcon: const HeroIcon(HeroIcons.pencil), enabledColor: Colors.transparent, @@ -122,12 +125,14 @@ class EditGroupPage extends HookConsumerWidget { }); }, builder: (child) => AdminButton(child: child), - child: const Text( + child: Text( AdminTextConstants.edit, style: TextStyle( fontSize: 18, fontWeight: FontWeight.w600, - color: Colors.white, + color: Theme.of( + context, + ).colorScheme.onPrimaryContainer, ), ), ), @@ -139,7 +144,7 @@ class EditGroupPage extends HookConsumerWidget { ], ); }, - loaderColor: Colors.white, + loaderColor: Theme.of(context).colorScheme.primary, ), ), ), diff --git a/lib/admin/ui/pages/groups/edit_group_page/results.dart b/lib/admin/ui/pages/groups/edit_group_page/results.dart index 9c3709453c..2ccb2f136e 100644 --- a/lib/admin/ui/pages/groups/edit_group_page/results.dart +++ b/lib/admin/ui/pages/groups/edit_group_page/results.dart @@ -5,7 +5,6 @@ import 'package:titan/admin/class/group.dart'; import 'package:titan/admin/providers/group_provider.dart'; import 'package:titan/admin/providers/simple_groups_groups_provider.dart'; import 'package:titan/admin/tools/constants.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/functions.dart'; import 'package:titan/tools/token_expire_wrapper.dart'; import 'package:titan/tools/ui/builders/async_child.dart'; @@ -76,7 +75,9 @@ class MemberResults extends HookConsumerWidget { }); } }, - waitingColor: ColorConstants.gradient1, + waitingColor: Theme.of( + context, + ).colorScheme.primaryContainer, builder: (child) => child, child: const HeroIcon(HeroIcons.plus), ), @@ -88,7 +89,7 @@ class MemberResults extends HookConsumerWidget { ) .toList(), ), - loaderColor: ColorConstants.gradient1, + loaderColor: Theme.of(context).colorScheme.primaryContainer, ); } } diff --git a/lib/admin/ui/pages/groups/edit_group_page/search_user.dart b/lib/admin/ui/pages/groups/edit_group_page/search_user.dart index b5655d6577..6d02a33bda 100644 --- a/lib/admin/ui/pages/groups/edit_group_page/search_user.dart +++ b/lib/admin/ui/pages/groups/edit_group_page/search_user.dart @@ -9,7 +9,6 @@ import 'package:titan/admin/providers/simple_groups_groups_provider.dart'; import 'package:titan/admin/tools/constants.dart'; import 'package:titan/admin/ui/pages/groups/edit_group_page/results.dart'; import 'package:titan/admin/ui/components/user_ui.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/ui/builders/async_child.dart'; import 'package:titan/tools/ui/widgets/custom_dialog_box.dart'; import 'package:titan/tools/functions.dart'; @@ -48,7 +47,7 @@ class SearchUser extends HookConsumerWidget { children: [ StyledSearchBar( label: AdminTextConstants.members, - color: ColorConstants.gradient1, + color: Theme.of(context).colorScheme.primaryContainer, padding: const EdgeInsets.all(0), onChanged: (value) async { if (value.isNotEmpty) { @@ -75,17 +74,19 @@ class SearchUser extends HookConsumerWidget { child: Container( padding: const EdgeInsets.all(7), decoration: BoxDecoration( - gradient: const LinearGradient( + gradient: LinearGradient( colors: [ - ColorConstants.gradient1, - ColorConstants.gradient2, + Theme.of(context).colorScheme.primaryContainer, + Theme.of(context).colorScheme.primaryFixed, ], begin: Alignment.topLeft, end: Alignment.bottomRight, ), boxShadow: [ BoxShadow( - color: ColorConstants.gradient2.withValues(alpha: 0.4), + color: Theme.of( + context, + ).colorScheme.primaryFixed.withValues(alpha: 0.4), offset: const Offset(2, 3), blurRadius: 5, ), @@ -95,7 +96,7 @@ class SearchUser extends HookConsumerWidget { child: HeroIcon( !add.value ? HeroIcons.plus : HeroIcons.xMark, size: 20, - color: Colors.white, + color: Theme.of(context).colorScheme.onPrimaryContainer, ), ), ), diff --git a/lib/admin/ui/pages/groups/group_page/group_page.dart b/lib/admin/ui/pages/groups/group_page/group_page.dart index 601a6d3bce..192bbac238 100644 --- a/lib/admin/ui/pages/groups/group_page/group_page.dart +++ b/lib/admin/ui/pages/groups/group_page/group_page.dart @@ -10,7 +10,6 @@ import 'package:titan/admin/ui/components/item_card_ui.dart'; import 'package:titan/admin/ui/pages/groups/group_page/group_ui.dart'; import 'package:titan/loan/providers/loaner_list_provider.dart'; import 'package:titan/admin/tools/constants.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/ui/builders/async_child.dart'; import 'package:titan/tools/ui/widgets/custom_dialog_box.dart'; import 'package:titan/tools/functions.dart'; @@ -51,14 +50,14 @@ class GroupsPage extends HookConsumerWidget { child: Column( children: [ const SizedBox(height: 20), - const Align( + Align( alignment: Alignment.centerLeft, child: Text( AdminTextConstants.groups, style: TextStyle( fontSize: 20, fontWeight: FontWeight.w700, - color: ColorConstants.gradient1, + color: Theme.of(context).colorScheme.primaryContainer, ), ), ), @@ -87,7 +86,9 @@ class GroupsPage extends HookConsumerWidget { const Spacer(), HeroIcon( HeroIcons.plus, - color: Colors.grey.shade700, + color: Theme.of( + context, + ).colorScheme.secondaryContainer, size: 40, ), const Spacer(), @@ -111,7 +112,9 @@ class GroupsPage extends HookConsumerWidget { children: [ HeroIcon( HeroIcons.buildingLibrary, - color: Colors.grey.shade700, + color: Theme.of( + context, + ).colorScheme.secondaryContainer, size: 40, ), Positioned( @@ -120,7 +123,9 @@ class GroupsPage extends HookConsumerWidget { child: HeroIcon( HeroIcons.plus, size: 15, - color: Colors.grey.shade700, + color: Theme.of( + context, + ).colorScheme.secondaryContainer, ), ), ], @@ -180,7 +185,7 @@ class GroupsPage extends HookConsumerWidget { ], ); }, - loaderColor: ColorConstants.gradient1, + loaderColor: Theme.of(context).colorScheme.primaryContainer, ), ], ), diff --git a/lib/admin/ui/pages/groups/group_page/group_ui.dart b/lib/admin/ui/pages/groups/group_page/group_ui.dart index faad00dce6..6e8afac246 100644 --- a/lib/admin/ui/pages/groups/group_page/group_ui.dart +++ b/lib/admin/ui/pages/groups/group_page/group_ui.dart @@ -4,7 +4,6 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:titan/admin/class/simple_group.dart'; import 'package:titan/admin/ui/components/item_card_ui.dart'; import 'package:titan/admin/ui/pages/groups/group_page/group_button.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/ui/builders/waiting_button.dart'; class GroupUi extends HookConsumerWidget { @@ -28,15 +27,18 @@ class GroupUi extends HookConsumerWidget { if (isLoaner) Row( children: [ - HeroIcon(HeroIcons.buildingLibrary, color: Colors.grey.shade700), + HeroIcon( + HeroIcons.buildingLibrary, + color: Theme.of(context).colorScheme.secondaryContainer, + ), const SizedBox(width: 15), ], ), Expanded( child: Text( group.name, - style: const TextStyle( - color: Colors.black, + style: TextStyle( + color: Theme.of(context).colorScheme.onPrimary, fontSize: 20, fontWeight: FontWeight.bold, ), @@ -48,20 +50,26 @@ class GroupUi extends HookConsumerWidget { GestureDetector( onTap: onEdit, child: GroupButton( - gradient1: Colors.grey.shade800, - gradient2: Colors.grey.shade900, - child: const HeroIcon(HeroIcons.eye, color: Colors.white), + gradient1: Theme.of(context).colorScheme.secondaryContainer, + gradient2: Theme.of(context).colorScheme.secondary, + child: HeroIcon( + HeroIcons.eye, + color: Theme.of(context).colorScheme.onSecondary, + ), ), ), const SizedBox(width: 10), WaitingButton( onTap: onDelete, builder: (child) => GroupButton( - gradient1: ColorConstants.gradient1, - gradient2: ColorConstants.gradient2, + gradient1: Theme.of(context).colorScheme.primaryContainer, + gradient2: Theme.of(context).colorScheme.primaryFixed, child: child, ), - child: const HeroIcon(HeroIcons.xMark, color: Colors.white), + child: HeroIcon( + HeroIcons.xMark, + color: Theme.of(context).colorScheme.onPrimaryContainer, + ), ), ], ), diff --git a/lib/admin/ui/pages/main_page/menu_card_ui.dart b/lib/admin/ui/pages/main_page/menu_card_ui.dart index 22fe6767e4..82c71e1610 100644 --- a/lib/admin/ui/pages/main_page/menu_card_ui.dart +++ b/lib/admin/ui/pages/main_page/menu_card_ui.dart @@ -12,11 +12,11 @@ class MenuCardUi extends StatelessWidget { margin: const EdgeInsets.symmetric(vertical: 10), padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10), decoration: BoxDecoration( - color: Colors.white, + color: Theme.of(context).colorScheme.surface, borderRadius: BorderRadius.circular(10), boxShadow: [ BoxShadow( - color: Colors.grey.withValues(alpha: 0.2), + color: Theme.of(context).shadowColor, blurRadius: 5, spreadRadius: 2, ), @@ -26,7 +26,11 @@ class MenuCardUi extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - HeroIcon(icon, color: Colors.grey.shade700, size: 40), + HeroIcon( + icon, + color: Theme.of(context).colorScheme.secondaryContainer, + size: 40, + ), const SizedBox(width: 10), Text(text, style: const TextStyle(fontSize: 20)), ], diff --git a/lib/admin/ui/pages/memberships/add_edit_user_membership_page/add_edit_user_membership_page.dart b/lib/admin/ui/pages/memberships/add_edit_user_membership_page/add_edit_user_membership_page.dart index 3ec8fa38b3..e611fce5cd 100644 --- a/lib/admin/ui/pages/memberships/add_edit_user_membership_page/add_edit_user_membership_page.dart +++ b/lib/admin/ui/pages/memberships/add_edit_user_membership_page/add_edit_user_membership_page.dart @@ -8,7 +8,6 @@ import 'package:titan/admin/providers/user_association_membership_provider.dart' import 'package:titan/admin/tools/constants.dart'; import 'package:titan/admin/ui/admin.dart'; import 'package:titan/admin/ui/pages/memberships/add_edit_user_membership_page/search_result.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/functions.dart'; import 'package:titan/tools/token_expire_wrapper.dart'; import 'package:titan/tools/ui/builders/waiting_button.dart'; @@ -103,18 +102,18 @@ class AddEditUserMembershipPage extends HookConsumerWidget { const SizedBox(height: 50), WaitingButton( builder: (child) => AddEditButtonLayout( - colors: const [ - ColorConstants.gradient1, - ColorConstants.gradient2, + colors: [ + Theme.of(context).colorScheme.primaryContainer, + Theme.of(context).colorScheme.primaryFixed, ], child: child, ), child: Text( !isEdit ? AdminTextConstants.add : AdminTextConstants.edit, - style: const TextStyle( + style: TextStyle( fontSize: 18, fontWeight: FontWeight.w600, - color: Color.fromARGB(255, 255, 255, 255), + color: Theme.of(context).colorScheme.onPrimaryContainer, ), ), onTap: () async { diff --git a/lib/admin/ui/pages/memberships/add_edit_user_membership_page/search_result.dart b/lib/admin/ui/pages/memberships/add_edit_user_membership_page/search_result.dart index e9d0994a6b..4c67dde404 100644 --- a/lib/admin/ui/pages/memberships/add_edit_user_membership_page/search_result.dart +++ b/lib/admin/ui/pages/memberships/add_edit_user_membership_page/search_result.dart @@ -28,10 +28,10 @@ class SearchResult extends HookConsumerWidget { child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - color: Colors.white, + color: Theme.of(context).colorScheme.surface, boxShadow: [ BoxShadow( - color: Colors.black.withValues(alpha: 0.1), + color: Theme.of(context).shadowColor, offset: const Offset(0, 1), blurRadius: 4, spreadRadius: 2, diff --git a/lib/admin/ui/pages/memberships/association_membership_detail_page/association_membership_detail_page.dart b/lib/admin/ui/pages/memberships/association_membership_detail_page/association_membership_detail_page.dart index 87b343fff3..201537ae13 100644 --- a/lib/admin/ui/pages/memberships/association_membership_detail_page/association_membership_detail_page.dart +++ b/lib/admin/ui/pages/memberships/association_membership_detail_page/association_membership_detail_page.dart @@ -13,7 +13,6 @@ import 'package:titan/admin/ui/pages/memberships/association_membership_detail_p import 'package:titan/admin/ui/pages/memberships/association_membership_detail_page/association_membership_member_editable_card.dart'; import 'package:titan/admin/ui/pages/memberships/association_membership_detail_page/research_bar.dart'; import 'package:titan/admin/ui/pages/memberships/association_membership_detail_page/search_filters.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/ui/builders/waiting_button.dart'; import 'package:titan/tools/ui/layouts/refresher.dart'; import 'package:qlevar_router/qlevar_router.dart'; @@ -53,7 +52,7 @@ class AssociationMembershipEditorPage extends HookConsumerWidget { style: TextStyle( fontSize: 20, fontWeight: FontWeight.w700, - color: ColorConstants.gradient1, + color: Theme.of(context).colorScheme.primaryContainer, ), ), ), @@ -61,21 +60,21 @@ class AssociationMembershipEditorPage extends HookConsumerWidget { const SizedBox(height: 30), Row( children: [ - const Text( + Text( AdminTextConstants.members, style: TextStyle( fontSize: 20, fontWeight: FontWeight.w700, - color: ColorConstants.gradient1, + color: Theme.of(context).colorScheme.primaryContainer, ), ), const SizedBox(width: 10), Text( "(${associationMembershipFilteredList.length} ${AdminTextConstants.members})", - style: const TextStyle( + style: TextStyle( fontSize: 20, fontWeight: FontWeight.w700, - color: ColorConstants.gradient1, + color: Theme.of(context).colorScheme.primaryContainer, ), ), const Spacer(), @@ -85,7 +84,7 @@ class AssociationMembershipEditorPage extends HookConsumerWidget { height: 40, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - color: ColorConstants.gradient1, + color: Theme.of(context).colorScheme.primaryContainer, ), child: child, ), @@ -103,10 +102,10 @@ class AssociationMembershipEditorPage extends HookConsumerWidget { AdminRouter.addEditMember, ); }, - child: const HeroIcon( + child: HeroIcon( HeroIcons.plus, size: 30, - color: Colors.white, + color: Theme.of(context).colorScheme.onPrimaryContainer, ), ), ], diff --git a/lib/admin/ui/pages/memberships/association_membership_detail_page/association_membership_information_editor.dart b/lib/admin/ui/pages/memberships/association_membership_detail_page/association_membership_information_editor.dart index f791809568..70f5d71f31 100644 --- a/lib/admin/ui/pages/memberships/association_membership_detail_page/association_membership_information_editor.dart +++ b/lib/admin/ui/pages/memberships/association_membership_detail_page/association_membership_information_editor.dart @@ -6,7 +6,6 @@ import 'package:titan/admin/providers/all_groups_list_provider.dart'; import 'package:titan/admin/providers/association_membership_list_provider.dart'; import 'package:titan/admin/providers/association_membership_provider.dart'; import 'package:titan/admin/tools/constants.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/functions.dart'; import 'package:titan/tools/token_expire_wrapper.dart'; import 'package:titan/tools/ui/builders/waiting_button.dart'; @@ -53,7 +52,9 @@ class AssociationMembershipInformationEditor extends HookConsumerWidget { SizedBox( child: TextFormField( controller: name, - cursorColor: ColorConstants.gradient1, + cursorColor: Theme.of( + context, + ).colorScheme.primaryContainer, decoration: InputDecoration( labelText: AdminTextConstants.name, labelStyle: const TextStyle( @@ -67,9 +68,11 @@ class AssociationMembershipInformationEditor extends HookConsumerWidget { enabledBorder: const UnderlineInputBorder( borderSide: BorderSide(color: Colors.transparent), ), - focusedBorder: const UnderlineInputBorder( + focusedBorder: UnderlineInputBorder( borderSide: BorderSide( - color: ColorConstants.gradient1, + color: Theme.of( + context, + ).colorScheme.primaryContainer, ), ), ), @@ -111,9 +114,9 @@ class AssociationMembershipInformationEditor extends HookConsumerWidget { const SizedBox(height: 20), WaitingButton( builder: (child) => AddEditButtonLayout( - colors: const [ - ColorConstants.gradient1, - ColorConstants.gradient2, + colors: [ + Theme.of(context).colorScheme.primaryContainer, + Theme.of(context).colorScheme.primaryFixed, ], child: child, ), @@ -146,12 +149,12 @@ class AssociationMembershipInformationEditor extends HookConsumerWidget { } }); }, - child: const Text( + child: Text( AdminTextConstants.edit, style: TextStyle( fontSize: 18, fontWeight: FontWeight.w600, - color: Color.fromARGB(255, 255, 255, 255), + color: Theme.of(context).colorScheme.onPrimaryContainer, ), ), ), diff --git a/lib/admin/ui/pages/memberships/association_membership_detail_page/research_bar.dart b/lib/admin/ui/pages/memberships/association_membership_detail_page/research_bar.dart index 783cb553fb..0a765a925c 100644 --- a/lib/admin/ui/pages/memberships/association_membership_detail_page/research_bar.dart +++ b/lib/admin/ui/pages/memberships/association_membership_detail_page/research_bar.dart @@ -3,7 +3,6 @@ import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:titan/admin/providers/research_filter_provider.dart'; import 'package:titan/admin/tools/constants.dart'; -import 'package:titan/tools/constants.dart'; class ResearchBar extends HookConsumerWidget { const ResearchBar({super.key}); @@ -20,16 +19,24 @@ class ResearchBar extends HookConsumerWidget { }, focusNode: focusNode, controller: editingController, - cursorColor: Color(0xFF1D1D1D), - decoration: const InputDecoration( + cursorColor: Theme.of(context).colorScheme.secondaryContainer, + decoration: InputDecoration( isDense: true, - suffixIcon: Icon(Icons.search, color: Color(0xFF1D1D1D), size: 30), + suffixIcon: Icon( + Icons.search, + color: Theme.of(context).colorScheme.secondaryContainer, + size: 30, + ), label: Text( AdminTextConstants.research, - style: TextStyle(color: Color(0xFF1D1D1D)), + style: TextStyle( + color: Theme.of(context).colorScheme.secondaryContainer, + ), ), focusedBorder: UnderlineInputBorder( - borderSide: BorderSide(color: ColorConstants.gradient1), + borderSide: BorderSide( + color: Theme.of(context).colorScheme.primaryContainer, + ), ), ), ); diff --git a/lib/admin/ui/pages/memberships/association_membership_detail_page/search_filters.dart b/lib/admin/ui/pages/memberships/association_membership_detail_page/search_filters.dart index 694d366265..13315849be 100644 --- a/lib/admin/ui/pages/memberships/association_membership_detail_page/search_filters.dart +++ b/lib/admin/ui/pages/memberships/association_membership_detail_page/search_filters.dart @@ -4,7 +4,6 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:titan/admin/providers/association_membership_members_list_provider.dart'; import 'package:titan/admin/providers/association_membership_provider.dart'; import 'package:titan/admin/tools/constants.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/functions.dart'; import 'package:titan/tools/token_expire_wrapper.dart'; import 'package:titan/tools/ui/builders/waiting_button.dart'; @@ -132,9 +131,9 @@ class SearchFilters extends HookConsumerWidget { }); }, builder: (child) => AddEditButtonLayout( - colors: const [ - ColorConstants.gradient1, - ColorConstants.gradient2, + colors: [ + Theme.of(context).colorScheme.primaryContainer, + Theme.of(context).colorScheme.primaryFixed, ], child: child, ), @@ -143,7 +142,7 @@ class SearchFilters extends HookConsumerWidget { style: TextStyle( fontSize: 18, fontWeight: FontWeight.w600, - color: Color.fromARGB(255, 255, 255, 255), + color: Theme.of(context).colorScheme.onPrimaryContainer, ), textAlign: TextAlign.center, ), @@ -166,9 +165,9 @@ class SearchFilters extends HookConsumerWidget { }); }, builder: (child) => AddEditButtonLayout( - colors: const [ - ColorConstants.gradient1, - ColorConstants.gradient2, + colors: [ + Theme.of(context).colorScheme.primaryContainer, + Theme.of(context).colorScheme.primaryFixed, ], child: child, ), @@ -177,7 +176,7 @@ class SearchFilters extends HookConsumerWidget { style: TextStyle( fontSize: 18, fontWeight: FontWeight.w600, - color: Color.fromARGB(255, 255, 255, 255), + color: Theme.of(context).colorScheme.onPrimaryContainer, ), textAlign: TextAlign.center, ), diff --git a/lib/admin/ui/pages/memberships/association_membership_page/association_membership_creation_dialog.dart b/lib/admin/ui/pages/memberships/association_membership_page/association_membership_creation_dialog.dart index b90cf5b69f..fb341857fd 100644 --- a/lib/admin/ui/pages/memberships/association_membership_page/association_membership_creation_dialog.dart +++ b/lib/admin/ui/pages/memberships/association_membership_page/association_membership_creation_dialog.dart @@ -1,14 +1,8 @@ import 'package:flutter/material.dart'; import 'package:titan/admin/class/simple_group.dart'; import 'package:titan/admin/tools/constants.dart'; -import 'package:titan/tools/constants.dart'; class MembershipCreationDialogBox extends StatelessWidget { - static const Color titleColor = ColorConstants.gradient1; - static const Color descriptionColor = Colors.black; - static const Color yesColor = ColorConstants.gradient2; - static const Color noColor = ColorConstants.background2; - final Function() onYes; final Function()? onNo; final TextEditingController nameController; @@ -18,7 +12,6 @@ class MembershipCreationDialogBox extends StatelessWidget { static const double _padding = 20; static const double _avatarRadius = 45; - static const Color background = Color(0xfffafafa); const MembershipCreationDialogBox({ super.key, required this.nameController, @@ -52,13 +45,13 @@ class MembershipCreationDialogBox extends StatelessWidget { ), decoration: BoxDecoration( shape: BoxShape.rectangle, - color: MembershipCreationDialogBox.background, + color: Theme.of(context).colorScheme.surface, borderRadius: BorderRadius.circular( MembershipCreationDialogBox._padding, ), boxShadow: [ BoxShadow( - color: Colors.grey.shade700, + color: Theme.of(context).shadowColor, offset: const Offset(0, 5), blurRadius: 5, ), @@ -69,10 +62,10 @@ class MembershipCreationDialogBox extends StatelessWidget { children: [ Text( AdminTextConstants.createAssociationMembership, - style: const TextStyle( + style: TextStyle( fontSize: 25, fontWeight: FontWeight.w800, - color: titleColor, + color: Theme.of(context).colorScheme.primaryContainer, ), ), const SizedBox(height: 15), @@ -111,12 +104,12 @@ class MembershipCreationDialogBox extends StatelessWidget { Navigator.of(context).pop(); await onYes(); }, - child: const Text( + child: Text( "Créer", style: TextStyle( fontSize: 18, fontWeight: FontWeight.w600, - color: noColor, + color: Theme.of(context).colorScheme.onSurface, ), ), ), @@ -127,12 +120,12 @@ class MembershipCreationDialogBox extends StatelessWidget { } onNo?.call(); }, - child: const Text( + child: Text( "Annuler", style: TextStyle( fontSize: 18, fontWeight: FontWeight.w600, - color: yesColor, + color: Theme.of(context).colorScheme.error, ), ), ), diff --git a/lib/admin/ui/pages/memberships/association_membership_page/association_membership_page.dart b/lib/admin/ui/pages/memberships/association_membership_page/association_membership_page.dart index 8ae53d5400..34e164056a 100644 --- a/lib/admin/ui/pages/memberships/association_membership_page/association_membership_page.dart +++ b/lib/admin/ui/pages/memberships/association_membership_page/association_membership_page.dart @@ -12,7 +12,6 @@ import 'package:titan/admin/ui/components/item_card_ui.dart'; import 'package:titan/admin/tools/constants.dart'; import 'package:titan/admin/ui/pages/memberships/association_membership_page/association_membership_creation_dialog.dart'; import 'package:titan/admin/ui/pages/memberships/association_membership_page/association_membership_ui.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/ui/builders/async_child.dart'; import 'package:titan/tools/ui/widgets/custom_dialog_box.dart'; import 'package:titan/tools/functions.dart'; @@ -55,14 +54,14 @@ class AssociationMembershipsPage extends HookConsumerWidget { child: Column( children: [ const SizedBox(height: 20), - const Align( + Align( alignment: Alignment.centerLeft, child: Text( AdminTextConstants.associationsMemberships, style: TextStyle( fontSize: 20, fontWeight: FontWeight.w700, - color: ColorConstants.gradient1, + color: Theme.of(context).colorScheme.primaryContainer, ), ), ), @@ -124,7 +123,9 @@ class AssociationMembershipsPage extends HookConsumerWidget { const Spacer(), HeroIcon( HeroIcons.plus, - color: Colors.grey.shade700, + color: Theme.of( + context, + ).colorScheme.secondaryContainer, size: 40, ), const Spacer(), @@ -190,7 +191,7 @@ class AssociationMembershipsPage extends HookConsumerWidget { ], ); }, - loaderColor: ColorConstants.gradient1, + loaderColor: Theme.of(context).colorScheme.primaryContainer, ), ], ), diff --git a/lib/admin/ui/pages/memberships/association_membership_page/association_membership_ui.dart b/lib/admin/ui/pages/memberships/association_membership_page/association_membership_ui.dart index 694a576747..05d6327df2 100644 --- a/lib/admin/ui/pages/memberships/association_membership_page/association_membership_ui.dart +++ b/lib/admin/ui/pages/memberships/association_membership_page/association_membership_ui.dart @@ -4,7 +4,6 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:titan/admin/class/association_membership_simple.dart'; import 'package:titan/admin/ui/components/item_card_ui.dart'; import 'package:titan/admin/ui/pages/memberships/association_membership_page/association_membership_button.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/ui/builders/waiting_button.dart'; class AssociationMembershipUi extends HookConsumerWidget { @@ -26,8 +25,8 @@ class AssociationMembershipUi extends HookConsumerWidget { Expanded( child: Text( associationMembership.name, - style: const TextStyle( - color: Colors.black, + style: TextStyle( + color: Theme.of(context).colorScheme.onSurface, fontSize: 20, fontWeight: FontWeight.bold, ), @@ -39,20 +38,26 @@ class AssociationMembershipUi extends HookConsumerWidget { GestureDetector( onTap: onEdit, child: AssociationMembershipButton( - gradient1: Colors.grey.shade800, - gradient2: Colors.grey.shade900, - child: const HeroIcon(HeroIcons.eye, color: Colors.white), + gradient1: Theme.of(context).colorScheme.secondaryContainer, + gradient2: Theme.of(context).colorScheme.secondary, + child: HeroIcon( + HeroIcons.eye, + color: Theme.of(context).colorScheme.onSecondary, + ), ), ), const SizedBox(width: 10), WaitingButton( onTap: onDelete, builder: (child) => AssociationMembershipButton( - gradient1: ColorConstants.gradient1, - gradient2: ColorConstants.gradient2, + gradient1: Theme.of(context).colorScheme.primaryContainer, + gradient2: Theme.of(context).colorScheme.primaryFixed, child: child, ), - child: const HeroIcon(HeroIcons.xMark, color: Colors.white), + child: HeroIcon( + HeroIcons.xMark, + color: Theme.of(context).colorScheme.onPrimaryContainer, + ), ), ], ), diff --git a/lib/admin/ui/pages/permissions/module_expansion_panel.dart b/lib/admin/ui/pages/permissions/module_expansion_panel.dart index dd3851d3d6..999756f8db 100644 --- a/lib/admin/ui/pages/permissions/module_expansion_panel.dart +++ b/lib/admin/ui/pages/permissions/module_expansion_panel.dart @@ -30,6 +30,7 @@ class ModuleExpansionPanel extends HookConsumerWidget { isExpanded.value[i] = isOpen; isExpanded.value = List.from(isExpanded.value); }, + dividerColor: Theme.of(context).colorScheme.tertiary, children: modulesPermissionNames.keys.map((module) { final index = modulesPermissionNames.keys.toList().indexOf(module); return ExpansionPanel( @@ -39,8 +40,8 @@ class ModuleExpansionPanel extends HookConsumerWidget { padding: const EdgeInsets.symmetric(vertical: 10), child: Text( module, - style: const TextStyle( - color: Color.fromARGB(255, 0, 0, 0), + style: TextStyle( + color: Theme.of(context).colorScheme.onPrimary, fontSize: 22, fontWeight: FontWeight.w800, ), @@ -54,6 +55,7 @@ class ModuleExpansionPanel extends HookConsumerWidget { groups: groups, ) : const SizedBox.shrink(), + backgroundColor: Theme.of(context).colorScheme.secondaryFixed, ); }).toList(), ); diff --git a/lib/admin/ui/pages/permissions/permission_expansion_panel.dart b/lib/admin/ui/pages/permissions/permission_expansion_panel.dart index c31c764a95..f2a886682f 100644 --- a/lib/admin/ui/pages/permissions/permission_expansion_panel.dart +++ b/lib/admin/ui/pages/permissions/permission_expansion_panel.dart @@ -34,6 +34,7 @@ class PermissionsExpansionPanel extends HookConsumerWidget { permissionExpanded.value[i] = isOpen; permissionExpanded.value = List.from(permissionExpanded.value); }, + dividerColor: Theme.of(context).colorScheme.tertiary, children: permissionNames.map((permissionName) { final index = permissionNames.indexOf(permissionName); return ExpansionPanel( @@ -42,8 +43,8 @@ class PermissionsExpansionPanel extends HookConsumerWidget { headerBuilder: (context, isOpen) => ListTile( title: Text( capitalizePermissionName(permissionName), - style: const TextStyle( - color: Color.fromARGB(255, 0, 0, 0), + style: TextStyle( + color: Theme.of(context).colorScheme.onPrimary, fontSize: 18, fontWeight: FontWeight.w600, ), @@ -52,10 +53,10 @@ class PermissionsExpansionPanel extends HookConsumerWidget { body: permissionExpanded.value[index] ? Column( children: [ - const Text( + Text( AdminTextConstants.accountTypes, style: TextStyle( - color: Color.fromARGB(255, 0, 0, 0), + color: Theme.of(context).colorScheme.onPrimary, fontSize: 20, fontWeight: FontWeight.w800, ), @@ -81,11 +82,10 @@ class PermissionsExpansionPanel extends HookConsumerWidget { }, ); }), - const Divider(), - const Text( + Divider(color: Theme.of(context).colorScheme.tertiary), + Text( AdminTextConstants.groups, style: TextStyle( - color: Color.fromARGB(255, 0, 0, 0), fontSize: 20, fontWeight: FontWeight.w900, ), @@ -115,6 +115,7 @@ class PermissionsExpansionPanel extends HookConsumerWidget { ], ) : const SizedBox.shrink(), + backgroundColor: Theme.of(context).colorScheme.secondaryFixed, ); }).toList(), ); diff --git a/lib/admin/ui/pages/permissions/permission_row.dart b/lib/admin/ui/pages/permissions/permission_row.dart index 6ad32062ce..f146ceb309 100644 --- a/lib/admin/ui/pages/permissions/permission_row.dart +++ b/lib/admin/ui/pages/permissions/permission_row.dart @@ -31,6 +31,7 @@ class PermissionRow extends StatelessWidget { child: HeroIcon( isAuthorized ? HeroIcons.check : HeroIcons.xMark, size: 40, + // It's ok to have this green-red hard-coded color: isAuthorized ? Colors.green : Colors.red, ), ), diff --git a/lib/admin/ui/pages/permissions/permissions.dart b/lib/admin/ui/pages/permissions/permissions.dart index cf54beee60..7e7d098f8f 100644 --- a/lib/admin/ui/pages/permissions/permissions.dart +++ b/lib/admin/ui/pages/permissions/permissions.dart @@ -7,7 +7,6 @@ import 'package:titan/admin/providers/permissions_list_provider.dart'; import 'package:titan/admin/tools/constants.dart'; import 'package:titan/admin/ui/admin.dart'; import 'package:titan/admin/ui/pages/permissions/module_expansion_panel.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/ui/builders/async_child.dart'; import 'package:tuple/tuple.dart'; @@ -30,14 +29,14 @@ class PermissionsPage extends HookConsumerWidget { SizedBox( child: Column( children: [ - const Align( + Align( alignment: Alignment.centerLeft, child: Text( AdminTextConstants.modifyModuleVisibility, style: TextStyle( fontSize: 20, fontWeight: FontWeight.w700, - color: ColorConstants.gradient1, + color: Theme.of(context).colorScheme.primaryContainer, ), ), ), diff --git a/lib/admin/ui/pages/schools/add_school_page/add_school_page.dart b/lib/admin/ui/pages/schools/add_school_page/add_school_page.dart index 7ae21c8247..2e646793d1 100644 --- a/lib/admin/ui/pages/schools/add_school_page/add_school_page.dart +++ b/lib/admin/ui/pages/schools/add_school_page/add_school_page.dart @@ -69,12 +69,12 @@ class AddSchoolPage extends HookConsumerWidget { }); }, builder: (child) => AdminButton(child: child), - child: const Text( + child: Text( AdminTextConstants.add, style: TextStyle( fontSize: 18, fontWeight: FontWeight.w600, - color: Colors.white, + color: Theme.of(context).colorScheme.onPrimaryContainer, ), ), ), diff --git a/lib/admin/ui/pages/schools/edit_school_page/edit_school_page.dart b/lib/admin/ui/pages/schools/edit_school_page/edit_school_page.dart index 4253ff6305..7f90f3610c 100644 --- a/lib/admin/ui/pages/schools/edit_school_page/edit_school_page.dart +++ b/lib/admin/ui/pages/schools/edit_school_page/edit_school_page.dart @@ -8,7 +8,6 @@ import 'package:titan/admin/providers/school_provider.dart'; import 'package:titan/admin/tools/constants.dart'; import 'package:titan/admin/ui/admin.dart'; import 'package:titan/admin/ui/components/admin_button.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/functions.dart'; import 'package:titan/tools/token_expire_wrapper.dart'; import 'package:titan/tools/ui/widgets/align_left_text.dart'; @@ -40,10 +39,10 @@ class EditSchoolPage extends HookConsumerWidget { padding: const EdgeInsets.symmetric(horizontal: 30.0), child: Column( children: [ - const AlignLeftText( + AlignLeftText( AdminTextConstants.edit, fontSize: 20, - color: ColorConstants.gradient1, + color: Theme.of(context).colorScheme.primaryContainer, ), const SizedBox(height: 20), Form( @@ -55,7 +54,7 @@ class EditSchoolPage extends HookConsumerWidget { alignment: Alignment.centerLeft, child: TextEntry( controller: name, - color: ColorConstants.gradient1, + color: Theme.of(context).colorScheme.primaryContainer, label: AdminTextConstants.name, suffixIcon: const HeroIcon(HeroIcons.pencil), enabledColor: Colors.transparent, @@ -66,7 +65,7 @@ class EditSchoolPage extends HookConsumerWidget { alignment: Alignment.centerLeft, child: TextEntry( controller: emailRegex, - color: ColorConstants.gradient1, + color: Theme.of(context).colorScheme.primaryContainer, label: AdminTextConstants.emailRegex, suffixIcon: const HeroIcon(HeroIcons.pencil), enabledColor: Colors.transparent, @@ -102,12 +101,12 @@ class EditSchoolPage extends HookConsumerWidget { }); }, builder: (child) => AdminButton(child: child), - child: const Text( + child: Text( AdminTextConstants.edit, style: TextStyle( fontSize: 18, fontWeight: FontWeight.w600, - color: Colors.white, + color: Theme.of(context).colorScheme.onPrimaryContainer, ), ), ), diff --git a/lib/admin/ui/pages/schools/school_page/school_page.dart b/lib/admin/ui/pages/schools/school_page/school_page.dart index 719dc74911..9e4229e700 100644 --- a/lib/admin/ui/pages/schools/school_page/school_page.dart +++ b/lib/admin/ui/pages/schools/school_page/school_page.dart @@ -8,7 +8,6 @@ import 'package:titan/admin/ui/admin.dart'; import 'package:titan/admin/ui/components/item_card_ui.dart'; import 'package:titan/admin/ui/pages/schools/school_page/school_ui.dart'; import 'package:titan/admin/tools/constants.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/ui/builders/async_child.dart'; import 'package:titan/tools/ui/widgets/custom_dialog_box.dart'; import 'package:titan/tools/functions.dart'; @@ -40,14 +39,14 @@ class SchoolsPage extends HookConsumerWidget { child: Column( children: [ const SizedBox(height: 20), - const Align( + Align( alignment: Alignment.centerLeft, child: Text( AdminTextConstants.schools, style: TextStyle( fontSize: 20, fontWeight: FontWeight.w700, - color: ColorConstants.gradient1, + color: Theme.of(context).colorScheme.primaryContainer, ), ), ), @@ -76,7 +75,9 @@ class SchoolsPage extends HookConsumerWidget { const Spacer(), HeroIcon( HeroIcons.plus, - color: Colors.grey.shade700, + color: Theme.of( + context, + ).colorScheme.secondaryContainer, size: 40, ), const Spacer(), @@ -133,7 +134,7 @@ class SchoolsPage extends HookConsumerWidget { ], ); }, - loaderColor: ColorConstants.gradient1, + loaderColor: Theme.of(context).colorScheme.primaryContainer, ), ], ), diff --git a/lib/admin/ui/pages/schools/school_page/school_ui.dart b/lib/admin/ui/pages/schools/school_page/school_ui.dart index 54f788df7b..2f80ba997c 100644 --- a/lib/admin/ui/pages/schools/school_page/school_ui.dart +++ b/lib/admin/ui/pages/schools/school_page/school_ui.dart @@ -5,7 +5,6 @@ import 'package:titan/admin/class/school.dart'; import 'package:titan/admin/tools/constants.dart'; import 'package:titan/admin/ui/components/item_card_ui.dart'; import 'package:titan/admin/ui/pages/schools/school_page/school_button.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/ui/builders/waiting_button.dart'; class SchoolUi extends HookConsumerWidget { @@ -27,8 +26,8 @@ class SchoolUi extends HookConsumerWidget { Expanded( child: Text( school.name, - style: const TextStyle( - color: Colors.black, + style: TextStyle( + color: Theme.of(context).colorScheme.onSurface, fontSize: 20, fontWeight: FontWeight.bold, ), @@ -40,9 +39,12 @@ class SchoolUi extends HookConsumerWidget { GestureDetector( onTap: onEdit, child: SchoolButton( - gradient1: Colors.grey.shade800, - gradient2: Colors.grey.shade900, - child: const HeroIcon(HeroIcons.eye, color: Colors.white), + gradient1: Theme.of(context).colorScheme.secondaryContainer, + gradient2: Theme.of(context).colorScheme.secondary, + child: HeroIcon( + HeroIcons.eye, + color: Theme.of(context).colorScheme.onSecondary, + ), ), ), const SizedBox(width: 10), @@ -51,11 +53,14 @@ class SchoolUi extends HookConsumerWidget { WaitingButton( onTap: onDelete, builder: (child) => SchoolButton( - gradient1: ColorConstants.gradient1, - gradient2: ColorConstants.gradient2, + gradient1: Theme.of(context).colorScheme.primaryContainer, + gradient2: Theme.of(context).colorScheme.primaryFixed, child: child, ), - child: const HeroIcon(HeroIcons.xMark, color: Colors.white), + child: HeroIcon( + HeroIcons.xMark, + color: Theme.of(context).colorScheme.onPrimaryContainer, + ), ), ], ), diff --git a/lib/admin/ui/pages/structure_page/add_edit_structure_page/add_edit_structure_page.dart b/lib/admin/ui/pages/structure_page/add_edit_structure_page/add_edit_structure_page.dart index 643b517171..c99ef5f959 100644 --- a/lib/admin/ui/pages/structure_page/add_edit_structure_page/add_edit_structure_page.dart +++ b/lib/admin/ui/pages/structure_page/add_edit_structure_page/add_edit_structure_page.dart @@ -11,7 +11,6 @@ import 'package:titan/admin/ui/components/admin_button.dart'; import 'package:titan/admin/ui/pages/structure_page/add_edit_structure_page/search_user.dart'; import 'package:titan/mypayment/class/structure.dart'; import 'package:titan/mypayment/providers/structure_list_provider.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/functions.dart'; import 'package:titan/tools/token_expire_wrapper.dart'; import 'package:titan/tools/ui/builders/async_child.dart'; @@ -195,7 +194,9 @@ class AddEditStructurePage extends HookConsumerWidget { child: Text( associationMembership.name.toUpperCase(), style: TextStyle( - color: selected ? Colors.white : Colors.black, + color: selected + ? Theme.of(context).colorScheme.onSecondary + : Theme.of(context).colorScheme.onPrimary, fontWeight: FontWeight.bold, ), ), @@ -211,7 +212,9 @@ class AddEditStructurePage extends HookConsumerWidget { Text( AdminTextConstants.manager, style: TextStyle( - color: ColorConstants.gradient1, + color: Theme.of( + context, + ).colorScheme.primaryContainer, fontSize: 20, fontWeight: FontWeight.bold, ), @@ -220,7 +223,9 @@ class AddEditStructurePage extends HookConsumerWidget { Text( structureManager.getName(), style: TextStyle( - color: ColorConstants.gradient1, + color: Theme.of( + context, + ).colorScheme.primaryContainer, fontSize: 20, fontWeight: FontWeight.bold, ), @@ -307,7 +312,7 @@ class AddEditStructurePage extends HookConsumerWidget { style: TextStyle( fontSize: 18, fontWeight: FontWeight.w600, - color: Colors.white, + color: Theme.of(context).colorScheme.onPrimaryContainer, ), ), ), diff --git a/lib/admin/ui/pages/structure_page/add_edit_structure_page/results.dart b/lib/admin/ui/pages/structure_page/add_edit_structure_page/results.dart index 351f91eea7..4844c59c45 100644 --- a/lib/admin/ui/pages/structure_page/add_edit_structure_page/results.dart +++ b/lib/admin/ui/pages/structure_page/add_edit_structure_page/results.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:heroicons/heroicons.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:titan/admin/providers/structure_manager_provider.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/ui/builders/async_child.dart'; import 'package:titan/tools/ui/builders/waiting_button.dart'; import 'package:titan/user/providers/user_list_provider.dart'; @@ -43,7 +42,9 @@ class MemberResults extends HookConsumerWidget { usersNotifier.clear(); // TODO: Confirmation dialog }, - waitingColor: ColorConstants.gradient1, + waitingColor: Theme.of( + context, + ).colorScheme.primaryContainer, builder: (child) => child, child: const HeroIcon(HeroIcons.plus), ), @@ -55,7 +56,7 @@ class MemberResults extends HookConsumerWidget { ) .toList(), ), - loaderColor: ColorConstants.gradient1, + loaderColor: Theme.of(context).colorScheme.primaryContainer, ); } } diff --git a/lib/admin/ui/pages/structure_page/add_edit_structure_page/search_user.dart b/lib/admin/ui/pages/structure_page/add_edit_structure_page/search_user.dart index 291478fb8e..8b2efc591b 100644 --- a/lib/admin/ui/pages/structure_page/add_edit_structure_page/search_user.dart +++ b/lib/admin/ui/pages/structure_page/add_edit_structure_page/search_user.dart @@ -5,7 +5,6 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:titan/admin/providers/structure_manager_provider.dart'; import 'package:titan/admin/tools/constants.dart'; import 'package:titan/admin/ui/pages/structure_page/add_edit_structure_page/results.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/ui/widgets/styled_search_bar.dart'; import 'package:titan/user/class/simple_users.dart'; import 'package:titan/user/providers/user_list_provider.dart'; @@ -22,7 +21,7 @@ class SearchUser extends HookConsumerWidget { children: [ StyledSearchBar( label: AdminTextConstants.manager, - color: ColorConstants.gradient1, + color: Theme.of(context).colorScheme.primaryContainer, padding: const EdgeInsets.all(0), editingController: useTextEditingController( text: structureManager.id == SimpleUser.empty().id @@ -41,21 +40,30 @@ class SearchUser extends HookConsumerWidget { child: Container( padding: const EdgeInsets.all(7), decoration: BoxDecoration( - gradient: const LinearGradient( - colors: [ColorConstants.gradient1, ColorConstants.gradient2], + gradient: LinearGradient( + colors: [ + Theme.of(context).colorScheme.primaryContainer, + Theme.of(context).colorScheme.primaryFixed, + ], begin: Alignment.topLeft, end: Alignment.bottomRight, ), boxShadow: [ BoxShadow( - color: ColorConstants.gradient2.withValues(alpha: 0.4), + color: Theme.of( + context, + ).colorScheme.primaryFixed.withValues(alpha: 0.4), offset: const Offset(2, 3), blurRadius: 5, ), ], borderRadius: const BorderRadius.all(Radius.circular(10)), ), - child: HeroIcon(HeroIcons.plus, size: 20, color: Colors.white), + child: HeroIcon( + HeroIcons.plus, + size: 20, + color: Theme.of(context).colorScheme.onPrimaryContainer, + ), ), ), ), diff --git a/lib/admin/ui/pages/structure_page/structure_page.dart b/lib/admin/ui/pages/structure_page/structure_page.dart index 9e4894f00a..f1de363158 100644 --- a/lib/admin/ui/pages/structure_page/structure_page.dart +++ b/lib/admin/ui/pages/structure_page/structure_page.dart @@ -11,7 +11,6 @@ import 'package:titan/admin/ui/pages/structure_page/structure_ui.dart'; import 'package:titan/mypayment/class/structure.dart'; import 'package:titan/mypayment/providers/bank_account_holder_provider.dart'; import 'package:titan/mypayment/providers/structure_list_provider.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/ui/builders/async_child.dart'; import 'package:titan/tools/ui/layouts/refresher.dart'; import 'package:titan/user/class/simple_users.dart'; @@ -44,14 +43,14 @@ class StructurePage extends HookConsumerWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ const SizedBox(height: 20), - const Align( + Align( alignment: Alignment.centerLeft, child: Text( AdminTextConstants.structures, style: TextStyle( fontSize: 20, fontWeight: FontWeight.w700, - color: ColorConstants.gradient1, + color: Theme.of(context).colorScheme.primaryContainer, ), ), ), @@ -94,7 +93,9 @@ class StructurePage extends HookConsumerWidget { const Spacer(), HeroIcon( HeroIcons.plus, - color: Colors.grey.shade700, + color: Theme.of( + context, + ).colorScheme.secondaryContainer, size: 40, ), const Spacer(), diff --git a/lib/admin/ui/pages/structure_page/structure_ui.dart b/lib/admin/ui/pages/structure_page/structure_ui.dart index 72a46b216a..aa86ade5cd 100644 --- a/lib/admin/ui/pages/structure_page/structure_ui.dart +++ b/lib/admin/ui/pages/structure_page/structure_ui.dart @@ -39,76 +39,74 @@ class StructureUi extends HookConsumerWidget { context: context, modal: BottomModalTemplate( title: structure.name, - child: Column( - children: [ - Button( - onPressed: () { - structureNotifier.setStructure(structure); - structureManagerNotifier.setUser(structure.managerUser); + actions: [ + Button( + onPressed: () { + structureNotifier.setStructure(structure); + structureManagerNotifier.setUser(structure.managerUser); - QR.to( - AdminRouter.root + - AdminRouter.structures + - AdminRouter.addEditStructure, + QR.to( + AdminRouter.root + + AdminRouter.structures + + AdminRouter.addEditStructure, + ); + Navigator.of(context).pop(); + }, + text: AdminTextConstants.editStructure, + ), + const SizedBox(height: 10), + Button( + onPressed: () async { + final value = await bankAccountHolderNotifier + .updateBankAccountHolder(structure); + if (value) { + displayToastWithContext( + TypeMsg.msg, + AdminTextConstants.setAsBankAccountHolderSuccess, ); - Navigator.of(context).pop(); - }, - text: AdminTextConstants.editStructure, - ), - const SizedBox(height: 10), - Button( - onPressed: () async { - final value = await bankAccountHolderNotifier - .updateBankAccountHolder(structure); - if (value) { - displayToastWithContext( - TypeMsg.msg, - AdminTextConstants.setAsBankAccountHolderSuccess, - ); - } else { - displayToastWithContext( - TypeMsg.error, - AdminTextConstants.setAsBankAccountHolderError, - ); - } - }, - text: AdminTextConstants.setAsBankAccountHolder, - ), - const SizedBox(height: 10), - Button.danger( - onPressed: () async { - await showDialog( - context: context, - builder: (context) { - return CustomDialogBox( - title: AdminTextConstants.delete, - descriptions: AdminTextConstants.deletingDescription, - onYes: () async { - tokenExpireWrapper(ref, () async { - final value = await structuresNotifier - .deleteStructure(structure); - if (value) { - displayToastWithContext( - TypeMsg.msg, - AdminTextConstants.deletedStructure, - ); - } else { - displayToastWithContext( - TypeMsg.error, - AdminTextConstants.deletingStructureError, - ); - } - }); - Navigator.of(context).pop(); - }, - ); - }, + } else { + displayToastWithContext( + TypeMsg.error, + AdminTextConstants.setAsBankAccountHolderError, ); - }, - text: AdminTextConstants.deleteStructure, - ), - ], - ), + } + }, + text: AdminTextConstants.setAsBankAccountHolder, + ), + const SizedBox(height: 10), + Button.danger( + onPressed: () async { + await showDialog( + context: context, + builder: (context) { + return CustomDialogBox( + title: AdminTextConstants.delete, + descriptions: AdminTextConstants.deletingDescription, + onYes: () async { + tokenExpireWrapper(ref, () async { + final value = await structuresNotifier + .deleteStructure(structure); + if (value) { + displayToastWithContext( + TypeMsg.msg, + AdminTextConstants.deletedStructure, + ); + } else { + displayToastWithContext( + TypeMsg.error, + AdminTextConstants.deletingStructureError, + ); + } + }); + Navigator.of(context).pop(); + }, + ); + }, + ); + }, + text: AdminTextConstants.deleteStructure, + ), + ], ), ), child: ItemCardUi( @@ -117,8 +115,8 @@ class StructureUi extends HookConsumerWidget { Expanded( child: Text( structure.name, - style: const TextStyle( - color: Colors.black, + style: TextStyle( + color: Theme.of(context).colorScheme.onSurface, fontSize: 20, fontWeight: FontWeight.bold, ), diff --git a/lib/advert/tools/constants.dart b/lib/advert/tools/constants.dart index 850796300b..747f4e6e6a 100644 --- a/lib/advert/tools/constants.dart +++ b/lib/advert/tools/constants.dart @@ -1,5 +1,3 @@ -import 'dart:ui'; - class AdvertTextConstants { static const String add = 'Ajouter'; static const String addedAdvert = 'Annonce publiée'; @@ -46,11 +44,6 @@ class AdvertTextConstants { ]; } -class AdvertColorConstants { - static const Color redGradient1 = Color(0xFF9E131F); - static const Color redGradient2 = Color(0xFF590512); -} - class AdvertPermissionConstants { static const String accessAdvert = 'access_advert'; static const String manageAdvertisers = 'manage_advertisers'; diff --git a/lib/advert/ui/components/advert_card.dart b/lib/advert/ui/components/advert_card.dart index dfbce33dfc..8bf94af09f 100644 --- a/lib/advert/ui/components/advert_card.dart +++ b/lib/advert/ui/components/advert_card.dart @@ -111,11 +111,11 @@ class AdvertCard extends HookConsumerWidget { width: width, height: height, decoration: BoxDecoration( - color: Colors.white, - boxShadow: const [ + color: Theme.of(context).colorScheme.surface, + boxShadow: [ BoxShadow( blurRadius: 5, - color: Color(0x33000000), + color: Theme.of(context).shadowColor, offset: Offset(2, 2), spreadRadius: 3, ), @@ -179,10 +179,10 @@ class AdvertCard extends HookConsumerWidget { overflow: TextOverflow.ellipsis, maxLines: 1, minFontSize: 15, - style: const TextStyle( - color: Colors.black, - fontSize: 16, - fontWeight: FontWeight.bold, + style: TextStyle( + color: Theme.of( + context, + ).colorScheme.onSurface, ), ), ), @@ -195,8 +195,10 @@ class AdvertCard extends HookConsumerWidget { maxLines: 3, minFontSize: 13, maxFontSize: 15, - style: const TextStyle( - color: Colors.black, + style: TextStyle( + color: Theme.of( + context, + ).colorScheme.onSurface, fontSize: 15, ), ), @@ -216,7 +218,7 @@ class AdvertCard extends HookConsumerWidget { boxShadow: [ BoxShadow( blurRadius: 5, - color: Colors.black.withValues(alpha: 0.3), + color: Theme.of(context).shadowColor, offset: const Offset(2, 2), spreadRadius: 3, ), @@ -227,7 +229,7 @@ class AdvertCard extends HookConsumerWidget { Radius.circular(8), ), child: Container( - color: Colors.white, + color: Theme.of(context).colorScheme.surface, height: 50, width: 50, padding: const EdgeInsets.symmetric( @@ -241,8 +243,10 @@ class AdvertCard extends HookConsumerWidget { AutoSizeText( DateFormat('dd').format(advert.date), textAlign: TextAlign.center, - style: const TextStyle( - color: Colors.black, + style: TextStyle( + color: Theme.of( + context, + ).colorScheme.onSurface, fontSize: 22, fontWeight: FontWeight.bold, height: 1.0, @@ -254,8 +258,10 @@ class AdvertCard extends HookConsumerWidget { ) - 1], textAlign: TextAlign.center, - style: const TextStyle( - color: Colors.black, + style: TextStyle( + color: Theme.of( + context, + ).colorScheme.onSurface, fontSize: 11, fontWeight: FontWeight.bold, height: 1.0, @@ -278,7 +284,7 @@ class AdvertCard extends HookConsumerWidget { boxShadow: [ BoxShadow( blurRadius: 5, - color: Colors.black.withValues(alpha: 0.3), + color: Theme.of(context).shadowColor, offset: const Offset(2, 2), spreadRadius: 3, ), @@ -289,7 +295,7 @@ class AdvertCard extends HookConsumerWidget { Radius.circular(8), ), child: Container( - color: Colors.white, + color: Theme.of(context).colorScheme.surface, height: 30, padding: const EdgeInsets.symmetric( vertical: 5, @@ -299,8 +305,8 @@ class AdvertCard extends HookConsumerWidget { child: AutoSizeText( advert.announcer.name, textAlign: TextAlign.center, - style: const TextStyle( - color: Colors.black, + style: TextStyle( + color: Theme.of(context).colorScheme.onSurface, fontSize: 14, fontWeight: FontWeight.bold, ), diff --git a/lib/advert/ui/components/announcer_bar.dart b/lib/advert/ui/components/announcer_bar.dart index ce1a331382..48b6010cb8 100644 --- a/lib/advert/ui/components/announcer_bar.dart +++ b/lib/advert/ui/components/announcer_bar.dart @@ -25,7 +25,6 @@ class AnnouncerBar extends HookConsumerWidget { final announcerList = useUserAnnouncers ? ref.watch(userAnnouncerListProvider) : ref.watch(announcerListProvider); - final darkerColor = (isNotClickable) ? Colors.grey[800] : Colors.black; return AsyncChild( value: announcerList, @@ -54,7 +53,11 @@ class AnnouncerBar extends HookConsumerWidget { child: Text( e.name, style: TextStyle( - color: selectedId.contains(e.id) ? Colors.white : darkerColor, + color: selectedId.contains(e.id) + ? Theme.of(context).colorScheme.onSecondary + : isNotClickable + ? Theme.of(context).colorScheme.secondaryContainer + : Theme.of(context).colorScheme.onSurface, fontWeight: FontWeight.bold, ), ), diff --git a/lib/advert/ui/components/tag_chip.dart b/lib/advert/ui/components/tag_chip.dart index fba084f3c5..d267d6eedc 100644 --- a/lib/advert/ui/components/tag_chip.dart +++ b/lib/advert/ui/components/tag_chip.dart @@ -1,25 +1,38 @@ import 'dart:math'; import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:titan/advert/tools/functions.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; -class TagChip extends StatelessWidget { +class TagChip extends ConsumerWidget { final String tagName; - const TagChip({super.key, required this.tagName}); @override - Widget build(BuildContext context) { + Widget build(BuildContext context, WidgetRef ref) { + final isDarkTheme = ref.watch(themeProvider); Color bgColor = generateColor(tagName); - Color borderColor = bgColor.computeLuminance() > 0.1 - ? bgColor - : Colors.white; - Color darkerBgColor = Color.from( - alpha: bgColor.a, - red: max(bgColor.r - 0.12, 0), // 0.12 = 30/255 - green: max(bgColor.g - 0.12, 0), - blue: max(bgColor.b - 0.12, 0), - ); + Color borderColor = isDarkTheme + ? (bgColor.computeLuminance() < 0.1 + ? Theme.of(context).colorScheme.onPrimary + : bgColor) + : (bgColor.computeLuminance() > 0.9 + ? Theme.of(context).colorScheme.onPrimary + : bgColor); + Color secondaryBgColor = isDarkTheme + ? Color.from( + alpha: bgColor.a, + red: min(bgColor.r + 0.12, 1), // 0.12 = 30/255 + green: min(bgColor.g + 0.12, 1), + blue: min(bgColor.b + 0.12, 1), + ) + : Color.from( + alpha: bgColor.a, + red: max(bgColor.r - 0.12, 0), // 0.12 = 30/255 + green: max(bgColor.g - 0.12, 0), + blue: max(bgColor.b - 0.12, 0), + ); return Container( margin: const EdgeInsets.symmetric(horizontal: 5), @@ -29,7 +42,7 @@ class TagChip extends StatelessWidget { gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomLeft, - colors: [bgColor, darkerBgColor], + colors: [bgColor, secondaryBgColor], stops: const [0.7, 1.0], ), borderRadius: BorderRadius.circular(20), @@ -41,7 +54,12 @@ class TagChip extends StatelessWidget { tagName, textAlign: TextAlign.center, maxLines: 1, - style: const TextStyle(color: Colors.white, fontSize: 13), + style: TextStyle( + color: bgColor.computeLuminance() < 0.75 + ? Colors.white + : Colors.black, + fontSize: 13, + ), ), ), ); diff --git a/lib/advert/ui/pages/admin_page/admin_advert_card.dart b/lib/advert/ui/pages/admin_page/admin_advert_card.dart index 7397504045..14036671b0 100644 --- a/lib/advert/ui/pages/admin_page/admin_advert_card.dart +++ b/lib/advert/ui/pages/admin_page/admin_advert_card.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:heroicons/heroicons.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:titan/advert/class/advert.dart'; -import 'package:titan/advert/tools/constants.dart'; import 'package:titan/advert/ui/components/advert_card.dart'; import 'package:titan/tools/ui/builders/waiting_button.dart'; import 'package:titan/tools/ui/layouts/card_button.dart'; @@ -38,11 +37,14 @@ class AdminAdvertCard extends HookConsumerWidget { GestureDetector( onTap: onEdit, child: CardButton( - colors: [Colors.grey.shade100, Colors.grey.shade400], - shadowColor: Colors.grey.shade300.withValues(alpha: 0.2), - child: const HeroIcon( + colors: [ + Theme.of(context).colorScheme.surface, + Theme.of(context).colorScheme.secondaryFixed, + ], + shadowColor: Theme.of(context).shadowColor, + child: HeroIcon( HeroIcons.pencil, - color: Colors.black, + color: Theme.of(context).colorScheme.onSurface, ), ), ), @@ -50,16 +52,19 @@ class AdminAdvertCard extends HookConsumerWidget { WaitingButton( onTap: onDelete, builder: (child) => CardButton( - colors: const [ - AdvertColorConstants.redGradient1, - AdvertColorConstants.redGradient2, + colors: [ + Theme.of(context).colorScheme.primaryContainer, + Theme.of(context).colorScheme.primaryFixed, ], - shadowColor: AdvertColorConstants.redGradient2.withValues( - alpha: 0.2, - ), + shadowColor: Theme.of( + context, + ).colorScheme.primaryFixed.withValues(alpha: 0.2), child: child, ), - child: const HeroIcon(HeroIcons.trash, color: Colors.white), + child: HeroIcon( + HeroIcons.trash, + color: Theme.of(context).colorScheme.onPrimaryContainer, + ), ), ], ), diff --git a/lib/advert/ui/pages/admin_page/admin_page.dart b/lib/advert/ui/pages/admin_page/admin_page.dart index 6092ee5bc9..317cd615be 100644 --- a/lib/advert/ui/pages/admin_page/admin_page.dart +++ b/lib/advert/ui/pages/admin_page/admin_page.dart @@ -88,13 +88,16 @@ class AdvertAdminPage extends HookConsumerWidget { ), width: 300, height: 100, - colors: [Colors.white, Colors.grey.shade100], - shadowColor: Colors.grey.withValues(alpha: 0.2), + colors: [ + Theme.of(context).colorScheme.surface, + Theme.of(context).colorScheme.secondaryFixed, + ], + shadowColor: Theme.of(context).shadowColor, child: Center( child: HeroIcon( HeroIcons.plus, size: 40, - color: Colors.grey.shade500, + color: Theme.of(context).colorScheme.tertiary, ), ), ), diff --git a/lib/advert/ui/pages/advert.dart b/lib/advert/ui/pages/advert.dart index f737e5dc07..870b0138cf 100644 --- a/lib/advert/ui/pages/advert.dart +++ b/lib/advert/ui/pages/advert.dart @@ -13,22 +13,19 @@ class AdvertTemplate extends HookConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final selectedAnnouncersNotifier = ref.read(announcerProvider.notifier); return Scaffold( - body: Container( - color: Colors.white, - child: SafeArea( - child: Column( - children: [ - TopBar( - title: AdvertTextConstants.advert, - root: AdvertRouter.root, - onBack: () { - selectedAnnouncersNotifier.clearAnnouncer(); - }, - ), - const SizedBox(height: 30), - Expanded(child: child), - ], - ), + body: SafeArea( + child: Column( + children: [ + TopBar( + title: AdvertTextConstants.advert, + root: AdvertRouter.root, + onBack: () { + selectedAnnouncersNotifier.clearAnnouncer(); + }, + ), + const SizedBox(height: 30), + Expanded(child: child), + ], ), ), ); diff --git a/lib/advert/ui/pages/detail_page/detail.dart b/lib/advert/ui/pages/detail_page/detail.dart index 643d28fb42..bd014be5e2 100644 --- a/lib/advert/ui/pages/detail_page/detail.dart +++ b/lib/advert/ui/pages/detail_page/detail.dart @@ -33,13 +33,13 @@ class AdvertDetailPage extends HookConsumerWidget { children: [ Container( width: double.infinity, - decoration: const BoxDecoration( + decoration: BoxDecoration( boxShadow: [ BoxShadow( - color: Colors.black26, + color: Theme.of(context).shadowColor, blurRadius: 10, spreadRadius: 7, - offset: Offset(0, 5), + offset: const Offset(0, 5), ), ], ), @@ -65,16 +65,18 @@ class AdvertDetailPage extends HookConsumerWidget { begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [ - const Color.fromARGB(0, 255, 255, 255), - Colors.grey.shade50.withValues(alpha: 0.85), - Colors.grey.shade50, + Colors.transparent, + Theme.of( + context, + ).colorScheme.primary.withValues(alpha: 0.85), + Theme.of(context).colorScheme.primary, ], stops: const [0.0, 0.65, 1.0], ), ), ), Container( - color: Colors.grey.shade50, + color: Theme.of(context).colorScheme.primary, child: Column( children: [ const SizedBox(height: 15), @@ -136,18 +138,23 @@ class AdvertDetailPage extends HookConsumerWidget { child: Container( padding: const EdgeInsets.all(8), decoration: BoxDecoration( - color: Colors.white.withValues(alpha: 0.9), + color: Theme.of( + context, + ).colorScheme.surface.withValues(alpha: 0.75), borderRadius: BorderRadius.circular(18), boxShadow: [ BoxShadow( - color: Colors.white.withValues(alpha: 0.3), + color: Theme.of(context).shadowColor, blurRadius: 7, spreadRadius: 2, offset: const Offset(2, 3), ), ], ), - child: const Icon(Icons.arrow_back, color: Colors.black), + child: Icon( + Icons.arrow_back, + color: Theme.of(context).colorScheme.onSurface, + ), ), ), const Spacer(), @@ -157,11 +164,13 @@ class AdvertDetailPage extends HookConsumerWidget { horizontal: 12, ), decoration: BoxDecoration( - color: Colors.white.withValues(alpha: 0.9), + color: Theme.of( + context, + ).colorScheme.surface.withValues(alpha: 0.75), borderRadius: BorderRadius.circular(18), boxShadow: [ BoxShadow( - color: Colors.white.withValues(alpha: 0.3), + color: Theme.of(context).shadowColor, blurRadius: 7, spreadRadius: 2, offset: const Offset(2, 3), diff --git a/lib/advert/ui/pages/form_page/add_edit_advert_page.dart b/lib/advert/ui/pages/form_page/add_edit_advert_page.dart index 0cac9788ce..3f4fa6a465 100644 --- a/lib/advert/ui/pages/form_page/add_edit_advert_page.dart +++ b/lib/advert/ui/pages/form_page/add_edit_advert_page.dart @@ -95,12 +95,12 @@ class AdvertAddEditAdvertPage extends HookConsumerWidget { displayAdvertToastWithContext, child: Container( decoration: BoxDecoration( - color: Colors.white, + color: Theme.of(context).colorScheme.primary, boxShadow: [ BoxShadow( color: formFieldState.hasError - ? Colors.red - : Colors.black.withValues(alpha: 0.1), + ? Theme.of(context).colorScheme.error + : Theme.of(context).shadowColor, spreadRadius: 5, blurRadius: 10, offset: const Offset(2, 3), @@ -137,13 +137,17 @@ class AdvertAddEditAdvertPage extends HookConsumerWidget { const BorderRadius.all( Radius.circular(5), ), - color: Colors.white + color: Theme.of(context) + .colorScheme + .primary .withValues(alpha: 0.4), ), child: HeroIcon( HeroIcons.photo, size: 40, - color: Colors.black + color: Theme.of(context) + .colorScheme + .onPrimary .withValues(alpha: 0.5), ), ), @@ -151,10 +155,12 @@ class AdvertAddEditAdvertPage extends HookConsumerWidget { ), ], ) - : const HeroIcon( + : HeroIcon( HeroIcons.photo, size: 160, - color: Colors.grey, + color: Theme.of( + context, + ).colorScheme.tertiary, ), ), ), @@ -182,15 +188,17 @@ class AdvertAddEditAdvertPage extends HookConsumerWidget { }, builder: (formFieldState) => Container( decoration: BoxDecoration( - color: Colors.white, + color: Theme.of(context).colorScheme.primary, borderRadius: const BorderRadius.all(Radius.circular(20)), boxShadow: formFieldState.hasError ? [ - const BoxShadow( - color: Colors.red, + BoxShadow( + color: Theme.of( + context, + ).colorScheme.primaryContainer, spreadRadius: 3, blurRadius: 3, - offset: Offset(2, 2), + offset: const Offset(2, 2), ), ] : [], @@ -289,8 +297,8 @@ class AdvertAddEditAdvertPage extends HookConsumerWidget { isEdit ? AdvertTextConstants.edit : AdvertTextConstants.add, - style: const TextStyle( - color: Colors.white, + style: TextStyle( + color: Theme.of(context).colorScheme.onSecondary, fontSize: 25, fontWeight: FontWeight.bold, ), diff --git a/lib/advert/ui/pages/form_page/add_rem_announcer_page.dart b/lib/advert/ui/pages/form_page/add_rem_announcer_page.dart index f3843d7288..56d45e5d58 100644 --- a/lib/advert/ui/pages/form_page/add_rem_announcer_page.dart +++ b/lib/advert/ui/pages/form_page/add_rem_announcer_page.dart @@ -8,7 +8,6 @@ import 'package:titan/advert/providers/announcer_list_provider.dart'; import 'package:titan/advert/tools/constants.dart'; import 'package:titan/advert/ui/pages/advert.dart'; import 'package:titan/advert/ui/pages/form_page/announcer_card.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/functions.dart'; import 'package:titan/tools/token_expire_wrapper.dart'; import 'package:titan/tools/ui/builders/async_child.dart'; @@ -40,14 +39,14 @@ class AddRemAnnouncerPage extends HookConsumerWidget { SizedBox( child: Column( children: [ - const Align( + Align( alignment: Alignment.centerLeft, child: Text( AdvertTextConstants.modifyAnnouncingGroup, style: TextStyle( fontSize: 20, fontWeight: FontWeight.w700, - color: ColorConstants.gradient1, + color: Theme.of(context).colorScheme.primaryContainer, ), ), ), diff --git a/lib/advert/ui/pages/form_page/announcer_card.dart b/lib/advert/ui/pages/form_page/announcer_card.dart index 8a118d8d21..66e52648e5 100644 --- a/lib/advert/ui/pages/form_page/announcer_card.dart +++ b/lib/advert/ui/pages/form_page/announcer_card.dart @@ -18,7 +18,11 @@ class AnnouncerCard extends StatelessWidget { e.name, style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w500), ), - HeroIcon(icon, size: 25, color: Colors.black), + HeroIcon( + icon, + size: 25, + color: Theme.of(context).colorScheme.onPrimary, + ), ], ), ); diff --git a/lib/amap/tools/constants.dart b/lib/amap/tools/constants.dart index e19225af24..4d3e6bb3b0 100644 --- a/lib/amap/tools/constants.dart +++ b/lib/amap/tools/constants.dart @@ -2,23 +2,50 @@ import 'package:flutter/material.dart'; import 'package:titan/tools/constants.dart'; class AMAPColorConstants extends ColorConstants { - static final Color background = Colors.grey.shade100; - static final Color background2 = Colors.grey.shade200; - static final Color background3 = Colors.grey.shade300; + static const Color enabled = Color(0xff6b9200); + static const Color red = Color(0xFFC91717); +} + +class AMAPColors { + bool isDarkTheme; + AMAPColors(this.isDarkTheme); static const Color greenGradient1 = Color(0xff79a400); static const Color greenGradient2 = Color(0xff387200); static const Color darkGreen = Color(0xff204300); + static const Color lightGreen = Color(0xFFF4FFB7); // former green3 static const Color textDark = Color(0xff255000); static const Color textLight = Color(0xff528700); static const Color green1 = Color(0xdfa8c700); static const Color green2 = Color(0xdF79a400); - static const Color green3 = Color(0xFFF4FFB7); static const Color lightGradient1 = Color(0xffB6D40A); static const Color lightGradient2 = Color(0xff6C9300); static const Color enabled = Color(0xff6b9200); static const Color red = Color(0xFFC91717); static const Color redGradient1 = Color(0xFF9E131F); static const Color redGradient2 = Color(0xFF590512); + + Color get background => + isDarkTheme ? Colors.grey.shade900 : Colors.grey.shade100; + Color get background2 => + isDarkTheme ? Colors.grey.shade800 : Colors.grey.shade200; + Color get background3 => + isDarkTheme ? Colors.grey.shade700 : Colors.grey.shade300; + Color get greenGradientPrimary => + isDarkTheme ? lightGradient1 : greenGradient1; + Color get greenGradientSecondary => + isDarkTheme ? lightGradient2 : greenGradient2; + Color get primaryGreen => isDarkTheme ? darkGreen : lightGreen; + Color get secondaryGreen => isDarkTheme ? lightGreen : darkGreen; + Color get textOnPrimary => isDarkTheme ? textLight : textDark; + Color get textOnSecondary => isDarkTheme ? textDark : textLight; + Color get primaryFixedGreen => isDarkTheme ? green2 : green1; + Color get secondaryFixedGreen => isDarkTheme ? green1 : green2; + Color get lightGradientPrimary => + isDarkTheme ? greenGradient1 : lightGradient1; + Color get lightGradientSecondary => + isDarkTheme ? greenGradient2 : lightGradient2; + Color get redGradientPrimary => isDarkTheme ? redGradient2 : redGradient1; + Color get redGradientSecondary => isDarkTheme ? redGradient1 : redGradient2; } class AMAPTextConstants { diff --git a/lib/amap/ui/amap.dart b/lib/amap/ui/amap.dart index d2e8c6b9b9..2cd1a105c9 100644 --- a/lib/amap/ui/amap.dart +++ b/lib/amap/ui/amap.dart @@ -22,9 +22,9 @@ class AmapTemplate extends StatelessWidget { onPressed: () { QR.to(AmapRouter.root + AmapRouter.presentation); }, - icon: const HeroIcon( + icon: HeroIcon( HeroIcons.informationCircle, - color: Colors.black, + color: Theme.of(context).colorScheme.onPrimary, size: 40, ), ) diff --git a/lib/amap/ui/components/order_ui.dart b/lib/amap/ui/components/order_ui.dart index 2dee70ccfc..39718a1952 100644 --- a/lib/amap/ui/components/order_ui.dart +++ b/lib/amap/ui/components/order_ui.dart @@ -13,6 +13,7 @@ import 'package:titan/tools/ui/widgets/custom_dialog_box.dart'; import 'package:titan/tools/functions.dart'; import 'package:titan/tools/token_expire_wrapper.dart'; import 'package:titan/tools/ui/builders/waiting_button.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; class OrderUI extends HookConsumerWidget { final Order order; @@ -32,18 +33,16 @@ class OrderUI extends HookConsumerWidget { final orderListNotifier = ref.watch(userOrderListProvider.notifier); final orderNotifier = ref.watch(orderProvider.notifier); final balanceNotifier = ref.watch(userAmountProvider.notifier); + final isDarkTheme = ref.watch(themeProvider); void displayToastWithContext(TypeMsg type, String msg) { displayToast(context, type, msg); } - final style = TextStyle( - fontSize: 18, - fontWeight: FontWeight.bold, - color: AMAPColorConstants.textDark, - ); - final tp = TextPainter( - text: TextSpan(text: order.deliveryName, style: style), + text: TextSpan( + text: order.deliveryName, + style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), + ), textDirection: TextDirection.ltr, maxLines: isDetail ? 3 : 2, ); @@ -55,9 +54,9 @@ class OrderUI extends HookConsumerWidget { id: order.id, width: 214, height: isDetail ? 104 + 26.0 * lines : 144 + 26.0 * lines, - colors: const [ - AMAPColorConstants.lightGradient1, - AMAPColorConstants.greenGradient1, + colors: [ + AMAPColors(isDarkTheme).lightGradientPrimary, + AMAPColors(isDarkTheme).lightGradientSecondary, ], padding: const EdgeInsets.symmetric(horizontal: 17.0, vertical: 12), child: Column( @@ -75,20 +74,20 @@ class OrderUI extends HookConsumerWidget { constraints: BoxConstraints(maxWidth: maxTextWidth), child: Text( order.deliveryName, - style: const TextStyle( + style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: AMAPColorConstants.textDark, + color: AMAPColors(isDarkTheme).secondaryGreen, ), maxLines: isDetail ? 3 : 2, ), ), Text( '${AMAPTextConstants.the} ${processDate(order.deliveryDate)}', - style: const TextStyle( + style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: AMAPColorConstants.textDark, + color: AMAPColors(isDarkTheme).secondaryGreen, ), ), ], @@ -100,9 +99,9 @@ class OrderUI extends HookConsumerWidget { orderNotifier.setOrder(order); onTap?.call(); }, - child: const HeroIcon( + child: HeroIcon( HeroIcons.informationCircle, - color: AMAPColorConstants.textDark, + color: AMAPColors(isDarkTheme).secondaryGreen, size: 30, ), ), @@ -113,19 +112,19 @@ class OrderUI extends HookConsumerWidget { children: [ Text( "${order.products.length} ${AMAPTextConstants.product}${order.products.length != 1 ? "s" : ""}", - style: const TextStyle( + style: TextStyle( fontSize: 17, fontWeight: FontWeight.w700, - color: Colors.white, + color: AMAPColors(isDarkTheme).primaryGreen, ), ), const Spacer(), Text( "${(order.amount / 100).toStringAsFixed(2)}€", - style: const TextStyle( + style: TextStyle( fontSize: 17, fontWeight: FontWeight.w700, - color: Colors.white, + color: AMAPColors(isDarkTheme).primaryGreen, ), ), ], @@ -133,10 +132,10 @@ class OrderUI extends HookConsumerWidget { const SizedBox(height: 3), Text( uiCollectionSlotToString(order.collectionSlot), - style: const TextStyle( + style: TextStyle( fontSize: 17, fontWeight: FontWeight.w700, - color: AMAPColorConstants.textDark, + color: AMAPColors(isDarkTheme).secondaryGreen, ), ), const Spacer(), @@ -149,14 +148,14 @@ class OrderUI extends HookConsumerWidget { orderNotifier.setOrder(order); onEdit?.call(); }, - child: const CardButton( + child: CardButton( colors: [ - AMAPColorConstants.greenGradient1, - AMAPColorConstants.greenGradient2, + AMAPColors(isDarkTheme).greenGradientPrimary, + AMAPColors(isDarkTheme).greenGradientSecondary, ], child: HeroIcon( HeroIcons.pencil, - color: Colors.white, + color: Theme.of(context).colorScheme.onSecondary, ), ), ), @@ -192,25 +191,25 @@ class OrderUI extends HookConsumerWidget { ); }, builder: (child) => CardButton( - colors: const [ - AMAPColorConstants.redGradient1, - AMAPColorConstants.redGradient2, + colors: [ + AMAPColors(isDarkTheme).redGradientPrimary, + AMAPColors(isDarkTheme).redGradientSecondary, ], child: child, ), - child: const HeroIcon( + child: HeroIcon( HeroIcons.trash, - color: Colors.white, + color: Theme.of(context).colorScheme.onSecondary, ), ), ], ) - : const Text( + : Text( AMAPTextConstants.locked, style: TextStyle( fontSize: 17, fontWeight: FontWeight.w700, - color: AMAPColorConstants.textDark, + color: AMAPColors(isDarkTheme).secondaryGreen, ), ), ], diff --git a/lib/amap/ui/components/product_ui.dart b/lib/amap/ui/components/product_ui.dart index 1ac6706a27..c9d09eda1a 100644 --- a/lib/amap/ui/components/product_ui.dart +++ b/lib/amap/ui/components/product_ui.dart @@ -1,13 +1,15 @@ import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:heroicons/heroicons.dart'; import 'package:titan/amap/class/product.dart'; import 'package:titan/amap/tools/constants.dart'; import 'package:titan/tools/ui/layouts/card_button.dart'; import 'package:titan/tools/ui/layouts/card_layout.dart'; import 'package:titan/tools/ui/builders/waiting_button.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; -class ProductCard extends StatelessWidget { +class ProductCard extends ConsumerWidget { final Product product; final Function()? onEdit; final Future Function()? onDelete; @@ -21,14 +23,15 @@ class ProductCard extends StatelessWidget { }); @override - Widget build(BuildContext context) { + Widget build(BuildContext context, WidgetRef ref) { + final isDarkTheme = ref.watch(themeProvider); return CardLayout( id: product.id, width: 130, height: showButton ? 155 : 130, - colors: const [ - AMAPColorConstants.lightGradient1, - AMAPColorConstants.lightGradient2, + colors: [ + AMAPColors(isDarkTheme).lightGradientPrimary, + AMAPColors(isDarkTheme).lightGradientSecondary, ], padding: const EdgeInsets.only(left: 17.0, top: 5, right: 17), child: Column( @@ -40,10 +43,10 @@ class ProductCard extends StatelessWidget { product.category, maxLines: 1, overflow: TextOverflow.ellipsis, - style: const TextStyle( + style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: AMAPColorConstants.darkGreen, + color: AMAPColors(isDarkTheme).secondaryGreen, ), ), const SizedBox(height: 4), @@ -51,10 +54,10 @@ class ProductCard extends StatelessWidget { product.name, maxLines: 2, overflow: TextOverflow.ellipsis, - style: const TextStyle( + style: TextStyle( fontSize: 13, fontWeight: FontWeight.bold, - color: Colors.white, + color: AMAPColors(isDarkTheme).primaryGreen, ), ), const SizedBox(height: 4), @@ -63,10 +66,10 @@ class ProductCard extends StatelessWidget { maxLines: 1, minFontSize: 10, overflow: TextOverflow.ellipsis, - style: const TextStyle( + style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: AMAPColorConstants.darkGreen, + color: AMAPColors(isDarkTheme).secondaryGreen, ), ), const Spacer(), @@ -76,26 +79,29 @@ class ProductCard extends StatelessWidget { children: [ GestureDetector( onTap: onEdit, - child: const CardButton( + child: CardButton( colors: [ - AMAPColorConstants.greenGradient2, - AMAPColorConstants.textDark, + AMAPColors(isDarkTheme).greenGradientPrimary, + AMAPColors(isDarkTheme).greenGradientSecondary, ], - child: HeroIcon(HeroIcons.pencil, color: Colors.white), + child: HeroIcon( + HeroIcons.pencil, + color: Theme.of(context).colorScheme.onSecondary, + ), ), ), WaitingButton( onTap: onDelete, builder: (child) => CardButton( - colors: const [ - AMAPColorConstants.redGradient1, - AMAPColorConstants.redGradient2, + colors: [ + AMAPColors(isDarkTheme).redGradientPrimary, + AMAPColors(isDarkTheme).redGradientSecondary, ], child: child, ), - child: const HeroIcon( + child: HeroIcon( HeroIcons.trash, - color: Colors.white, + color: Theme.of(context).colorScheme.onSecondary, ), ), ], @@ -104,10 +110,10 @@ class ProductCard extends StatelessWidget { margin: const EdgeInsets.only(bottom: 5), child: Text( "${AMAPTextConstants.quantity} : ${product.quantity}", - style: const TextStyle( + style: TextStyle( fontSize: 15, fontWeight: FontWeight.bold, - color: AMAPColorConstants.darkGreen, + color: AMAPColors(isDarkTheme).secondaryGreen, ), ), ), diff --git a/lib/amap/ui/pages/admin_page/account_handler.dart b/lib/amap/ui/pages/admin_page/account_handler.dart index 134c3bb763..f05edd19cb 100644 --- a/lib/amap/ui/pages/admin_page/account_handler.dart +++ b/lib/amap/ui/pages/admin_page/account_handler.dart @@ -11,6 +11,7 @@ import 'package:titan/tools/ui/layouts/card_layout.dart'; import 'package:titan/tools/ui/layouts/horizontal_list_view.dart'; import 'package:titan/tools/ui/widgets/styled_search_bar.dart'; import 'package:titan/user/providers/user_list_provider.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; class AccountHandler extends HookConsumerWidget { const AccountHandler({super.key}); @@ -24,12 +25,13 @@ class AccountHandler extends HookConsumerWidget { final searchingAmapUserNotifier = ref.read( searchingAmapUserProvider.notifier, ); + final isDarkTheme = ref.watch(themeProvider); return Column( children: [ StyledSearchBar( label: AMAPTextConstants.accounts, - color: AMAPColorConstants.textDark, + color: AMAPColors(isDarkTheme).textOnPrimary, onChanged: (value) async { if (!searchingAmapUser) { if (value.isNotEmpty) { @@ -70,17 +72,19 @@ class AccountHandler extends HookConsumerWidget { child: CardLayout( height: 110, width: 100, - colors: const [ - AMAPColorConstants.green1, - AMAPColorConstants.textLight, + colors: [ + AMAPColors(isDarkTheme).primaryFixedGreen, + AMAPColors(isDarkTheme).textOnSecondary, ], - shadowColor: AMAPColorConstants.textDark.withValues(alpha: 0.2), + shadowColor: AMAPColors( + isDarkTheme, + ).textOnPrimary.withValues(alpha: 0.2), padding: const EdgeInsets.symmetric(horizontal: 17.0), child: Container( padding: const EdgeInsets.symmetric(horizontal: 12.0), child: HeroIcon( searchingAmapUser ? HeroIcons.plus : HeroIcons.xMark, - color: AMAPColorConstants.green3, + color: AMAPColors(isDarkTheme).primaryGreen, size: 50, ), ), diff --git a/lib/amap/ui/pages/admin_page/adding_user_card.dart b/lib/amap/ui/pages/admin_page/adding_user_card.dart index ec5d137568..2e8a1acd15 100644 --- a/lib/amap/ui/pages/admin_page/adding_user_card.dart +++ b/lib/amap/ui/pages/admin_page/adding_user_card.dart @@ -5,6 +5,7 @@ import 'package:titan/amap/class/cash.dart'; import 'package:titan/amap/providers/cash_list_provider.dart'; import 'package:titan/amap/tools/constants.dart'; import 'package:titan/user/class/simple_users.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; class AddingUserCard extends HookConsumerWidget { final SimpleUser user; @@ -14,6 +15,7 @@ class AddingUserCard extends HookConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final cashNotifier = ref.watch(cashListProvider.notifier); + final isDarkTheme = ref.watch(themeProvider); return GestureDetector( onTap: () { cashNotifier.addCash( @@ -27,7 +29,7 @@ class AddingUserCard extends HookConsumerWidget { width: 140, height: 75, decoration: BoxDecoration( - color: Colors.white, + color: Theme.of(context).colorScheme.surface, borderRadius: BorderRadius.circular(25), ), child: Padding( @@ -40,10 +42,10 @@ class AddingUserCard extends HookConsumerWidget { user.nickname ?? user.firstname, maxLines: 1, overflow: TextOverflow.ellipsis, - style: const TextStyle( + style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: AMAPColorConstants.textLight, + color: AMAPColors(isDarkTheme).textOnSecondary, ), ), const SizedBox(height: 2), @@ -53,10 +55,10 @@ class AddingUserCard extends HookConsumerWidget { : user.name, maxLines: 2, overflow: TextOverflow.ellipsis, - style: const TextStyle( + style: TextStyle( fontSize: 13, fontWeight: FontWeight.bold, - color: AMAPColorConstants.textDark, + color: AMAPColors(isDarkTheme).textOnPrimary, ), ), const SizedBox(height: 3), diff --git a/lib/amap/ui/pages/admin_page/adding_user_container.dart b/lib/amap/ui/pages/admin_page/adding_user_container.dart index 8777ea625f..cf1befe2b2 100644 --- a/lib/amap/ui/pages/admin_page/adding_user_container.dart +++ b/lib/amap/ui/pages/admin_page/adding_user_container.dart @@ -4,6 +4,7 @@ import 'package:titan/amap/tools/constants.dart'; import 'package:titan/amap/ui/pages/admin_page/adding_user_card.dart'; import 'package:titan/tools/ui/builders/async_child.dart'; import 'package:titan/user/providers/user_list_provider.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; class AddingUserContainer extends HookConsumerWidget { final VoidCallback onAdd; @@ -12,6 +13,7 @@ class AddingUserContainer extends HookConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final users = ref.watch(userList); + final isDarkTheme = ref.watch(themeProvider); return AsyncChild( value: users, builder: (context, users) => Row( @@ -19,7 +21,7 @@ class AddingUserContainer extends HookConsumerWidget { .map((e) => AddingUserCard(user: e, onAdd: onAdd)) .toList(), ), - loaderColor: AMAPColorConstants.greenGradient2, + loaderColor: AMAPColors(isDarkTheme).greenGradientSecondary, ); } } diff --git a/lib/amap/ui/pages/admin_page/cash_container.dart b/lib/amap/ui/pages/admin_page/cash_container.dart index cd1d2f89b1..9ed28d8dc3 100644 --- a/lib/amap/ui/pages/admin_page/cash_container.dart +++ b/lib/amap/ui/pages/admin_page/cash_container.dart @@ -5,6 +5,7 @@ import 'package:titan/amap/providers/cash_list_provider.dart'; import 'package:titan/amap/tools/constants.dart'; import 'package:titan/amap/ui/pages/admin_page/user_cash_ui.dart'; import 'package:titan/tools/ui/builders/async_child.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; class CashContainer extends HookConsumerWidget { const CashContainer({super.key}); @@ -12,6 +13,7 @@ class CashContainer extends HookConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final cash = ref.watch(cashListProvider); + final isDarkTheme = ref.watch(themeProvider); return AsyncChild( value: cash, builder: (context, cash) => Row( @@ -20,7 +22,7 @@ class CashContainer extends HookConsumerWidget { .map((e) => UserCashUi(cash: e)) .toList(), ), - loaderColor: AMAPColorConstants.greenGradient2, + loaderColor: AMAPColors(isDarkTheme).greenGradientSecondary, ); } } diff --git a/lib/amap/ui/pages/admin_page/delivery_handler.dart b/lib/amap/ui/pages/admin_page/delivery_handler.dart index 9c78e1f583..4850f3638b 100644 --- a/lib/amap/ui/pages/admin_page/delivery_handler.dart +++ b/lib/amap/ui/pages/admin_page/delivery_handler.dart @@ -13,6 +13,7 @@ import 'package:titan/tools/ui/builders/async_child.dart'; import 'package:titan/tools/ui/layouts/card_layout.dart'; import 'package:titan/tools/ui/layouts/horizontal_list_view.dart'; import 'package:qlevar_router/qlevar_router.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; class DeliveryHandler extends HookConsumerWidget { const DeliveryHandler({super.key}); @@ -22,12 +23,13 @@ class DeliveryHandler extends HookConsumerWidget { final deliveries = ref.watch(deliveryListProvider); final deliveryIdNotifier = ref.watch(deliveryIdProvider.notifier); final selectedNotifier = ref.watch(selectedListProvider.notifier); + final isDarkTheme = ref.watch(themeProvider); return Column( children: [ - const AlignLeftText( + AlignLeftText( AMAPTextConstants.deliveries, - padding: EdgeInsets.symmetric(horizontal: 30), - color: AMAPColorConstants.textDark, + padding: const EdgeInsets.symmetric(horizontal: 30), + color: AMAPColors(isDarkTheme).textOnPrimary, ), const SizedBox(height: 10), HorizontalListView( @@ -47,11 +49,13 @@ class DeliveryHandler extends HookConsumerWidget { child: CardLayout( height: 160, width: 100, - shadowColor: AMAPColorConstants.textDark.withValues(alpha: 0.2), - child: const Center( + shadowColor: AMAPColors( + isDarkTheme, + ).textOnPrimary.withValues(alpha: 0.2), + child: Center( child: HeroIcon( HeroIcons.plus, - color: AMAPColorConstants.textDark, + color: AMAPColors(isDarkTheme).textOnPrimary, size: 50, ), ), @@ -65,7 +69,7 @@ class DeliveryHandler extends HookConsumerWidget { children: data.map((e) => DeliveryUi(delivery: e)).toList(), ); }, - loaderColor: AMAPColorConstants.greenGradient2, + loaderColor: AMAPColors(isDarkTheme).greenGradientSecondary, ), const SizedBox(width: 5), ], diff --git a/lib/amap/ui/pages/admin_page/delivery_ui.dart b/lib/amap/ui/pages/admin_page/delivery_ui.dart index 863a8eae68..a83bed95af 100644 --- a/lib/amap/ui/pages/admin_page/delivery_ui.dart +++ b/lib/amap/ui/pages/admin_page/delivery_ui.dart @@ -19,6 +19,7 @@ import 'package:titan/tools/functions.dart'; import 'package:titan/tools/token_expire_wrapper.dart'; import 'package:titan/tools/ui/builders/waiting_button.dart'; import 'package:qlevar_router/qlevar_router.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; class DeliveryUi extends HookConsumerWidget { final Delivery delivery; @@ -40,6 +41,7 @@ class DeliveryUi extends HookConsumerWidget { final ordersByDeliveryListNotifier = ref.watch( orderByDeliveryListProvider.notifier, ); + final isDarkTheme = ref.watch(themeProvider); void displayVoteWithContext(TypeMsg type, String msg) { displayToast(context, type, msg); @@ -48,7 +50,7 @@ class DeliveryUi extends HookConsumerWidget { final style = TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: AMAPColorConstants.textDark, + color: AMAPColors(isDarkTheme).textOnPrimary, ); final tp = TextPainter( @@ -64,7 +66,7 @@ class DeliveryUi extends HookConsumerWidget { id: delivery.id, height: 155 + 26.0 * (lines), width: 280, - shadowColor: AMAPColorConstants.textDark.withValues(alpha: 0.2), + shadowColor: AMAPColors(isDarkTheme).textOnPrimary.withValues(alpha: 0.2), padding: const EdgeInsets.all(10), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -89,20 +91,20 @@ class DeliveryUi extends HookConsumerWidget { constraints: BoxConstraints(maxWidth: maxTextWidth), child: Text( delivery.name, - style: const TextStyle( + style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: AMAPColorConstants.textDark, + color: AMAPColors(isDarkTheme).textOnPrimary, ), maxLines: 3, ), ), Text( ' ${AMAPTextConstants.the} ${processDate(delivery.deliveryDate)}', - style: const TextStyle( + style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: AMAPColorConstants.textDark, + color: AMAPColors(isDarkTheme).textOnPrimary, ), ), ], @@ -119,9 +121,9 @@ class DeliveryUi extends HookConsumerWidget { AmapRouter.detailDelivery, ); }, - child: const HeroIcon( + child: HeroIcon( HeroIcons.arrowTopRightOnSquare, - color: AMAPColorConstants.textDark, + color: AMAPColors(isDarkTheme).textOnPrimary, ), ), ], @@ -137,20 +139,20 @@ class DeliveryUi extends HookConsumerWidget { orders.isEmpty ? AMAPTextConstants.noCurrentOrder : '${orders.length} ${AMAPTextConstants.oneOrder}${orders.length != 1 ? "s" : ""}', - style: const TextStyle( + style: TextStyle( fontSize: 15, fontWeight: FontWeight.bold, - color: AMAPColorConstants.textDark, + color: AMAPColors(isDarkTheme).textOnPrimary, ), ); }, ), Text( "${delivery.products.length} ${AMAPTextConstants.product}${delivery.products.length != 1 ? "s" : ""}", - style: const TextStyle( + style: TextStyle( fontSize: 15, fontWeight: FontWeight.w700, - color: AMAPColorConstants.textLight, + color: AMAPColors(isDarkTheme).textOnSecondary, ), ), ], @@ -192,14 +194,14 @@ class DeliveryUi extends HookConsumerWidget { orElse: () {}, ); }, - child: const CardButton( + child: CardButton( colors: [ - AMAPColorConstants.greenGradient1, - AMAPColorConstants.greenGradient1, + AMAPColors(isDarkTheme).greenGradientPrimary, + AMAPColors(isDarkTheme).greenGradientPrimary, ], child: HeroIcon( HeroIcons.pencil, - color: Colors.white, + color: Theme.of(context).colorScheme.onSecondary, size: 22, ), ), @@ -236,15 +238,15 @@ class DeliveryUi extends HookConsumerWidget { ); }, builder: (child) => CardButton( - colors: const [ - AMAPColorConstants.redGradient1, - AMAPColorConstants.redGradient2, + colors: [ + AMAPColors(isDarkTheme).redGradientPrimary, + AMAPColors(isDarkTheme).redGradientSecondary, ], child: child, ), - child: const HeroIcon( + child: HeroIcon( HeroIcons.trash, - color: Colors.white, + color: Theme.of(context).colorScheme.onSecondary, size: 22, ), ), @@ -346,12 +348,12 @@ class DeliveryUi extends HookConsumerWidget { gradient: LinearGradient( colors: !(delivery.status == DeliveryStatus.creation) ? [ - AMAPColorConstants.redGradient1, - AMAPColorConstants.redGradient2, + AMAPColors(isDarkTheme).redGradientPrimary, + AMAPColors(isDarkTheme).redGradientSecondary, ] : [ - AMAPColorConstants.greenGradient1, - AMAPColorConstants.greenGradient2, + AMAPColors(isDarkTheme).greenGradientPrimary, + AMAPColors(isDarkTheme).greenGradientSecondary, ], begin: Alignment.topLeft, end: Alignment.bottomRight, @@ -359,12 +361,12 @@ class DeliveryUi extends HookConsumerWidget { boxShadow: [ BoxShadow( color: !(delivery.status == DeliveryStatus.creation) - ? AMAPColorConstants.redGradient2.withValues( - alpha: 0.5, - ) - : AMAPColorConstants.greenGradient2.withValues( - alpha: 0.5, - ), + ? AMAPColors( + isDarkTheme, + ).redGradientSecondary.withValues(alpha: 0.5) + : AMAPColors( + isDarkTheme, + ).greenGradientSecondary.withValues(alpha: 0.5), blurRadius: 10, offset: const Offset(2, 3), ), @@ -384,8 +386,8 @@ class DeliveryUi extends HookConsumerWidget { : delivery.status == DeliveryStatus.locked ? AMAPTextConstants.endingDelivery : AMAPTextConstants.archiveDelivery, - style: const TextStyle( - color: Colors.white, + style: TextStyle( + color: Theme.of(context).colorScheme.onSecondary, fontSize: 20, ), ), @@ -399,7 +401,7 @@ class DeliveryUi extends HookConsumerWidget { : delivery.status == DeliveryStatus.locked ? HeroIcons.truck : HeroIcons.archiveBoxArrowDown, - color: Colors.white, + color: Theme.of(context).colorScheme.onSecondary, size: 22, ), ], diff --git a/lib/amap/ui/pages/admin_page/product_handler.dart b/lib/amap/ui/pages/admin_page/product_handler.dart index 57abe7c04f..de692ce966 100644 --- a/lib/amap/ui/pages/admin_page/product_handler.dart +++ b/lib/amap/ui/pages/admin_page/product_handler.dart @@ -15,6 +15,7 @@ import 'package:titan/tools/ui/widgets/custom_dialog_box.dart'; import 'package:titan/tools/token_expire_wrapper.dart'; import 'package:titan/tools/ui/layouts/horizontal_list_view.dart'; import 'package:qlevar_router/qlevar_router.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; class ProductHandler extends HookConsumerWidget { const ProductHandler({super.key}); @@ -30,6 +31,7 @@ class ProductHandler extends HookConsumerWidget { .expand((element) => element) .toList(); final productsNotifier = ref.read(productListProvider.notifier); + final isDarkTheme = ref.watch(themeProvider); void displayToastWithContext(TypeMsg type, String msg) { displayToast(context, type, msg); @@ -37,10 +39,10 @@ class ProductHandler extends HookConsumerWidget { return Column( children: [ - const AlignLeftText( - padding: EdgeInsets.symmetric(horizontal: 30), + AlignLeftText( + padding: const EdgeInsets.symmetric(horizontal: 30), AMAPTextConstants.products, - color: AMAPColorConstants.textDark, + color: AMAPColors(isDarkTheme).textOnPrimary, ), const SizedBox(height: 10), HorizontalListView( @@ -59,15 +61,14 @@ class ProductHandler extends HookConsumerWidget { child: CardLayout( height: 155, width: 100, - colors: const [ - AMAPColorConstants.lightGradient1, - AMAPColorConstants.lightGradient2, + colors: [ + AMAPColors(isDarkTheme).lightGradientPrimary, + AMAPColors(isDarkTheme).lightGradientSecondary, ], - shadowColor: AMAPColorConstants.textDark.withValues(alpha: 0.3), - child: const Center( + child: Center( child: HeroIcon( HeroIcons.plus, - color: Colors.white, + color: AMAPColors(isDarkTheme).primaryGreen, size: 50, ), ), diff --git a/lib/amap/ui/pages/admin_page/user_cash_ui.dart b/lib/amap/ui/pages/admin_page/user_cash_ui.dart index 8d6d2b99b7..3737682f8e 100644 --- a/lib/amap/ui/pages/admin_page/user_cash_ui.dart +++ b/lib/amap/ui/pages/admin_page/user_cash_ui.dart @@ -13,6 +13,7 @@ import 'package:titan/tools/functions.dart'; import 'package:titan/tools/token_expire_wrapper.dart'; import 'package:titan/tools/ui/builders/waiting_button.dart'; import 'package:titan/tools/ui/widgets/text_entry.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; class UserCashUi extends HookConsumerWidget { final Cash cash; @@ -23,6 +24,7 @@ class UserCashUi extends HookConsumerWidget { final flipped = useState(true); final amount = useTextEditingController(); final key = GlobalKey(); + final isDarkTheme = ref.watch(themeProvider); bool isFront = true; double anglePlus = 0; final controller = useAnimationController( @@ -76,10 +78,10 @@ class UserCashUi extends HookConsumerWidget { cash.user.nickname ?? cash.user.firstname, maxLines: 1, overflow: TextOverflow.ellipsis, - style: const TextStyle( + style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: AMAPColorConstants.green3, + color: AMAPColors(isDarkTheme).primaryGreen, ), ), const SizedBox(height: 5), @@ -89,10 +91,10 @@ class UserCashUi extends HookConsumerWidget { : cash.user.name, maxLines: 1, overflow: TextOverflow.ellipsis, - style: const TextStyle( + style: TextStyle( fontSize: 13, fontWeight: FontWeight.bold, - color: AMAPColorConstants.textDark, + color: AMAPColors(isDarkTheme).secondaryGreen, ), ), const SizedBox(height: 5), @@ -104,15 +106,15 @@ class UserCashUi extends HookConsumerWidget { maxLines: 1, minFontSize: 10, overflow: TextOverflow.ellipsis, - style: const TextStyle( + style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: AMAPColorConstants.green3, + color: AMAPColors(isDarkTheme).primaryGreen, ), ), - const HeroIcon( + HeroIcon( HeroIcons.plus, - color: AMAPColorConstants.green3, + color: AMAPColors(isDarkTheme).primaryGreen, size: 20, ), ], @@ -137,8 +139,10 @@ class UserCashUi extends HookConsumerWidget { controller: amount, keyboardType: TextInputType.number, isDouble: true, - color: AMAPColorConstants.textDark, - enabledColor: AMAPColorConstants.green3, + color: AMAPColors(isDarkTheme).secondaryGreen, + enabledColor: AMAPColors( + isDarkTheme, + ).primaryGreen, suffix: '€', isNegative: true, ), @@ -187,9 +191,9 @@ class UserCashUi extends HookConsumerWidget { }); } }, - child: const Icon( + child: Icon( Icons.add, - color: AMAPColorConstants.green3, + color: AMAPColors(isDarkTheme).primaryGreen, size: 30, ), ), diff --git a/lib/amap/ui/pages/admin_page/user_cash_ui_layout.dart b/lib/amap/ui/pages/admin_page/user_cash_ui_layout.dart index 7d75e6384e..540d4583f2 100644 --- a/lib/amap/ui/pages/admin_page/user_cash_ui_layout.dart +++ b/lib/amap/ui/pages/admin_page/user_cash_ui_layout.dart @@ -1,18 +1,24 @@ import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:titan/amap/tools/constants.dart'; import 'package:titan/tools/ui/layouts/card_layout.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; -class UserCashUiLayout extends StatelessWidget { +class UserCashUiLayout extends ConsumerWidget { final Widget child; const UserCashUiLayout({super.key, required this.child}); @override - Widget build(BuildContext context) { + Widget build(BuildContext context, WidgetRef ref) { + final isDarkTheme = ref.watch(themeProvider); return CardLayout( width: 150, height: 110, - colors: const [AMAPColorConstants.green1, AMAPColorConstants.textLight], - shadowColor: AMAPColorConstants.textDark.withValues(alpha: 0.2), + colors: [ + AMAPColors(isDarkTheme).primaryFixedGreen, + AMAPColors(isDarkTheme).textOnSecondary, + ], + shadowColor: AMAPColors(isDarkTheme).textOnPrimary.withValues(alpha: 0.2), padding: const EdgeInsets.symmetric(horizontal: 17.0, vertical: 5), child: child, ); diff --git a/lib/amap/ui/pages/delivery_pages/add_edit_delivery_cmd_page.dart b/lib/amap/ui/pages/delivery_pages/add_edit_delivery_cmd_page.dart index 4a6c97f99e..146e24e15b 100644 --- a/lib/amap/ui/pages/delivery_pages/add_edit_delivery_cmd_page.dart +++ b/lib/amap/ui/pages/delivery_pages/add_edit_delivery_cmd_page.dart @@ -20,6 +20,7 @@ import 'package:titan/tools/ui/widgets/date_entry.dart'; import 'package:titan/tools/ui/builders/waiting_button.dart'; import 'package:titan/tools/ui/widgets/text_entry.dart'; import 'package:qlevar_router/qlevar_router.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; class AddEditDeliveryPage extends HookConsumerWidget { const AddEditDeliveryPage({super.key}); @@ -37,6 +38,7 @@ class AddEditDeliveryPage extends HookConsumerWidget { final sortedProductsList = ref.watch(sortedByCategoryProductsProvider); final selected = ref.watch(selectedListProvider); final selectedNotifier = ref.watch(selectedListProvider.notifier); + final isDarkTheme = ref.watch(themeProvider); void displayToastWithContext(TypeMsg type, String msg) { displayToast(context, type, msg); @@ -56,15 +58,15 @@ class AddEditDeliveryPage extends HookConsumerWidget { physics: const BouncingScrollPhysics(), child: Column( children: [ - const AlignLeftText( + AlignLeftText( AMAPTextConstants.addDelivery, - color: AMAPColorConstants.green2, + color: AMAPColors(isDarkTheme).secondaryFixedGreen, ), const SizedBox(height: 20), TextEntry( label: AMAPTextConstants.name, controller: nameController, - color: AMAPColorConstants.greenGradient2, + color: AMAPColors(isDarkTheme).greenGradientSecondary, enabledColor: AMAPColorConstants.enabled, ), @@ -75,7 +77,7 @@ class AddEditDeliveryPage extends HookConsumerWidget { label: AMAPTextConstants.commandDate, controller: dateController, enabledColor: AMAPColorConstants.enabled, - color: AMAPColorConstants.greenGradient2, + color: AMAPColors(isDarkTheme).greenGradientSecondary, ), ), const SizedBox(height: 15), @@ -103,12 +105,6 @@ class AddEditDeliveryPage extends HookConsumerWidget { style: const TextStyle( fontSize: 20, fontWeight: FontWeight.w800, - color: Color.fromARGB( - 0, - 255, - 0, - 0, - ), ), ), ), @@ -136,9 +132,9 @@ class AddEditDeliveryPage extends HookConsumerWidget { const SizedBox(height: 30), WaitingButton( builder: (child) => AddEditButtonLayout( - colors: const [ - AMAPColorConstants.greenGradient1, - AMAPColorConstants.greenGradient2, + colors: [ + AMAPColors(isDarkTheme).greenGradientPrimary, + AMAPColors(isDarkTheme).greenGradientSecondary, ], child: child, ), @@ -221,13 +217,15 @@ class AddEditDeliveryPage extends HookConsumerWidget { style: TextStyle( fontSize: 20, fontWeight: FontWeight.w700, - color: AMAPColorConstants.background, + color: AMAPColors(isDarkTheme).background, ), ), ), ], ), - loaderColor: AMAPColorConstants.greenGradient2, + loaderColor: AMAPColors( + isDarkTheme, + ).greenGradientSecondary, ), const SizedBox(height: 40), ], diff --git a/lib/amap/ui/pages/delivery_pages/product_ui_check.dart b/lib/amap/ui/pages/delivery_pages/product_ui_check.dart index 036704793b..5fa79c701f 100644 --- a/lib/amap/ui/pages/delivery_pages/product_ui_check.dart +++ b/lib/amap/ui/pages/delivery_pages/product_ui_check.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:titan/amap/class/product.dart'; import 'package:titan/amap/tools/constants.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; class ProductUi extends ConsumerWidget { final Product product; @@ -16,6 +17,7 @@ class ProductUi extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { + final isDarkTheme = ref.watch(themeProvider); return Container( height: 55, alignment: Alignment.centerLeft, @@ -43,8 +45,8 @@ class ProductUi extends ConsumerWidget { const SizedBox(width: 15), Checkbox( value: isModification, - checkColor: AMAPColorConstants.background, - activeColor: const Color.fromARGB(223, 121, 164, 0), + checkColor: AMAPColors(isDarkTheme).background, + activeColor: AMAPColors(isDarkTheme).secondaryFixedGreen, onChanged: (value) { onclick(); }, diff --git a/lib/amap/ui/pages/detail_delivery_page/detail_page.dart b/lib/amap/ui/pages/detail_delivery_page/detail_page.dart index e42347c3fd..f1b24039dd 100644 --- a/lib/amap/ui/pages/detail_delivery_page/detail_page.dart +++ b/lib/amap/ui/pages/detail_delivery_page/detail_page.dart @@ -17,6 +17,7 @@ import 'package:titan/tools/ui/widgets/align_left_text.dart'; import 'package:titan/tools/ui/builders/async_child.dart'; import 'package:titan/tools/ui/widgets/loader.dart'; import 'package:titan/tools/ui/layouts/refresher.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; class DetailDeliveryPage extends HookConsumerWidget { const DetailDeliveryPage({super.key}); @@ -34,6 +35,7 @@ class DetailDeliveryPage extends HookConsumerWidget { sortedByCategoryDeliveryProductsProvider, ); final cash = ref.watch(cashListProvider); + final isDarkTheme = ref.watch(themeProvider); return AmapTemplate( child: Refresher( onRefresh: () async { @@ -61,9 +63,9 @@ class DetailDeliveryPage extends HookConsumerWidget { ), ), const SizedBox(height: 20), - const AlignLeftText( + AlignLeftText( "${AMAPTextConstants.products} :", - color: AMAPColorConstants.textDark, + color: AMAPColors(isDarkTheme).textOnPrimary, ), ], ), @@ -118,19 +120,23 @@ class DetailDeliveryPage extends HookConsumerWidget { ); }).values, const SizedBox(height: 20), - const AlignLeftText( + AlignLeftText( "${AMAPTextConstants.orders} :", - padding: EdgeInsets.only(left: 30), - color: AMAPColorConstants.textDark, + padding: const EdgeInsets.only(left: 30), + color: AMAPColors(isDarkTheme).textOnPrimary, ), const SizedBox(height: 30), Container( margin: const EdgeInsets.symmetric(horizontal: 10), child: orders == null - ? const Loader(color: AMAPColorConstants.greenGradient2) + ? Loader( + color: AMAPColors(isDarkTheme).greenGradientSecondary, + ) : AsyncChild( value: orders, - loaderColor: AMAPColorConstants.greenGradient2, + loaderColor: AMAPColors( + isDarkTheme, + ).greenGradientSecondary, builder: (context, data) { if (data.isEmpty) { return Container( @@ -142,7 +148,9 @@ class DetailDeliveryPage extends HookConsumerWidget { } return AsyncChild( value: cash, - loaderColor: AMAPColorConstants.greenGradient2, + loaderColor: AMAPColors( + isDarkTheme, + ).greenGradientSecondary, builder: (context, cash) { return Wrap( spacing: 20, diff --git a/lib/amap/ui/pages/detail_delivery_page/order_detail_ui.dart b/lib/amap/ui/pages/detail_delivery_page/order_detail_ui.dart index 21385908ac..78a02e6835 100644 --- a/lib/amap/ui/pages/detail_delivery_page/order_detail_ui.dart +++ b/lib/amap/ui/pages/detail_delivery_page/order_detail_ui.dart @@ -14,6 +14,7 @@ import 'package:titan/tools/ui/widgets/custom_dialog_box.dart'; import 'package:titan/tools/functions.dart'; import 'package:titan/tools/token_expire_wrapper.dart'; import 'package:titan/tools/ui/builders/waiting_button.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; class DetailOrderUI extends HookConsumerWidget { final Order order; @@ -34,6 +35,7 @@ class DetailOrderUI extends HookConsumerWidget { adminDeliveryOrderListProvider.notifier, ); final cashListNotifier = ref.watch(cashListProvider.notifier); + final isDarkTheme = ref.watch(themeProvider); void displayToastWithContext(TypeMsg type, String msg) { displayToast(context, type, msg); } @@ -41,9 +43,9 @@ class DetailOrderUI extends HookConsumerWidget { return CardLayout( width: 250, height: 139 + (24.0 * order.products.length), - colors: const [ - AMAPColorConstants.lightGradient1, - AMAPColorConstants.greenGradient1, + colors: [ + AMAPColors(isDarkTheme).lightGradientPrimary, + AMAPColors(isDarkTheme).lightGradientSecondary, ], padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 17.0), child: Column( @@ -55,10 +57,10 @@ class DetailOrderUI extends HookConsumerWidget { child: AutoSizeText( order.user.getName(), maxLines: 1, - style: const TextStyle( + style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: AMAPColorConstants.textDark, + color: AMAPColors(isDarkTheme).secondaryGreen, ), ), ), @@ -72,10 +74,10 @@ class DetailOrderUI extends HookConsumerWidget { maxLines: 1, minFontSize: 10, overflow: TextOverflow.ellipsis, - style: const TextStyle( + style: TextStyle( fontSize: 17, fontWeight: FontWeight.w700, - color: Colors.white, + color: AMAPColors(isDarkTheme).primaryGreen, ), ), ), @@ -84,10 +86,10 @@ class DetailOrderUI extends HookConsumerWidget { child: Text( "${product.quantity} (${((product.quantity * product.price) / 100).toStringAsFixed(2)}€)", textAlign: TextAlign.right, - style: const TextStyle( + style: TextStyle( fontSize: 17, fontWeight: FontWeight.w700, - color: Colors.white, + color: AMAPColors(isDarkTheme).primaryGreen, ), ), ), @@ -96,9 +98,9 @@ class DetailOrderUI extends HookConsumerWidget { ), Container( height: 3, - decoration: const BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.all(Radius.circular(10)), + decoration: BoxDecoration( + color: AMAPColors(isDarkTheme).primaryGreen, + borderRadius: const BorderRadius.all(Radius.circular(10)), ), margin: const EdgeInsets.symmetric(vertical: 7), ), @@ -106,19 +108,19 @@ class DetailOrderUI extends HookConsumerWidget { children: [ Text( "${order.products.fold(0, (value, product) => value + product.quantity)} ${AMAPTextConstants.product}${order.products.fold(0, (value, product) => value + product.quantity) != 1 ? "s" : ""}", - style: const TextStyle( + style: TextStyle( fontSize: 17, fontWeight: FontWeight.w700, - color: Colors.white, + color: AMAPColors(isDarkTheme).primaryGreen, ), ), const Spacer(), Text( "${(order.amount / 100).toStringAsFixed(2)}€", - style: const TextStyle( + style: TextStyle( fontSize: 17, fontWeight: FontWeight.w700, - color: Colors.white, + color: AMAPColors(isDarkTheme).primaryGreen, ), ), ], @@ -128,10 +130,10 @@ class DetailOrderUI extends HookConsumerWidget { children: [ Text( "${AMAPTextConstants.amount} : ${(userCash.balance / 100).toStringAsFixed(2)}€", - style: const TextStyle( + style: TextStyle( fontSize: 17, fontWeight: FontWeight.w700, - color: AMAPColorConstants.textDark, + color: AMAPColors(isDarkTheme).secondaryGreen, ), ), const Spacer(), @@ -182,15 +184,15 @@ class DetailOrderUI extends HookConsumerWidget { ); }, builder: (child) => CardButton( - colors: const [ - AMAPColorConstants.redGradient1, - AMAPColorConstants.redGradient2, + colors: [ + AMAPColors(isDarkTheme).redGradientPrimary, + AMAPColors(isDarkTheme).redGradientSecondary, ], child: child, ), - child: const HeroIcon( + child: HeroIcon( HeroIcons.trash, - color: Colors.white, + color: Theme.of(context).colorScheme.onSecondary, size: 20, ), ), diff --git a/lib/amap/ui/pages/detail_delivery_page/product_detail_ui.dart b/lib/amap/ui/pages/detail_delivery_page/product_detail_ui.dart index a98c04de76..c1685a67fb 100644 --- a/lib/amap/ui/pages/detail_delivery_page/product_detail_ui.dart +++ b/lib/amap/ui/pages/detail_delivery_page/product_detail_ui.dart @@ -1,10 +1,12 @@ import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:titan/amap/class/product.dart'; import 'package:titan/amap/tools/constants.dart'; import 'package:titan/tools/ui/layouts/card_layout.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; -class ProductDetailCard extends StatelessWidget { +class ProductDetailCard extends ConsumerWidget { final Product product; final int quantity; const ProductDetailCard({ @@ -14,15 +16,15 @@ class ProductDetailCard extends StatelessWidget { }); @override - Widget build(BuildContext context) { + Widget build(BuildContext context, WidgetRef ref) { + final isDarkTheme = ref.watch(themeProvider); return CardLayout( width: 130, height: 104, - colors: const [ - AMAPColorConstants.lightGradient1, - AMAPColorConstants.lightGradient2, + colors: [ + AMAPColors(isDarkTheme).lightGradientPrimary, + AMAPColors(isDarkTheme).lightGradientSecondary, ], - shadowColor: AMAPColorConstants.textDark.withValues(alpha: 0.3), padding: const EdgeInsets.only(left: 17.0, top: 5, right: 17), child: Column( mainAxisAlignment: MainAxisAlignment.start, @@ -33,10 +35,10 @@ class ProductDetailCard extends StatelessWidget { product.name, maxLines: 1, overflow: TextOverflow.ellipsis, - style: const TextStyle( + style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: AMAPColorConstants.darkGreen, + color: AMAPColors(isDarkTheme).secondaryGreen, ), ), const SizedBox(height: 4), @@ -44,10 +46,10 @@ class ProductDetailCard extends StatelessWidget { "${AMAPTextConstants.quantity} : $quantity", maxLines: 2, overflow: TextOverflow.ellipsis, - style: const TextStyle( + style: TextStyle( fontSize: 13, fontWeight: FontWeight.bold, - color: Colors.white, + color: AMAPColors(isDarkTheme).primaryGreen, ), ), const SizedBox(height: 4), @@ -56,10 +58,10 @@ class ProductDetailCard extends StatelessWidget { maxLines: 1, minFontSize: 10, overflow: TextOverflow.ellipsis, - style: const TextStyle( + style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: AMAPColorConstants.darkGreen, + color: AMAPColors(isDarkTheme).secondaryGreen, ), ), const SizedBox(height: 10), diff --git a/lib/amap/ui/pages/detail_page/detail_page.dart b/lib/amap/ui/pages/detail_page/detail_page.dart index b9fa3170a9..b75a284f8c 100644 --- a/lib/amap/ui/pages/detail_page/detail_page.dart +++ b/lib/amap/ui/pages/detail_page/detail_page.dart @@ -27,10 +27,10 @@ class DetailPage extends HookConsumerWidget { width: double.infinity, decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), - color: Colors.grey.shade50, + color: Theme.of(context).colorScheme.secondaryFixed, boxShadow: [ BoxShadow( - color: Colors.grey.withValues(alpha: 0.2), + color: Theme.of(context).shadowColor, blurRadius: 10, offset: const Offset(0, 10), ), diff --git a/lib/amap/ui/pages/list_products_page/category_page.dart b/lib/amap/ui/pages/list_products_page/category_page.dart index a390f1472e..aecbf35cf0 100644 --- a/lib/amap/ui/pages/list_products_page/category_page.dart +++ b/lib/amap/ui/pages/list_products_page/category_page.dart @@ -10,6 +10,7 @@ import 'package:titan/amap/tools/constants.dart'; import 'package:titan/amap/ui/pages/list_products_page/product_ui_list.dart'; import 'package:titan/tools/functions.dart'; import 'package:titan/tools/ui/widgets/align_left_text.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; class CategoryPage extends HookConsumerWidget { final String category; @@ -30,6 +31,7 @@ class CategoryPage extends HookConsumerWidget { final scrollController = ref.watch(scrollControllerProvider(hideAnimation)); final scroll = ref.watch(scrollProvider); + final isDarkTheme = ref.watch(themeProvider); double minScale = 0.8; double scale = 1; @@ -73,7 +75,7 @@ class CategoryPage extends HookConsumerWidget { top: 20, right: 20, ), - color: AMAPColorConstants.textDark, + color: AMAPColors(isDarkTheme).textOnPrimary, fontSize: 25, ), ), @@ -100,8 +102,9 @@ class CategoryPage extends HookConsumerWidget { ), child: Container( decoration: BoxDecoration( - color: AMAPColorConstants.background2 - .withValues(alpha: 0.5), + color: AMAPColors( + isDarkTheme, + ).background2.withValues(alpha: 0.5), ), child: Column(children: listWidgetProduct), ), @@ -129,17 +132,20 @@ class CategoryPage extends HookConsumerWidget { width: 150, height: 50, decoration: BoxDecoration( - gradient: const LinearGradient( + gradient: LinearGradient( colors: [ - AMAPColorConstants.green1, - AMAPColorConstants.green2, + AMAPColors(isDarkTheme).primaryFixedGreen, + AMAPColors( + isDarkTheme, + ).secondaryFixedGreen, ], begin: Alignment.topLeft, end: Alignment.bottomRight, ), boxShadow: [ BoxShadow( - color: AMAPColorConstants.green2 + color: AMAPColors(isDarkTheme) + .secondaryFixedGreen .withValues(alpha: 0.4), offset: const Offset(2, 3), blurRadius: 5, @@ -157,13 +163,15 @@ class CategoryPage extends HookConsumerWidget { HeroIcon( HeroIcons.chevronDoubleDown, size: 15, - color: AMAPColorConstants.background, + color: AMAPColors(isDarkTheme).background, ), Text( AMAPTextConstants.seeMore, style: TextStyle( fontSize: 18, - color: AMAPColorConstants.background, + color: AMAPColors( + isDarkTheme, + ).background, ), ), ], @@ -182,9 +190,9 @@ class CategoryPage extends HookConsumerWidget { filter: ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), child: Container( decoration: BoxDecoration( - color: AMAPColorConstants.background2.withValues( - alpha: 0.5, - ), + color: AMAPColors( + isDarkTheme, + ).background2.withValues(alpha: 0.5), ), child: Column(children: listWidgetProduct), ), diff --git a/lib/amap/ui/pages/list_products_page/list_products_page.dart b/lib/amap/ui/pages/list_products_page/list_products_page.dart index e40c9235e3..dfaaa564d3 100644 --- a/lib/amap/ui/pages/list_products_page/list_products_page.dart +++ b/lib/amap/ui/pages/list_products_page/list_products_page.dart @@ -39,9 +39,15 @@ class ListProductPage extends HookConsumerWidget { decoration: BoxDecoration( gradient: LinearGradient( colors: [ - Colors.white, - Colors.white.withValues(alpha: 0.8), - Colors.white.withValues(alpha: 0.0), + Theme.of( + context, + ).colorScheme.primary.withValues(alpha: 1.0), + Theme.of( + context, + ).colorScheme.primary.withValues(alpha: 0.8), + Theme.of( + context, + ).colorScheme.primary.withValues(alpha: 0.0), ], begin: Alignment.topCenter, end: Alignment.bottomCenter, diff --git a/lib/amap/ui/pages/list_products_page/page_view_dots.dart b/lib/amap/ui/pages/list_products_page/page_view_dots.dart index 6038947c7a..678ace0409 100644 --- a/lib/amap/ui/pages/list_products_page/page_view_dots.dart +++ b/lib/amap/ui/pages/list_products_page/page_view_dots.dart @@ -4,6 +4,7 @@ import 'package:titan/amap/providers/page_controller_provider.dart'; import 'package:titan/amap/providers/sorted_delivery_product.dart'; import 'package:titan/amap/tools/constants.dart'; import 'package:smooth_page_indicator/smooth_page_indicator.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; class Dots extends HookConsumerWidget { const Dots({super.key}); @@ -12,12 +13,13 @@ class Dots extends HookConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final pageController = ref.watch(amapPageControllerProvider); final len = ref.watch(sortedByCategoryDeliveryProductsProvider).length; + final isDarkTheme = ref.watch(themeProvider); return len > 0 ? SmoothPageIndicator( controller: pageController, count: len, effect: WormEffect( - dotColor: AMAPColorConstants.background3, + dotColor: AMAPColors(isDarkTheme).background3, activeDotColor: AMAPColorConstants.enabled, dotWidth: 7, dotHeight: 7, diff --git a/lib/amap/ui/pages/list_products_page/product_choice_button.dart b/lib/amap/ui/pages/list_products_page/product_choice_button.dart index 547351fca9..55f99320a7 100644 --- a/lib/amap/ui/pages/list_products_page/product_choice_button.dart +++ b/lib/amap/ui/pages/list_products_page/product_choice_button.dart @@ -7,6 +7,7 @@ import 'package:titan/amap/providers/delivery_id_provider.dart'; import 'package:titan/amap/providers/user_order_list_provider.dart'; import 'package:titan/amap/providers/user_amount_provider.dart'; import 'package:titan/amap/tools/constants.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; import 'package:titan/tools/ui/widgets/custom_dialog_box.dart'; import 'package:titan/tools/functions.dart'; import 'package:titan/tools/token_expire_wrapper.dart'; @@ -26,6 +27,7 @@ class ProductChoiceButton extends HookConsumerWidget { final userAmountNotifier = ref.watch(userAmountProvider.notifier); final me = ref.watch(userProvider); final isEdit = order.id != Order.empty().id; + final isDarkTheme = ref.watch(themeProvider); void displayToastWithContext(TypeMsg type, String msg) { displayToast(context, type, msg); } @@ -38,23 +40,23 @@ class ProductChoiceButton extends HookConsumerWidget { children: [ Expanded( child: WaitingButton( - waitingColor: AMAPColorConstants.background, + waitingColor: AMAPColors(isDarkTheme).background, builder: (child) => Container( margin: const EdgeInsets.only(right: 10), decoration: BoxDecoration( - gradient: const LinearGradient( + gradient: LinearGradient( colors: [ - AMAPColorConstants.greenGradient1, - AMAPColorConstants.greenGradient2, + AMAPColors(isDarkTheme).greenGradientPrimary, + AMAPColors(isDarkTheme).greenGradientSecondary, ], begin: Alignment.topLeft, end: Alignment.bottomRight, ), boxShadow: [ BoxShadow( - color: AMAPColorConstants.greenGradient2.withValues( - alpha: 0.4, - ), + color: AMAPColors( + isDarkTheme, + ).greenGradientSecondary.withValues(alpha: 0.4), offset: const Offset(2, 3), blurRadius: 5, ), @@ -118,7 +120,7 @@ class ProductChoiceButton extends HookConsumerWidget { style: TextStyle( fontSize: 20, fontWeight: FontWeight.w700, - color: AMAPColorConstants.background, + color: AMAPColors(isDarkTheme).background, ), ), ), @@ -128,19 +130,19 @@ class ProductChoiceButton extends HookConsumerWidget { padding: const EdgeInsets.symmetric(horizontal: 12), height: 70, decoration: BoxDecoration( - gradient: const LinearGradient( + gradient: LinearGradient( colors: [ - AMAPColorConstants.redGradient1, - AMAPColorConstants.redGradient2, + AMAPColors(isDarkTheme).redGradientPrimary, + AMAPColors(isDarkTheme).redGradientSecondary, ], begin: Alignment.topLeft, end: Alignment.bottomRight, ), boxShadow: [ BoxShadow( - color: AMAPColorConstants.redGradient2.withValues( - alpha: 0.4, - ), + color: AMAPColors( + isDarkTheme, + ).redGradientSecondary.withValues(alpha: 0.4), offset: const Offset(2, 3), blurRadius: 5, ), @@ -151,7 +153,7 @@ class ProductChoiceButton extends HookConsumerWidget { child: HeroIcon( HeroIcons.xMark, size: 35, - color: AMAPColorConstants.background, + color: AMAPColors(isDarkTheme).background, ), ), onTap: () { diff --git a/lib/amap/ui/pages/list_products_page/product_ui_list.dart b/lib/amap/ui/pages/list_products_page/product_ui_list.dart index c3ac4888fc..86be89cf2a 100644 --- a/lib/amap/ui/pages/list_products_page/product_ui_list.dart +++ b/lib/amap/ui/pages/list_products_page/product_ui_list.dart @@ -5,6 +5,7 @@ import 'package:heroicons/heroicons.dart'; import 'package:titan/amap/class/product.dart'; import 'package:titan/amap/providers/order_provider.dart'; import 'package:titan/amap/tools/constants.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; class ProductUiInList extends ConsumerWidget { final Product p; @@ -20,6 +21,7 @@ class ProductUiInList extends ConsumerWidget { orElse: () => Product.empty(), ) .quantity; + final isDarkTheme = ref.watch(themeProvider); return Container( height: 50, alignment: Alignment.centerLeft, @@ -54,8 +56,10 @@ class ProductUiInList extends ConsumerWidget { HeroIcons.minus, size: 22, color: quantity > 0 - ? AMAPColorConstants.green2.withValues(alpha: 0.8) - : AMAPColorConstants.background3, + ? AMAPColors( + isDarkTheme, + ).secondaryFixedGreen.withValues(alpha: 0.8) + : AMAPColors(isDarkTheme).background3, ), ), onTap: () { @@ -107,7 +111,9 @@ class ProductUiInList extends ConsumerWidget { child: HeroIcon( HeroIcons.plus, size: 22, - color: AMAPColorConstants.green2.withValues(alpha: 0.8), + color: AMAPColors( + isDarkTheme, + ).secondaryFixedGreen.withValues(alpha: 0.8), ), ), onTap: () { diff --git a/lib/amap/ui/pages/list_products_page/web_page_navigation_button.dart b/lib/amap/ui/pages/list_products_page/web_page_navigation_button.dart index f3d54cf6c3..05ce72600b 100644 --- a/lib/amap/ui/pages/list_products_page/web_page_navigation_button.dart +++ b/lib/amap/ui/pages/list_products_page/web_page_navigation_button.dart @@ -1,8 +1,9 @@ import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:heroicons/heroicons.dart'; import 'package:titan/amap/tools/constants.dart'; -class WebPageNavigationButton extends StatelessWidget { +class WebPageNavigationButton extends ConsumerWidget { final VoidCallback onPressed; final HeroIcons icon; const WebPageNavigationButton({ @@ -12,7 +13,7 @@ class WebPageNavigationButton extends StatelessWidget { }); @override - Widget build(BuildContext context) { + Widget build(BuildContext context, WidgetRef ref) { return Container( height: 50, width: 50, @@ -29,7 +30,11 @@ class WebPageNavigationButton extends StatelessWidget { ), child: IconButton( onPressed: onPressed, - icon: HeroIcon(icon, size: 25, color: Colors.white), + icon: HeroIcon( + icon, + size: 25, + color: Theme.of(context).colorScheme.onSecondary, + ), ), ); } diff --git a/lib/amap/ui/pages/main_page/collection_slot_selector.dart b/lib/amap/ui/pages/main_page/collection_slot_selector.dart index 9de132519b..cc3a8dd063 100644 --- a/lib/amap/ui/pages/main_page/collection_slot_selector.dart +++ b/lib/amap/ui/pages/main_page/collection_slot_selector.dart @@ -5,6 +5,7 @@ import 'package:titan/amap/providers/order_provider.dart'; import 'package:titan/amap/tools/constants.dart'; import 'package:titan/amap/tools/functions.dart'; import 'package:titan/tools/functions.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; class CollectionSlotSelector extends HookConsumerWidget { final CollectionSlot collectionSlot; @@ -16,6 +17,7 @@ class CollectionSlotSelector extends HookConsumerWidget { final orderNotifier = ref.read(orderProvider.notifier); final isSelected = collectionSlot == order.collectionSlot; final isFirst = CollectionSlot.values.first == collectionSlot; + final isDarkTheme = ref.watch(themeProvider); return Expanded( child: GestureDetector( onTap: () { @@ -33,7 +35,7 @@ class CollectionSlotSelector extends HookConsumerWidget { bottomRight: Radius.circular(!isFirst ? 22 : 0), ), color: isSelected - ? Colors.white.withValues(alpha: 0.7) + ? Theme.of(context).colorScheme.surface.withValues(alpha: 0.7) : Colors.transparent, ), child: Center( @@ -43,8 +45,8 @@ class CollectionSlotSelector extends HookConsumerWidget { fontSize: 25, fontWeight: FontWeight.bold, color: isSelected - ? AMAPColorConstants.greenGradient2 - : Colors.white, + ? AMAPColors(isDarkTheme).greenGradientSecondary + : Theme.of(context).colorScheme.onSecondary, ), ), ), diff --git a/lib/amap/ui/pages/main_page/delivery_section.dart b/lib/amap/ui/pages/main_page/delivery_section.dart index 65aba3ecfd..495257f84a 100644 --- a/lib/amap/ui/pages/main_page/delivery_section.dart +++ b/lib/amap/ui/pages/main_page/delivery_section.dart @@ -5,6 +5,7 @@ import 'package:titan/amap/providers/delivery_id_provider.dart'; import 'package:titan/amap/providers/delivery_list_provider.dart'; import 'package:titan/amap/tools/constants.dart'; import 'package:titan/amap/ui/pages/main_page/delivery_ui.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; import 'package:titan/tools/ui/widgets/align_left_text.dart'; import 'package:titan/tools/ui/builders/async_child.dart'; @@ -27,12 +28,15 @@ class DeliverySection extends HookConsumerWidget { .toList(), orElse: () => [], )..sort((a, b) => a.deliveryDate.compareTo(b.deliveryDate)); + final isDarkTheme = ref.watch(themeProvider); return Column( children: [ AlignLeftText( AMAPTextConstants.deliveries, padding: const EdgeInsets.symmetric(horizontal: 30), - color: showSelected ? Colors.white : AMAPColorConstants.textDark, + color: showSelected + ? Theme.of(context).colorScheme.onSecondary + : AMAPColors(isDarkTheme).textOnPrimary, ), AsyncChild( value: deliveries, @@ -67,7 +71,7 @@ class DeliverySection extends HookConsumerWidget { ), ); }, - loaderColor: AMAPColorConstants.greenGradient2, + loaderColor: AMAPColors(isDarkTheme).greenGradientSecondary, ), ], ); diff --git a/lib/amap/ui/pages/main_page/delivery_ui.dart b/lib/amap/ui/pages/main_page/delivery_ui.dart index 611f7ea41e..d33f71e853 100644 --- a/lib/amap/ui/pages/main_page/delivery_ui.dart +++ b/lib/amap/ui/pages/main_page/delivery_ui.dart @@ -4,6 +4,7 @@ import 'package:titan/amap/class/delivery.dart'; import 'package:titan/amap/providers/delivery_provider.dart'; import 'package:titan/amap/tools/constants.dart'; import 'package:titan/tools/functions.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; class DeliveryUi extends HookConsumerWidget { final Delivery delivery; @@ -20,6 +21,7 @@ class DeliveryUi extends HookConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final selectedDelivery = ref.watch(deliveryProvider); final selected = selectedDelivery.id == delivery.id; + final isDarkTheme = ref.watch(themeProvider); return GestureDetector( onTap: onTap, child: Container( @@ -32,16 +34,18 @@ class DeliveryUi extends HookConsumerWidget { gradient: LinearGradient( colors: [ (selected && showSelected) - ? AMAPColorConstants.greenGradient2 - : Colors.white, + ? AMAPColors(isDarkTheme).greenGradientSecondary + : Theme.of(context).colorScheme.surface, (selected && showSelected) - ? AMAPColorConstants.textDark - : Colors.white, + ? AMAPColors(isDarkTheme).textOnPrimary + : Theme.of(context).colorScheme.surface, ], ), boxShadow: [ BoxShadow( - color: AMAPColorConstants.textDark.withValues(alpha: 0.2), + color: AMAPColors( + isDarkTheme, + ).textOnPrimary.withValues(alpha: 0.2), spreadRadius: 5, blurRadius: 10, offset: const Offset(3, 3), @@ -70,8 +74,8 @@ class DeliveryUi extends HookConsumerWidget { fontSize: 18, fontWeight: FontWeight.bold, color: (selected && showSelected) - ? Colors.white - : AMAPColorConstants.textDark, + ? Theme.of(context).colorScheme.onSecondary + : AMAPColors(isDarkTheme).textOnPrimary, ), ), ), @@ -81,8 +85,8 @@ class DeliveryUi extends HookConsumerWidget { fontSize: 18, fontWeight: FontWeight.bold, color: (selected && showSelected) - ? Colors.white - : AMAPColorConstants.textDark, + ? Theme.of(context).colorScheme.onSecondary + : AMAPColors(isDarkTheme).textOnPrimary, ), ), ], @@ -94,8 +98,8 @@ class DeliveryUi extends HookConsumerWidget { fontSize: 18, fontWeight: FontWeight.w700, color: (selected && showSelected) - ? Colors.white - : AMAPColorConstants.textLight, + ? Theme.of(context).colorScheme.onSecondary + : AMAPColors(isDarkTheme).textOnSecondary, ), ), const SizedBox(width: 10), diff --git a/lib/amap/ui/pages/main_page/main_page.dart b/lib/amap/ui/pages/main_page/main_page.dart index 28fcf25205..b7049cfff4 100644 --- a/lib/amap/ui/pages/main_page/main_page.dart +++ b/lib/amap/ui/pages/main_page/main_page.dart @@ -3,6 +3,7 @@ import 'package:titan/amap/providers/available_deliveries.dart'; import 'package:titan/amap/router.dart'; import 'package:titan/amap/ui/amap.dart'; import 'package:titan/tools/functions.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; import 'package:titan/tools/ui/widgets/admin_button.dart'; import 'package:titan/tools/ui/widgets/align_left_text.dart'; import 'package:titan/tools/ui/builders/async_child.dart'; @@ -59,6 +60,8 @@ class AmapMainPage extends HookConsumerWidget { .map((delivery) => delivery.id) .toList(growable: false); + final isDarkTheme = ref.watch(themeProvider); + void displayToastWithoutContext(TypeMsg type, String text) { displayToast(context, type, text); } @@ -84,13 +87,15 @@ class AmapMainPage extends HookConsumerWidget { value: balance, builder: (context, s) => Text( "${AMAPTextConstants.amount} : ${(s.balance / 100).toStringAsFixed(2)}€", - style: const TextStyle( + style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold, - color: AMAPColorConstants.greenGradient1, + color: AMAPColors(isDarkTheme).lightGradientSecondary, ), ), - loaderColor: AMAPColorConstants.greenGradient1, + loaderColor: AMAPColors( + isDarkTheme, + ).lightGradientSecondary, ), ), if (isAdmin) @@ -98,9 +103,9 @@ class AmapMainPage extends HookConsumerWidget { onTap: () { QR.to(AmapRouter.root + AmapRouter.admin); }, - colors: const [ - AMAPColorConstants.greenGradient1, - AMAPColorConstants.greenGradient2, + colors: [ + AMAPColors(isDarkTheme).greenGradientPrimary, + AMAPColors(isDarkTheme).greenGradientSecondary, ], ), ], @@ -154,10 +159,10 @@ class AmapMainPage extends HookConsumerWidget { ? 350.0 + 90 * availableDeliveriesIds.length : MediaQuery.of(context).size.height - 150, decoration: BoxDecoration( - gradient: const RadialGradient( + gradient: RadialGradient( colors: [ - AMAPColorConstants.textLight, - AMAPColorConstants.greenGradient1, + AMAPColors(isDarkTheme).textOnSecondary, + AMAPColors(isDarkTheme).greenGradientPrimary, ], center: Alignment.topRight, radius: 1.5, @@ -168,9 +173,9 @@ class AmapMainPage extends HookConsumerWidget { ), boxShadow: [ BoxShadow( - color: AMAPColorConstants.textDark.withValues( - alpha: 0.3, - ), + color: AMAPColors( + isDarkTheme, + ).textOnPrimary.withValues(alpha: 0.3), spreadRadius: 5, blurRadius: 10, offset: const Offset(3, 3), @@ -185,14 +190,18 @@ class AmapMainPage extends HookConsumerWidget { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - const AlignLeftText( + AlignLeftText( AMAPTextConstants.addOrder, - color: Colors.white, + color: Theme.of( + context, + ).colorScheme.onSecondary, ), IconButton( - icon: const HeroIcon( + icon: HeroIcon( HeroIcons.xMark, - color: Colors.white, + color: Theme.of( + context, + ).colorScheme.onSecondary, size: 30, ), onPressed: () { @@ -211,7 +220,12 @@ class AmapMainPage extends HookConsumerWidget { width: double.infinity, decoration: BoxDecoration( borderRadius: BorderRadius.circular(25), - border: Border.all(color: Colors.white, width: 2), + border: Border.all( + color: Theme.of( + context, + ).colorScheme.onSecondary, + width: 2, + ), ), child: Row( children: CollectionSlot.values @@ -247,19 +261,21 @@ class AmapMainPage extends HookConsumerWidget { height: 70, decoration: BoxDecoration( borderRadius: BorderRadius.circular(25), - gradient: const LinearGradient( + gradient: LinearGradient( colors: [ - AMAPColorConstants.greenGradient2, - AMAPColorConstants.textDark, + AMAPColors( + isDarkTheme, + ).greenGradientSecondary, + AMAPColors(isDarkTheme).textOnPrimary, ], begin: Alignment.topLeft, end: Alignment.bottomRight, ), boxShadow: [ BoxShadow( - color: AMAPColorConstants.textDark.withValues( - alpha: 0.3, - ), + color: AMAPColors( + isDarkTheme, + ).textOnPrimary.withValues(alpha: 0.3), spreadRadius: 2, blurRadius: 10, offset: const Offset(2, 5), @@ -271,13 +287,15 @@ class AmapMainPage extends HookConsumerWidget { child: Container( padding: const EdgeInsets.only(bottom: 5), width: double.infinity, - child: const Center( + child: Center( child: Text( AMAPTextConstants.nextStep, style: TextStyle( fontSize: 25, fontWeight: FontWeight.w900, - color: Colors.white, + color: Theme.of( + context, + ).colorScheme.onSecondary, ), ), ), diff --git a/lib/amap/ui/pages/main_page/orders_section.dart b/lib/amap/ui/pages/main_page/orders_section.dart index 4561f4e2be..51ddfb50e7 100644 --- a/lib/amap/ui/pages/main_page/orders_section.dart +++ b/lib/amap/ui/pages/main_page/orders_section.dart @@ -9,6 +9,7 @@ import 'package:titan/amap/providers/order_provider.dart'; import 'package:titan/amap/providers/user_order_list_provider.dart'; import 'package:titan/amap/tools/constants.dart'; import 'package:titan/amap/ui/components/order_ui.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; import 'package:titan/tools/ui/widgets/align_left_text.dart'; import 'package:titan/tools/ui/builders/async_child.dart'; import 'package:titan/tools/ui/layouts/card_layout.dart'; @@ -35,13 +36,14 @@ class OrderSection extends HookConsumerWidget { .toList(), orElse: () => [], ); + final isDarkTheme = ref.watch(themeProvider); return Column( children: [ - const AlignLeftText( + AlignLeftText( AMAPTextConstants.orders, - padding: EdgeInsets.symmetric(horizontal: 30), - color: AMAPColorConstants.textDark, + padding: const EdgeInsets.symmetric(horizontal: 30), + color: AMAPColors(isDarkTheme).textOnPrimary, ), const SizedBox(height: 10), HorizontalListView( @@ -55,17 +57,17 @@ class OrderSection extends HookConsumerWidget { orderNotifier.setOrder(e); addOrder(); }, - child: const CardLayout( + child: CardLayout( width: 100, height: 150, colors: [ - AMAPColorConstants.lightGradient1, - AMAPColorConstants.greenGradient1, + AMAPColors(isDarkTheme).lightGradientPrimary, + AMAPColors(isDarkTheme).lightGradientSecondary, ], child: Center( child: HeroIcon( HeroIcons.plus, - color: Colors.white, + color: AMAPColors(isDarkTheme).primaryGreen, size: 50, ), ), @@ -93,7 +95,7 @@ class OrderSection extends HookConsumerWidget { }).toList(), ); }, - loaderColor: AMAPColorConstants.greenGradient2, + loaderColor: AMAPColors(isDarkTheme).greenGradientSecondary, ), const SizedBox(width: 25), ], diff --git a/lib/amap/ui/pages/presentation_page/text.dart b/lib/amap/ui/pages/presentation_page/text.dart index 16caacedf2..a86f9edf8d 100644 --- a/lib/amap/ui/pages/presentation_page/text.dart +++ b/lib/amap/ui/pages/presentation_page/text.dart @@ -5,6 +5,7 @@ import 'package:titan/amap/providers/information_provider.dart'; import 'package:titan/amap/tools/constants.dart'; import 'package:titan/amap/ui/amap.dart'; import 'package:titan/tools/functions.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; import 'package:titan/tools/ui/builders/async_child.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -14,6 +15,7 @@ class PresentationPage extends HookConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final information = ref.watch(informationProvider); + final isDarkTheme = ref.watch(themeProvider); void displayToastWithContext(TypeMsg type, String msg) { displayToast(context, type, msg); @@ -37,10 +39,10 @@ class PresentationPage extends HookConsumerWidget { fontWeight: FontWeight.w600, foreground: Paint() ..shader = - const RadialGradient( + RadialGradient( colors: [ - AMAPColorConstants.greenGradient1, - AMAPColorConstants.textDark, + AMAPColors(isDarkTheme).greenGradientPrimary, + AMAPColors(isDarkTheme).textOnPrimary, ], center: Alignment.topLeft, radius: 10, @@ -73,14 +75,17 @@ class PresentationPage extends HookConsumerWidget { } }, ), - error: (Object error, StackTrace stackTrace) => - const TextSpan( - text: AMAPTextConstants.loadingError, - style: TextStyle(color: Colors.red), - ), - loading: () => const TextSpan( + error: (Object error, StackTrace stackTrace) => TextSpan( + text: AMAPTextConstants.loadingError, + style: TextStyle( + color: Theme.of(context).colorScheme.error, + ), + ), + loading: () => TextSpan( text: AMAPTextConstants.loading, - style: TextStyle(color: Colors.red), + style: TextStyle( + color: Theme.of(context).colorScheme.error, + ), ), ), TextSpan( @@ -90,10 +95,10 @@ class PresentationPage extends HookConsumerWidget { fontWeight: FontWeight.w600, foreground: Paint() ..shader = - const RadialGradient( + RadialGradient( colors: [ - AMAPColorConstants.greenGradient1, - AMAPColorConstants.textDark, + AMAPColors(isDarkTheme).greenGradientPrimary, + AMAPColors(isDarkTheme).textOnPrimary, ], center: Alignment.topLeft, radius: 10, @@ -110,10 +115,10 @@ class PresentationPage extends HookConsumerWidget { value: information, builder: (context, info) => Text( "${AMAPTextConstants.contact} : ${info.manager} ", - style: const TextStyle( + style: TextStyle( fontSize: 15, fontWeight: FontWeight.w600, - color: AMAPColorConstants.textDark, + color: AMAPColors(isDarkTheme).textOnPrimary, ), ), ), diff --git a/lib/amap/ui/pages/product_pages/add_edit_product.dart b/lib/amap/ui/pages/product_pages/add_edit_product.dart index 110ac92201..827f7daeaf 100644 --- a/lib/amap/ui/pages/product_pages/add_edit_product.dart +++ b/lib/amap/ui/pages/product_pages/add_edit_product.dart @@ -10,6 +10,7 @@ import 'package:titan/amap/providers/selected_list_provider.dart'; import 'package:titan/amap/tools/constants.dart'; import 'package:titan/amap/ui/amap.dart'; import 'package:titan/tools/functions.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; import 'package:titan/tools/token_expire_wrapper.dart'; import 'package:titan/tools/ui/layouts/add_edit_button_layout.dart'; import 'package:titan/tools/ui/widgets/align_left_text.dart'; @@ -42,6 +43,7 @@ class AddEditProduct extends HookConsumerWidget { selectedCategoryProvider(beginState).notifier, ); final newCategory = useTextEditingController(text: ""); + final isDarkTheme = ref.watch(themeProvider); void displayToastWithContext(TypeMsg type, String msg) { displayToast(context, type, msg); @@ -61,7 +63,7 @@ class AddEditProduct extends HookConsumerWidget { isEdit ? AMAPTextConstants.editProduct : AMAPTextConstants.addProduct, - color: AMAPColorConstants.green2, + color: AMAPColors(isDarkTheme).secondaryFixedGreen, ), const SizedBox(height: 40), Column( @@ -70,7 +72,7 @@ class AddEditProduct extends HookConsumerWidget { child: TextEntry( label: AMAPTextConstants.name, controller: nameController, - color: AMAPColorConstants.greenGradient2, + color: AMAPColors(isDarkTheme).greenGradientSecondary, enabledColor: AMAPColorConstants.enabled, ), ), @@ -79,36 +81,38 @@ class AddEditProduct extends HookConsumerWidget { child: TextEntry( label: AMAPTextConstants.price, isDouble: true, - color: AMAPColorConstants.greenGradient2, + color: AMAPColors(isDarkTheme).greenGradientSecondary, enabledColor: AMAPColorConstants.enabled, keyboardType: TextInputType.number, controller: priceController, ), ), const SizedBox(height: 30), - const AlignLeftText( + AlignLeftText( AMAPTextConstants.category, fontSize: 20, - color: AMAPColorConstants.greenGradient2, + color: AMAPColors(isDarkTheme).greenGradientSecondary, ), const SizedBox(height: 10), Center( child: DropdownButtonFormField( initialValue: categoryController, - decoration: const InputDecoration( - enabledBorder: UnderlineInputBorder( + decoration: InputDecoration( + enabledBorder: const UnderlineInputBorder( borderSide: BorderSide( color: AMAPColorConstants.enabled, ), ), - errorBorder: UnderlineInputBorder( + errorBorder: const UnderlineInputBorder( borderSide: BorderSide( color: AMAPColorConstants.red, ), ), focusedBorder: UnderlineInputBorder( borderSide: BorderSide( - color: AMAPColorConstants.greenGradient2, + color: AMAPColors( + isDarkTheme, + ).greenGradientSecondary, ), ), ), @@ -144,7 +148,7 @@ class AddEditProduct extends HookConsumerWidget { TextPosition(offset: newCategory.text.length), ); }, - color: AMAPColorConstants.greenGradient2, + color: AMAPColors(isDarkTheme).greenGradientSecondary, enabledColor: AMAPColorConstants.enabled, controller: newCategory, ), @@ -152,11 +156,11 @@ class AddEditProduct extends HookConsumerWidget { ], const SizedBox(height: 40), WaitingButton( - waitingColor: AMAPColorConstants.background, + waitingColor: AMAPColors(isDarkTheme).background, builder: (child) => AddEditButtonLayout( - colors: const [ - AMAPColorConstants.greenGradient1, - AMAPColorConstants.greenGradient2, + colors: [ + AMAPColors(isDarkTheme).greenGradientPrimary, + AMAPColors(isDarkTheme).greenGradientSecondary, ], child: child, ), @@ -233,7 +237,7 @@ class AddEditProduct extends HookConsumerWidget { style: TextStyle( fontSize: 20, fontWeight: FontWeight.w700, - color: AMAPColorConstants.background, + color: AMAPColors(isDarkTheme).background, ), ), ), diff --git a/lib/booking/ui/calendar/calendar.dart b/lib/booking/ui/calendar/calendar.dart index 8b1b73c29d..bf911e3da9 100644 --- a/lib/booking/ui/calendar/calendar.dart +++ b/lib/booking/ui/calendar/calendar.dart @@ -14,7 +14,6 @@ import 'package:titan/booking/tools/constants.dart'; import 'package:titan/booking/ui/calendar/appointment_data_source.dart'; import 'package:titan/booking/ui/calendar/calendar_dialog.dart'; import 'package:titan/drawer/providers/is_web_format_provider.dart'; -import 'package:titan/tools/constants.dart'; import 'package:syncfusion_flutter_calendar/calendar.dart'; import 'package:titan/tools/functions.dart'; import 'package:titan/tools/token_expire_wrapper.dart'; @@ -158,13 +157,16 @@ class Calendar extends HookConsumerWidget { view: CalendarView.week, selectionDecoration: BoxDecoration( color: Colors.transparent, - border: Border.all(color: Colors.black, width: 2), + border: Border.all( + color: Theme.of(context).colorScheme.onPrimary, + width: 2, + ), borderRadius: const BorderRadius.all(Radius.circular(5)), shape: BoxShape.rectangle, ), - todayHighlightColor: Colors.black, - todayTextStyle: const TextStyle( - color: Colors.white, + todayHighlightColor: Theme.of(context).colorScheme.secondary, + todayTextStyle: TextStyle( + color: Theme.of(context).colorScheme.onSecondary, fontWeight: FontWeight.bold, ), firstDayOfWeek: 1, @@ -173,26 +175,27 @@ class Calendar extends HookConsumerWidget { timeIntervalHeight: 25, timeFormat: 'HH:mm', ), - viewHeaderStyle: const ViewHeaderStyle( + viewHeaderStyle: ViewHeaderStyle( dayTextStyle: TextStyle( - color: Colors.grey, + color: Theme.of(context).colorScheme.tertiary, fontSize: 12, fontWeight: FontWeight.w600, ), dateTextStyle: TextStyle( - color: Colors.grey, + color: Theme.of(context).colorScheme.tertiary, fontSize: 15, fontWeight: FontWeight.w600, ), ), - headerStyle: const CalendarHeaderStyle( + headerStyle: CalendarHeaderStyle( textAlign: TextAlign.center, textStyle: TextStyle( fontSize: 20, fontWeight: FontWeight.w600, - color: Colors.black, + color: Theme.of(context).colorScheme.onSurface, ), ), + cellBorderColor: Theme.of(context).colorScheme.secondaryFixed, ), if (isWebFormat) Positioned( @@ -201,11 +204,11 @@ class Calendar extends HookConsumerWidget { height: 50, width: 50, decoration: BoxDecoration( - color: Colors.black, + color: Theme.of(context).colorScheme.secondary, borderRadius: BorderRadius.circular(10), boxShadow: [ BoxShadow( - color: Colors.grey.shade700.withValues(alpha: 0.3), + color: Theme.of(context).shadowColor, blurRadius: 5, spreadRadius: 1, ), @@ -215,10 +218,10 @@ class Calendar extends HookConsumerWidget { onPressed: () { calendarController.forward!(); }, - icon: const HeroIcon( + icon: HeroIcon( HeroIcons.arrowRight, size: 25, - color: Colors.white, + color: Theme.of(context).colorScheme.onSecondary, ), ), ), @@ -230,11 +233,11 @@ class Calendar extends HookConsumerWidget { height: 50, width: 50, decoration: BoxDecoration( - color: Colors.black, + color: Theme.of(context).colorScheme.secondary, borderRadius: BorderRadius.circular(10), boxShadow: [ BoxShadow( - color: Colors.grey.shade700.withValues(alpha: 0.3), + color: Theme.of(context).shadowColor, blurRadius: 5, spreadRadius: 1, ), @@ -244,10 +247,10 @@ class Calendar extends HookConsumerWidget { onPressed: () { calendarController.backward!(); }, - icon: const HeroIcon( + icon: HeroIcon( HeroIcons.arrowLeft, size: 25, - color: Colors.white, + color: Theme.of(context).colorScheme.onSecondary, ), ), ), @@ -260,8 +263,10 @@ class Calendar extends HookConsumerWidget { return Center(child: Text(error.toString())); }, loading: () { - return const Center( - child: CircularProgressIndicator(color: ColorConstants.background2), + return Center( + child: CircularProgressIndicator( + color: Theme.of(context).colorScheme.primaryContainer, + ), ); }, ); diff --git a/lib/booking/ui/calendar/calendar_dialog.dart b/lib/booking/ui/calendar/calendar_dialog.dart index ca92700211..d78e25a520 100644 --- a/lib/booking/ui/calendar/calendar_dialog.dart +++ b/lib/booking/ui/calendar/calendar_dialog.dart @@ -35,6 +35,7 @@ class CalendarDialog extends StatelessWidget { return Dialog( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)), + backgroundColor: Theme.of(context).colorScheme.secondaryFixed, child: Stack( clipBehavior: Clip.none, children: [ @@ -44,10 +45,10 @@ class CalendarDialog extends StatelessWidget { children: [ Text( '${booking.room.name} - ${booking.reason}', - style: const TextStyle( + style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: Colors.black, + color: Theme.of(context).colorScheme.onSurface, ), ), const SizedBox(height: 10), @@ -60,7 +61,7 @@ class CalendarDialog extends StatelessWidget { ), style: TextStyle( fontWeight: FontWeight.w400, - color: Colors.grey.shade400, + color: Theme.of(context).colorScheme.tertiary, fontSize: 15, ), ), @@ -74,14 +75,17 @@ class CalendarDialog extends StatelessWidget { ), if (isManager) ...[ const SizedBox(height: 10), - const Divider(thickness: 3), + Divider( + thickness: 3, + color: Theme.of(context).colorScheme.tertiary, + ), const SizedBox(height: 10), if (booking.note != null) Text( booking.note!, - style: const TextStyle( + style: TextStyle( fontWeight: FontWeight.w400, - color: Colors.grey, + color: Theme.of(context).colorScheme.tertiary, fontSize: 15, ), ), @@ -136,11 +140,11 @@ class CalendarDialog extends StatelessWidget { GestureDetector( onTap: onEdit, child: CardButton( - color: Colors.white, - shadowColor: Colors.grey.withValues(alpha: 0.2), + color: Theme.of(context).colorScheme.primary, + shadowColor: Theme.of(context).shadowColor, child: HeroIcon( HeroIcons.pencil, - color: Colors.black, + color: Theme.of(context).colorScheme.onPrimary, ), ), ), @@ -148,11 +152,11 @@ class CalendarDialog extends StatelessWidget { GestureDetector( onTap: onCopy, child: CardButton( - color: Colors.white, - shadowColor: Colors.grey.withValues(alpha: 0.2), + color: Theme.of(context).colorScheme.primary, + shadowColor: Theme.of(context).shadowColor, child: HeroIcon( HeroIcons.documentDuplicate, - color: Colors.black, + color: Theme.of(context).colorScheme.onPrimary, ), ), ), @@ -160,20 +164,23 @@ class CalendarDialog extends StatelessWidget { GestureDetector( onTap: onConfirm, child: CardButton( - color: Colors.white, - shadowColor: Colors.grey.withValues(alpha: 0.2), - child: HeroIcon(HeroIcons.check, color: Colors.black), + color: Theme.of(context).colorScheme.primary, + shadowColor: Theme.of(context).shadowColor, + child: HeroIcon( + HeroIcons.check, + color: Theme.of(context).colorScheme.onPrimary, + ), ), ), const Spacer(), GestureDetector( onTap: onDecline, child: CardButton( - color: Colors.black, - shadowColor: Colors.black.withValues(alpha: 0.2), - child: const HeroIcon( + color: Theme.of(context).colorScheme.secondary, + shadowColor: Theme.of(context).shadowColor, + child: HeroIcon( HeroIcons.xMark, - color: Colors.white, + color: Theme.of(context).colorScheme.onSecondary, ), ), ), @@ -192,10 +199,10 @@ class CalendarDialog extends StatelessWidget { width: 40, padding: const EdgeInsets.all(7), decoration: BoxDecoration( - color: Colors.white, + color: Theme.of(context).colorScheme.surface, boxShadow: [ BoxShadow( - color: Colors.grey.shade500.withValues(alpha: 0.3), + color: Theme.of(context).shadowColor, blurRadius: 5, spreadRadius: 1, ), diff --git a/lib/booking/ui/calendar/calendar_dialog_button.dart b/lib/booking/ui/calendar/calendar_dialog_button.dart index ae3bf0fdf6..dd727d6ed6 100644 --- a/lib/booking/ui/calendar/calendar_dialog_button.dart +++ b/lib/booking/ui/calendar/calendar_dialog_button.dart @@ -34,17 +34,20 @@ class CalendarDialogButton extends StatelessWidget { padding: const EdgeInsets.all(5.0), decoration: BoxDecoration( borderRadius: BorderRadius.circular(15.0), - border: Border.all(color: Colors.black, width: 2), - color: Colors.grey.shade50, + border: Border.all( + color: Theme.of(context).colorScheme.onSurface, + width: 2, + ), + color: Theme.of(context).colorScheme.surface, boxShadow: [ BoxShadow( - color: Colors.grey.withValues(alpha: 0.2), + color: Theme.of(context).shadowColor, blurRadius: 10, offset: const Offset(0, 10), ), ], ), - child: HeroIcon(icon, color: Colors.black), + child: HeroIcon(icon, color: Theme.of(context).colorScheme.onSurface), ), ); } diff --git a/lib/booking/ui/components/booking_card.dart b/lib/booking/ui/components/booking_card.dart index fb3df46a66..04b87d2302 100644 --- a/lib/booking/ui/components/booking_card.dart +++ b/lib/booking/ui/components/booking_card.dart @@ -1,15 +1,17 @@ import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:heroicons/heroicons.dart'; import 'package:titan/booking/class/booking.dart'; import 'package:titan/booking/tools/constants.dart'; import 'package:titan/tools/functions.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; import 'package:titan/tools/ui/builders/waiting_button.dart'; import 'package:titan/tools/ui/layouts/card_button.dart'; import 'package:titan/tools/ui/layouts/card_layout.dart'; import 'package:syncfusion_flutter_calendar/calendar.dart'; -class BookingCard extends StatelessWidget { +class BookingCard extends ConsumerWidget { final Booking booking; final Function()? onEdit, onConfirm, onDecline, onCopy, onInfo; final Future Function()? onDelete; @@ -28,7 +30,7 @@ class BookingCard extends StatelessWidget { }); @override - Widget build(BuildContext context) { + Widget build(BuildContext context, WidgetRef ref) { final isNotEnded = booking.recurrenceRule.isNotEmpty ? SfCalendar.parseRRule( booking.recurrenceRule, @@ -37,47 +39,58 @@ class BookingCard extends StatelessWidget { : booking.end.isAfter(DateTime.now()); final showButton = (isNotEnded && booking.decision == Decision.pending) || isAdmin; + final isDarkTheme = ref.watch(themeProvider); final List cardColor; final Color smallTextColor; final Color bigTextColor; - final Color darkIconBackgroundColor; - final Color lightIconBackgroundColor; - final Color lightIconColor; + final Color secondaryIconBackgroundColor; + final Color primaryIconBackgroundColor; + final Color primaryIconColor; final Color cardBoxShadow; final Color informationCircleColor; switch (booking.decision) { case Decision.pending: - cardColor = [Colors.white, Colors.white]; - darkIconBackgroundColor = Colors.black; - + cardColor = [ + Theme.of(context).colorScheme.surface, + Theme.of(context).colorScheme.surface, + ]; + secondaryIconBackgroundColor = Theme.of(context).colorScheme.secondary; break; - case Decision.approved: - cardColor = [const Color(0xff79a400), const Color(0xff387200)]; - darkIconBackgroundColor = const Color.fromARGB(255, 26, 53, 0); + case Decision.approved: + cardColor = isDarkTheme + ? [const Color(0xFF387000), const Color(0xFF54a800)] + : [const Color(0xFF54A800), const Color(0xFF387000)]; + secondaryIconBackgroundColor = isDarkTheme + ? const Color(0xFF7EFC00) + : const Color(0xFF1C3800); break; + case Decision.declined: - cardColor = [ - const Color.fromARGB(255, 250, 66, 38), - const Color.fromARGB(255, 172, 32, 10), - ]; - darkIconBackgroundColor = const Color.fromARGB(255, 99, 13, 0); + cardColor = isDarkTheme + ? [const Color(0xFFA82A00), const Color(0xFFFC3F00)] + : [const Color(0xFFFC3F00), const Color(0xFFA82A00)]; + secondaryIconBackgroundColor = isDarkTheme + ? const Color(0xFFFF2A00) + : const Color(0xFF541500); break; } - lightIconColor = darkIconBackgroundColor; + primaryIconColor = secondaryIconBackgroundColor; if (booking.decision == Decision.pending) { - smallTextColor = Colors.grey.shade400; - cardBoxShadow = Colors.grey.shade200.withValues(alpha: 0.5); - lightIconBackgroundColor = Colors.white; - bigTextColor = Colors.black; + smallTextColor = Theme.of(context).colorScheme.tertiary; + cardBoxShadow = Theme.of(context).shadowColor; + primaryIconBackgroundColor = Theme.of(context).colorScheme.surface; + bigTextColor = Theme.of(context).colorScheme.onSurface; } else { - smallTextColor = Colors.white.withValues(alpha: 0.8); - cardBoxShadow = darkIconBackgroundColor; - lightIconBackgroundColor = Colors.grey.shade200; - bigTextColor = Colors.white; + smallTextColor = Theme.of( + context, + ).colorScheme.onSecondary.withValues(alpha: 0.8); + cardBoxShadow = secondaryIconBackgroundColor; + primaryIconBackgroundColor = Theme.of(context).colorScheme.secondaryFixed; + bigTextColor = Theme.of(context).colorScheme.onSecondary; } informationCircleColor = bigTextColor; @@ -182,20 +195,23 @@ class BookingCard extends StatelessWidget { GestureDetector( onTap: onEdit, child: CardButton( - color: lightIconBackgroundColor, - shadowColor: Colors.grey.withValues(alpha: 0.2), - child: HeroIcon(HeroIcons.pencil, color: lightIconColor), + color: primaryIconBackgroundColor, + shadowColor: Theme.of(context).shadowColor, + child: HeroIcon( + HeroIcons.pencil, + color: primaryIconColor, + ), ), ), if (showButton) const Spacer(), GestureDetector( onTap: onCopy, child: CardButton( - color: lightIconBackgroundColor, - shadowColor: Colors.grey.withValues(alpha: 0.2), + color: primaryIconBackgroundColor, + shadowColor: Theme.of(context).shadowColor, child: HeroIcon( HeroIcons.documentDuplicate, - color: lightIconColor, + color: primaryIconColor, ), ), ), @@ -204,16 +220,16 @@ class BookingCard extends StatelessWidget { GestureDetector( onTap: onConfirm, child: CardButton( - color: lightIconBackgroundColor, + color: primaryIconBackgroundColor, borderColor: isAdmin ? booking.decision == Decision.approved - ? darkIconBackgroundColor + ? secondaryIconBackgroundColor : Colors.transparent : Colors.transparent, - shadowColor: Colors.grey.withValues(alpha: 0.2), + shadowColor: Theme.of(context).shadowColor, child: HeroIcon( HeroIcons.check, - color: darkIconBackgroundColor, + color: secondaryIconBackgroundColor, ), ), ), @@ -222,18 +238,18 @@ class BookingCard extends StatelessWidget { GestureDetector( onTap: onDecline, child: CardButton( - color: darkIconBackgroundColor, + color: secondaryIconBackgroundColor, borderColor: isAdmin ? booking.decision == Decision.declined - ? Colors.white + ? Theme.of(context).colorScheme.onSecondary : Colors.transparent : Colors.transparent, - shadowColor: darkIconBackgroundColor.withValues( + shadowColor: secondaryIconBackgroundColor.withValues( alpha: 0.2, ), - child: const HeroIcon( + child: HeroIcon( HeroIcons.xMark, - color: Colors.white, + color: Theme.of(context).colorScheme.onSecondary, ), ), ), @@ -242,13 +258,16 @@ class BookingCard extends StatelessWidget { WaitingButton( onTap: onDelete, builder: (child) => CardButton( - color: darkIconBackgroundColor, - shadowColor: darkIconBackgroundColor.withValues( + color: secondaryIconBackgroundColor, + shadowColor: secondaryIconBackgroundColor.withValues( alpha: 0.2, ), child: child, ), - child: const HeroIcon(HeroIcons.trash, color: Colors.white), + child: HeroIcon( + HeroIcons.trash, + color: Theme.of(context).colorScheme.onSecondary, + ), ), ], ), diff --git a/lib/booking/ui/pages/admin_pages/add_edit_manager_page.dart b/lib/booking/ui/pages/admin_pages/add_edit_manager_page.dart index e89d0c1405..63ce8b9eff 100644 --- a/lib/booking/ui/pages/admin_pages/add_edit_manager_page.dart +++ b/lib/booking/ui/pages/admin_pages/add_edit_manager_page.dart @@ -48,10 +48,10 @@ class AddEditManagerPage extends HookConsumerWidget { isEdit ? BookingTextConstants.editManager : BookingTextConstants.addManager, - style: const TextStyle( + style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: Color.fromARGB(255, 149, 149, 149), + color: Theme.of(context).colorScheme.tertiary, ), ), ), @@ -82,7 +82,9 @@ class AddEditManagerPage extends HookConsumerWidget { child: Text( e.name, style: TextStyle( - color: selected ? Colors.white : Colors.black, + color: selected + ? Theme.of(context).colorScheme.onSecondary + : Theme.of(context).colorScheme.onSurface, fontWeight: FontWeight.bold, ), ), diff --git a/lib/booking/ui/pages/admin_pages/add_edit_room_page.dart b/lib/booking/ui/pages/admin_pages/add_edit_room_page.dart index 009859b011..955ddba2a1 100644 --- a/lib/booking/ui/pages/admin_pages/add_edit_room_page.dart +++ b/lib/booking/ui/pages/admin_pages/add_edit_room_page.dart @@ -48,10 +48,10 @@ class AddEditRoomPage extends HookConsumerWidget { isEdit ? BookingTextConstants.editRoom : BookingTextConstants.addRoom, - style: const TextStyle( + style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: Color.fromARGB(255, 149, 149, 149), + color: Theme.of(context).colorScheme.tertiary, ), ), ), @@ -82,7 +82,9 @@ class AddEditRoomPage extends HookConsumerWidget { child: Text( e.name, style: TextStyle( - color: selected ? Colors.white : Colors.black, + color: selected + ? Theme.of(context).colorScheme.onSecondary + : Theme.of(context).colorScheme.onSurface, fontWeight: FontWeight.bold, ), ), diff --git a/lib/booking/ui/pages/admin_pages/admin_entry.dart b/lib/booking/ui/pages/admin_pages/admin_entry.dart index 827422d3fa..d89883b57d 100644 --- a/lib/booking/ui/pages/admin_pages/admin_entry.dart +++ b/lib/booking/ui/pages/admin_pages/admin_entry.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:titan/tools/constants.dart'; class AdminEntry extends StatelessWidget { final String name; @@ -13,17 +12,20 @@ class AdminEntry extends StatelessWidget { @override Widget build(BuildContext context) { return TextField( - style: const TextStyle(color: ColorConstants.background2), + style: TextStyle(color: Theme.of(context).colorScheme.secondaryContainer), controller: nameController, - cursorColor: Colors.black, + cursorColor: Theme.of(context).colorScheme.onPrimary, decoration: InputDecoration( labelText: name, - floatingLabelStyle: const TextStyle( - color: Colors.black, + floatingLabelStyle: TextStyle( + color: Theme.of(context).colorScheme.onPrimary, fontWeight: FontWeight.bold, ), - focusedBorder: const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.black, width: 2.0), + focusedBorder: UnderlineInputBorder( + borderSide: BorderSide( + color: Theme.of(context).colorScheme.onPrimary, + width: 2.0, + ), ), ), ); diff --git a/lib/booking/ui/pages/admin_pages/admin_page.dart b/lib/booking/ui/pages/admin_pages/admin_page.dart index d6e8f2edd7..aa91546fdc 100644 --- a/lib/booking/ui/pages/admin_pages/admin_page.dart +++ b/lib/booking/ui/pages/admin_pages/admin_page.dart @@ -57,7 +57,7 @@ class AdminPage extends HookConsumerWidget { const Expanded(child: Calendar(isManagerPage: false)), if (isRoomsAdmin) ...[ const SizedBox(height: 30), - const Padding( + Padding( padding: EdgeInsets.symmetric(horizontal: 30.0), child: Align( alignment: Alignment.centerLeft, @@ -66,7 +66,7 @@ class AdminPage extends HookConsumerWidget { style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: Color.fromARGB(255, 149, 149, 149), + color: Theme.of(context).colorScheme.tertiary, ), ), ), @@ -90,9 +90,9 @@ class AdminPage extends HookConsumerWidget { BookingRouter.room, ); }, - child: const HeroIcon( + child: HeroIcon( HeroIcons.plus, - color: Colors.black, + color: Theme.of(context).colorScheme.onSurface, ), ), ...data.map( @@ -108,8 +108,10 @@ class AdminPage extends HookConsumerWidget { }, child: Text( capitalize(e.name), - style: const TextStyle( - color: Colors.black, + style: TextStyle( + color: Theme.of( + context, + ).colorScheme.onSurface, fontWeight: FontWeight.bold, ), ), @@ -129,7 +131,7 @@ class AdminPage extends HookConsumerWidget { ], if (isManagersAdmin) ...[ const SizedBox(height: 20), - const Padding( + Padding( padding: EdgeInsets.symmetric(horizontal: 30.0), child: Align( alignment: Alignment.centerLeft, @@ -138,7 +140,7 @@ class AdminPage extends HookConsumerWidget { style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: Color.fromARGB(255, 149, 149, 149), + color: Theme.of(context).colorScheme.tertiary, ), ), ), @@ -162,9 +164,9 @@ class AdminPage extends HookConsumerWidget { BookingRouter.manager, ); }, - child: const HeroIcon( + child: HeroIcon( HeroIcons.plus, - color: Colors.black, + color: Theme.of(context).colorScheme.onSurface, ), ), ...data.map( @@ -180,8 +182,10 @@ class AdminPage extends HookConsumerWidget { }, child: Text( e.name, - style: const TextStyle( - color: Colors.black, + style: TextStyle( + color: Theme.of( + context, + ).colorScheme.onSurface, fontWeight: FontWeight.bold, ), ), diff --git a/lib/booking/ui/pages/admin_pages/admin_shrink_button.dart b/lib/booking/ui/pages/admin_pages/admin_shrink_button.dart index 8f163903bf..426ddcb994 100644 --- a/lib/booking/ui/pages/admin_pages/admin_shrink_button.dart +++ b/lib/booking/ui/pages/admin_pages/admin_shrink_button.dart @@ -18,11 +18,11 @@ class AdminShrinkButton extends StatelessWidget { padding: const EdgeInsets.only(top: 8, bottom: 12), alignment: Alignment.center, decoration: BoxDecoration( - color: Colors.black, + color: Theme.of(context).colorScheme.secondary, borderRadius: BorderRadius.circular(10), boxShadow: [ BoxShadow( - color: Colors.grey.withValues(alpha: 0.5), + color: Theme.of(context).shadowColor, spreadRadius: 5, blurRadius: 10, offset: const Offset(3, 3), @@ -34,8 +34,8 @@ class AdminShrinkButton extends StatelessWidget { onTap: onTap, child: Text( buttonText, - style: const TextStyle( - color: Colors.white, + style: TextStyle( + color: Theme.of(context).colorScheme.onSecondary, fontSize: 25, fontWeight: FontWeight.bold, ), diff --git a/lib/booking/ui/pages/booking_pages/add_edit_booking_page.dart b/lib/booking/ui/pages/booking_pages/add_edit_booking_page.dart index ff76e882a5..6ecac2d6ae 100644 --- a/lib/booking/ui/pages/booking_pages/add_edit_booking_page.dart +++ b/lib/booking/ui/pages/booking_pages/add_edit_booking_page.dart @@ -108,7 +108,7 @@ class AddEditBookingPage extends HookConsumerWidget { isEdit ? BookingTextConstants.editBooking : BookingTextConstants.addBooking, - color: Colors.grey, + color: Theme.of(context).colorScheme.tertiary, ), ), const SizedBox(height: 20), @@ -138,7 +138,9 @@ class AddEditBookingPage extends HookConsumerWidget { child: Text( e.name, style: TextStyle( - color: selected ? Colors.white : Colors.black, + color: selected + ? Theme.of(context).colorScheme.onSecondary + : Theme.of(context).colorScheme.onSurface, fontWeight: FontWeight.bold, ), ), @@ -195,9 +197,13 @@ class AddEditBookingPage extends HookConsumerWidget { recurrent.value ? Column( children: [ - const Text( + Text( BookingTextConstants.recurrenceDays, - style: TextStyle(color: Colors.black), + style: TextStyle( + color: Theme.of( + context, + ).colorScheme.onPrimary, + ), ), const SizedBox(height: 10), Column( @@ -215,13 +221,19 @@ class AddEditBookingPage extends HookConsumerWidget { Text( weekDayToString(e), style: TextStyle( - color: Colors.grey.shade700, + color: Theme.of(context) + .colorScheme + .secondaryContainer, fontSize: 16, ), ), Checkbox( - checkColor: Colors.white, - activeColor: Colors.black, + checkColor: Theme.of( + context, + ).colorScheme.onSecondary, + activeColor: Theme.of( + context, + ).colorScheme.secondary, value: selectedDays.contains(e), onChanged: (value) { selectedDaysNotifier.toggle(e); @@ -234,9 +246,13 @@ class AddEditBookingPage extends HookConsumerWidget { .toList(), ), const SizedBox(height: 20), - const Text( + Text( BookingTextConstants.interval, - style: TextStyle(color: Colors.black), + style: TextStyle( + color: Theme.of( + context, + ).colorScheme.onPrimary, + ), ), const SizedBox(height: 10), TextEntry( @@ -464,8 +480,8 @@ class AddEditBookingPage extends HookConsumerWidget { isEdit ? BookingTextConstants.edit : BookingTextConstants.add, - style: const TextStyle( - color: Colors.white, + style: TextStyle( + color: Theme.of(context).colorScheme.onSecondary, fontSize: 25, fontWeight: FontWeight.bold, ), diff --git a/lib/booking/ui/pages/booking_pages/checkbox_entry.dart b/lib/booking/ui/pages/booking_pages/checkbox_entry.dart index a0b4572410..0edc0b9b41 100644 --- a/lib/booking/ui/pages/booking_pages/checkbox_entry.dart +++ b/lib/booking/ui/pages/booking_pages/checkbox_entry.dart @@ -23,11 +23,14 @@ class CheckBoxEntry extends StatelessWidget { children: [ Text( title, - style: TextStyle(color: Colors.grey.shade700, fontSize: 16), + style: TextStyle( + color: Theme.of(context).colorScheme.secondaryContainer, + fontSize: 16, + ), ), Checkbox( - checkColor: Colors.white, - activeColor: Colors.black, + checkColor: Theme.of(context).colorScheme.onSecondary, + activeColor: Theme.of(context).colorScheme.secondary, value: valueNotifier.value, onChanged: (value) { valueNotifier.value = value!; diff --git a/lib/booking/ui/pages/detail_pages/contact_button.dart b/lib/booking/ui/pages/detail_pages/contact_button.dart index c019fdf1a4..5e0efc00b2 100644 --- a/lib/booking/ui/pages/detail_pages/contact_button.dart +++ b/lib/booking/ui/pages/detail_pages/contact_button.dart @@ -12,11 +12,14 @@ class ContactButton extends StatelessWidget { padding: const EdgeInsets.all(15.0), decoration: BoxDecoration( borderRadius: BorderRadius.circular(30), - border: Border.all(color: Colors.black, width: 2), - color: Colors.grey.shade50, + border: Border.all( + color: Theme.of(context).colorScheme.onSurface, + width: 2, + ), + color: Theme.of(context).colorScheme.secondaryFixed, boxShadow: [ BoxShadow( - color: Colors.grey.withValues(alpha: 0.2), + color: Theme.of(context).shadowColor, blurRadius: 10, offset: const Offset(0, 10), ), diff --git a/lib/booking/ui/pages/detail_pages/detail_booking.dart b/lib/booking/ui/pages/detail_pages/detail_booking.dart index b8715de07a..307990ea04 100644 --- a/lib/booking/ui/pages/detail_pages/detail_booking.dart +++ b/lib/booking/ui/pages/detail_pages/detail_booking.dart @@ -37,10 +37,10 @@ class DetailBookingPage extends HookConsumerWidget { width: double.infinity, decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), - color: Colors.grey.shade50, + color: Theme.of(context).colorScheme.surface, boxShadow: [ BoxShadow( - color: Colors.grey.withValues(alpha: 0.2), + color: Theme.of(context).shadowColor, blurRadius: 10, offset: const Offset(0, 10), ), @@ -150,10 +150,12 @@ class DetailBookingPage extends HookConsumerWidget { } } }, - child: const ContactButton( + child: ContactButton( child: HeroIcon( HeroIcons.phone, - color: Colors.black, + color: Theme.of( + context, + ).colorScheme.onSurface, ), ), ), @@ -175,10 +177,12 @@ class DetailBookingPage extends HookConsumerWidget { } } }, - child: const ContactButton( + child: ContactButton( child: HeroIcon( HeroIcons.chatBubbleBottomCenterText, - color: Colors.black, + color: Theme.of( + context, + ).colorScheme.onSurface, ), ), ), diff --git a/lib/booking/ui/pages/main_page/main_page.dart b/lib/booking/ui/pages/main_page/main_page.dart index 435c5b9457..19ab950dea 100644 --- a/lib/booking/ui/pages/main_page/main_page.dart +++ b/lib/booking/ui/pages/main_page/main_page.dart @@ -96,8 +96,8 @@ class BookingMainPage extends HookConsumerWidget { const SizedBox(height: 10), const Expanded(child: Calendar(isManagerPage: false)), const SizedBox(height: 30), - const Padding( - padding: EdgeInsets.symmetric(horizontal: 30.0), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 30.0), child: Align( alignment: Alignment.centerLeft, child: Text( @@ -105,7 +105,7 @@ class BookingMainPage extends HookConsumerWidget { style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: Color.fromARGB(255, 149, 149, 149), + color: Theme.of(context).colorScheme.secondaryFixed, ), ), ), @@ -123,14 +123,14 @@ class BookingMainPage extends HookConsumerWidget { selectedDaysNotifier.clear(); QR.to(BookingRouter.root + BookingRouter.addEdit); }, - child: const CardLayout( + child: CardLayout( width: 120, height: 200, child: Center( child: HeroIcon( HeroIcons.plus, size: 40.0, - color: Colors.black, + color: Theme.of(context).colorScheme.onPrimary, ), ), ), diff --git a/lib/booking/ui/pages/manager_page/list_booking.dart b/lib/booking/ui/pages/manager_page/list_booking.dart index 912f3c6101..8ecb9cfbfd 100644 --- a/lib/booking/ui/pages/manager_page/list_booking.dart +++ b/lib/booking/ui/pages/manager_page/list_booking.dart @@ -73,10 +73,10 @@ class ListBooking extends HookConsumerWidget { alignment: Alignment.centerLeft, child: Text( "$title${bookings.length > 1 ? "s" : ""} (${bookings.length})", - style: const TextStyle( + style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: Color.fromARGB(255, 149, 149, 149), + color: Theme.of(context).colorScheme.tertiary, ), ), ), @@ -85,7 +85,7 @@ class ListBooking extends HookConsumerWidget { toggle.value ? HeroIcons.chevronUp : HeroIcons.chevronDown, - color: const Color.fromARGB(255, 149, 149, 149), + color: Theme.of(context).colorScheme.tertiary, size: 30, ), ], diff --git a/lib/booking/ui/pages/manager_page/manager_page.dart b/lib/booking/ui/pages/manager_page/manager_page.dart index b10f5ac4e0..9fa05d0620 100644 --- a/lib/booking/ui/pages/manager_page/manager_page.dart +++ b/lib/booking/ui/pages/manager_page/manager_page.dart @@ -63,11 +63,11 @@ class ManagerPage extends HookConsumerWidget { if (pendingBookings.isEmpty && confirmedBookings.isEmpty && canceledBookings.isEmpty) - const Center( + Center( child: Text( BookingTextConstants.noCurrentBooking, style: TextStyle( - color: Colors.black, + color: Theme.of(context).colorScheme.onPrimary, fontSize: 20, fontWeight: FontWeight.bold, ), diff --git a/lib/centralassociation/ui/centralassociation.dart b/lib/centralassociation/ui/centralassociation.dart index f26b7f5660..275b80e127 100644 --- a/lib/centralassociation/ui/centralassociation.dart +++ b/lib/centralassociation/ui/centralassociation.dart @@ -10,19 +10,16 @@ class CentralassociationTemplate extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - body: Container( - color: Colors.white, - child: SafeArea( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - const TopBar( - title: CentralassociationTextConstants.centralassociation, - root: CentralassociationRouter.root, - ), - Expanded(child: child), - ], - ), + body: SafeArea( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + const TopBar( + title: CentralassociationTextConstants.centralassociation, + root: CentralassociationRouter.root, + ), + Expanded(child: child), + ], ), ), ); diff --git a/lib/centralassociation/ui/pages/link_card.dart b/lib/centralassociation/ui/pages/link_card.dart index 8636240a26..1953e3488a 100644 --- a/lib/centralassociation/ui/pages/link_card.dart +++ b/lib/centralassociation/ui/pages/link_card.dart @@ -1,3 +1,4 @@ +import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:titan/centralassociation/class/link.dart'; @@ -15,10 +16,10 @@ class LinkCard extends HookConsumerWidget { margin: const EdgeInsets.symmetric(vertical: 7), decoration: BoxDecoration( borderRadius: const BorderRadius.all(Radius.circular(20)), - color: Colors.white, + color: Theme.of(context).colorScheme.primary, boxShadow: [ BoxShadow( - color: Colors.grey.withValues(alpha: 0.3), + color: Theme.of(context).shadowColor, blurRadius: 8, spreadRadius: 2, offset: const Offset(2, 3), @@ -31,9 +32,6 @@ class LinkCard extends HookConsumerWidget { shape: WidgetStateProperty.all( RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)), ), - overlayColor: WidgetStateProperty.all( - const Color.fromARGB(37, 0, 0, 0), - ), ), child: Row( children: [ @@ -41,6 +39,17 @@ class LinkCard extends HookConsumerWidget { margin: const EdgeInsets.only(left: 10.0, right: 10.0, bottom: 3), width: 45, height: 45, + decoration: BoxDecoration( + color: Colors.white, + boxShadow: [ + BoxShadow( + color: Theme.of(context).shadowColor, + blurRadius: 5, + spreadRadius: 2, + ), + ], + borderRadius: BorderRadius.circular(15), + ), child: link.icon.endsWith('.svg') ? SvgPicture.network( "${CentralassociationTextConstants.imagePath}${link.icon}", @@ -51,15 +60,19 @@ class LinkCard extends HookConsumerWidget { ), const SizedBox(width: 10), Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text( - link.name, - style: const TextStyle(fontSize: 18, color: Colors.black), + child: Container( + alignment: Alignment.center, + padding: const EdgeInsets.only(bottom: 7), + child: AutoSizeText( + link.name, + style: TextStyle( + fontSize: 18, + color: Theme.of(context).colorScheme.onPrimary, ), - ], + minFontSize: 10, + maxLines: 2, + textAlign: TextAlign.center, + ), ), ), ], diff --git a/lib/centralisation/ui/centralisation.dart b/lib/centralisation/ui/centralisation.dart index 3cba972886..baed401f8b 100644 --- a/lib/centralisation/ui/centralisation.dart +++ b/lib/centralisation/ui/centralisation.dart @@ -10,19 +10,16 @@ class CentralisationTemplate extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - body: Container( - color: Colors.white, - child: SafeArea( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - const TopBar( - title: CentralisationTextConstants.centralisation, - root: CentralisationRouter.root, - ), - Expanded(child: child), - ], - ), + body: SafeArea( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + const TopBar( + title: CentralisationTextConstants.centralisation, + root: CentralisationRouter.root, + ), + Expanded(child: child), + ], ), ), ); diff --git a/lib/centralisation/ui/pages/liked_card.dart b/lib/centralisation/ui/pages/liked_card.dart index 2547cc956e..1627c29aeb 100644 --- a/lib/centralisation/ui/pages/liked_card.dart +++ b/lib/centralisation/ui/pages/liked_card.dart @@ -23,10 +23,10 @@ class LikedCard extends StatelessWidget { padding: const EdgeInsets.all(10), decoration: BoxDecoration( borderRadius: const BorderRadius.all(Radius.circular(20)), - color: Colors.white, + color: Theme.of(context).colorScheme.primary, boxShadow: [ BoxShadow( - color: Colors.grey.withValues(alpha: 0.3), + color: Theme.of(context).shadowColor, blurRadius: 8, spreadRadius: 2, offset: const Offset(2, 3), @@ -38,6 +38,17 @@ class LikedCard extends StatelessWidget { children: [ Container( margin: const EdgeInsets.all(4.0), + decoration: BoxDecoration( + color: Colors.white, + boxShadow: [ + BoxShadow( + color: Colors.white, + blurRadius: 5, + spreadRadius: 2, + ), + ], + borderRadius: BorderRadius.circular(15), + ), child: module.icon.endsWith('.svg') ? SvgPicture.network( "${CentralisationTextConstants.imagePath}${module.icon}", diff --git a/lib/centralisation/ui/pages/module_card.dart b/lib/centralisation/ui/pages/module_card.dart index 6d2dadc2ee..8e70e16a01 100644 --- a/lib/centralisation/ui/pages/module_card.dart +++ b/lib/centralisation/ui/pages/module_card.dart @@ -19,10 +19,10 @@ class ModuleCard extends HookConsumerWidget { margin: const EdgeInsets.symmetric(vertical: 7), decoration: BoxDecoration( borderRadius: const BorderRadius.all(Radius.circular(20)), - color: Colors.white, + color: Theme.of(context).colorScheme.primary, boxShadow: [ BoxShadow( - color: Colors.grey.withValues(alpha: 0.3), + color: Theme.of(context).shadowColor, blurRadius: 8, spreadRadius: 2, offset: const Offset(2, 3), @@ -36,7 +36,7 @@ class ModuleCard extends HookConsumerWidget { RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)), ), overlayColor: WidgetStateProperty.all( - const Color.fromARGB(37, 0, 0, 0), + Theme.of(context).shadowColor, ), ), onLongPress: () { @@ -45,6 +45,17 @@ class ModuleCard extends HookConsumerWidget { child: Row( children: [ Container( + decoration: BoxDecoration( + color: Colors.white, + boxShadow: [ + BoxShadow( + color: Colors.white, + blurRadius: 5, + spreadRadius: 2, + ), + ], + borderRadius: BorderRadius.circular(15), + ), margin: const EdgeInsets.only(left: 10.0, right: 10.0, bottom: 3), width: 45, height: 45, @@ -64,15 +75,21 @@ class ModuleCard extends HookConsumerWidget { children: [ Text( module.name, - style: const TextStyle(fontSize: 18, color: Colors.black), + style: TextStyle( + fontSize: 18, + color: Theme.of(context).colorScheme.onPrimary, + ), ), ], ), ), IconButton( - icon: favorites.contains(module.name) - ? const Icon(Icons.star, color: Colors.grey) - : const Icon(Icons.star_border, color: Colors.grey), + icon: Icon( + favorites.contains(module.name) + ? Icons.star + : Icons.star_border, + color: Theme.of(context).colorScheme.tertiary, + ), onPressed: () { favoritesProviderNotifier.toggleFavorite(module.name); }, diff --git a/lib/cinema/tools/constants.dart b/lib/cinema/tools/constants.dart index 7bac449682..1a6dbc4f93 100644 --- a/lib/cinema/tools/constants.dart +++ b/lib/cinema/tools/constants.dart @@ -1,8 +1,8 @@ -import 'package:flutter/material.dart'; +// import 'package:flutter/material.dart'; -class CinemaColorConstants { - static const Color tmdbColor = Color(0xffe2b616); -} +// class CinemaColorConstants { +// static const Color tmdbColor = Color(0xffe2b616); +// } class CinemaTextConstants { static const String add = "Ajouter"; diff --git a/lib/cinema/ui/pages/admin_page/admin_session_card.dart b/lib/cinema/ui/pages/admin_page/admin_session_card.dart index 15ac4dfcb3..fa3d60c86a 100644 --- a/lib/cinema/ui/pages/admin_page/admin_session_card.dart +++ b/lib/cinema/ui/pages/admin_page/admin_session_card.dart @@ -37,11 +37,11 @@ class AdminSessionCard extends HookConsumerWidget { height: 300, margin: const EdgeInsets.all(8), decoration: BoxDecoration( - color: Colors.white, + color: Theme.of(context).colorScheme.primary, borderRadius: BorderRadius.circular(18), boxShadow: [ BoxShadow( - color: Colors.grey.withValues(alpha: 0.2), + color: Theme.of(context).shadowColor, spreadRadius: 1, blurRadius: 10, offset: const Offset(0, 5), // changes position of shadow @@ -93,21 +93,23 @@ class AdminSessionCard extends HookConsumerWidget { GestureDetector( onTap: onEdit, child: CardButton( - color: Colors.grey.shade200, - shadowColor: Colors.grey.withValues(alpha: 0.2), - child: const HeroIcon( + color: Theme.of(context).shadowColor, + shadowColor: Theme.of(context).shadowColor, + child: HeroIcon( HeroIcons.pencil, - color: Colors.black, + color: Theme.of(context).colorScheme.onPrimary, ), ), ), WaitingButton( onTap: onDelete, - builder: (child) => - CardButton(color: Colors.black, child: child), - child: const HeroIcon( + builder: (child) => CardButton( + color: Theme.of(context).colorScheme.secondary, + child: child, + ), + child: HeroIcon( HeroIcons.trash, - color: Colors.white, + color: Theme.of(context).colorScheme.onSecondary, ), ), ], diff --git a/lib/cinema/ui/pages/detail_page/detail_page.dart b/lib/cinema/ui/pages/detail_page/detail_page.dart index b9d8976307..c314e76898 100644 --- a/lib/cinema/ui/pages/detail_page/detail_page.dart +++ b/lib/cinema/ui/pages/detail_page/detail_page.dart @@ -54,13 +54,13 @@ class DetailPage extends HookConsumerWidget { children: [ Container( width: double.infinity, - decoration: const BoxDecoration( + decoration: BoxDecoration( boxShadow: [ BoxShadow( - color: Colors.black26, + color: Theme.of(context).colorScheme.secondary, blurRadius: 10, spreadRadius: 7, - offset: Offset(0, 5), + offset: const Offset(0, 5), ), ], ), @@ -89,15 +89,17 @@ class DetailPage extends HookConsumerWidget { end: Alignment.bottomCenter, colors: [ Colors.transparent, - Colors.grey.shade50.withValues(alpha: 0.85), - Colors.grey.shade50, + Theme.of( + context, + ).colorScheme.secondaryFixed.withValues(alpha: 0.85), + Theme.of(context).colorScheme.secondaryFixed, ], stops: const [0.0, 0.65, 1.0], ), ), ), Container( - color: Colors.grey.shade50, + color: Theme.of(context).colorScheme.secondaryFixed, child: Column( children: [ const SizedBox(height: 15), @@ -135,13 +137,15 @@ class DetailPage extends HookConsumerWidget { vertical: 10, ), decoration: BoxDecoration( - color: Colors.grey.shade900, + color: Theme.of( + context, + ).colorScheme.secondaryContainer, borderRadius: BorderRadius.circular(18), ), child: Text( genre, - style: const TextStyle( - color: Colors.white, + style: TextStyle( + color: Theme.of(context).colorScheme.onSecondary, fontWeight: FontWeight.bold, ), ), @@ -176,18 +180,21 @@ class DetailPage extends HookConsumerWidget { child: Container( padding: const EdgeInsets.all(8), decoration: BoxDecoration( - color: Colors.white.withValues(alpha: 0.9), + color: Theme.of(context).colorScheme.surface, borderRadius: BorderRadius.circular(18), boxShadow: [ BoxShadow( - color: Colors.white.withValues(alpha: 0.3), + color: Theme.of(context).shadowColor, blurRadius: 7, spreadRadius: 2, offset: const Offset(2, 3), ), ], ), - child: const Icon(Icons.arrow_back, color: Colors.black), + child: Icon( + Icons.arrow_back, + color: Theme.of(context).colorScheme.onSurface, + ), ), ), const Spacer(), @@ -197,11 +204,11 @@ class DetailPage extends HookConsumerWidget { horizontal: 12, ), decoration: BoxDecoration( - color: Colors.white.withValues(alpha: 0.9), + color: Theme.of(context).colorScheme.surface, borderRadius: BorderRadius.circular(18), boxShadow: [ BoxShadow( - color: Colors.white.withValues(alpha: 0.3), + color: Theme.of(context).shadowColor, blurRadius: 7, spreadRadius: 2, offset: const Offset(2, 3), @@ -236,9 +243,11 @@ class DetailPage extends HookConsumerWidget { begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [ - const Color.fromARGB(0, 255, 255, 255), - Colors.grey.shade50.withValues(alpha: 0.85), - Colors.grey.shade50, + Colors.transparent, + Theme.of( + context, + ).colorScheme.secondaryFixed.withValues(alpha: 0.85), + Theme.of(context).colorScheme.secondaryFixed, ], stops: const [0.0, 0.25, 1.0], ), @@ -256,11 +265,11 @@ class DetailPage extends HookConsumerWidget { right: sideMargin, ), decoration: BoxDecoration( - color: Colors.black, + color: Theme.of(context).colorScheme.secondary, borderRadius: BorderRadius.circular(18), boxShadow: [ BoxShadow( - color: Colors.black.withValues(alpha: 0.2), + color: Theme.of(context).shadowColor, blurRadius: 7, spreadRadius: 2, offset: const Offset(2, 3), @@ -305,7 +314,7 @@ class DetailPage extends HookConsumerWidget { child: HeroIcon( selected ? HeroIcons.bellSlash : HeroIcons.bell, size: 30, - color: Colors.white, + color: Theme.of(context).colorScheme.onSecondary, ), ), SizedBox( @@ -314,8 +323,10 @@ class DetailPage extends HookConsumerWidget { selected ? 'Supprimer le rappel ' : 'Ajouter un rappel', - style: const TextStyle( - color: Colors.white, + style: TextStyle( + color: Theme.of( + context, + ).colorScheme.onSecondary, fontSize: 20, ), ), diff --git a/lib/cinema/ui/pages/main_page/main_page.dart b/lib/cinema/ui/pages/main_page/main_page.dart index 1423fe525d..fb234f7d81 100644 --- a/lib/cinema/ui/pages/main_page/main_page.dart +++ b/lib/cinema/ui/pages/main_page/main_page.dart @@ -63,12 +63,12 @@ class CinemaMainPage extends HookConsumerWidget { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - const Text( + Text( CinemaTextConstants.incomingSession, style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: Colors.grey, + color: Theme.of(context).colorScheme.tertiary, ), ), if (isAdmin) @@ -88,7 +88,7 @@ class CinemaMainPage extends HookConsumerWidget { builder: (context, data) { data.sort((a, b) => a.start.compareTo(b.start)); if (data.isEmpty) { - return const SizedBox( + return SizedBox( height: 200, child: Center( child: Text( @@ -96,7 +96,7 @@ class CinemaMainPage extends HookConsumerWidget { style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: Colors.black, + color: Theme.of(context).colorScheme.onPrimary, ), ), ), diff --git a/lib/cinema/ui/pages/main_page/session_card.dart b/lib/cinema/ui/pages/main_page/session_card.dart index c1513a9ad0..44d8db2456 100644 --- a/lib/cinema/ui/pages/main_page/session_card.dart +++ b/lib/cinema/ui/pages/main_page/session_card.dart @@ -106,7 +106,7 @@ class SessionCard extends HookConsumerWidget { borderRadius: BorderRadius.circular(30), boxShadow: [ BoxShadow( - color: Colors.grey.withValues(alpha: 0.2), + color: Theme.of(context).shadowColor, spreadRadius: 5, blurRadius: 7, offset: const Offset(0, 3), @@ -187,7 +187,12 @@ class SessionCard extends HookConsumerWidget { border: (selected && session.start.isAfter(DateTime.now())) - ? Border.all(color: Colors.black, width: 3) + ? Border.all( + color: Theme.of( + context, + ).colorScheme.onPrimary, + width: 3, + ) : null, ), ), @@ -199,18 +204,22 @@ class SessionCard extends HookConsumerWidget { child: Container( width: 80, height: 60, - decoration: const BoxDecoration( - color: Colors.black, - borderRadius: BorderRadius.only( + decoration: BoxDecoration( + color: Theme.of( + context, + ).colorScheme.secondary, + borderRadius: const BorderRadius.only( topRight: Radius.circular(30), bottomLeft: Radius.circular(30), ), ), - child: const Center( + child: Center( child: HeroIcon( HeroIcons.bell, size: 30, - color: Colors.red, + color: Theme.of( + context, + ).colorScheme.primaryFixed, ), ), ), diff --git a/lib/cinema/ui/pages/session_pages/add_edit_session.dart b/lib/cinema/ui/pages/session_pages/add_edit_session.dart index 86e350a3ec..0182f6b40e 100644 --- a/lib/cinema/ui/pages/session_pages/add_edit_session.dart +++ b/lib/cinema/ui/pages/session_pages/add_edit_session.dart @@ -63,6 +63,13 @@ class AddEditSessionPage extends HookConsumerWidget { displayToast(context, type, msg); } + final underlineInputBorder = UnderlineInputBorder( + borderSide: BorderSide( + color: Theme.of(context).colorScheme.onPrimary, + width: 2.0, + ), + ); + return CinemaTemplate( child: SingleChildScrollView( physics: const BouncingScrollPhysics(), @@ -76,16 +83,16 @@ class AddEditSessionPage extends HookConsumerWidget { isEdit ? CinemaTextConstants.editSession : CinemaTextConstants.addSession, - color: Colors.grey, + color: Theme.of(context).colorScheme.tertiary, ), const SizedBox(height: 30), TextField( controller: tmdbUrl, - cursorColor: Colors.black, + cursorColor: Theme.of(context).colorScheme.onPrimary, decoration: InputDecoration( labelText: CinemaTextConstants.importFromTMDB, - labelStyle: const TextStyle( - color: Colors.black, + labelStyle: TextStyle( + color: Theme.of(context).colorScheme.onPrimary, fontSize: 20, ), suffixIcon: Container( @@ -141,22 +148,18 @@ class AddEditSessionPage extends HookConsumerWidget { } }, builder: (child) => TmdbButton(child: child), - child: const HeroIcon( + child: HeroIcon( HeroIcons.arrowRight, size: 22, - color: Colors.black, + color: Theme.of( + context, + ).colorScheme.onPrimaryContainer, ), ), ), - border: const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.black, width: 2.0), - ), - enabledBorder: const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.black, width: 2.0), - ), - focusedBorder: const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.black, width: 2.0), - ), + border: underlineInputBorder, + enabledBorder: underlineInputBorder, + focusedBorder: underlineInputBorder, ), ), const SizedBox(height: 30), @@ -168,13 +171,15 @@ class AddEditSessionPage extends HookConsumerWidget { horizontal: 30, ), decoration: BoxDecoration( - color: Colors.grey[200], + color: Theme.of( + context, + ).colorScheme.secondaryFixed, borderRadius: BorderRadius.circular(20), ), child: HeroIcon( HeroIcons.camera, size: 100, - color: Colors.grey.shade500, + color: Theme.of(context).colorScheme.tertiary, ), ) : Image( @@ -329,8 +334,8 @@ class AddEditSessionPage extends HookConsumerWidget { }, child: Text( isEdit ? CinemaTextConstants.edit : CinemaTextConstants.add, - style: const TextStyle( - color: Colors.white, + style: TextStyle( + color: Theme.of(context).colorScheme.onSecondary, fontSize: 25, fontWeight: FontWeight.bold, ), diff --git a/lib/cinema/ui/pages/session_pages/tmdb_button.dart b/lib/cinema/ui/pages/session_pages/tmdb_button.dart index ba595c28ee..8ab7091e49 100644 --- a/lib/cinema/ui/pages/session_pages/tmdb_button.dart +++ b/lib/cinema/ui/pages/session_pages/tmdb_button.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:titan/cinema/tools/constants.dart'; class TmdbButton extends StatelessWidget { final Widget child; @@ -11,7 +10,7 @@ class TmdbButton extends StatelessWidget { padding: const EdgeInsets.all(10), decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), - color: CinemaColorConstants.tmdbColor, + color: Theme.of(context).colorScheme.primaryContainer, ), child: child, ); diff --git a/lib/drawer/tools/constants.dart b/lib/drawer/tools/constants.dart index 915bd67786..4b4837884e 100644 --- a/lib/drawer/tools/constants.dart +++ b/lib/drawer/tools/constants.dart @@ -14,6 +14,8 @@ class DrawerTextConstants { static const String androidAppLink = "https://play.google.com/store/apps/details?id=fr.myecl.titan"; static const String copied = "Copié !"; + static const String lightMode = "Mode clair"; + static const String darkMode = "Mode sombre"; static const String downloadAppOnMobileDevice = "Ce site est la version Web de l'application MyECL. Nous vous invitons à télécharger l'application. N'utilisez ce site qu'en cas de problème avec l'application.\n"; static const String iosAppLink = diff --git a/lib/drawer/ui/bottom_bar.dart b/lib/drawer/ui/bottom_bar.dart index 94d74e5942..a0bcf24ce4 100644 --- a/lib/drawer/ui/bottom_bar.dart +++ b/lib/drawer/ui/bottom_bar.dart @@ -1,17 +1,53 @@ import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:heroicons/heroicons.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:titan/drawer/providers/display_quit_popup.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; import 'package:titan/drawer/tools/constants.dart'; -class BottomBar extends ConsumerWidget { +class BottomBar extends HookConsumerWidget { const BottomBar({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { final displayQuitNotifier = ref.watch(displayQuitProvider.notifier); + final isDarkTheme = ref.watch(themeProvider); + final themeNotifier = ref.watch(themeProvider.notifier); + return Column( children: [ + SizedBox( + height: 30, + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const SizedBox(width: 25), + HeroIcon( + isDarkTheme ? HeroIcons.moon : HeroIcons.sun, + color: DrawerColorConstants.lightText, + size: 27, + ), + const SizedBox(width: 15), + Text( + isDarkTheme + ? DrawerTextConstants.darkMode + : DrawerTextConstants.lightMode, + style: TextStyle( + color: DrawerColorConstants.lightText, + fontSize: 18, + ), + ), + const SizedBox(width: 15), + Switch( + value: isDarkTheme, + onChanged: (_) { + themeNotifier.toggleTheme(); + }, + ), + ], + ), + ), + const SizedBox(height: 30), SizedBox( height: 30, child: Row( diff --git a/lib/flappybird/providers/pipe_image_provider.dart b/lib/flappybird/providers/pipe_image_provider.dart index aced448ec0..6da47debc0 100644 --- a/lib/flappybird/providers/pipe_image_provider.dart +++ b/lib/flappybird/providers/pipe_image_provider.dart @@ -1,6 +1,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:image/image.dart' as external_image; +import 'package:titan/tools/providers/theme_provider.dart'; class PipeImageNotifier extends StateNotifier { PipeImageNotifier() : super(Uint8List.fromList([])); @@ -9,8 +10,10 @@ class PipeImageNotifier extends StateNotifier { state = list; } - Future getPipeImage() async { - final image = await rootBundle.load("assets/images/pipe.png"); + Future getPipeImage(bool isDarkTheme) async { + final image = await rootBundle.load( + "assets/images/pipe_${isDarkTheme ? "night" : "day"}.png", + ); external_image.Image? img = external_image.decodeImage( image.buffer.asUint8List(), ); @@ -23,6 +26,7 @@ final pipeImageProvider = StateNotifierProvider(( ref, ) { PipeImageNotifier notifier = PipeImageNotifier(); - notifier.getPipeImage(); + final isDarkTheme = ref.watch(themeProvider); + notifier.getPipeImage(isDarkTheme); return notifier; }); diff --git a/lib/flappybird/tools/constants.dart b/lib/flappybird/tools/constants.dart new file mode 100644 index 0000000000..d34ac0f8e2 --- /dev/null +++ b/lib/flappybird/tools/constants.dart @@ -0,0 +1,9 @@ +import 'package:flutter/material.dart'; + +class FlappyBirdColors { + bool isDarkTheme; + FlappyBirdColors(this.isDarkTheme); + Color get sky => isDarkTheme ? const Color(0xff040348) : Colors.blue; + Color get land => isDarkTheme ? const Color(0xff402000) : Colors.brown; + Color get text => isDarkTheme ? Colors.amber : Colors.white; +} diff --git a/lib/flappybird/ui/flappybird_item_chip.dart b/lib/flappybird/ui/flappybird_item_chip.dart index 8063d90c97..51c6fd5e71 100644 --- a/lib/flappybird/ui/flappybird_item_chip.dart +++ b/lib/flappybird/ui/flappybird_item_chip.dart @@ -35,8 +35,8 @@ class FlappyBirdItemChip extends HookConsumerWidget { "assets/images/logo_flappybird.svg", width: 20, height: 20, - colorFilter: const ColorFilter.mode( - Colors.white, + colorFilter: ColorFilter.mode( + Theme.of(context).colorScheme.onSecondary, BlendMode.srcIn, ), ), diff --git a/lib/flappybird/ui/flappybird_template.dart b/lib/flappybird/ui/flappybird_template.dart index efab4dea41..be4e5fec7b 100644 --- a/lib/flappybird/ui/flappybird_template.dart +++ b/lib/flappybird/ui/flappybird_template.dart @@ -5,6 +5,8 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:titan/flappybird/providers/score_list_provider.dart'; import 'package:titan/flappybird/providers/user_score_provider.dart'; import 'package:titan/flappybird/router.dart'; +import 'package:titan/flappybird/tools/constants.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; import 'package:titan/tools/ui/widgets/top_bar.dart'; import 'package:qlevar_router/qlevar_router.dart'; @@ -16,8 +18,9 @@ class FlappyBirdTemplate extends HookConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final leaderBoardNotifier = ref.watch(scoreListProvider.notifier); final bestUserScoreNotifier = ref.watch(userScoreProvider.notifier); + final isDarkTheme = ref.watch(themeProvider); return Container( - color: Colors.blue, + color: FlappyBirdColors(isDarkTheme).sky, child: SafeArea( child: Column( children: [ @@ -25,10 +28,10 @@ class FlappyBirdTemplate extends HookConsumerWidget { title: "Flappy Bird", root: FlappyBirdRouter.root, textStyle: GoogleFonts.silkscreen( - textStyle: const TextStyle( + textStyle: TextStyle( fontSize: 20, fontWeight: FontWeight.bold, - color: Colors.white, + color: FlappyBirdColors(isDarkTheme).text, ), ), rightIcon: QR.currentPath == FlappyBirdRouter.root @@ -40,9 +43,9 @@ class FlappyBirdTemplate extends HookConsumerWidget { FlappyBirdRouter.root + FlappyBirdRouter.leaderBoard, ); }, - icon: const HeroIcon( + icon: HeroIcon( HeroIcons.trophy, - color: Colors.white, + color: FlappyBirdColors(isDarkTheme).text, size: 40, ), ) diff --git a/lib/flappybird/ui/pages/game_page/game_page.dart b/lib/flappybird/ui/pages/game_page/game_page.dart index aad892f14f..82a29c9a2a 100644 --- a/lib/flappybird/ui/pages/game_page/game_page.dart +++ b/lib/flappybird/ui/pages/game_page/game_page.dart @@ -11,10 +11,12 @@ import 'package:titan/flappybird/providers/game_loop_provider.dart'; import 'package:titan/flappybird/providers/game_state_provider.dart'; import 'package:titan/flappybird/providers/pipe_list_provider.dart'; import 'package:titan/flappybird/providers/score_list_provider.dart'; +import 'package:titan/flappybird/tools/constants.dart'; import 'package:titan/flappybird/ui/flappybird_template.dart'; import 'package:titan/flappybird/ui/pages/game_page/pipe_handler.dart'; import 'package:titan/flappybird/ui/pages/game_page/score.dart'; import 'package:titan/flappybird/ui/pages/game_page/start_screen.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; import 'bird.dart'; @@ -35,6 +37,8 @@ class GamePage extends HookConsumerWidget { final bestScoreNotifier = ref.read(bestScoreProvider.notifier); final width = MediaQuery.of(context).size.width; + final isDarkTheme = ref.watch(themeProvider); + void showGameOverDialog() { showDialog( context: context, @@ -47,12 +51,14 @@ class GamePage extends HookConsumerWidget { Navigator.of(context).pop(); }, child: AlertDialog( - backgroundColor: Colors.brown, + backgroundColor: FlappyBirdColors(isDarkTheme).land, title: Center( child: Text( 'Game over!'.toUpperCase(), style: GoogleFonts.silkscreen( - textStyle: const TextStyle(color: Colors.white), + textStyle: TextStyle( + color: FlappyBirdColors(isDarkTheme).text, + ), ), ), ), @@ -60,13 +66,16 @@ class GamePage extends HookConsumerWidget { Container( margin: const EdgeInsets.only(bottom: 10), child: MaterialButton( - color: Colors.grey[100], + color: FlappyBirdColors(isDarkTheme).text, onPressed: () { birdNotifier.resetBird(); pipeListNotifier.clearPipe(); Navigator.pop(context); }, - child: const Icon(Icons.refresh, color: Colors.brown), + child: Icon( + Icons.refresh, + color: FlappyBirdColors(isDarkTheme).land, + ), ), ), ], @@ -132,7 +141,7 @@ class GamePage extends HookConsumerWidget { } }, child: Container( - color: Colors.blue, + color: FlappyBirdColors(isDarkTheme).sky, child: Stack( children: [ const BirdDisplay(), diff --git a/lib/flappybird/ui/pages/game_page/score.dart b/lib/flappybird/ui/pages/game_page/score.dart index 06c33679bc..c44882da69 100644 --- a/lib/flappybird/ui/pages/game_page/score.dart +++ b/lib/flappybird/ui/pages/game_page/score.dart @@ -3,6 +3,8 @@ import 'package:google_fonts/google_fonts.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:titan/flappybird/providers/bird_provider.dart'; import 'package:titan/flappybird/providers/current_best_score.dart'; +import 'package:titan/flappybird/tools/constants.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; class GameScore extends HookConsumerWidget { const GameScore({super.key}); @@ -11,9 +13,10 @@ class GameScore extends HookConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final bird = ref.watch(birdProvider); final record = ref.watch(bestScoreProvider); + final isDarkTheme = ref.watch(themeProvider); return Expanded( child: Container( - color: Colors.brown, + color: FlappyBirdColors(isDarkTheme).land, child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ @@ -26,28 +29,35 @@ class GameScore extends HookConsumerWidget { } } -class _TextWidget extends StatelessWidget { +class _TextWidget extends ConsumerWidget { const _TextWidget({required this.title, required this.number}); final String title; final String number; @override - Widget build(BuildContext context) { + Widget build(BuildContext context, WidgetRef ref) { + final isDarkTheme = ref.watch(themeProvider); return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( number, style: GoogleFonts.silkscreen( - textStyle: const TextStyle(color: Colors.white, fontSize: 25), + textStyle: TextStyle( + color: FlappyBirdColors(isDarkTheme).text, + fontSize: 25, + ), ), ), const SizedBox(height: 15), Text( title, style: GoogleFonts.silkscreen( - textStyle: const TextStyle(color: Colors.white, fontSize: 20), + textStyle: TextStyle( + color: FlappyBirdColors(isDarkTheme).text, + fontSize: 20, + ), ), ), ], diff --git a/lib/flappybird/ui/pages/game_page/start_screen.dart b/lib/flappybird/ui/pages/game_page/start_screen.dart index fb9c4742cc..8a9ff473b0 100644 --- a/lib/flappybird/ui/pages/game_page/start_screen.dart +++ b/lib/flappybird/ui/pages/game_page/start_screen.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:titan/flappybird/providers/game_state_provider.dart'; +import 'package:titan/flappybird/tools/constants.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; class StartScreen extends HookConsumerWidget { const StartScreen({super.key}); @@ -9,13 +11,17 @@ class StartScreen extends HookConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final gameStarted = ref.watch(gameStateProvider); + final isDarkTheme = ref.watch(themeProvider); return !gameStarted ? Container( alignment: const Alignment(0, -0.4), child: Text( 'T A P T O P L A Y', style: GoogleFonts.silkscreen( - textStyle: const TextStyle(color: Colors.white, fontSize: 20), + textStyle: TextStyle( + color: FlappyBirdColors(isDarkTheme).text, + fontSize: 20, + ), ), ), ) diff --git a/lib/flappybird/ui/pages/leaderboard_page/leaderboard_item.dart b/lib/flappybird/ui/pages/leaderboard_page/leaderboard_item.dart index d092617208..ab8917effa 100644 --- a/lib/flappybird/ui/pages/leaderboard_page/leaderboard_item.dart +++ b/lib/flappybird/ui/pages/leaderboard_page/leaderboard_item.dart @@ -1,14 +1,18 @@ import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:titan/flappybird/class/score.dart'; +import 'package:titan/flappybird/tools/constants.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; -class LeaderBoardItem extends StatelessWidget { +class LeaderBoardItem extends ConsumerWidget { final Score score; const LeaderBoardItem({super.key, required this.score}); @override - Widget build(BuildContext context) { + Widget build(BuildContext context, WidgetRef ref) { + final isDarkTheme = ref.watch(themeProvider); final style = GoogleFonts.silkscreen( textStyle: TextStyle( fontSize: 20, @@ -19,7 +23,7 @@ class LeaderBoardItem extends StatelessWidget { ? Colors.grey.shade400 : score.position == 3 ? Colors.brown.shade400 - : Colors.white, + : FlappyBirdColors(isDarkTheme).text, ), ); return Container( diff --git a/lib/flappybird/ui/pages/leaderboard_page/leaderboard_page.dart b/lib/flappybird/ui/pages/leaderboard_page/leaderboard_page.dart index 1affcbee2f..c9a587e160 100644 --- a/lib/flappybird/ui/pages/leaderboard_page/leaderboard_page.dart +++ b/lib/flappybird/ui/pages/leaderboard_page/leaderboard_page.dart @@ -3,8 +3,10 @@ import 'package:google_fonts/google_fonts.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:titan/flappybird/providers/score_list_provider.dart'; import 'package:titan/flappybird/providers/user_score_provider.dart'; +import 'package:titan/flappybird/tools/constants.dart'; import 'package:titan/flappybird/ui/flappybird_template.dart'; import 'package:titan/flappybird/ui/pages/leaderboard_page/leaderboard_item.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; class LeaderBoardPage extends HookConsumerWidget { const LeaderBoardPage({super.key}); @@ -13,6 +15,7 @@ class LeaderBoardPage extends HookConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final leaderBoard = ref.watch(scoreListProvider); final bestUserScore = ref.watch(userScoreProvider); + final isDarkTheme = ref.watch(themeProvider); return FlappyBirdTemplate( child: Column( children: [ @@ -21,7 +24,7 @@ class LeaderBoardPage extends HookConsumerWidget { child: Container( width: double.infinity, height: double.infinity, - color: Colors.blue, + color: FlappyBirdColors(isDarkTheme).sky, padding: const EdgeInsets.only(top: 90, left: 30, right: 30), child: leaderBoard.when( data: (scoreList) => ListView.builder( @@ -35,9 +38,10 @@ class LeaderBoardPage extends HookConsumerWidget { "LeaderBoard", textAlign: TextAlign.center, style: GoogleFonts.silkscreen( - textStyle: const TextStyle( + textStyle: TextStyle( fontSize: 30, fontWeight: FontWeight.bold, + color: FlappyBirdColors(isDarkTheme).text, ), ), ), @@ -54,7 +58,7 @@ class LeaderBoardPage extends HookConsumerWidget { ), Expanded( child: Container( - color: Colors.brown, + color: FlappyBirdColors(isDarkTheme).land, child: Container( alignment: Alignment.center, padding: const EdgeInsets.symmetric(horizontal: 30), diff --git a/lib/home/ui/day_card.dart b/lib/home/ui/day_card.dart index 85a0468ea1..82ee07ff74 100644 --- a/lib/home/ui/day_card.dart +++ b/lib/home/ui/day_card.dart @@ -39,7 +39,7 @@ class DayCard extends HookConsumerWidget { borderRadius: BorderRadius.circular(70), border: Border.all( color: (selectedDay == index && !isToday) - ? Colors.black + ? Theme.of(context).colorScheme.onPrimary : Colors.transparent, width: 2, ), @@ -47,14 +47,24 @@ class DayCard extends HookConsumerWidget { begin: Alignment.topLeft, end: Alignment.bottomRight, colors: isToday - ? [HomeColorConstants.gradient1, HomeColorConstants.gradient2] - : [Colors.white, Colors.grey.shade100], + ? [ + Theme.of(context).colorScheme.primaryContainer, + Theme.of(context).colorScheme.primaryFixed, + ] + : [ + Theme.of(context).colorScheme.primary, + Theme.of(context).colorScheme.secondaryFixed, + ], ), boxShadow: [ BoxShadow( color: isToday - ? HomeColorConstants.gradient2.withValues(alpha: 0.2) - : Colors.grey.withValues(alpha: 0.2), + ? Theme.of( + context, + ).colorScheme.primaryFixed.withValues(alpha: 0.2) + : Theme.of( + context, + ).colorScheme.secondaryFixed.withValues(alpha: 0.2), spreadRadius: 5, blurRadius: 10, offset: const Offset(3, 3), @@ -72,7 +82,9 @@ class DayCard extends HookConsumerWidget { day.day.toString(), textAlign: TextAlign.center, style: TextStyle( - color: isToday ? Colors.white : Colors.black, + color: isToday + ? Theme.of(context).colorScheme.onPrimaryContainer + : Theme.of(context).colorScheme.onPrimary, fontWeight: FontWeight.bold, fontSize: 30, ), @@ -86,7 +98,9 @@ class DayCard extends HookConsumerWidget { ).format(day)]!, textAlign: TextAlign.center, style: TextStyle( - color: isToday ? Colors.white : Colors.black, + color: isToday + ? Theme.of(context).colorScheme.onPrimaryContainer + : Theme.of(context).colorScheme.onPrimary, fontWeight: FontWeight.bold, fontSize: 12, ), @@ -103,7 +117,11 @@ class DayCard extends HookConsumerWidget { width: 7, child: Icon( Icons.circle, - color: isToday ? Colors.white : Colors.black, + color: isToday + ? Theme.of( + context, + ).colorScheme.onPrimaryContainer + : Theme.of(context).colorScheme.onPrimary, size: 5, ), ), @@ -114,7 +132,9 @@ class DayCard extends HookConsumerWidget { child: Text( "$numberOfEvent", style: TextStyle( - color: isToday ? Colors.white : Colors.black, + color: isToday + ? Theme.of(context).colorScheme.onPrimaryContainer + : Theme.of(context).colorScheme.onPrimary, fontWeight: FontWeight.bold, fontSize: 12, ), diff --git a/lib/home/ui/days_event.dart b/lib/home/ui/days_event.dart index c5df74ef18..c86edbc711 100644 --- a/lib/home/ui/days_event.dart +++ b/lib/home/ui/days_event.dart @@ -5,7 +5,6 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:titan/event/class/event.dart'; import 'package:titan/event/providers/event_provider.dart'; import 'package:titan/home/router.dart'; -import 'package:titan/home/tools/constants.dart'; import 'package:titan/tools/functions.dart'; import 'package:titan/tools/ui/widgets/align_left_text.dart'; import 'package:titan/tools/ui/layouts/card_layout.dart'; @@ -29,7 +28,7 @@ class DaysEvent extends HookConsumerWidget { padding: const EdgeInsets.symmetric(horizontal: 30.0, vertical: 10), child: Column( children: [ - AlignLeftText(day, color: Colors.grey), + AlignLeftText(day, color: Theme.of(context).colorScheme.tertiary), const SizedBox(height: 10), ...events.map((event) { final start = DateTime( @@ -47,18 +46,27 @@ class DaysEvent extends HookConsumerWidget { event.end.minute, ); final textColor = start.compareTo(now) <= 0 - ? Colors.white - : Colors.black; + ? Theme.of(context).colorScheme.onSecondary + : Theme.of(context).colorScheme.onPrimary; return CardLayout( id: event.id, margin: const EdgeInsets.all(10), height: 135, width: double.infinity, colors: end.compareTo(now) < 0 - ? [Colors.grey.shade700, Colors.grey.shade800] + ? [ + Theme.of(context).colorScheme.tertiary, + Theme.of(context).colorScheme.secondaryContainer, + ] : start.compareTo(now) <= 0 - ? [HomeColorConstants.gradient1, HomeColorConstants.gradient2] - : [Colors.white, Colors.white], + ? [ + Theme.of(context).colorScheme.primaryContainer, + Theme.of(context).colorScheme.primaryFixed, + ] + : [ + Theme.of(context).colorScheme.primary, + Theme.of(context).colorScheme.secondaryFixed, + ], padding: const EdgeInsets.symmetric( horizontal: 15.0, vertical: 12, diff --git a/lib/home/ui/home.dart b/lib/home/ui/home.dart index 37a9e157c3..5ddd2f1e36 100644 --- a/lib/home/ui/home.dart +++ b/lib/home/ui/home.dart @@ -24,66 +24,62 @@ class HomePage extends HookConsumerWidget { DateTime now = DateTime.now(); final ScrollController scrollController = useScrollController(); final daysEventScrollController = useScrollController(); - - return Container( - color: Colors.white, - child: SafeArea( - child: Refresher( - onRefresh: () async { - await confirmedEventListNotifier.loadConfirmedEvent(); - now = DateTime.now(); - }, - child: Column( - children: [ - const TopBar( - title: HomeTextConstants.calendar, - root: HomeRouter.root, - ), - const SizedBox(height: 20), - MonthBar( - scrollController: scrollController, - width: MediaQuery.of(context).size.width, - ), - const SizedBox(height: 10), - DayList(scrollController, daysEventScrollController), - const SizedBox(height: 15), - const AlignLeftText( - HomeTextConstants.incomingEvents, - padding: EdgeInsets.symmetric(horizontal: 30.0), - fontSize: 25, - ), - const SizedBox(height: 10), - SizedBox( - height: MediaQuery.of(context).size.height - 320, - child: SingleChildScrollView( - physics: const BouncingScrollPhysics(), - controller: daysEventScrollController, - child: sortedEventList.keys.isNotEmpty - ? Column( - children: sortedEventList - .map( - (key, value) => MapEntry( - key, - DaysEvent(day: key, now: now, events: value), - ), - ) - .values - .toList(), - ) - : const Center( - child: Text( - HomeTextConstants.noEvents, - style: TextStyle( - fontSize: 15, - fontWeight: FontWeight.bold, - color: Colors.grey, - ), + return SafeArea( + child: Refresher( + onRefresh: () async { + await confirmedEventListNotifier.loadConfirmedEvent(); + now = DateTime.now(); + }, + child: Column( + children: [ + const TopBar( + title: HomeTextConstants.calendar, + root: HomeRouter.root, + ), + const SizedBox(height: 20), + MonthBar( + scrollController: scrollController, + width: MediaQuery.of(context).size.width, + ), + const SizedBox(height: 10), + DayList(scrollController, daysEventScrollController), + const SizedBox(height: 15), + const AlignLeftText( + HomeTextConstants.incomingEvents, + padding: EdgeInsets.symmetric(horizontal: 30.0), + fontSize: 25, + ), + const SizedBox(height: 10), + SizedBox( + height: MediaQuery.of(context).size.height - 320, + child: SingleChildScrollView( + physics: const BouncingScrollPhysics(), + controller: daysEventScrollController, + child: sortedEventList.keys.isNotEmpty + ? Column( + children: sortedEventList + .map( + (key, value) => MapEntry( + key, + DaysEvent(day: key, now: now, events: value), + ), + ) + .values + .toList(), + ) + : Center( + child: Text( + HomeTextConstants.noEvents, + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold, + color: Theme.of(context).colorScheme.tertiary, ), ), - ), + ), ), - ], - ), + ), + ], ), ), ); diff --git a/lib/home/ui/month_bar.dart b/lib/home/ui/month_bar.dart index 37aa5a8612..d7c35bac35 100644 --- a/lib/home/ui/month_bar.dart +++ b/lib/home/ui/month_bar.dart @@ -55,10 +55,10 @@ class MonthBar extends HookConsumerWidget { }, child: Text( getMonth((currentMonth.value - 1) % 12), - style: const TextStyle( + style: TextStyle( fontSize: 13, fontWeight: FontWeight.bold, - color: Colors.grey, + color: Theme.of(context).colorScheme.tertiary, ), ), ), @@ -66,9 +66,9 @@ class MonthBar extends HookConsumerWidget { ), Text( getMonth(currentMonth.value % 12), - style: const TextStyle( + style: TextStyle( fontSize: 20, - color: Colors.black, + color: Theme.of(context).colorScheme.onPrimary, fontWeight: FontWeight.bold, ), ), @@ -94,10 +94,10 @@ class MonthBar extends HookConsumerWidget { }, child: Text( getMonth((currentMonth.value + 1) % 12), - style: const TextStyle( + style: TextStyle( fontSize: 13, fontWeight: FontWeight.bold, - color: Colors.grey, + color: Theme.of(context).colorScheme.tertiary, ), ), ), diff --git a/lib/main.dart b/lib/main.dart index 8c1f719fd7..d36922a58b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -11,13 +11,14 @@ import 'package:flutter/foundation.dart' show kIsWeb; import 'package:titan/drawer/providers/animation_provider.dart'; import 'package:titan/drawer/providers/swipe_provider.dart'; import 'package:titan/drawer/providers/top_bar_callback_provider.dart'; -import 'package:google_fonts/google_fonts.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:titan/router.dart'; import 'package:titan/service/tools/setup.dart'; +import 'package:titan/tools/constants.dart'; import 'package:titan/tools/functions.dart'; import 'package:titan/tools/plausible/plausible_observer.dart'; import 'package:titan/tools/providers/path_forwarding_provider.dart'; +import 'package:titan/tools/providers/theme_provider.dart'; import 'package:titan/tools/ui/layouts/app_template.dart'; import 'package:qlevar_router/qlevar_router.dart'; import 'package:qlevar_router/qlevar_router.dart' as qqr; @@ -58,6 +59,7 @@ class MyApp extends HookConsumerWidget { final plausible = getPlausible(); final pathForwardingNotifier = ref.watch(pathForwardingProvider.notifier); Future(() => animationNotifier.setController(animationController)); + final isDarkTheme = ref.watch(themeProvider); if (!kIsWeb) { useEffect(() { @@ -124,11 +126,9 @@ class MyApp extends HookConsumerWidget { GlobalWidgetsLocalizations.delegate, GlobalCupertinoLocalizations.delegate, ], - theme: ThemeData( - primarySwatch: Colors.orange, - textTheme: GoogleFonts.latoTextTheme(Theme.of(context).textTheme), - brightness: Brightness.light, - ), + theme: ThemeConstants(context).lightTheme, + darkTheme: ThemeConstants(context).darkTheme, + themeMode: isDarkTheme ? ThemeMode.dark : ThemeMode.light, routeInformationParser: const QRouteInformationParser(), builder: (context, child) { if (child == null) { diff --git a/lib/mypayment/ui/pages/invoices_admin_page/invoice_card.dart b/lib/mypayment/ui/pages/invoices_admin_page/invoice_card.dart index b08b647a91..412a641454 100644 --- a/lib/mypayment/ui/pages/invoices_admin_page/invoice_card.dart +++ b/lib/mypayment/ui/pages/invoices_admin_page/invoice_card.dart @@ -37,128 +37,126 @@ class InvoiceCard extends HookConsumerWidget { context: context, modal: BottomModalTemplate( title: invoice.reference, - child: Column( - children: [ + actions: [ + Button( + onPressed: () async { + late final Uint8List pdfBytes; + try { + pdfBytes = await invoicePdf; + } catch (e) { + displayToastWithContext(TypeMsg.error, e.toString()); + return; + } + final path = kIsWeb + ? await FileSaver.instance.saveFile( + name: invoice.reference, + bytes: pdfBytes, + ext: "pdf", + mimeType: MimeType.pdf, + ) + : await FileSaver.instance.saveAs( + name: invoice.reference, + bytes: pdfBytes, + ext: "pdf", + mimeType: MimeType.pdf, + ); + if (path != null) { + displayToastWithContext( + TypeMsg.msg, + "Téléchargement réussi", + ); + } + }, + text: "Télécharger la facture (PDF)", + ), + if (!invoice.received && isAdmin) ...[ + const SizedBox(height: 10), Button( onPressed: () async { - late final Uint8List pdfBytes; - try { - pdfBytes = await invoicePdf; - } catch (e) { - displayToastWithContext(TypeMsg.error, e.toString()); - return; - } - final path = kIsWeb - ? await FileSaver.instance.saveFile( - name: invoice.reference, - bytes: pdfBytes, - ext: "pdf", - mimeType: MimeType.pdf, - ) - : await FileSaver.instance.saveAs( - name: invoice.reference, - bytes: pdfBytes, - ext: "pdf", - mimeType: MimeType.pdf, - ); - if (path != null) { + final value = await invoicesNotifier + .updateInvoicePaidStatus(invoice, !invoice.paid); + if (value) { displayToastWithContext( TypeMsg.msg, - "Téléchargement réussi", + "Statut mis à jour avec succès", + ); + } else { + displayToastWithContext( + TypeMsg.error, + "Erreur lors de la mise à jour du statut", ); } }, - text: "Télécharger la facture (PDF)", + text: invoice.paid + ? "Marquer comme impayée" + : "Marquer comme payée", ), - if (!invoice.received && isAdmin) ...[ - const SizedBox(height: 10), - Button( - onPressed: () async { - final value = await invoicesNotifier - .updateInvoicePaidStatus(invoice, !invoice.paid); - if (value) { - displayToastWithContext( - TypeMsg.msg, - "Statut mis à jour avec succès", - ); - } else { - displayToastWithContext( - TypeMsg.error, - "Erreur lors de la mise à jour du statut", - ); - } - }, - text: invoice.paid - ? "Marquer comme impayée" - : "Marquer comme payée", - ), - ], - if (!isAdmin && invoice.paid && !invoice.received) ...[ - const SizedBox(height: 10), - Button( - onPressed: () async { - Navigator.of(context).pop(); - showDialog( - context: context, - builder: (context) => CustomDialogBox( - title: "Marquer comme reçue", - descriptions: - "Confirmez-vous avoir bien reçu le paiement ?", - onYes: () async { - final value = await invoicesNotifier - .updateInvoiceReceivedStatus(invoice, true); - if (value) { - displayToastWithContext( - TypeMsg.msg, - "Statut mis à jour avec succès", - ); - } else { - displayToastWithContext( - TypeMsg.error, - "Erreur lors de la mise à jour du statut", - ); - } - }, - ), - ); - }, - text: "Marquer comme reçue", - ), - ], - if (!invoice.paid && isAdmin) ...[ - const SizedBox(height: 10), - Button( - onPressed: () async { - Navigator.of(context).pop(); - showDialog( - context: context, - builder: (context) => CustomDialogBox( - title: "Supprimer la facture", - descriptions: "Cette action est irréversible", - onYes: () async { - final value = await invoicesNotifier.deleteInvoice( - invoice, + ], + if (!isAdmin && invoice.paid && !invoice.received) ...[ + const SizedBox(height: 10), + Button( + onPressed: () async { + Navigator.of(context).pop(); + showDialog( + context: context, + builder: (context) => CustomDialogBox( + title: "Marquer comme reçue", + descriptions: + "Confirmez-vous avoir bien reçu le paiement ?", + onYes: () async { + final value = await invoicesNotifier + .updateInvoiceReceivedStatus(invoice, true); + if (value) { + displayToastWithContext( + TypeMsg.msg, + "Statut mis à jour avec succès", ); - if (value) { - displayToastWithContext( - TypeMsg.msg, - "Facture supprimée avec succès", - ); - } else { - displayToastWithContext( - TypeMsg.error, - "Erreur lors de la suppression de la facture", - ); - } - }, - ), - ); - }, - text: "Supprimer la facture", - ), - ], + } else { + displayToastWithContext( + TypeMsg.error, + "Erreur lors de la mise à jour du statut", + ); + } + }, + ), + ); + }, + text: "Marquer comme reçue", + ), ], - ), + if (!invoice.paid && isAdmin) ...[ + const SizedBox(height: 10), + Button( + onPressed: () async { + Navigator.of(context).pop(); + showDialog( + context: context, + builder: (context) => CustomDialogBox( + title: "Supprimer la facture", + descriptions: "Cette action est irréversible", + onYes: () async { + final value = await invoicesNotifier.deleteInvoice( + invoice, + ); + if (value) { + displayToastWithContext( + TypeMsg.msg, + "Facture supprimée avec succès", + ); + } else { + displayToastWithContext( + TypeMsg.error, + "Erreur lors de la suppression de la facture", + ); + } + }, + ), + ); + }, + text: "Supprimer la facture", + ), + ], + ], ), ), child: CardLayout( diff --git a/lib/mypayment/ui/pages/invoices_admin_page/invoices_admin_page.dart b/lib/mypayment/ui/pages/invoices_admin_page/invoices_admin_page.dart index 327fe45668..6f80942eb5 100644 --- a/lib/mypayment/ui/pages/invoices_admin_page/invoices_admin_page.dart +++ b/lib/mypayment/ui/pages/invoices_admin_page/invoices_admin_page.dart @@ -109,69 +109,67 @@ class InvoicesAdminPage extends HookConsumerWidget { final structure = ref.watch(structureProvider); return BottomModalTemplate( title: "Créer une nouvelle facture", - child: Column( - children: [ - Text( - "Sélectionnez une structure", - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold, - ), + actions: [ + Text( + "Sélectionnez une structure", + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, ), - SizedBox( - height: min( - structures.length * 50, - MediaQuery.of(context).size.height * 0.8, - ), - child: SingleChildScrollView( - child: Column( - children: structures - .map( - (e) => ItemChip( - vertical: true, - onTap: () => structureNotifier - .setStructure(e), - selected: structure.id == e.id, - child: Text( - e.name, - style: TextStyle( - fontSize: 16, - color: structure.id == e.id - ? Colors.white - : Colors.black, - ), + ), + SizedBox( + height: min( + structures.length * 50, + MediaQuery.of(context).size.height * 0.8, + ), + child: SingleChildScrollView( + child: Column( + children: structures + .map( + (e) => ItemChip( + vertical: true, + onTap: () => structureNotifier + .setStructure(e), + selected: structure.id == e.id, + child: Text( + e.name, + style: TextStyle( + fontSize: 16, + color: structure.id == e.id + ? Colors.white + : Colors.black, ), ), - ) - .toList(), - ), + ), + ) + .toList(), ), ), - Button( - onPressed: () async { - if (structure.id == "") return; - Navigator.pop(context); - await tokenExpireWrapper(ref, () async { - final value = await invoicesNotifier - .createInvoice(structure); - if (value) { - displayToastWithContext( - TypeMsg.msg, - "Facture créée avec succès", - ); - refreshInvoices(); - } else { - displayToastWithContext( - TypeMsg.error, - "Aucune facture à générer pour cette structure", - ); - } - }); - }, - text: "Créer la facture", - ), - ], - ), + ), + Button( + onPressed: () async { + if (structure.id == "") return; + Navigator.pop(context); + await tokenExpireWrapper(ref, () async { + final value = await invoicesNotifier + .createInvoice(structure); + if (value) { + displayToastWithContext( + TypeMsg.msg, + "Facture créée avec succès", + ); + refreshInvoices(); + } else { + displayToastWithContext( + TypeMsg.error, + "Aucune facture à générer pour cette structure", + ); + } + }); + }, + text: "Créer la facture", + ), + ], ); }, ), diff --git a/lib/mypayment/ui/pages/main_page/seller_card/structure_admin_card.dart b/lib/mypayment/ui/pages/main_page/seller_card/structure_admin_card.dart index 0aa72e8e65..3efd77b965 100644 --- a/lib/mypayment/ui/pages/main_page/seller_card/structure_admin_card.dart +++ b/lib/mypayment/ui/pages/main_page/seller_card/structure_admin_card.dart @@ -64,49 +64,44 @@ class StructureAdminCard extends ConsumerWidget { context: context, modal: BottomModalTemplate( title: "Gestion de ${structure.name}", - child: Column( - children: [ - if (isManager) ...[ - Button( - onPressed: () { - Navigator.of(context).pop(); - selectedStructureNotifier.setStructure(structure); - QR.to( - PaymentRouter.root + PaymentRouter.administrators, - ); - }, - text: "Administrateurs", - ), - const SizedBox(height: 10), - ], + actions: [ + if (isManager) ...[ Button( onPressed: () { Navigator.of(context).pop(); selectedStructureNotifier.setStructure(structure); QR.to( - PaymentRouter.root + PaymentRouter.structureStores, + PaymentRouter.root + PaymentRouter.administrators, ); }, - text: "Magasins", + text: "Administrateurs", ), const SizedBox(height: 10), - Button( - onPressed: () { - Navigator.of(context).pop(); - tokenExpireWrapper( - ref, - () => invoicesNotifier.getStructureInvoices( - structure.id, - ), - ); - QR.to( - PaymentRouter.root + PaymentRouter.invoicesStructure, - ); - }, - text: "Factures", - ), ], - ), + Button( + onPressed: () { + Navigator.of(context).pop(); + selectedStructureNotifier.setStructure(structure); + QR.to(PaymentRouter.root + PaymentRouter.structureStores); + }, + text: "Magasins", + ), + const SizedBox(height: 10), + Button( + onPressed: () { + Navigator.of(context).pop(); + tokenExpireWrapper( + ref, + () => + invoicesNotifier.getStructureInvoices(structure.id), + ); + QR.to( + PaymentRouter.root + PaymentRouter.invoicesStructure, + ); + }, + text: "Factures", + ), + ], ), ); }, diff --git a/lib/others/ui/no_internet_page.dart b/lib/others/ui/no_internet_page.dart index a5449fe0f2..14d542740f 100644 --- a/lib/others/ui/no_internet_page.dart +++ b/lib/others/ui/no_internet_page.dart @@ -4,7 +4,6 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:titan/auth/providers/is_connected_provider.dart'; import 'package:titan/home/router.dart'; import 'package:titan/others/tools/constants.dart'; -import 'package:titan/tools/constants.dart'; import 'package:qlevar_router/qlevar_router.dart'; import 'package:titan/tools/repository/repository.dart'; @@ -48,36 +47,40 @@ class NoInternetPage extends HookConsumerWidget { padding: const EdgeInsets.only(top: 12, bottom: 15), width: double.infinity, decoration: BoxDecoration( - gradient: const LinearGradient( + gradient: LinearGradient( colors: [ - ColorConstants.gradient1, - ColorConstants.gradient2, + Theme.of(context).colorScheme.primaryContainer, + Theme.of(context).colorScheme.primaryFixed, ], begin: Alignment.topLeft, end: Alignment.bottomRight, ), boxShadow: [ BoxShadow( - color: ColorConstants.gradient1.withValues(alpha: 0.2), + color: Theme.of( + context, + ).colorScheme.primaryContainer.withValues(alpha: 0.2), blurRadius: 10, offset: const Offset(0, 5), ), ], borderRadius: BorderRadius.circular(15), ), - child: const Row( + child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ HeroIcon( HeroIcons.arrowPath, size: 35, - color: Colors.white, + color: Theme.of(context).colorScheme.onPrimaryContainer, ), Text( OthersTextConstants.retry, style: TextStyle( fontSize: 25, - color: Colors.white, + color: Theme.of( + context, + ).colorScheme.onPrimaryContainer, fontWeight: FontWeight.bold, ), ), diff --git a/lib/others/ui/rollback_page.dart b/lib/others/ui/rollback_page.dart index 88255bc987..fd8a4797c6 100644 --- a/lib/others/ui/rollback_page.dart +++ b/lib/others/ui/rollback_page.dart @@ -37,31 +37,19 @@ class RollbackPage extends HookConsumerWidget { const Spacer(flex: 3), Text( "${OthersTextConstants.version} $titanVersion, flavor ${getAppFlavor()}", - style: const TextStyle( - fontSize: 15, - fontWeight: FontWeight.w500, - color: Colors.black, - ), + style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w500), ), const SizedBox(height: 20), Text( "${OthersTextConstants.minimalHyperionVersion} : $minimalHyperionVersion", - style: const TextStyle( - fontSize: 15, - fontWeight: FontWeight.w500, - color: Colors.black, - ), + style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w500), ), const SizedBox(height: 20), Text( "${OthersTextConstants.hyperionVersion} (${Repository.host}) : ${versionVerifier.whenOrNull(data: (value) { return value.version; })}", - style: const TextStyle( - fontSize: 15, - fontWeight: FontWeight.w500, - color: Colors.black, - ), + style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w500), ), const SizedBox(height: 20), ], diff --git a/lib/others/ui/update_page.dart b/lib/others/ui/update_page.dart index 5e6013d8b8..34d41c70a9 100644 --- a/lib/others/ui/update_page.dart +++ b/lib/others/ui/update_page.dart @@ -28,11 +28,7 @@ class UpdatePage extends HookConsumerWidget { const Spacer(flex: 3), Text( "${OthersTextConstants.version} $titanVersion", - style: const TextStyle( - fontSize: 15, - fontWeight: FontWeight.w500, - color: Colors.black, - ), + style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w500), ), const SizedBox(height: 20), ], diff --git a/lib/ph/ui/button.dart b/lib/ph/ui/button.dart index 5dc4b66f86..81d71b2804 100644 --- a/lib/ph/ui/button.dart +++ b/lib/ph/ui/button.dart @@ -23,10 +23,13 @@ class MyButton extends StatelessWidget { gradient: LinearGradient( colors: enabled ? [ - const Color.fromARGB(255, 115, 3, 3), - const Color.fromARGB(255, 231, 84, 31), + Theme.of(context).colorScheme.primaryFixed, + Theme.of(context).colorScheme.primaryContainer, ] - : [Colors.grey.shade200, Colors.grey.shade200], + : [ + Theme.of(context).colorScheme.tertiary, + Theme.of(context).colorScheme.tertiary, + ], begin: Alignment.bottomRight, end: Alignment.topLeft, ), @@ -38,8 +41,8 @@ class MyButton extends StatelessWidget { style: TextStyle( fontWeight: FontWeight.w700, color: enabled - ? const Color.fromARGB(255, 255, 252, 251) - : Colors.black, + ? Theme.of(context).colorScheme.onPrimaryContainer + : Theme.of(context).colorScheme.onSurface, ), maxLines: 1, ), diff --git a/lib/ph/ui/components/year_bar.dart b/lib/ph/ui/components/year_bar.dart index 78475038fc..9c89ff92b8 100644 --- a/lib/ph/ui/components/year_bar.dart +++ b/lib/ph/ui/components/year_bar.dart @@ -32,7 +32,9 @@ class YearBar extends HookConsumerWidget { child: Text( e.toString(), style: TextStyle( - color: selected.contains(e) ? Colors.white : Colors.black, + color: selected.contains(e) + ? Theme.of(context).colorScheme.onSecondary + : Theme.of(context).colorScheme.onSurface, fontWeight: FontWeight.bold, ), ), diff --git a/lib/ph/ui/pages/admin_page/admin_ph_card.dart b/lib/ph/ui/pages/admin_page/admin_ph_card.dart index e03b0fd8b6..f3a43ef589 100644 --- a/lib/ph/ui/pages/admin_page/admin_ph_card.dart +++ b/lib/ph/ui/pages/admin_page/admin_ph_card.dart @@ -53,18 +53,31 @@ class AdminPhCard extends StatelessWidget { GestureDetector( onTap: onEdit, child: CardButton( - colors: [Colors.grey.shade100, Colors.grey.shade400], - shadowColor: Colors.grey.shade300.withValues(alpha: 0.2), - child: const HeroIcon(HeroIcons.pencil, color: Colors.black), + colors: [ + Theme.of(context).colorScheme.primary, + Theme.of(context).colorScheme.secondaryFixed, + ], + child: HeroIcon( + HeroIcons.pencil, + color: Theme.of(context).colorScheme.onSurface, + ), ), ), const SizedBox(width: 10), GestureDetector( onTap: onDelete, child: CardButton( - colors: const [Color(0xFF9E131F), Color(0xFF590512)], - shadowColor: const Color(0xFF590512).withValues(alpha: 0.2), - child: const HeroIcon(HeroIcons.trash, color: Colors.white), + colors: [ + Theme.of(context).colorScheme.primaryContainer, + Theme.of(context).colorScheme.primaryFixed, + ], + shadowColor: Theme.of( + context, + ).colorScheme.primaryFixed.withValues(alpha: 0.2), + child: HeroIcon( + HeroIcons.trash, + color: Theme.of(context).colorScheme.onPrimaryContainer, + ), ), ), ], diff --git a/lib/ph/ui/pages/form_page/add_edit_ph_page.dart b/lib/ph/ui/pages/form_page/add_edit_ph_page.dart index 37a3cf4c4f..e298553c96 100644 --- a/lib/ph/ui/pages/form_page/add_edit_ph_page.dart +++ b/lib/ph/ui/pages/form_page/add_edit_ph_page.dart @@ -157,8 +157,8 @@ class PhAddEditPhPage extends HookConsumerWidget { }, child: Text( isEdit ? PhTextConstants.edit : PhTextConstants.add, - style: const TextStyle( - color: Colors.white, + style: TextStyle( + color: Theme.of(context).colorScheme.onSecondary, fontSize: 25, fontWeight: FontWeight.bold, ), diff --git a/lib/ph/ui/pages/past_ph_selection_page/ph_card.dart b/lib/ph/ui/pages/past_ph_selection_page/ph_card.dart index 1e1f90ec26..a70f022c81 100644 --- a/lib/ph/ui/pages/past_ph_selection_page/ph_card.dart +++ b/lib/ph/ui/pages/past_ph_selection_page/ph_card.dart @@ -87,10 +87,10 @@ class PhCard extends HookConsumerWidget { child: CardButton( borderRadius: const BorderRadius.all(Radius.circular(10000)), size: 60, - color: Colors.grey.shade300.withValues(alpha: 0.9), - child: const HeroIcon( + color: Theme.of(context).shadowColor, + child: HeroIcon( HeroIcons.arrowDownTray, - color: Colors.black, + color: Theme.of(context).colorScheme.onPrimary, ), ), ), diff --git a/lib/phonebook/tools/constants.dart b/lib/phonebook/tools/constants.dart index 854e6e1d57..6e502f2cf7 100644 --- a/lib/phonebook/tools/constants.dart +++ b/lib/phonebook/tools/constants.dart @@ -1,5 +1,3 @@ -import 'package:flutter/material.dart'; - class PhonebookTextConstants { static const String activeMandate = "Mandat actif :"; static const String add = "Ajouter"; @@ -140,10 +138,6 @@ class PhonebookTextConstants { static const String validation = "Valider"; } -class PhonebookColorConstants { - static const Color textDark = Color(0xFF1D1D1D); -} - class PhonebookPermissionConstants { static const String accessPhonebook = "access_phonebook"; static const String managePhonebook = "manage_phonebook"; diff --git a/lib/phonebook/tools/function.dart b/lib/phonebook/tools/function.dart index a4655b2f1c..95791c6dfa 100644 --- a/lib/phonebook/tools/function.dart +++ b/lib/phonebook/tools/function.dart @@ -50,7 +50,11 @@ List sortedAssociationByKind( return sortedByGroupement.values.expand((list) => list).toList(); } -Color getColorFromTagList(WidgetRef ref, List tags) { +Color getColorFromTagList( + BuildContext context, + WidgetRef ref, + List tags, +) { final rolesTags = ref.watch(rolesTagsProvider).keys.toList(); int index = 4; for (String tag in tags) { @@ -58,15 +62,15 @@ Color getColorFromTagList(WidgetRef ref, List tags) { index = rolesTags.indexOf(tag); } } - switch (index) { - case 0: - return const Color.fromARGB(255, 251, 109, 16); - case 1: - return const Color.fromARGB(255, 252, 145, 74); - case 2: - return const Color.fromARGB(255, 253, 193, 153); - case 3: - return const Color.fromARGB(255, 254, 205, 180); - } - return Colors.white; + return index < 4 + ? Theme.of(context).colorScheme.primaryContainer.withValues( + alpha: switch (index) { + 0 => 1, + 1 => 0.75, + 2 => 0.5, + 3 => 0.25, + _ => 0, // unreachable anyway + }, + ) + : Theme.of(context).colorScheme.surface; } diff --git a/lib/phonebook/ui/components/groupement_bar.dart b/lib/phonebook/ui/components/groupement_bar.dart index a62951938e..48cacdc8d0 100644 --- a/lib/phonebook/ui/components/groupement_bar.dart +++ b/lib/phonebook/ui/components/groupement_bar.dart @@ -98,7 +98,7 @@ class GroupementsBar extends HookConsumerWidget { }, ), ], - child: SizedBox.shrink(), + //child: SizedBox.shrink(), ), ); @@ -118,10 +118,10 @@ class GroupementsBar extends HookConsumerWidget { height: 40, firstChild: !restrictToManaged && isAdmin ? ItemChip( - child: const Text( + child: Text( "+", style: TextStyle( - color: Colors.black, + color: Theme.of(context).colorScheme.onSurface, fontWeight: FontWeight.bold, ), ), @@ -157,7 +157,9 @@ class GroupementsBar extends HookConsumerWidget { child: Text( item.name, style: TextStyle( - color: selected ? Colors.white : Colors.black, + color: selected + ? Theme.of(context).colorScheme.onSecondary + : Theme.of(context).colorScheme.onSurface, fontWeight: FontWeight.bold, ), ), diff --git a/lib/phonebook/ui/components/radio_chip.dart b/lib/phonebook/ui/components/radio_chip.dart deleted file mode 100644 index 5e8047274f..0000000000 --- a/lib/phonebook/ui/components/radio_chip.dart +++ /dev/null @@ -1,36 +0,0 @@ -import 'package:flutter/material.dart'; - -class RadioChip extends StatelessWidget { - final bool selected; - final String label; - final Function() onTap; - const RadioChip({ - super.key, - required this.label, - required this.selected, - required this.onTap, - }); - - @override - Widget build(BuildContext context) { - return GestureDetector( - onTap: onTap, - child: Container( - margin: const EdgeInsets.symmetric(horizontal: 10.0), - child: Chip( - label: Padding( - padding: const EdgeInsets.all(8.0), - child: Text( - label, - style: TextStyle( - color: selected ? Colors.white : Colors.black, - fontWeight: FontWeight.bold, - ), - ), - ), - backgroundColor: selected ? Colors.black : Colors.grey.shade200, - ), - ), - ); - } -} diff --git a/lib/phonebook/ui/components/text_input_dialog.dart b/lib/phonebook/ui/components/text_input_dialog.dart deleted file mode 100644 index 2b7bd0beeb..0000000000 --- a/lib/phonebook/ui/components/text_input_dialog.dart +++ /dev/null @@ -1,62 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:titan/phonebook/tools/constants.dart'; - -class TextInputDialog extends HookConsumerWidget { - const TextInputDialog({ - super.key, - required this.controller, - required this.title, - required this.text, - required this.defaultText, - required this.onConfirm, - }); - - final String title; - final String text; - final String defaultText; - final VoidCallback onConfirm; - final TextEditingController controller; - - @override - Widget build(BuildContext context, WidgetRef ref) { - controller.text = defaultText; - return AlertDialog( - title: Center( - child: Container( - decoration: const BoxDecoration( - border: Border(bottom: BorderSide(color: Colors.black)), - color: Colors.white, - ), - child: Text(title, style: const TextStyle(fontSize: 20)), - ), - ), - content: SizedBox( - height: 100, - child: Column( - children: [ - const SizedBox(height: 25), - Text(text), - const SizedBox(height: 5), - SizedBox(width: 200, child: TextField(controller: controller)), - ], - ), - ), - actions: [ - TextButton( - onPressed: () { - Navigator.of(context).pop(); - }, - child: const Text(PhonebookTextConstants.cancel), - ), - TextButton( - onPressed: () { - Navigator.of(context).pop(); - onConfirm(); - }, - child: const Text(PhonebookTextConstants.validation), - ), - ], - ); - } -} diff --git a/lib/phonebook/ui/pages/add_edit_groupement/add_edit_groupement_page.dart b/lib/phonebook/ui/pages/add_edit_groupement/add_edit_groupement_page.dart index 16658231b1..b580bf7f16 100644 --- a/lib/phonebook/ui/pages/add_edit_groupement/add_edit_groupement_page.dart +++ b/lib/phonebook/ui/pages/add_edit_groupement/add_edit_groupement_page.dart @@ -8,7 +8,6 @@ import 'package:titan/phonebook/providers/association_groupement_list_provider.d import 'package:titan/phonebook/providers/association_groupement_provider.dart'; import 'package:titan/phonebook/tools/constants.dart'; import 'package:titan/phonebook/ui/phonebook.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/functions.dart'; import 'package:titan/tools/token_expire_wrapper.dart'; import 'package:qlevar_router/qlevar_router.dart'; @@ -47,11 +46,7 @@ class AssociationGroupementAddEditPage extends HookConsumerWidget { associationGroupement.id.isNotEmpty ? PhonebookTextConstants.editAssociationGroupement : PhonebookTextConstants.addAssociationGroupement, - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w700, - color: ColorConstants.title, - ), + style: TextStyle(fontSize: 20, fontWeight: FontWeight.w700), ), ), const SizedBox(height: 30), @@ -87,8 +82,8 @@ class AssociationGroupementAddEditPage extends HookConsumerWidget { group.name, style: TextStyle( color: selectedGroup.value == group.id - ? Colors.white - : Colors.black, + ? Theme.of(context).colorScheme.onSecondary + : Theme.of(context).colorScheme.onSurface, ), ), ); diff --git a/lib/phonebook/ui/pages/admin_page/admin_page.dart b/lib/phonebook/ui/pages/admin_page/admin_page.dart index 1918269537..1ecb6f57f3 100644 --- a/lib/phonebook/ui/pages/admin_page/admin_page.dart +++ b/lib/phonebook/ui/pages/admin_page/admin_page.dart @@ -15,7 +15,6 @@ import 'package:titan/phonebook/ui/components/groupement_bar.dart'; import 'package:titan/phonebook/ui/phonebook.dart'; import 'package:titan/phonebook/ui/pages/admin_page/association_research_bar.dart'; import 'package:titan/phonebook/ui/pages/admin_page/editable_association_card.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/functions.dart'; import 'package:titan/tools/ui/builders/async_child.dart'; import 'package:titan/tools/ui/layouts/card_layout.dart'; @@ -98,13 +97,13 @@ class AdminPage extends HookConsumerWidget { color: isPhonebookAdmin || groupementAdminProviderList.isNotEmpty - ? Colors.white - : ColorConstants.deactivated2, + ? Theme.of(context).colorScheme.surface + : Theme.of(context).colorScheme.tertiary, child: Center( child: HeroIcon( HeroIcons.plus, size: 40, - color: Colors.grey.shade500, + color: Theme.of(context).colorScheme.tertiary, ), ), ), diff --git a/lib/phonebook/ui/pages/admin_page/association_research_bar.dart b/lib/phonebook/ui/pages/admin_page/association_research_bar.dart index 86b4a7f703..e9a6589e8c 100644 --- a/lib/phonebook/ui/pages/admin_page/association_research_bar.dart +++ b/lib/phonebook/ui/pages/admin_page/association_research_bar.dart @@ -3,7 +3,6 @@ import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:titan/phonebook/providers/research_filter_provider.dart'; import 'package:titan/phonebook/tools/constants.dart'; -import 'package:titan/tools/constants.dart'; class AssociationResearchBar extends HookConsumerWidget { const AssociationResearchBar({super.key}); @@ -20,20 +19,24 @@ class AssociationResearchBar extends HookConsumerWidget { }, focusNode: focusNode, controller: editingController, - cursorColor: PhonebookColorConstants.textDark, - decoration: const InputDecoration( + cursorColor: Theme.of(context).colorScheme.secondaryContainer, + decoration: InputDecoration( isDense: true, suffixIcon: Icon( Icons.search, - color: PhonebookColorConstants.textDark, + color: Theme.of(context).colorScheme.secondaryContainer, size: 30, ), label: Text( PhonebookTextConstants.research, - style: TextStyle(color: PhonebookColorConstants.textDark), + style: TextStyle( + color: Theme.of(context).colorScheme.secondaryContainer, + ), ), focusedBorder: UnderlineInputBorder( - borderSide: BorderSide(color: ColorConstants.gradient1), + borderSide: BorderSide( + color: Theme.of(context).colorScheme.primaryContainer, + ), ), ), ); diff --git a/lib/phonebook/ui/pages/admin_page/delete_button.dart b/lib/phonebook/ui/pages/admin_page/delete_button.dart index 93b7c44ca3..f3e3dcd1a4 100644 --- a/lib/phonebook/ui/pages/admin_page/delete_button.dart +++ b/lib/phonebook/ui/pages/admin_page/delete_button.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:heroicons/heroicons.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/ui/builders/waiting_button.dart'; class DeleteButton extends StatelessWidget { @@ -23,16 +22,26 @@ class DeleteButton extends StatelessWidget { decoration: BoxDecoration( gradient: LinearGradient( colors: !deactivated - ? [ColorConstants.gradient1, ColorConstants.gradient2] - : [ColorConstants.deactivated1, ColorConstants.deactivated2], + ? [ + Theme.of(context).colorScheme.primaryContainer, + Theme.of(context).colorScheme.primaryFixed, + ] + : [ + Theme.of(context).colorScheme.secondaryFixed, + Theme.of(context).colorScheme.tertiary, + ], begin: Alignment.topLeft, end: Alignment.bottomRight, ), boxShadow: [ BoxShadow( color: !deactivated - ? ColorConstants.gradient2.withValues(alpha: 0.2) - : ColorConstants.deactivated2.withValues(alpha: 0.2), + ? Theme.of( + context, + ).colorScheme.primaryFixed.withValues(alpha: 0.2) + : Theme.of( + context, + ).colorScheme.tertiary.withValues(alpha: 0.2), blurRadius: 10, offset: const Offset(2, 3), ), @@ -44,8 +53,8 @@ class DeleteButton extends StatelessWidget { onTap: !deactivated ? onDelete : () async {}, child: HeroIcon( deletion ? HeroIcons.trash : HeroIcons.noSymbol, - size: 30, - color: Colors.white, + + color: Theme.of(context).colorScheme.onPrimaryContainer, ), ); } diff --git a/lib/phonebook/ui/pages/admin_page/editable_association_card.dart b/lib/phonebook/ui/pages/admin_page/editable_association_card.dart index 1b81f416f1..873bb5ed45 100644 --- a/lib/phonebook/ui/pages/admin_page/editable_association_card.dart +++ b/lib/phonebook/ui/pages/admin_page/editable_association_card.dart @@ -28,11 +28,13 @@ class EditableAssociationCard extends HookConsumerWidget { margin: const EdgeInsets.symmetric(vertical: 5), padding: const EdgeInsets.all(10), decoration: BoxDecoration( - color: association.deactivated ? Colors.grey[500] : Colors.white, + color: association.deactivated + ? Theme.of(context).colorScheme.tertiary + : Theme.of(context).colorScheme.surface, borderRadius: BorderRadius.circular(15), boxShadow: [ BoxShadow( - color: Colors.grey.withValues(alpha: 0.2), + color: Theme.of(context).shadowColor, blurRadius: 5, spreadRadius: 2, ), @@ -45,27 +47,19 @@ class EditableAssociationCard extends HookConsumerWidget { Expanded( child: Text( association.name, - style: const TextStyle( - color: Colors.black, - fontSize: 16, - fontWeight: FontWeight.bold, - ), + style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold), ), ), Expanded( child: Text( associationGroupement.name, - style: const TextStyle( - color: Colors.black, - fontSize: 16, - fontWeight: FontWeight.bold, - ), + style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold), ), ), Row( children: [ EditionButton(onEdition: onEdit, deactivated: !canEdit), - const SizedBox(width: 5), + const SizedBox(width: 10), DeleteButton( onDelete: onDelete, deactivated: !canDelete, diff --git a/lib/phonebook/ui/pages/admin_page/edition_button.dart b/lib/phonebook/ui/pages/admin_page/edition_button.dart index 0610372c55..e4d61467a8 100644 --- a/lib/phonebook/ui/pages/admin_page/edition_button.dart +++ b/lib/phonebook/ui/pages/admin_page/edition_button.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:heroicons/heroicons.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:titan/tools/constants.dart'; class EditionButton extends HookConsumerWidget { const EditionButton({ @@ -20,18 +19,21 @@ class EditionButton extends HookConsumerWidget { padding: const EdgeInsets.all(8), decoration: BoxDecoration( color: !deactivated - ? Colors.grey.shade200 - : ColorConstants.deactivated1, + ? Theme.of(context).colorScheme.secondaryFixed + : Theme.of(context).colorScheme.tertiary, borderRadius: BorderRadius.circular(10), boxShadow: [ BoxShadow( - color: Colors.grey.withValues(alpha: 0.2), + color: Theme.of(context).shadowColor, blurRadius: 10, offset: const Offset(2, 3), ), ], ), - child: const HeroIcon(HeroIcons.pencil, color: Colors.black), + child: HeroIcon( + HeroIcons.pencil, + color: Theme.of(context).colorScheme.onSurface, + ), ), ); } diff --git a/lib/phonebook/ui/pages/association_creation_page/association_creation_page.dart b/lib/phonebook/ui/pages/association_creation_page/association_creation_page.dart index 1c3b31cd0c..186b0e666c 100644 --- a/lib/phonebook/ui/pages/association_creation_page/association_creation_page.dart +++ b/lib/phonebook/ui/pages/association_creation_page/association_creation_page.dart @@ -11,7 +11,6 @@ import 'package:titan/phonebook/router.dart'; import 'package:titan/phonebook/tools/constants.dart'; import 'package:titan/phonebook/ui/components/groupement_bar.dart'; import 'package:titan/phonebook/ui/phonebook.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/functions.dart'; import 'package:titan/tools/token_expire_wrapper.dart'; import 'package:titan/tools/ui/builders/waiting_button.dart'; @@ -47,8 +46,8 @@ class AssociationCreationPage extends HookConsumerWidget { child: Column( children: [ const SizedBox(height: 30), - const Padding( - padding: EdgeInsets.symmetric(horizontal: 30.0), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 30.0), child: Align( alignment: Alignment.centerLeft, child: Text( @@ -56,7 +55,7 @@ class AssociationCreationPage extends HookConsumerWidget { style: TextStyle( fontSize: 20, fontWeight: FontWeight.w700, - color: ColorConstants.gradient1, + color: Theme.of(context).colorScheme.primaryContainer, ), ), ), @@ -86,9 +85,9 @@ class AssociationCreationPage extends HookConsumerWidget { const SizedBox(height: 50), WaitingButton( builder: (child) => AddEditButtonLayout( - colors: const [ - ColorConstants.gradient1, - ColorConstants.gradient2, + colors: [ + Theme.of(context).colorScheme.primaryContainer, + Theme.of(context).colorScheme.primaryFixed, ], child: child, ), @@ -145,12 +144,14 @@ class AssociationCreationPage extends HookConsumerWidget { } }); }, - child: const Text( + child: Text( AdminTextConstants.add, style: TextStyle( fontSize: 18, fontWeight: FontWeight.w600, - color: Color.fromARGB(255, 255, 255, 255), + color: Theme.of( + context, + ).colorScheme.onPrimaryContainer, ), ), ), diff --git a/lib/phonebook/ui/pages/association_creation_page/text_entry.dart b/lib/phonebook/ui/pages/association_creation_page/text_entry.dart deleted file mode 100644 index f3d011e7a4..0000000000 --- a/lib/phonebook/ui/pages/association_creation_page/text_entry.dart +++ /dev/null @@ -1,58 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:titan/admin/tools/constants.dart'; -import 'package:titan/tools/constants.dart'; - -class AddAssociationTextEntry extends StatelessWidget { - final TextEditingController controller; - final String title; - final bool canBeEmpty; - const AddAssociationTextEntry({ - super.key, - required this.controller, - required this.title, - required this.canBeEmpty, - }); - - @override - Widget build(BuildContext context) { - return Container( - margin: const EdgeInsets.symmetric(vertical: 20), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - alignment: Alignment.centerLeft, - child: Text( - title, - style: const TextStyle( - fontSize: 14, - fontWeight: FontWeight.w400, - color: Color.fromARGB(255, 158, 158, 158), - ), - ), - ), - SizedBox( - child: TextFormField( - controller: controller, - decoration: const InputDecoration( - isDense: true, - focusedBorder: UnderlineInputBorder( - borderSide: BorderSide(color: ColorConstants.gradient1), - ), - ), - validator: canBeEmpty - ? null - : (value) { - if (value == null || value.isEmpty) { - return AdminTextConstants.emptyFieldError; - } - return null; - }, - ), - ), - ], - ), - ); - } -} diff --git a/lib/phonebook/ui/pages/association_editor_page/association_editor_page.dart b/lib/phonebook/ui/pages/association_editor_page/association_editor_page.dart index 41d0cbae57..c841c1211a 100644 --- a/lib/phonebook/ui/pages/association_editor_page/association_editor_page.dart +++ b/lib/phonebook/ui/pages/association_editor_page/association_editor_page.dart @@ -20,7 +20,6 @@ import 'package:titan/phonebook/tools/constants.dart'; import 'package:titan/phonebook/ui/pages/association_editor_page/association_information_editor.dart'; import 'package:titan/phonebook/ui/phonebook.dart'; import 'package:titan/phonebook/ui/pages/association_editor_page/member_editable_card.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/functions.dart'; import 'package:titan/tools/token_expire_wrapper.dart'; import 'package:titan/tools/ui/builders/async_child.dart'; @@ -83,12 +82,12 @@ class AssociationEditorPage extends HookConsumerWidget { Container( padding: const EdgeInsets.symmetric(horizontal: 30), alignment: Alignment.centerLeft, - child: const Text( + child: Text( PhonebookTextConstants.edit, style: TextStyle( fontSize: 20, fontWeight: FontWeight.w700, - color: ColorConstants.gradient1, + color: Theme.of(context).colorScheme.primaryContainer, ), ), ), @@ -111,8 +110,8 @@ class AssociationEditorPage extends HookConsumerWidget { isAssociationPresident || isGroupementAdmin) && !association.deactivated - ? ColorConstants.gradient1 - : ColorConstants.deactivated1, + ? Theme.of(context).colorScheme.primaryContainer + : Theme.of(context).colorScheme.tertiary, borderRadius: BorderRadius.circular(10), ), child: child, @@ -152,10 +151,10 @@ class AssociationEditorPage extends HookConsumerWidget { } } : () async {}, - child: const HeroIcon( + child: HeroIcon( HeroIcons.plus, size: 30, - color: Colors.white, + color: Theme.of(context).colorScheme.onPrimaryContainer, ), ), ], @@ -248,10 +247,13 @@ class AssociationEditorPage extends HookConsumerWidget { colors: (isPhonebookAdmin || isGroupementAdmin) && !association.deactivated - ? [ColorConstants.gradient1, ColorConstants.gradient2] + ? [ + Theme.of(context).colorScheme.primaryContainer, + Theme.of(context).colorScheme.primaryFixed, + ] : [ - ColorConstants.deactivated1, - ColorConstants.deactivated2, + Theme.of(context).colorScheme.secondaryFixed, + Theme.of(context).colorScheme.tertiary, ], child: child, ), @@ -330,10 +332,10 @@ class AssociationEditorPage extends HookConsumerWidget { : () async {}, child: Text( "${PhonebookTextConstants.changeMandate} ${association.mandateYear + 1}", - style: const TextStyle( + style: TextStyle( fontSize: 18, fontWeight: FontWeight.w600, - color: Color.fromARGB(255, 255, 255, 255), + color: Theme.of(context).colorScheme.onPrimaryContainer, ), ), ), diff --git a/lib/phonebook/ui/pages/association_editor_page/association_information_editor.dart b/lib/phonebook/ui/pages/association_editor_page/association_information_editor.dart index 0f89b1544a..30cef4cd22 100644 --- a/lib/phonebook/ui/pages/association_editor_page/association_information_editor.dart +++ b/lib/phonebook/ui/pages/association_editor_page/association_information_editor.dart @@ -11,7 +11,6 @@ import 'package:titan/phonebook/providers/association_provider.dart'; import 'package:titan/phonebook/providers/is_phonebook_admin_provider.dart'; import 'package:titan/phonebook/tools/constants.dart'; import 'package:titan/phonebook/ui/components/groupement_bar.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/functions.dart'; import 'package:titan/tools/token_expire_wrapper.dart'; import 'package:titan/tools/ui/builders/waiting_button.dart'; @@ -73,7 +72,9 @@ class AssociationInformationEditor extends HookConsumerWidget { SizedBox( child: TextFormField( controller: name, - cursorColor: ColorConstants.gradient1, + cursorColor: Theme.of( + context, + ).colorScheme.primaryContainer, decoration: InputDecoration( labelText: PhonebookTextConstants.namePure, @@ -90,9 +91,11 @@ class AssociationInformationEditor extends HookConsumerWidget { color: Colors.transparent, ), ), - focusedBorder: const UnderlineInputBorder( + focusedBorder: UnderlineInputBorder( borderSide: BorderSide( - color: ColorConstants.gradient1, + color: Theme.of( + context, + ).colorScheme.primaryContainer, ), ), ), @@ -117,7 +120,9 @@ class AssociationInformationEditor extends HookConsumerWidget { SizedBox( child: TextFormField( controller: description, - cursorColor: ColorConstants.gradient1, + cursorColor: Theme.of( + context, + ).colorScheme.primaryContainer, decoration: InputDecoration( labelText: PhonebookTextConstants.description, @@ -134,9 +139,11 @@ class AssociationInformationEditor extends HookConsumerWidget { color: Colors.transparent, ), ), - focusedBorder: const UnderlineInputBorder( + focusedBorder: UnderlineInputBorder( borderSide: BorderSide( - color: ColorConstants.gradient1, + color: Theme.of( + context, + ).colorScheme.primaryContainer, ), ), ), @@ -147,9 +154,9 @@ class AssociationInformationEditor extends HookConsumerWidget { ), WaitingButton( builder: (child) => AddEditButtonLayout( - colors: const [ - ColorConstants.gradient1, - ColorConstants.gradient2, + colors: [ + Theme.of(context).colorScheme.primaryContainer, + Theme.of(context).colorScheme.primaryFixed, ], child: child, ), @@ -186,12 +193,14 @@ class AssociationInformationEditor extends HookConsumerWidget { } }); }, - child: const Text( + child: Text( PhonebookTextConstants.edit, style: TextStyle( fontSize: 18, fontWeight: FontWeight.w600, - color: Color.fromARGB(255, 255, 255, 255), + color: Theme.of( + context, + ).colorScheme.onPrimaryContainer, ), ), ), @@ -208,12 +217,12 @@ class AssociationInformationEditor extends HookConsumerWidget { if (association.deactivated) Container( margin: const EdgeInsets.symmetric(vertical: 10), - child: const Text( + child: Text( PhonebookTextConstants.deactivatedAssociationWarning, style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: Colors.red, + color: Theme.of(context).colorScheme.error, ), ), ), @@ -265,12 +274,12 @@ class AssociationInformationEditor extends HookConsumerWidget { horizontal: 20, ), decoration: BoxDecoration( - color: Colors.white, + color: Theme.of( + context, + ).colorScheme.primary, boxShadow: [ BoxShadow( - color: Colors.black.withValues( - alpha: 0.1, - ), + color: Theme.of(context).shadowColor, offset: const Offset(0, 1), blurRadius: 4, spreadRadius: 2, @@ -325,9 +334,9 @@ class AssociationInformationEditor extends HookConsumerWidget { ), WaitingButton( builder: (child) => AddEditButtonLayout( - colors: const [ - ColorConstants.gradient1, - ColorConstants.gradient2, + colors: [ + Theme.of(context).colorScheme.primaryContainer, + Theme.of(context).colorScheme.primaryFixed, ], child: child, ), @@ -354,12 +363,12 @@ class AssociationInformationEditor extends HookConsumerWidget { } }); }, - child: const Text( + child: Text( PhonebookTextConstants.updateGroups, style: TextStyle( fontSize: 18, fontWeight: FontWeight.w600, - color: Color.fromARGB(255, 255, 255, 255), + color: Theme.of(context).colorScheme.onPrimaryContainer, ), ), ), diff --git a/lib/phonebook/ui/pages/association_editor_page/member_editable_card.dart b/lib/phonebook/ui/pages/association_editor_page/member_editable_card.dart index 587851c886..c3d71d8191 100644 --- a/lib/phonebook/ui/pages/association_editor_page/member_editable_card.dart +++ b/lib/phonebook/ui/pages/association_editor_page/member_editable_card.dart @@ -64,6 +64,7 @@ class MemberEditableCard extends HookConsumerWidget { decoration: BoxDecoration( border: Border.all(), color: getColorFromTagList( + context, ref, member.memberships .firstWhere( @@ -82,7 +83,7 @@ class MemberEditableCard extends HookConsumerWidget { shape: BoxShape.circle, boxShadow: [ BoxShadow( - color: Colors.black.withValues(alpha: 0.1), + color: Theme.of(context).shadowColor, spreadRadius: 5, blurRadius: 10, offset: const Offset(2, 3), diff --git a/lib/phonebook/ui/pages/association_page/association_page.dart b/lib/phonebook/ui/pages/association_page/association_page.dart index 771520b2e9..b4befc639d 100644 --- a/lib/phonebook/ui/pages/association_page/association_page.dart +++ b/lib/phonebook/ui/pages/association_page/association_page.dart @@ -62,22 +62,34 @@ class AssociationPage extends HookConsumerWidget { const SizedBox(height: 20), Text( association.name, - style: const TextStyle(fontSize: 40, color: Colors.black), + style: TextStyle( + fontSize: 40, + color: Theme.of(context).colorScheme.onPrimary, + ), ), const SizedBox(height: 10), Text( associationGroupement.name, - style: const TextStyle(fontSize: 20, color: Colors.black), + style: TextStyle( + fontSize: 20, + color: Theme.of(context).colorScheme.onPrimary, + ), ), const SizedBox(height: 10), Text( association.description, - style: const TextStyle(fontSize: 15, color: Colors.black), + style: TextStyle( + fontSize: 15, + color: Theme.of(context).colorScheme.onPrimary, + ), ), const SizedBox(height: 10), Text( "${PhonebookTextConstants.activeMandate} ${association.mandateYear}", - style: const TextStyle(fontSize: 15, color: Colors.black), + style: TextStyle( + fontSize: 15, + color: Theme.of(context).colorScheme.onPrimary, + ), ), const SizedBox(height: 20), AsyncChild( @@ -131,22 +143,17 @@ class AssociationPage extends HookConsumerWidget { ), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - gradient: const RadialGradient( + gradient: RadialGradient( colors: [ - Color.fromARGB(255, 98, 98, 98), - Color.fromARGB(255, 27, 27, 27), + Theme.of(context).colorScheme.tertiary, + Theme.of(context).colorScheme.secondary, ], center: Alignment.topLeft, radius: 1.3, ), boxShadow: [ BoxShadow( - color: const Color.fromARGB( - 255, - 27, - 27, - 27, - ).withValues(alpha: 0.3), + color: Theme.of(context).shadowColor, spreadRadius: 5, blurRadius: 10, offset: const Offset( @@ -156,9 +163,9 @@ class AssociationPage extends HookConsumerWidget { ), ], ), - child: const HeroIcon( + child: HeroIcon( HeroIcons.envelope, - color: Colors.white, + color: Theme.of(context).colorScheme.onSecondary, ), ), ), @@ -182,22 +189,17 @@ class AssociationPage extends HookConsumerWidget { ), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - gradient: const RadialGradient( + gradient: RadialGradient( colors: [ - Color.fromARGB(255, 98, 98, 98), - Color.fromARGB(255, 27, 27, 27), + Theme.of(context).colorScheme.tertiary, + Theme.of(context).colorScheme.secondary, ], center: Alignment.topLeft, radius: 1.3, ), boxShadow: [ BoxShadow( - color: const Color.fromARGB( - 255, - 27, - 27, - 27, - ).withValues(alpha: 0.3), + color: Theme.of(context).shadowColor, spreadRadius: 5, blurRadius: 10, offset: const Offset( @@ -207,9 +209,9 @@ class AssociationPage extends HookConsumerWidget { ), ], ), - child: const HeroIcon( + child: HeroIcon( HeroIcons.pencil, - color: Colors.white, + color: Theme.of(context).colorScheme.onSecondary, ), ), ), diff --git a/lib/phonebook/ui/pages/association_page/member_card.dart b/lib/phonebook/ui/pages/association_page/member_card.dart index c1bc07159b..a11df12985 100644 --- a/lib/phonebook/ui/pages/association_page/member_card.dart +++ b/lib/phonebook/ui/pages/association_page/member_card.dart @@ -49,6 +49,7 @@ class MemberCard extends HookConsumerWidget { padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 5), child: CardLayout( color: getColorFromTagList( + context, ref, member.memberships .firstWhere( @@ -70,7 +71,7 @@ class MemberCard extends HookConsumerWidget { shape: BoxShape.circle, boxShadow: [ BoxShadow( - color: Colors.black.withValues(alpha: 0.1), + color: Theme.of(context).shadowColor, spreadRadius: 5, blurRadius: 10, offset: const Offset(2, 3), @@ -109,10 +110,10 @@ class MemberCard extends HookConsumerWidget { ), Text( "(${member.member.name} ${member.member.firstname})", - style: const TextStyle( + style: TextStyle( fontWeight: FontWeight.bold, fontSize: 16, - color: Color.fromARGB(255, 115, 115, 115), + color: Theme.of(context).colorScheme.tertiary, ), ), ], diff --git a/lib/phonebook/ui/pages/association_page/web_member_card.dart b/lib/phonebook/ui/pages/association_page/web_member_card.dart index d944ce67a8..c819e01cba 100644 --- a/lib/phonebook/ui/pages/association_page/web_member_card.dart +++ b/lib/phonebook/ui/pages/association_page/web_member_card.dart @@ -50,6 +50,7 @@ class WebMemberCard extends HookConsumerWidget { }, child: CardLayout( color: getColorFromTagList( + context, ref, member.memberships .firstWhere( @@ -71,7 +72,7 @@ class WebMemberCard extends HookConsumerWidget { shape: BoxShape.circle, boxShadow: [ BoxShadow( - color: Colors.black.withValues(alpha: 0.1), + color: Theme.of(context).shadowColor, spreadRadius: 5, blurRadius: 10, offset: const Offset(2, 3), @@ -114,10 +115,12 @@ class WebMemberCard extends HookConsumerWidget { const SizedBox(width: 10), SelectableText( "(${member.member.name} ${member.member.firstname})", - style: const TextStyle( + style: TextStyle( fontWeight: FontWeight.bold, fontSize: 20, - color: Color.fromARGB(255, 115, 115, 115), + color: Theme.of( + context, + ).colorScheme.tertiary, ), ), ], @@ -198,10 +201,10 @@ class WebMemberCard extends HookConsumerWidget { const SizedBox(width: 10), SelectableText( "(${member.member.name} ${member.member.firstname})", - style: const TextStyle( + style: TextStyle( fontWeight: FontWeight.bold, fontSize: 20, - color: Color.fromARGB(255, 115, 115, 115), + color: Theme.of(context).colorScheme.tertiary, ), ), ], diff --git a/lib/phonebook/ui/pages/main_page/research_bar.dart b/lib/phonebook/ui/pages/main_page/research_bar.dart index a2bde51a97..9f826afc4c 100644 --- a/lib/phonebook/ui/pages/main_page/research_bar.dart +++ b/lib/phonebook/ui/pages/main_page/research_bar.dart @@ -3,7 +3,6 @@ import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:titan/phonebook/providers/research_filter_provider.dart'; import 'package:titan/phonebook/tools/constants.dart'; -import 'package:titan/tools/constants.dart'; class ResearchBar extends HookConsumerWidget { const ResearchBar({super.key}); @@ -21,20 +20,24 @@ class ResearchBar extends HookConsumerWidget { }, focusNode: focusNode, controller: editingController, - cursorColor: PhonebookColorConstants.textDark, - decoration: const InputDecoration( + cursorColor: Theme.of(context).colorScheme.secondaryContainer, + decoration: InputDecoration( isDense: true, suffixIcon: Icon( Icons.search, - color: PhonebookColorConstants.textDark, + color: Theme.of(context).colorScheme.secondaryContainer, size: 30, ), label: Text( PhonebookTextConstants.research, - style: TextStyle(color: PhonebookColorConstants.textDark), + style: TextStyle( + color: Theme.of(context).colorScheme.secondaryContainer, + ), ), focusedBorder: UnderlineInputBorder( - borderSide: BorderSide(color: ColorConstants.gradient1), + borderSide: BorderSide( + color: Theme.of(context).colorScheme.primaryContainer, + ), ), ), ), diff --git a/lib/phonebook/ui/pages/membership_editor_page/membership_editor_page.dart b/lib/phonebook/ui/pages/membership_editor_page/membership_editor_page.dart index ca7cdf0db5..975f71c474 100644 --- a/lib/phonebook/ui/pages/membership_editor_page/membership_editor_page.dart +++ b/lib/phonebook/ui/pages/membership_editor_page/membership_editor_page.dart @@ -13,7 +13,6 @@ import 'package:titan/phonebook/providers/is_phonebook_admin_provider.dart'; import 'package:titan/phonebook/providers/roles_tags_provider.dart'; import 'package:titan/phonebook/tools/constants.dart'; import 'package:titan/phonebook/ui/phonebook.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/functions.dart'; import 'package:titan/tools/token_expire_wrapper.dart'; import 'package:titan/tools/ui/builders/waiting_button.dart'; @@ -116,11 +115,18 @@ class MembershipEditorPage extends HookConsumerWidget { data: (rolesTag) => rolesTag[0], orElse: () => false, ), + checkColor: Theme.of( + context, + ).colorScheme.onSecondary, fillColor: rolesTagList.keys.first == tagKey && (!isPhonebookAdmin && !isGroupementAdmin) - ? WidgetStateProperty.all(Colors.black) - : WidgetStateProperty.all(Colors.grey), + ? WidgetStateProperty.all( + Theme.of(context).colorScheme.secondary, + ) + : WidgetStateProperty.all( + Theme.of(context).colorScheme.tertiary, + ), onChanged: rolesTagList.keys.first == tagKey && (!isPhonebookAdmin && !isGroupementAdmin) @@ -156,9 +162,9 @@ class MembershipEditorPage extends HookConsumerWidget { const SizedBox(height: 50), WaitingButton( builder: (child) => AddEditButtonLayout( - colors: const [ - ColorConstants.gradient1, - ColorConstants.gradient2, + colors: [ + Theme.of(context).colorScheme.primaryContainer, + Theme.of(context).colorScheme.primaryFixed, ], child: child, ), @@ -166,10 +172,10 @@ class MembershipEditorPage extends HookConsumerWidget { !isEdit ? PhonebookTextConstants.add : PhonebookTextConstants.edit, - style: const TextStyle( + style: TextStyle( fontSize: 18, fontWeight: FontWeight.w600, - color: Color.fromARGB(255, 255, 255, 255), + color: Theme.of(context).colorScheme.onPrimaryContainer, ), ), onTap: () async { diff --git a/lib/phonebook/ui/pages/membership_editor_page/search_result.dart b/lib/phonebook/ui/pages/membership_editor_page/search_result.dart index d4b0244735..35e74abb15 100644 --- a/lib/phonebook/ui/pages/membership_editor_page/search_result.dart +++ b/lib/phonebook/ui/pages/membership_editor_page/search_result.dart @@ -26,10 +26,10 @@ class SearchResult extends HookConsumerWidget { child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - color: Colors.white, + color: Theme.of(context).colorScheme.surface, boxShadow: [ BoxShadow( - color: Colors.black.withValues(alpha: 0.1), + color: Theme.of(context).shadowColor, offset: const Offset(0, 1), blurRadius: 4, spreadRadius: 2, diff --git a/lib/settings/ui/pages/edit_user_page/edit_user_page.dart b/lib/settings/ui/pages/edit_user_page/edit_user_page.dart index 17c5486269..325744109b 100644 --- a/lib/settings/ui/pages/edit_user_page/edit_user_page.dart +++ b/lib/settings/ui/pages/edit_user_page/edit_user_page.dart @@ -9,7 +9,6 @@ import 'package:titan/settings/tools/constants.dart'; import 'package:titan/settings/ui/pages/edit_user_page/picture_button.dart'; import 'package:titan/settings/ui/pages/edit_user_page/user_field_modifier.dart'; import 'package:titan/settings/ui/settings.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/functions.dart'; import 'package:titan/tools/ui/layouts/add_edit_button_layout.dart'; import 'package:titan/tools/ui/widgets/align_left_text.dart'; @@ -69,9 +68,9 @@ class EditUserPage extends HookConsumerWidget { child: Column( children: [ const SizedBox(height: 20), - const AlignLeftText( + AlignLeftText( SettingsTextConstants.editAccount, - color: Colors.grey, + color: Theme.of(context).colorScheme.tertiary, ), const SizedBox(height: 40), AsyncChild( @@ -86,7 +85,8 @@ class EditUserPage extends HookConsumerWidget { shape: BoxShape.circle, boxShadow: [ BoxShadow( - color: Colors.black.withValues(alpha: 0.1), + color: Theme.of(context).colorScheme.onPrimary + .withValues(alpha: 0.1), spreadRadius: 5, blurRadius: 10, offset: const Offset(2, 3), @@ -207,7 +207,6 @@ class EditUserPage extends HookConsumerWidget { style: const TextStyle( fontSize: 20, fontWeight: FontWeight.w500, - color: Colors.black, ), ), ), @@ -217,7 +216,6 @@ class EditUserPage extends HookConsumerWidget { style: const TextStyle( fontSize: 18, fontWeight: FontWeight.w500, - color: Colors.black, ), ), const SizedBox(height: 50), @@ -242,7 +240,7 @@ class EditUserPage extends HookConsumerWidget { style: TextStyle( fontSize: 15, fontWeight: FontWeight.w400, - color: Colors.grey.shade500, + color: Theme.of(context).colorScheme.tertiary, ), ), ), @@ -251,6 +249,7 @@ class EditUserPage extends HookConsumerWidget { child: TextEntry( label: SettingsTextConstants.birthday, controller: dateController, + color: Theme.of(context).colorScheme.primaryContainer, ), ), ), @@ -266,19 +265,19 @@ class EditUserPage extends HookConsumerWidget { margin: const EdgeInsets.only(left: 30), padding: const EdgeInsets.all(12), decoration: BoxDecoration( - gradient: const LinearGradient( + gradient: LinearGradient( colors: [ - ColorConstants.gradient1, - ColorConstants.gradient2, + Theme.of(context).colorScheme.primaryContainer, + Theme.of(context).colorScheme.primaryFixed, ], begin: Alignment.topLeft, end: Alignment.bottomRight, ), boxShadow: [ BoxShadow( - color: ColorConstants.gradient2.withValues( - alpha: 0.5, - ), + color: Theme.of( + context, + ).colorScheme.primaryFixed.withValues(alpha: 0.5), spreadRadius: 1, blurRadius: 7, offset: const Offset(0, 3), @@ -286,10 +285,12 @@ class EditUserPage extends HookConsumerWidget { ], borderRadius: BorderRadius.circular(10), ), - child: const HeroIcon( + child: HeroIcon( HeroIcons.calendar, size: 25, - color: Colors.white, + color: Theme.of( + context, + ).colorScheme.onPrimaryContainer, ), ), ), @@ -305,7 +306,7 @@ class EditUserPage extends HookConsumerWidget { style: TextStyle( fontSize: 15, fontWeight: FontWeight.w400, - color: Colors.grey.shade500, + color: Theme.of(context).colorScheme.tertiary, ), ), ), @@ -313,27 +314,44 @@ class EditUserPage extends HookConsumerWidget { child: DropdownButtonFormField( items: items, initialValue: floorController.text, - hint: Text( - SettingsTextConstants.floor, - style: TextStyle( - fontSize: 15, - fontWeight: FontWeight.w400, - color: Colors.grey.shade500, - ), - ), + + // hint: Text( + // SettingsTextConstants.floor, + // style: TextStyle( + // fontSize: 15, + // fontWeight: FontWeight.w400, + // color: Colors.grey.shade500, + // ), + // ), onChanged: (value) { floorController.text = value.toString(); }, style: TextStyle( - fontSize: 20, - color: Colors.grey.shade800, + fontSize: 16, + color: Theme.of( + context, + ).colorScheme.secondaryContainer, ), - decoration: const InputDecoration( - contentPadding: EdgeInsets.all(10), + decoration: InputDecoration( + contentPadding: const EdgeInsets.symmetric( + vertical: 10, + ), isDense: true, focusedBorder: UnderlineInputBorder( borderSide: BorderSide( - color: ColorConstants.gradient1, + color: Theme.of( + context, + ).colorScheme.primaryContainer, + ), + ), + label: Text( + SettingsTextConstants.floor, + style: TextStyle( + color: Theme.of( + context, + ).colorScheme.primaryContainer, + height: 0.5, + fontWeight: FontWeight.bold, ), ), ), @@ -344,9 +362,9 @@ class EditUserPage extends HookConsumerWidget { const SizedBox(height: 50), WaitingButton( builder: (child) => AddEditButtonLayout( - colors: const [ - ColorConstants.gradient1, - ColorConstants.gradient2, + colors: [ + Theme.of(context).colorScheme.primaryContainer, + Theme.of(context).colorScheme.primaryFixed, ], child: child, ), @@ -384,13 +402,13 @@ class EditUserPage extends HookConsumerWidget { } }); }, - child: const Center( + child: Center( child: Text( SettingsTextConstants.save, style: TextStyle( fontSize: 25, fontWeight: FontWeight.w400, - color: Colors.white, + color: Theme.of(context).colorScheme.onPrimaryContainer, ), ), ), diff --git a/lib/settings/ui/pages/edit_user_page/picture_button.dart b/lib/settings/ui/pages/edit_user_page/picture_button.dart index 905238fb15..c1d6f00c76 100644 --- a/lib/settings/ui/pages/edit_user_page/picture_button.dart +++ b/lib/settings/ui/pages/edit_user_page/picture_button.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:heroicons/heroicons.dart'; -import 'package:titan/tools/constants.dart'; class PictureButton extends StatelessWidget { final HeroIcons icon; @@ -14,21 +13,29 @@ class PictureButton extends StatelessWidget { padding: const EdgeInsets.all(7), decoration: BoxDecoration( shape: BoxShape.circle, - gradient: const LinearGradient( - colors: [ColorConstants.gradient1, ColorConstants.gradient2], + gradient: LinearGradient( + colors: [ + Theme.of(context).colorScheme.primaryContainer, + Theme.of(context).colorScheme.primaryFixed, + ], begin: Alignment.topLeft, end: Alignment.bottomRight, ), boxShadow: [ BoxShadow( - color: ColorConstants.gradient2.withValues(alpha: 0.3), + color: Theme.of( + context, + ).colorScheme.primaryFixed.withValues(alpha: 0.3), spreadRadius: 2, blurRadius: 4, offset: const Offset(2, 3), ), ], ), - child: HeroIcon(icon, color: Colors.white), + child: HeroIcon( + icon, + color: Theme.of(context).colorScheme.onPrimaryContainer, + ), ); } } diff --git a/lib/settings/ui/pages/edit_user_page/user_field_modifier.dart b/lib/settings/ui/pages/edit_user_page/user_field_modifier.dart index 43220bf684..6d0e3f66c4 100644 --- a/lib/settings/ui/pages/edit_user_page/user_field_modifier.dart +++ b/lib/settings/ui/pages/edit_user_page/user_field_modifier.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/ui/widgets/text_entry.dart'; class UserFieldModifier extends StatelessWidget { @@ -24,7 +23,7 @@ class UserFieldModifier extends StatelessWidget { style: TextStyle( fontSize: 15, fontWeight: FontWeight.w400, - color: Colors.grey.shade500, + color: Theme.of(context).colorScheme.tertiary, ), ), ), @@ -33,7 +32,7 @@ class UserFieldModifier extends StatelessWidget { label: label, keyboardType: keyboardType, controller: controller, - color: ColorConstants.gradient1, + color: Theme.of(context).colorScheme.primaryContainer, isInt: keyboardType == TextInputType.number, ), ), diff --git a/lib/settings/ui/pages/log_page/log_card.dart b/lib/settings/ui/pages/log_page/log_card.dart index d601395b61..b3dd5e98a2 100644 --- a/lib/settings/ui/pages/log_page/log_card.dart +++ b/lib/settings/ui/pages/log_page/log_card.dart @@ -11,18 +11,16 @@ class LogCard extends StatelessWidget { @override Widget build(BuildContext context) { - List colors = log.level == LogLevel.debug - ? [const Color(0xff00c3ff), const Color(0xff0077ff)] - : log.level == LogLevel.info - ? [const Color(0xff549227), const Color(0xFF3E721A)] - : log.level == LogLevel.warning - ? [const Color(0xfffc9a01), const Color(0xffee8300)] - : log.level == LogLevel.error - ? [const Color(0xffc72c41), const Color(0xff801336)] - : [ - const Color.fromARGB(255, 198, 190, 21), - const Color.fromARGB(255, 187, 178, 14), - ]; + List colors = switch (log.level) { + LogLevel.debug => [const Color(0xff00c3ff), const Color(0xff0077ff)], + LogLevel.info => [const Color(0xff549227), const Color(0xFF3E721A)], + LogLevel.warning => [const Color(0xfffc9a01), const Color(0xffee8300)], + LogLevel.error => [const Color(0xffc72c41), const Color(0xff801336)], + _ => [ + const Color.fromARGB(255, 198, 190, 21), + const Color.fromARGB(255, 187, 178, 14), + ], + }; Color color = colors[0]; @@ -49,6 +47,7 @@ class LogCard extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ + // it's ok to leave text & icon explicitly white here Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ diff --git a/lib/settings/ui/pages/log_page/log_page.dart b/lib/settings/ui/pages/log_page/log_page.dart index e13f9664ee..c64ab87987 100644 --- a/lib/settings/ui/pages/log_page/log_page.dart +++ b/lib/settings/ui/pages/log_page/log_page.dart @@ -54,7 +54,9 @@ class LogPage extends HookConsumerWidget { child: Text( capitalize(item.name), style: TextStyle( - color: logTab == item ? Colors.white : Colors.black, + color: logTab == item + ? Theme.of(context).colorScheme.onSecondary + : Theme.of(context).colorScheme.onSurface, fontWeight: FontWeight.bold, ), ), diff --git a/lib/settings/ui/pages/log_page/log_tab.dart b/lib/settings/ui/pages/log_page/log_tab.dart index c59eb9182a..fa5761a813 100644 --- a/lib/settings/ui/pages/log_page/log_tab.dart +++ b/lib/settings/ui/pages/log_page/log_tab.dart @@ -20,12 +20,12 @@ class LogTab extends HookConsumerWidget { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - const Text( + Text( SettingsTextConstants.logs, style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: Colors.grey, + color: Theme.of(context).colorScheme.secondaryContainer, ), ), GestureDetector( @@ -47,19 +47,23 @@ class LogTab extends HookConsumerWidget { vertical: 12, ), decoration: BoxDecoration( - color: Colors.black, + color: Theme.of(context).colorScheme.secondary, borderRadius: BorderRadius.circular(10), boxShadow: [ BoxShadow( - color: Colors.black.withValues(alpha: 0.2), + color: Theme.of(context).shadowColor, blurRadius: 10, offset: const Offset(0, 5), ), ], ), - child: const Row( + child: Row( children: [ - HeroIcon(HeroIcons.trash, color: Colors.white, size: 20), + HeroIcon( + HeroIcons.trash, + color: Theme.of(context).colorScheme.onSecondary, + size: 20, + ), ], ), ), diff --git a/lib/settings/ui/pages/log_page/notification_tab.dart b/lib/settings/ui/pages/log_page/notification_tab.dart index f7da8d2f1f..e059335a54 100644 --- a/lib/settings/ui/pages/log_page/notification_tab.dart +++ b/lib/settings/ui/pages/log_page/notification_tab.dart @@ -20,12 +20,12 @@ class NotificationTab extends HookConsumerWidget { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - const Text( + Text( SettingsTextConstants.notifications, style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: Colors.grey, + color: Theme.of(context).colorScheme.secondaryContainer, ), ), GestureDetector( @@ -47,19 +47,23 @@ class NotificationTab extends HookConsumerWidget { vertical: 12, ), decoration: BoxDecoration( - color: Colors.black, + color: Theme.of(context).colorScheme.secondary, borderRadius: BorderRadius.circular(10), boxShadow: [ BoxShadow( - color: Colors.black.withValues(alpha: 0.2), + color: Theme.of(context).shadowColor, blurRadius: 10, offset: const Offset(0, 5), ), ], ), - child: const Row( + child: Row( children: [ - HeroIcon(HeroIcons.trash, color: Colors.white, size: 20), + HeroIcon( + HeroIcons.trash, + color: Theme.of(context).colorScheme.onSecondary, + size: 20, + ), ], ), ), diff --git a/lib/settings/ui/pages/main_page/main_page.dart b/lib/settings/ui/pages/main_page/main_page.dart index 0368069f1c..4def4f09c9 100644 --- a/lib/settings/ui/pages/main_page/main_page.dart +++ b/lib/settings/ui/pages/main_page/main_page.dart @@ -59,7 +59,9 @@ class SettingsMainPage extends HookConsumerWidget { shape: BoxShape.circle, boxShadow: [ BoxShadow( - color: Colors.black.withValues(alpha: 0.3), + color: Theme.of( + context, + ).colorScheme.onPrimary.withValues(alpha: 0.3), spreadRadius: 6, blurRadius: 10, offset: const Offset(0, 2), @@ -82,10 +84,10 @@ class SettingsMainPage extends HookConsumerWidget { Container( width: MediaQuery.of(context).size.width, decoration: BoxDecoration( - color: Colors.white, boxShadow: [ BoxShadow( - color: Colors.white.withValues(alpha: 0.5), + color: Theme.of(context).colorScheme.primary + .withValues(alpha: 0.5), spreadRadius: 5, blurRadius: 10, offset: const Offset(-2, -3), @@ -135,8 +137,8 @@ class SettingsMainPage extends HookConsumerWidget { selected: true, child: Text( capitalize(item.name), - style: const TextStyle( - color: Colors.white, + style: TextStyle( + color: Theme.of(context).colorScheme.onSecondary, fontWeight: FontWeight.bold, ), ), @@ -158,9 +160,12 @@ class SettingsMainPage extends HookConsumerWidget { onTap: () { QR.to(SettingsRouter.root + SettingsRouter.editAccount); }, - child: const Text( + child: Text( SettingsTextConstants.editAccount, - style: TextStyle(fontSize: 16, color: Colors.black), + style: TextStyle( + fontSize: 16, + color: Theme.of(context).colorScheme.onPrimary, + ), ), ), const SizedBox(height: 30), @@ -176,9 +181,12 @@ class SettingsMainPage extends HookConsumerWidget { ); }); }, - child: const Text( + child: Text( SettingsTextConstants.eventsIcal, - style: TextStyle(fontSize: 16, color: Colors.black), + style: TextStyle( + fontSize: 16, + color: Theme.of(context).colorScheme.onPrimary, + ), ), ), const SizedBox(height: 50), @@ -194,9 +202,12 @@ class SettingsMainPage extends HookConsumerWidget { "${getTitanHost()}calypsso/change-password/?email=${me.email}", ); }, - child: const Text( + child: Text( SettingsTextConstants.editPassword, - style: TextStyle(fontSize: 16, color: Colors.black), + style: TextStyle( + fontSize: 16, + color: Theme.of(context).colorScheme.onPrimary, + ), ), ), const SizedBox(height: 50), @@ -211,9 +222,12 @@ class SettingsMainPage extends HookConsumerWidget { onTap: () { QR.to(SettingsRouter.root + SettingsRouter.logs); }, - child: const Text( + child: Text( SettingsTextConstants.logs, - style: TextStyle(fontSize: 16, color: Colors.black), + style: TextStyle( + fontSize: 16, + color: Theme.of(context).colorScheme.onPrimary, + ), ), ), const SizedBox(height: 50), @@ -228,9 +242,12 @@ class SettingsMainPage extends HookConsumerWidget { onTap: () { QR.to(SettingsRouter.root + SettingsRouter.modules); }, - child: const Text( + child: Text( SettingsTextConstants.modules, - style: TextStyle(fontSize: 16, color: Colors.black), + style: TextStyle( + fontSize: 16, + color: Theme.of(context).colorScheme.onPrimary, + ), ), ), const SizedBox(height: 30), @@ -239,9 +256,12 @@ class SettingsMainPage extends HookConsumerWidget { onTap: () { QR.to(SettingsRouter.root + SettingsRouter.notifications); }, - child: const Text( + child: Text( SettingsTextConstants.notifications, - style: TextStyle(fontSize: 16, color: Colors.black), + style: TextStyle( + fontSize: 16, + color: Theme.of(context).colorScheme.onPrimary, + ), ), ), const SizedBox(height: 50), @@ -278,18 +298,21 @@ class SettingsMainPage extends HookConsumerWidget { }, ); }, - child: const Text( + child: Text( SettingsTextConstants.detelePersonalData, - style: TextStyle(fontSize: 16, color: Colors.black), + style: TextStyle( + fontSize: 16, + color: Theme.of(context).colorScheme.onPrimary, + ), ), ), const SizedBox(height: 60), Text( "${SettingsTextConstants.version} $titanVersion", - style: const TextStyle( + style: TextStyle( fontSize: 15, fontWeight: FontWeight.w500, - color: Colors.black, + color: Theme.of(context).colorScheme.onPrimary, ), ), const SizedBox(height: 10), @@ -297,10 +320,10 @@ class SettingsMainPage extends HookConsumerWidget { Repository.host, maxLines: 1, minFontSize: 10, - style: const TextStyle( + style: TextStyle( fontSize: 15, fontWeight: FontWeight.w500, - color: Colors.black, + color: Theme.of(context).colorScheme.onPrimary, ), ), const SizedBox(height: 20), diff --git a/lib/settings/ui/pages/main_page/settings_item.dart b/lib/settings/ui/pages/main_page/settings_item.dart index 4b26ad2bba..27dab4a34e 100644 --- a/lib/settings/ui/pages/main_page/settings_item.dart +++ b/lib/settings/ui/pages/main_page/settings_item.dart @@ -23,17 +23,23 @@ class SettingsItem extends StatelessWidget { children: [ Padding( padding: const EdgeInsets.only(right: 20), - child: HeroIcon(icon, size: 30, color: Colors.black), + child: HeroIcon( + icon, + size: 30, + color: Theme.of(context).colorScheme.onPrimary, + ), ), Expanded(child: child), Container( padding: const EdgeInsets.all(10), decoration: BoxDecoration( - color: Colors.white, - border: Border.all(color: Colors.black), + color: Theme.of(context).colorScheme.primary, + border: Border.all( + color: Theme.of(context).colorScheme.onPrimary, + ), boxShadow: [ BoxShadow( - color: Colors.grey.shade400.withValues(alpha: 0.3), + color: Theme.of(context).shadowColor, spreadRadius: 2, blurRadius: 5, offset: const Offset(2, 3), @@ -41,10 +47,10 @@ class SettingsItem extends StatelessWidget { ], borderRadius: BorderRadius.circular(10), ), - child: const HeroIcon( + child: HeroIcon( HeroIcons.chevronRight, size: 25, - color: Colors.black, + color: Theme.of(context).colorScheme.onPrimary, ), ), ], diff --git a/lib/settings/ui/pages/modules_page/modules_page.dart b/lib/settings/ui/pages/modules_page/modules_page.dart index 4a2dbec914..77b18e658d 100644 --- a/lib/settings/ui/pages/modules_page/modules_page.dart +++ b/lib/settings/ui/pages/modules_page/modules_page.dart @@ -32,25 +32,25 @@ class ModulesPage extends HookConsumerWidget { decoration: BoxDecoration( boxShadow: [ BoxShadow( - color: Colors.grey.withValues(alpha: 0.2), + color: Theme.of(context).shadowColor, spreadRadius: 5, blurRadius: 10, offset: const Offset(0, 2), // changes position of shadow ), ], - color: Colors.white, + color: Theme.of(context).colorScheme.primary, borderRadius: BorderRadius.circular(15), ), child: Container( padding: const EdgeInsets.symmetric(vertical: 5), child: Row( children: [ - module.getIcon(Colors.grey.shade700), + module.getIcon(Theme.of(context).colorScheme.tertiary), const SizedBox(width: 20), Text( module.name, - style: const TextStyle( - color: Colors.black, + style: TextStyle( + color: Theme.of(context).colorScheme.onPrimary, fontSize: 20, fontWeight: FontWeight.w500, ), @@ -59,7 +59,10 @@ class ModulesPage extends HookConsumerWidget { const Spacer(), Checkbox( value: modules.contains(module), - activeColor: Colors.grey.shade700, + checkColor: Theme.of(context).colorScheme.onSecondary, + activeColor: Theme.of( + context, + ).colorScheme.secondaryContainer, onChanged: (bool? value) { modulesNotifier.toggleModule(module); }, diff --git a/lib/settings/ui/pages/notification_page/notification_page.dart b/lib/settings/ui/pages/notification_page/notification_page.dart index 3912ae09f1..31f41955ec 100644 --- a/lib/settings/ui/pages/notification_page/notification_page.dart +++ b/lib/settings/ui/pages/notification_page/notification_page.dart @@ -6,7 +6,6 @@ import 'package:titan/service/providers/topic_provider.dart'; import 'package:titan/service/tools/functions.dart'; import 'package:titan/settings/tools/constants.dart'; import 'package:titan/settings/ui/settings.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/ui/widgets/align_left_text.dart'; import 'package:titan/tools/ui/builders/async_child.dart'; import 'package:titan/tools/ui/layouts/refresher.dart'; @@ -27,10 +26,10 @@ class NotificationPage extends HookConsumerWidget { padding: const EdgeInsets.symmetric(horizontal: 30.0), child: Column( children: [ - const AlignLeftText( + AlignLeftText( SettingsTextConstants.updateNotification, - padding: EdgeInsets.symmetric(vertical: 30), - color: Colors.grey, + padding: const EdgeInsets.symmetric(vertical: 30), + color: Theme.of(context).colorScheme.tertiary, ), AsyncChild( value: topics, @@ -44,10 +43,12 @@ class NotificationPage extends HookConsumerWidget { children: [ Text( topicToFrenchString(e), - style: const TextStyle( + style: TextStyle( fontSize: 20, fontWeight: FontWeight.w700, - color: ColorConstants.background2, + color: Theme.of( + context, + ).colorScheme.secondaryContainer, ), ), LoadSwitch( @@ -63,19 +64,26 @@ class NotificationPage extends HookConsumerWidget { ), switchDecoration: (value, _) => BoxDecoration( color: value - ? ColorConstants.gradient1.withValues( - alpha: 0.3, - ) - : Colors.grey.shade200, + ? Theme.of(context) + .colorScheme + .primaryContainer + .withValues(alpha: 0.3) + : Theme.of( + context, + ).colorScheme.secondaryFixed, borderRadius: BorderRadius.circular(30), shape: BoxShape.rectangle, boxShadow: [ BoxShadow( color: value - ? ColorConstants.gradient1.withValues( - alpha: 0.2, - ) - : Colors.grey.withValues(alpha: 0.2), + ? Theme.of(context) + .colorScheme + .primaryContainer + .withValues(alpha: 0.2) + : Theme.of(context) + .colorScheme + .tertiary + .withValues(alpha: 0.2), spreadRadius: 1, blurRadius: 3, offset: const Offset(0, 1), @@ -83,22 +91,26 @@ class NotificationPage extends HookConsumerWidget { ], ), spinColor: (value) => value - ? ColorConstants.gradient1 - : Colors.grey, + ? Theme.of( + context, + ).colorScheme.primaryContainer + : Theme.of(context).colorScheme.tertiary, spinStrokeWidth: 2, thumbDecoration: (value, _) => BoxDecoration( - color: Colors.white, + color: Theme.of(context).colorScheme.surface, borderRadius: BorderRadius.circular(30), shape: BoxShape.rectangle, boxShadow: [ BoxShadow( color: value - ? ColorConstants.gradient1.withValues( - alpha: 0.2, - ) - : Colors.grey.shade200.withValues( - alpha: 0.2, - ), + ? Theme.of(context) + .colorScheme + .primaryContainer + .withValues(alpha: 0.2) + : Theme.of(context) + .colorScheme + .secondaryFixed + .withValues(alpha: 0.2), spreadRadius: 5, blurRadius: 7, offset: const Offset( @@ -117,7 +129,7 @@ class NotificationPage extends HookConsumerWidget { ) .toList(), ), - loaderColor: ColorConstants.gradient1, + loaderColor: Theme.of(context).colorScheme.primaryContainer, ), ], ), diff --git a/lib/settings/ui/settings.dart b/lib/settings/ui/settings.dart index d80b9f7c4e..4b152df6e6 100644 --- a/lib/settings/ui/settings.dart +++ b/lib/settings/ui/settings.dart @@ -9,19 +9,16 @@ class SettingsTemplate extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( - decoration: const BoxDecoration(color: Colors.white), - child: SafeArea( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - const TopBar( - title: SettingsTextConstants.settings, - root: SettingsRouter.root, - ), - Expanded(child: child), - ], - ), + return SafeArea( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + const TopBar( + title: SettingsTextConstants.settings, + root: SettingsRouter.root, + ), + Expanded(child: child), + ], ), ); } diff --git a/lib/tools/constants.dart b/lib/tools/constants.dart index aa85a97fee..9baec689c5 100644 --- a/lib/tools/constants.dart +++ b/lib/tools/constants.dart @@ -1,23 +1,5 @@ import 'package:flutter/material.dart'; - -class ColorConstants { - static const Color gradient1 = Color(0xFFfb6d10); - static const Color gradient2 = Color(0xffeb3e1b); - static const Color error = Color(0xFFC91717); - static const Color background2 = Color(0xFF222643); - static const Color deactivated1 = Color(0xFF9E9E9E); - static const Color deactivated2 = Color(0xFFC0C0C0); - - static const Color background = Color(0xFFffffff); - static const Color onBackground = Color(0xffb4b4b4); - static const Color secondary = Color(0xFFb1b2b5); - static const Color tertiary = Color(0xFF424242); - static const Color onTertiary = Color(0xFF212121); - static const Color title = Color(0xFF000000); - static const Color main = Color(0xFFfb6d10); - static const Color onMain = Color(0xffeb3e1b); - static const Color mainBorder = Color.fromARGB(255, 87, 3, 3); -} +import 'package:google_fonts/google_fonts.dart'; class TextConstants { static const String admin = 'Admin'; @@ -28,8 +10,164 @@ class TextConstants { static const String imageSizeTooBig = "La taille de l'image ne doit pas dépasser 4 Mio"; static const String imageError = "Erreur lors de l'ajout de l'image"; + static const String yes = "Oui"; + static const String no = "Non"; } const String unableToOpen = 'Impossible d\'ouvrir le lien'; const int maxHyperionFileSize = 4194304; + +// Old colors: don't forget to nuke that class when there will be no more references to it +class ColorConstants { + static const Color gradient1 = Color(0xFFfb6d10); + static const Color gradient2 = Color(0xffeb3e1b); + static const Color error = Color(0xFFC91717); + static const Color background2 = Color(0xFF222643); + static const Color deactivated1 = Color(0xFF9E9E9E); + static const Color deactivated2 = Color(0xFFC0C0C0); +} + +/// ## Semantics of the Colors +/// +/// ### Main colors +/// +/// `primary` is the ultimate background, hence the most prominent onscreen, +/// the theme is named after the "brightness" of `primary`. +/// +/// There are 3 main colors, they strongly contrast with each other: +/// * `secondary` is the opposite of `primary`; +/// * `primaryContainer` is a true color (not some grayscale), a vivid one, to emphasize. +/// +/// `secondary` and `primaryContainer` are for surfaces displayed on top of `primary`. +/// +/// `surface` is identical to `primary`, in case a surface of this color is needed. +/// +/// ### Miscellaneous colors +/// +/// * `tertiary` is a blend of `primary` and `secondary`, +/// and in practice is it the same for both themes (and is seldom used, so far). +/// * `error` is red in any case. +/// * `primaryContainer` is defined to be close to `primarySwatch`, +/// which is outside of `colorScheme` and never written in code, +/// it is just to have a default non-grayscale color. +/// * However `shadowColor` is written in code altough defined outside of `colorScheme`, +/// it is a translucent color, closer to `primary`, meant to be the default for shadows. +/// +/// ### `on-` prefix +/// +/// * Without the `on-` prefix, it is for surfaces (buttons, cards). +/// * With `on-`, it is for things with no "thickness" (texts, icons, borders), +/// such that nothing could be displayed on top of them. +/// +/// `onSomeColor` should be very legible on `someColor`, +/// so `onPrimaryContainer` and `onError` should be chosen carefully +/// since they do not have a natural opposite. +/// +/// Meanwhile, the primary-secondary duality is still there with `on-`, thus: +/// * `onSurface` = `onPrimary` := `secondary` +/// * `onSecondary` := `primary` +/// * etc. +/// +/// ### `-Fixed` suffix +/// +/// Likewise, the `-Fixed` suffix is for a less strong variant, +/// needed in some contexts (a discrete shadow, a minimal yet visible contrast), +/// hence `primaryFixed` and `secondaryFixed` are opposite. +/// +/// `secondaryContainer` is to be understood as "primaryContainerFixed" +/// as it is actually a variant of `primaryContainer`, +/// slightly farther from `primary` and used mostly for gradients: +/// `primaryContainer` and `primaryFixed` are formerly known +/// as "gradient1" and "gradient2" here on Titan. +/// +/// ### LIST OF INCONSISTENCIES to fix (in that order) +/// +/// 1. Replace most `secondaryFixed` with `tertiary` (don't remember why, though) +/// 1. Swap `primaryFixed` and `secondaryContainer` +/// 1. Swap the `-Fixed` +/// +class ThemeConstants { + // for textTheme + BuildContext context; + ThemeConstants(this.context); + + ThemeData get lightTheme => ThemeData( + brightness: .light, + primarySwatch: Colors.orange, + shadowColor: Colors.grey.withValues(alpha: 0.3), + colorScheme: const ColorScheme( + brightness: .light, + primary: Colors.white, //Color(0xffFEF7FF), + onPrimary: Colors.black, + secondary: Colors.black, + onSecondary: Colors.white, + surface: Colors.white, + onSurface: Colors.black, + primaryContainer: Color(0xfffb6d10), + primaryFixed: Color(0xffeb3e1b), + onPrimaryContainer: Colors.white, + secondaryFixed: Color(0xFFDDDDDD), + secondaryContainer: Color(0xFF222222), + tertiary: Colors.grey, + error: Colors.red, + onError: Colors.white, + ), + textTheme: GoogleFonts.latoTextTheme( + Theme.of( + context, + ).textTheme.apply(bodyColor: Colors.black, displayColor: Colors.black), + ), + ); + ThemeData get darkTheme => ThemeData( + brightness: .dark, + primarySwatch: Colors.orange, + shadowColor: Colors.grey.withValues(alpha: 0.7), + colorScheme: const ColorScheme( + brightness: .dark, + primary: Colors.black, + onPrimary: Colors.white, + secondary: Colors.white, + onSecondary: Colors.black, + surface: Colors.black, + onSurface: Colors.white, + primaryContainer: Color(0xffeb3e1b), + primaryFixed: Color(0xfffb6d10), + onPrimaryContainer: Colors.white, + secondaryFixed: Color(0xFF222222), + secondaryContainer: Color(0xFFDDDDDD), + tertiary: Colors.grey, + error: Colors.red, + onError: Colors.white, + ), + textTheme: GoogleFonts.latoTextTheme( + Theme.of( + context, + ).textTheme.apply(bodyColor: Colors.white, displayColor: Colors.white), + ), + ); +} + +// Reference: Flutter's default theme +// ignore: unused_element +ThemeData _ = ThemeData( + brightness: .light, + shadowColor: Color(0xff000000), + colorScheme: const ColorScheme( + brightness: .light, + primary: Color(0xff6750a4), + onPrimary: Color(0xffffffff), + secondary: Color(0xff625b71), + onSecondary: Color(0xffffffff), + surface: Color(0xfffef7ff), + onSurface: Color(0xff1d1b20), + primaryContainer: Color(0xffeaddff), + primaryFixed: Color(0xffeaddff), + onPrimaryContainer: Color(0xff4f378b), + secondaryFixed: Color(0xffe8def8), + secondaryContainer: Color(0xffe8def8), + tertiary: Color(0xff7d5260), + error: Color(0xffb3261e), + onError: Color(0xffffffff), + ), +); diff --git a/lib/tools/functions.dart b/lib/tools/functions.dart index 9ff3f8b72d..b199074f25 100644 --- a/lib/tools/functions.dart +++ b/lib/tools/functions.dart @@ -8,7 +8,6 @@ import 'package:heroicons/heroicons.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:intl/intl.dart'; import 'package:titan/admin/providers/permissions_list_provider.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/plausible/plausible.dart'; import 'package:titan/tools/repository/repository.dart'; import 'package:titan/version/repositories/version_repository.dart'; @@ -41,23 +40,32 @@ void displayToast( }) { LinearGradient linearGradient; HeroIcons icon; + Color color; switch (type) { case TypeMsg.msg: - linearGradient = const LinearGradient( - colors: [ColorConstants.gradient1, ColorConstants.gradient2], + linearGradient = LinearGradient( + colors: [ + Theme.of(context).colorScheme.primaryContainer, + Theme.of(context).colorScheme.primaryFixed, + ], begin: Alignment.topLeft, end: Alignment.bottomRight, ); + color = Theme.of(context).colorScheme.onPrimaryContainer; icon = HeroIcons.check; duration = duration ?? 1500; break; case TypeMsg.error: - linearGradient = const LinearGradient( - colors: [ColorConstants.background2, Colors.black], + linearGradient = LinearGradient( + colors: [ + Theme.of(context).colorScheme.secondaryContainer, + Theme.of(context).colorScheme.secondary, + ], begin: Alignment.topLeft, end: Alignment.bottomRight, ); + color = Theme.of(context).colorScheme.onSecondary; icon = HeroIcons.exclamationTriangle; duration = duration ?? 3000; break; @@ -88,7 +96,7 @@ void displayToast( Container( width: 40, alignment: Alignment.center, - child: HeroIcon(icon, color: Colors.white), + child: HeroIcon(icon, color: color), ), const SizedBox(width: 10), Expanded( @@ -96,8 +104,8 @@ void displayToast( child: AutoSizeText( text, overflow: TextOverflow.ellipsis, - style: const TextStyle( - color: Colors.white, + style: TextStyle( + color: color, fontSize: 20, fontWeight: FontWeight.bold, ), @@ -322,14 +330,11 @@ Future _getTime(BuildContext context) async { initialTime: TimeOfDay.now(), builder: (BuildContext context, Widget? child) { return Theme( - data: ThemeData.light().copyWith( - colorScheme: const ColorScheme.light( - primary: ColorConstants.gradient1, - onPrimary: Colors.white, - surface: Colors.white, - onSurface: Colors.black, + data: Theme.of(context).copyWith( + colorScheme: Theme.of(context).colorScheme.copyWith( + primary: Theme.of(context).colorScheme.primaryContainer, + onPrimary: Theme.of(context).colorScheme.onPrimaryContainer, ), - dialogTheme: DialogThemeData(backgroundColor: Colors.white), ), child: child!, ); @@ -351,14 +356,11 @@ Future _getDate( lastDate: lastDate ?? DateTime(now.year + 1, now.month, now.day), builder: (BuildContext context, Widget? child) { return Theme( - data: ThemeData.light().copyWith( - colorScheme: const ColorScheme.light( - primary: ColorConstants.gradient1, - onPrimary: Colors.white, - surface: Colors.white, - onSurface: Colors.black, + data: Theme.of(context).copyWith( + colorScheme: Theme.of(context).colorScheme.copyWith( + primary: Theme.of(context).colorScheme.primaryContainer, + onPrimary: Theme.of(context).colorScheme.onPrimaryContainer, ), - dialogTheme: DialogThemeData(backgroundColor: Colors.white), ), child: child!, ); diff --git a/lib/tools/providers/theme_provider.dart b/lib/tools/providers/theme_provider.dart new file mode 100644 index 0000000000..f5f62d4122 --- /dev/null +++ b/lib/tools/providers/theme_provider.dart @@ -0,0 +1,38 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:flutter/scheduler.dart'; + +final themeProvider = StateNotifierProvider((ref) { + ThemeNotifier themeNotifier = ThemeNotifier(); + themeNotifier.loadTheme(); + return themeNotifier; +}); + +class ThemeNotifier extends StateNotifier { + ThemeNotifier() + : super( + SchedulerBinding.instance.platformDispatcher.platformBrightness == + Brightness.dark, + ); // System-based default theme + + void saveTheme() { + SharedPreferences.getInstance().then((pref) { + pref.setBool('isDarkMode', state); + }); + } + + void loadTheme() { + SharedPreferences.getInstance().then((pref) { + state = + pref.getBool('isDarkMode') ?? + (SchedulerBinding.instance.platformDispatcher.platformBrightness == + Brightness.dark); + }); + } + + void toggleTheme() { + state = !state; + saveTheme(); + } +} diff --git a/lib/tools/ui/builders/waiting_button.dart b/lib/tools/ui/builders/waiting_button.dart index 2e6551204c..73722d5abb 100644 --- a/lib/tools/ui/builders/waiting_button.dart +++ b/lib/tools/ui/builders/waiting_button.dart @@ -5,7 +5,7 @@ import 'package:titan/tools/ui/widgets/loader.dart'; class WaitingButton extends HookWidget { final Widget child; final Widget Function(Widget) builder; - final Color waitingColor; + final Color? waitingColor; final Future Function()? onTap; const WaitingButton({ @@ -13,7 +13,7 @@ class WaitingButton extends HookWidget { required this.child, required this.onTap, required this.builder, - this.waitingColor = Colors.white, + this.waitingColor, }); @override @@ -47,7 +47,12 @@ class WaitingButton extends HookWidget { scale: 1 - animationController.value, child: builder(child!), ), - child: clicked.value ? Loader(color: waitingColor) : child, + child: clicked.value + ? Loader( + color: + waitingColor ?? Theme.of(context).colorScheme.onSecondary, + ) + : child, ), ); } diff --git a/lib/tools/ui/layouts/add_edit_button_layout.dart b/lib/tools/ui/layouts/add_edit_button_layout.dart index deee33ecbd..e020b88a84 100644 --- a/lib/tools/ui/layouts/add_edit_button_layout.dart +++ b/lib/tools/ui/layouts/add_edit_button_layout.dart @@ -2,12 +2,12 @@ import 'package:flutter/material.dart'; class AddEditButtonLayout extends StatelessWidget { final Widget child; - final Color color; + final Color? color; final List? colors; const AddEditButtonLayout({ super.key, required this.child, - this.color = Colors.black, + this.color, this.colors, }); @@ -27,10 +27,12 @@ class AddEditButtonLayout extends StatelessWidget { radius: 1.3, ) : null, - color: useColors ? null : color, + color: useColors + ? null + : color ?? Theme.of(context).colorScheme.secondary, boxShadow: [ BoxShadow( - color: (useColors ? colors!.last : color).withValues(alpha: 0.3), + color: Theme.of(context).shadowColor, spreadRadius: 5, blurRadius: 10, offset: const Offset(3, 3), // changes position of shadow diff --git a/lib/tools/ui/layouts/bottom_modal_template.dart b/lib/tools/ui/layouts/bottom_modal_template.dart index 38c0725b37..08fc7923cd 100644 --- a/lib/tools/ui/layouts/bottom_modal_template.dart +++ b/lib/tools/ui/layouts/bottom_modal_template.dart @@ -1,35 +1,19 @@ import 'package:flutter/material.dart'; -import 'package:titan/tools/constants.dart'; - -enum BottomModalType { main, danger } class BottomModalTemplate extends StatelessWidget { - final Widget child; final String title; final String? description; - final List? actions; - final BottomModalType type; + final List actions; final String? animationKey; const BottomModalTemplate({ super.key, - required this.child, - this.type = BottomModalType.main, this.animationKey, required this.title, this.description, - this.actions, + required this.actions, }); - const BottomModalTemplate.danger({ - super.key, - required this.child, - this.animationKey, - required this.title, - this.description, - this.actions, - }) : type = BottomModalType.danger; - @override Widget build(BuildContext context) { return Column( @@ -42,11 +26,11 @@ class BottomModalTemplate extends StatelessWidget { width: 120, height: 4, decoration: BoxDecoration( - color: ColorConstants.onTertiary, + color: Theme.of(context).colorScheme.secondaryContainer, borderRadius: BorderRadius.circular(2), boxShadow: [ BoxShadow( - color: ColorConstants.onTertiary.withAlpha(50), + color: Theme.of(context).shadowColor, blurRadius: 4, spreadRadius: 1, ), @@ -58,9 +42,7 @@ class BottomModalTemplate extends StatelessWidget { tag: animationKey ?? 'bottom_modal', child: Container( decoration: BoxDecoration( - color: type == BottomModalType.main - ? ColorConstants.background - : ColorConstants.main, + color: Theme.of(context).colorScheme.surface, borderRadius: BorderRadius.vertical(top: Radius.circular(30)), ), padding: EdgeInsets.all(20), @@ -73,9 +55,7 @@ class BottomModalTemplate extends StatelessWidget { style: TextStyle( fontSize: 20, fontWeight: FontWeight.w900, - color: type == BottomModalType.main - ? ColorConstants.tertiary - : ColorConstants.background, + color: Theme.of(context).colorScheme.secondaryContainer, ), ), SizedBox(height: 20), @@ -84,14 +64,10 @@ class BottomModalTemplate extends StatelessWidget { description!, style: TextStyle( fontSize: 15, - color: type == BottomModalType.main - ? ColorConstants.tertiary - : ColorConstants.background, + color: Theme.of(context).colorScheme.secondaryContainer, ), ), - child, - if (actions != null && actions!.isNotEmpty) - Column(children: actions!), + Column(children: actions), SizedBox(height: 20), ], ), diff --git a/lib/tools/ui/layouts/button.dart b/lib/tools/ui/layouts/button.dart index cdd4c08d9b..99b667fb89 100644 --- a/lib/tools/ui/layouts/button.dart +++ b/lib/tools/ui/layouts/button.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:titan/tools/constants.dart'; -enum ButtonType { main, danger, onDanger, secondary } +enum ButtonType { main, danger, secondary } class Button extends StatelessWidget { final ButtonType type; @@ -27,14 +26,6 @@ class Button extends StatelessWidget { this.fontSize, }) : type = ButtonType.danger; - const Button.onDanger({ - super.key, - required this.text, - required this.onPressed, - this.disabled = false, - this.fontSize, - }) : type = ButtonType.onDanger; - const Button.secondary({ super.key, required this.text, @@ -43,50 +34,6 @@ class Button extends StatelessWidget { this.fontSize, }) : type = ButtonType.secondary; - Color get backgroundColor { - switch (type) { - case ButtonType.main: - return ColorConstants.tertiary; - case ButtonType.danger: - return ColorConstants.main; - case ButtonType.onDanger: - return ColorConstants.onMain; - case ButtonType.secondary: - return ColorConstants.background; - } - } - - Color get borderColor { - switch (type) { - case ButtonType.main: - return ColorConstants.onTertiary; - case ButtonType.danger: - return ColorConstants.mainBorder; - case ButtonType.onDanger: - return ColorConstants.mainBorder; - case ButtonType.secondary: - return ColorConstants.onBackground; - } - } - - Color get textColor { - Color color; - switch (type) { - case ButtonType.main: - color = ColorConstants.background; - case ButtonType.onDanger: - color = ColorConstants.background; - case ButtonType.danger: - color = ColorConstants.background; - case ButtonType.secondary: - color = ColorConstants.tertiary; - } - if (disabled == true) { - return color.withAlpha(150); - } - return color; - } - @override Widget build(BuildContext context) { return GestureDetector( @@ -95,16 +42,36 @@ class Button extends StatelessWidget { width: double.infinity, padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10), decoration: BoxDecoration( - color: backgroundColor, + color: switch (type) { + .main => Theme.of(context).colorScheme.secondaryContainer, + .danger => Theme.of(context).colorScheme.primaryContainer, + .secondary => Theme.of(context).colorScheme.secondaryFixed, + }, borderRadius: BorderRadius.circular(8), - border: Border.all(color: borderColor), + border: Border.all( + color: switch (type) { + .main => Theme.of(context).colorScheme.tertiary, + .danger => Theme.of(context).colorScheme.primaryFixed, + .secondary => Theme.of(context).colorScheme.tertiary, + }, + ), ), child: Center( child: Text( text, textAlign: TextAlign.center, style: TextStyle( - color: textColor, + color: disabled == true + ? Theme.of(context).colorScheme.tertiary + : switch (type) { + .main => Theme.of(context).colorScheme.secondaryFixed, + .danger => Theme.of( + context, + ).colorScheme.onPrimaryContainer, + .secondary => Theme.of( + context, + ).colorScheme.secondaryContainer, + }, fontSize: fontSize ?? 18, fontWeight: FontWeight.w900, ), diff --git a/lib/tools/ui/layouts/card_button.dart b/lib/tools/ui/layouts/card_button.dart index a60dc90418..4088263d55 100644 --- a/lib/tools/ui/layouts/card_button.dart +++ b/lib/tools/ui/layouts/card_button.dart @@ -2,18 +2,18 @@ import 'package:flutter/material.dart'; class CardButton extends StatelessWidget { final Widget child; - final Color color; + final Color? color; final List? colors; - final Color shadowColor; + final Color? shadowColor; final Color? borderColor; final double? size; final BorderRadiusGeometry? borderRadius; const CardButton({ super.key, required this.child, - this.color = const Color(0xFFEEEEEE), + this.color, this.colors, - this.shadowColor = const Color(0x339E9E9E), + this.shadowColor, this.borderColor, this.size = 40, this.borderRadius = const BorderRadius.all(Radius.circular(15)), @@ -22,14 +22,16 @@ class CardButton extends StatelessWidget { @override Widget build(BuildContext context) { final useColors = colors != null && colors!.length > 1; - final useShadow = !useColors || (useColors && colors!.last == Colors.white); + final useShadow = + !useColors || + (useColors && colors!.last == Theme.of(context).colorScheme.primary); return Container( width: size, height: size, padding: const EdgeInsets.all(7), decoration: BoxDecoration( borderRadius: borderRadius, - color: color, + color: color ?? Theme.of(context).colorScheme.secondaryFixed, gradient: useColors ? RadialGradient( colors: colors!, @@ -42,9 +44,11 @@ class CardButton extends StatelessWidget { : null, boxShadow: [ BoxShadow( - color: (useShadow || !useColors) - ? shadowColor - : colors!.last.withValues(alpha: 0.5), + color: + (useShadow + ? shadowColor + : colors!.last.withValues(alpha: 0.5)) ?? + Theme.of(context).shadowColor, blurRadius: 10, offset: const Offset(2, 3), ), diff --git a/lib/tools/ui/layouts/card_layout.dart b/lib/tools/ui/layouts/card_layout.dart index af5317fecc..9496062116 100644 --- a/lib/tools/ui/layouts/card_layout.dart +++ b/lib/tools/ui/layouts/card_layout.dart @@ -3,9 +3,9 @@ import 'package:flutter/material.dart'; class CardLayout extends StatelessWidget { final Widget child; final double? width, height; - final Color color; + final Color? color; final List? colors; - final Color shadowColor; + final Color? shadowColor; final Color? borderColor; final String? id; final EdgeInsetsGeometry padding, margin; @@ -17,8 +17,8 @@ class CardLayout extends StatelessWidget { this.width, this.height, this.colors, - this.color = Colors.white, - this.shadowColor = const Color(0x80EEEEEE), + this.color, + this.shadowColor, this.borderColor, this.padding = const EdgeInsets.all(12.0), this.margin = const EdgeInsets.symmetric(horizontal: 15.0), @@ -28,7 +28,9 @@ class CardLayout extends StatelessWidget { @override Widget build(BuildContext context) { final useColors = colors != null && colors!.length > 1; - final useShadow = !useColors || (useColors && colors!.last == Colors.white); + final useShadow = + !useColors || + (useColors && colors!.last == Theme.of(context).colorScheme.primary); return Hero( tag: id ?? UniqueKey(), child: Container( @@ -45,15 +47,19 @@ class CardLayout extends StatelessWidget { radius: 1.3, ) : null, - color: useColors ? null : color, + color: useColors + ? null + : color ?? Theme.of(context).colorScheme.primary, border: borderColor != null ? Border.all(color: borderColor!, width: 2) : null, boxShadow: [ BoxShadow( - color: (useShadow || !useColors) - ? shadowColor - : colors!.last.withValues(alpha: 0.3), + color: + (useShadow + ? shadowColor + : colors!.last.withValues(alpha: 0.3)) ?? + Theme.of(context).shadowColor, spreadRadius: 5, blurRadius: 10, offset: const Offset(3, 3), diff --git a/lib/tools/ui/layouts/item_chip.dart b/lib/tools/ui/layouts/item_chip.dart index 3d8f079777..93056e5b4d 100644 --- a/lib/tools/ui/layouts/item_chip.dart +++ b/lib/tools/ui/layouts/item_chip.dart @@ -29,7 +29,9 @@ class ItemChip extends StatelessWidget { padding: const EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0), decoration: BoxDecoration( borderRadius: BorderRadius.circular(30.0), - color: selected ? Colors.black : Colors.grey.shade200, + color: selected + ? Theme.of(context).colorScheme.secondary + : Theme.of(context).colorScheme.secondaryFixed, ), child: Center(child: child), ), diff --git a/lib/tools/ui/widgets/admin_button.dart b/lib/tools/ui/widgets/admin_button.dart index 2b90fc97e8..ba68154bad 100644 --- a/lib/tools/ui/widgets/admin_button.dart +++ b/lib/tools/ui/widgets/admin_button.dart @@ -4,22 +4,22 @@ import 'package:titan/tools/constants.dart'; class AdminButton extends StatelessWidget { final VoidCallback onTap; - final Color textColor; + final Color? textColor; final Color? color; final List? colors; final String text; const AdminButton({ super.key, required this.onTap, - this.textColor = Colors.white, - this.color = Colors.black, + this.textColor, + this.color, this.text = TextConstants.admin, this.colors, }); @override Widget build(BuildContext context) { - final useColors = colors != null; + final useColors = colors != null && colors!.length > 1; return GestureDetector( onTap: onTap, child: Container( @@ -32,11 +32,13 @@ class AdminButton extends StatelessWidget { radius: 2, ) : null, - color: color, + color: useColors + ? null + : color ?? Theme.of(context).colorScheme.secondary, borderRadius: BorderRadius.circular(10), boxShadow: [ BoxShadow( - color: (useColors ? colors!.last : color)!.withValues(alpha: 0.2), + color: Theme.of(context).shadowColor, blurRadius: 10, offset: const Offset(0, 5), ), @@ -44,14 +46,17 @@ class AdminButton extends StatelessWidget { ), child: Row( children: [ - HeroIcon(HeroIcons.userGroup, color: textColor), + HeroIcon( + HeroIcons.userGroup, + color: textColor ?? Theme.of(context).colorScheme.onSecondary, + ), const SizedBox(width: 10), Text( text, style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold, - color: textColor, + color: textColor ?? Theme.of(context).colorScheme.onSecondary, ), ), ], diff --git a/lib/tools/ui/widgets/align_left_text.dart b/lib/tools/ui/widgets/align_left_text.dart index 7768962141..80f22a7fd0 100644 --- a/lib/tools/ui/widgets/align_left_text.dart +++ b/lib/tools/ui/widgets/align_left_text.dart @@ -4,14 +4,14 @@ class AlignLeftText extends StatelessWidget { final String title; final double fontSize; final FontWeight fontWeight; - final Color color; + final Color? color; final EdgeInsetsGeometry padding; const AlignLeftText( this.title, { super.key, this.fontSize = 18, this.fontWeight = FontWeight.bold, - this.color = Colors.black, + this.color, this.padding = const EdgeInsets.all(0), }); @@ -25,7 +25,7 @@ class AlignLeftText extends StatelessWidget { style: TextStyle( fontSize: fontSize, fontWeight: fontWeight, - color: color, + color: color ?? Theme.of(context).colorScheme.onPrimary, ), ), ); diff --git a/lib/tools/ui/widgets/calendar.dart b/lib/tools/ui/widgets/calendar.dart index 70b2df7288..dd1641251d 100644 --- a/lib/tools/ui/widgets/calendar.dart +++ b/lib/tools/ui/widgets/calendar.dart @@ -3,7 +3,6 @@ import 'package:flutter/material.dart'; import 'package:heroicons/heroicons.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:titan/drawer/providers/is_web_format_provider.dart'; -import 'package:titan/tools/constants.dart'; import 'package:titan/tools/functions.dart'; import 'package:titan/tools/ui/builders/async_child.dart'; import 'package:titan/tools/ui/layouts/card_button.dart'; @@ -51,7 +50,6 @@ class Calendar extends HookConsumerWidget { style: const TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: Colors.black, ), ), const SizedBox(height: 10), @@ -63,7 +61,7 @@ class Calendar extends HookConsumerWidget { ), style: TextStyle( fontWeight: FontWeight.w400, - color: Colors.grey.shade400, + color: Theme.of(context).colorScheme.tertiary, fontSize: 15, ), ), @@ -84,10 +82,8 @@ class Calendar extends HookConsumerWidget { child: GestureDetector( onTap: () => Navigator.pop(context), child: CardButton( - color: Colors.white, - shadowColor: Colors.grey.shade500.withValues( - alpha: 0.3, - ), + color: Theme.of(context).colorScheme.surface, + shadowColor: Theme.of(context).shadowColor, child: const HeroIcon(HeroIcons.xMark, size: 20), ), ), @@ -120,15 +116,20 @@ class Calendar extends HookConsumerWidget { view: CalendarView.week, selectionDecoration: BoxDecoration( color: Colors.transparent, - border: Border.all(color: Colors.black, width: 2), + border: Border.all( + color: Theme.of(context).colorScheme.onPrimary, + width: 2, + ), borderRadius: const BorderRadius.all( Radius.circular(5), ), shape: BoxShape.rectangle, ), - todayHighlightColor: Colors.black, - todayTextStyle: const TextStyle( - color: Colors.white, + todayHighlightColor: Theme.of( + context, + ).colorScheme.secondary, + todayTextStyle: TextStyle( + color: Theme.of(context).colorScheme.onSecondary, fontWeight: FontWeight.bold, ), firstDayOfWeek: 1, @@ -136,24 +137,24 @@ class Calendar extends HookConsumerWidget { timeSlotViewSettings: const TimeSlotViewSettings( timeFormat: 'HH:mm', ), - viewHeaderStyle: const ViewHeaderStyle( + viewHeaderStyle: ViewHeaderStyle( dayTextStyle: TextStyle( - color: Colors.grey, + color: Theme.of(context).colorScheme.tertiary, fontSize: 12, fontWeight: FontWeight.w600, ), dateTextStyle: TextStyle( - color: Colors.grey, + color: Theme.of(context).colorScheme.tertiary, fontSize: 15, fontWeight: FontWeight.w600, ), ), - headerStyle: const CalendarHeaderStyle( + headerStyle: CalendarHeaderStyle( textAlign: TextAlign.center, textStyle: TextStyle( fontSize: 20, fontWeight: FontWeight.w600, - color: Colors.black, + color: Theme.of(context).colorScheme.onSurface, ), ), ), @@ -164,13 +165,11 @@ class Calendar extends HookConsumerWidget { height: 50, width: 50, decoration: BoxDecoration( - color: Colors.black, + color: Theme.of(context).colorScheme.secondary, borderRadius: BorderRadius.circular(10), boxShadow: [ BoxShadow( - color: Colors.grey.shade700.withValues( - alpha: 0.3, - ), + color: Theme.of(context).shadowColor, blurRadius: 5, spreadRadius: 1, ), @@ -180,10 +179,10 @@ class Calendar extends HookConsumerWidget { onPressed: () { calendarController.forward!(); }, - icon: const HeroIcon( + icon: HeroIcon( HeroIcons.arrowRight, size: 25, - color: Colors.white, + color: Theme.of(context).colorScheme.onSecondary, ), ), ), @@ -195,13 +194,11 @@ class Calendar extends HookConsumerWidget { height: 50, width: 50, decoration: BoxDecoration( - color: Colors.black, + color: Theme.of(context).colorScheme.secondary, borderRadius: BorderRadius.circular(10), boxShadow: [ BoxShadow( - color: Colors.grey.shade700.withValues( - alpha: 0.3, - ), + color: Theme.of(context).shadowColor, blurRadius: 5, spreadRadius: 1, ), @@ -211,10 +208,10 @@ class Calendar extends HookConsumerWidget { onPressed: () { calendarController.backward!(); }, - icon: const HeroIcon( + icon: HeroIcon( HeroIcons.arrowLeft, size: 25, - color: Colors.white, + color: Theme.of(context).colorScheme.onSecondary, ), ), ), @@ -223,7 +220,7 @@ class Calendar extends HookConsumerWidget { ), ); }, - loaderColor: ColorConstants.background2, + loaderColor: Theme.of(context).colorScheme.primaryContainer, ), ); }, diff --git a/lib/tools/ui/widgets/custom_dialog_box.dart b/lib/tools/ui/widgets/custom_dialog_box.dart index 3c301a6c85..486e103d1a 100644 --- a/lib/tools/ui/widgets/custom_dialog_box.dart +++ b/lib/tools/ui/widgets/custom_dialog_box.dart @@ -7,6 +7,7 @@ class Consts { static const double padding = 20.0; static const double avatarRadius = 50.0; + // it's ok to have these dark "danger red" hard-coded static const Color redGradient1 = Color(0xFF9E131F); static const Color redGradient2 = Color(0xFF590512); } @@ -34,6 +35,7 @@ class CustomDialogBox extends StatelessWidget { Navigator.of(context).pop(); }, child: Container( + // to darken the page behind the dialog, independently on the theme color: Colors.black54, child: GestureDetector( onTap: () {}, @@ -56,14 +58,14 @@ class CustomDialogBox extends StatelessWidget { ), margin: const EdgeInsets.only(top: Consts.avatarRadius), decoration: BoxDecoration( - color: Colors.white, + color: Theme.of(context).colorScheme.surface, shape: BoxShape.rectangle, borderRadius: BorderRadius.circular(Consts.padding), - boxShadow: const [ + boxShadow: [ BoxShadow( - color: Colors.black26, + color: Theme.of(context).shadowColor, blurRadius: 10.0, - offset: Offset(0.0, 10.0), + offset: const Offset(0.0, 10.0), ), ], ), @@ -98,14 +100,10 @@ class CustomDialogBox extends StatelessWidget { padding: const EdgeInsets.symmetric(vertical: 16), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - gradient: const LinearGradient( - colors: [Colors.black87, Colors.black], - begin: Alignment.topLeft, - end: Alignment.bottomRight, - ), + color: Theme.of(context).colorScheme.secondary, boxShadow: [ BoxShadow( - color: Colors.black.withValues(alpha: 0.3), + color: Theme.of(context).shadowColor, blurRadius: 2.0, offset: const Offset(1.0, 2.0), ), @@ -115,7 +113,9 @@ class CustomDialogBox extends StatelessWidget { child: Text( noText ?? "Annuler", style: TextStyle( - color: Colors.white, + color: Theme.of( + context, + ).colorScheme.onSecondary, fontWeight: FontWeight.bold, ), ), @@ -129,16 +129,20 @@ class CustomDialogBox extends StatelessWidget { } await onYes(); }, - waitingColor: Colors.black, + waitingColor: Theme.of( + context, + ).colorScheme.onPrimary, builder: (child) => Container( width: 100, padding: const EdgeInsets.symmetric(vertical: 16), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - color: Colors.grey.shade300, + color: Theme.of( + context, + ).colorScheme.secondaryFixed, boxShadow: [ BoxShadow( - color: Colors.grey.withValues(alpha: 0.3), + color: Theme.of(context).shadowColor, blurRadius: 2.0, offset: const Offset(1.0, 2.0), ), diff --git a/lib/tools/ui/widgets/date_entry.dart b/lib/tools/ui/widgets/date_entry.dart index 25c852de64..2d3a743ef9 100644 --- a/lib/tools/ui/widgets/date_entry.dart +++ b/lib/tools/ui/widgets/date_entry.dart @@ -7,7 +7,7 @@ class DateEntry extends StatelessWidget { final String label; final bool enabled; final TextEditingController controller; - final Color color, enabledColor, errorColor; + final Color? color, enabledColor, errorColor; final Widget? suffixIcon; const DateEntry({ @@ -16,9 +16,9 @@ class DateEntry extends StatelessWidget { required this.controller, required this.onTap, this.enabled = true, - this.color = Colors.black, - this.enabledColor = Colors.black, - this.errorColor = Colors.red, + this.color, + this.enabledColor, + this.errorColor, this.suffixIcon, }); @override diff --git a/lib/tools/ui/widgets/loader.dart b/lib/tools/ui/widgets/loader.dart index 1de61ddfea..4b7a48f084 100644 --- a/lib/tools/ui/widgets/loader.dart +++ b/lib/tools/ui/widgets/loader.dart @@ -2,10 +2,14 @@ import 'package:flutter/material.dart'; class Loader extends StatelessWidget { final Color? color; - const Loader({super.key, this.color = Colors.black}); + const Loader({super.key, this.color}); @override Widget build(BuildContext context) { - return Center(child: CircularProgressIndicator(color: color)); + return Center( + child: CircularProgressIndicator( + color: color ?? Theme.of(context).colorScheme.primaryContainer, + ), + ); } } diff --git a/lib/tools/ui/widgets/styled_search_bar.dart b/lib/tools/ui/widgets/styled_search_bar.dart index 964d638b42..de65280f21 100644 --- a/lib/tools/ui/widgets/styled_search_bar.dart +++ b/lib/tools/ui/widgets/styled_search_bar.dart @@ -7,7 +7,7 @@ class StyledSearchBar extends HookConsumerWidget { final Future Function(String)? onChanged; final String label; final Widget? suffixIcon; - final Color color; + final Color? color; final EdgeInsetsGeometry? padding; final void Function(FocusNode focusNode, TextEditingController controller)? onSuffixIconTap; @@ -19,7 +19,7 @@ class StyledSearchBar extends HookConsumerWidget { this.suffixIcon, this.onSuffixIconTap, this.padding, - this.color = Colors.grey, + this.color, this.editingController, }); @@ -28,6 +28,7 @@ class StyledSearchBar extends HookConsumerWidget { final focusNode = useFocusNode(); final editingController = this.editingController ?? useTextEditingController(); + final color_ = color ?? Theme.of(context).colorScheme.tertiary; return Container( padding: padding ?? const EdgeInsets.symmetric(horizontal: 30), alignment: Alignment.centerLeft, @@ -39,28 +40,28 @@ class StyledSearchBar extends HookConsumerWidget { }); }, controller: editingController, - cursorColor: color, + cursorColor: color_, decoration: InputDecoration( labelText: label, labelStyle: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: color, + color: color_, ), suffixIcon: onSuffixIconTap == null - ? suffixIcon ?? Icon(Icons.search, color: color, size: 30) + ? suffixIcon ?? Icon(Icons.search, color: color_, size: 30) : GestureDetector( onTap: () { onSuffixIconTap!(focusNode, editingController); }, child: - suffixIcon ?? Icon(Icons.search, color: color, size: 30), + suffixIcon ?? Icon(Icons.search, color: color_, size: 30), ), enabledBorder: const UnderlineInputBorder( borderSide: BorderSide(color: Colors.transparent), ), focusedBorder: UnderlineInputBorder( - borderSide: BorderSide(color: color), + borderSide: BorderSide(color: color_), ), ), ), diff --git a/lib/tools/ui/widgets/text_entry.dart b/lib/tools/ui/widgets/text_entry.dart index 89bdae241c..c7150d6fd5 100644 --- a/lib/tools/ui/widgets/text_entry.dart +++ b/lib/tools/ui/widgets/text_entry.dart @@ -8,7 +8,7 @@ class TextEntry extends StatelessWidget { final bool enabled; final TextEditingController controller; final TextInputType keyboardType; - final Color color, enabledColor, errorColor; + final Color? color, enabledColor, errorColor; final Widget? suffixIcon; final Function(String)? onChanged; final String? Function(String)? validator; @@ -30,9 +30,9 @@ class TextEntry extends StatelessWidget { this.isDouble = false, this.keyboardType = TextInputType.text, this.canBeEmpty = false, - this.color = Colors.black, - this.enabledColor = Colors.black, - this.errorColor = ColorConstants.error, + this.color, + this.enabledColor, + this.errorColor, this.noValueError = TextConstants.noValue, this.suffixIcon, this.isNegative = false, @@ -41,12 +41,13 @@ class TextEntry extends StatelessWidget { @override Widget build(BuildContext context) { + final color_ = color ?? Theme.of(context).colorScheme.onPrimary; return TextFormField( minLines: minLines, maxLines: maxLines, controller: controller, keyboardType: keyboardType, - cursorColor: color, + cursorColor: color ?? Theme.of(context).colorScheme.primaryContainer, onChanged: onChanged, textInputAction: (keyboardType == TextInputType.multiline) ? TextInputAction.newline @@ -55,33 +56,38 @@ class TextEntry extends StatelessWidget { decoration: InputDecoration( label: Text( canBeEmpty ? '$label (optionnel)' : label, - style: TextStyle(color: color, height: 0.5), + style: TextStyle(color: color_, height: 0.5), ), suffix: suffixIcon == null && suffix.isEmpty ? null : Container( padding: const EdgeInsets.only(left: 10), child: - suffixIcon ?? Text(suffix, style: TextStyle(color: color)), + suffixIcon ?? Text(suffix, style: TextStyle(color: color_)), ), prefix: prefix.isEmpty ? null : Container( padding: const EdgeInsets.only(right: 10), - child: Text(prefix, style: TextStyle(color: color)), + child: Text(prefix, style: TextStyle(color: color_)), ), - floatingLabelStyle: const TextStyle( - color: Colors.black, - fontWeight: FontWeight.bold, - ), + floatingLabelStyle: TextStyle(fontWeight: FontWeight.bold), enabledBorder: UnderlineInputBorder( - borderSide: BorderSide(color: enabledColor), + borderSide: BorderSide( + color: enabledColor ?? Theme.of(context).colorScheme.onPrimary, + ), ), errorBorder: UnderlineInputBorder( - borderSide: BorderSide(color: errorColor, width: 2.0), + borderSide: BorderSide( + color: errorColor ?? Theme.of(context).colorScheme.error, + width: 2.0, + ), ), focusedBorder: UnderlineInputBorder( - borderSide: BorderSide(color: color, width: 2.0), + borderSide: BorderSide( + color: color ?? Theme.of(context).colorScheme.primaryContainer, + width: 2.0, + ), ), ), validator: (value) { diff --git a/lib/tools/ui/widgets/text_with_hyper_link.dart b/lib/tools/ui/widgets/text_with_hyper_link.dart index 56141520fc..5bc78fcfc9 100644 --- a/lib/tools/ui/widgets/text_with_hyper_link.dart +++ b/lib/tools/ui/widgets/text_with_hyper_link.dart @@ -65,7 +65,7 @@ class TextWithHyperLink extends StatelessWidget { final hyperLinkStyle = linkStyle ?? theme.textTheme.bodyMedium?.copyWith( - color: ColorConstants.gradient1, + color: Theme.of(context).colorScheme.primaryContainer, decoration: TextDecoration.underline, ); diff --git a/lib/tools/ui/widgets/top_bar.dart b/lib/tools/ui/widgets/top_bar.dart index fdf040074d..37cfac7d64 100644 --- a/lib/tools/ui/widgets/top_bar.dart +++ b/lib/tools/ui/widgets/top_bar.dart @@ -62,7 +62,9 @@ class TopBar extends HookConsumerWidget { QR.currentPath == root ? HeroIcons.bars3BottomLeft : HeroIcons.chevronLeft, - color: textStyle?.color ?? Colors.black, + color: + textStyle?.color ?? + Theme.of(context).colorScheme.onPrimary, size: 30, ), ); @@ -79,7 +81,6 @@ class TopBar extends HookConsumerWidget { const TextStyle( fontSize: 30, fontWeight: FontWeight.w700, - color: Colors.black, ), ), ), diff --git a/lib/vote/tools/constants.dart b/lib/vote/tools/constants.dart index 2a8e7cbd94..5963dbf756 100644 --- a/lib/vote/tools/constants.dart +++ b/lib/vote/tools/constants.dart @@ -1,3 +1,5 @@ +import 'package:flutter/material.dart'; + class VoteTextConstants { static const String add = 'Ajouter'; static const String addMember = 'Ajouter un membre'; @@ -94,3 +96,8 @@ class VotePermissionConstants { static const String manageVotes = "manage_campaign"; static const String vote = "vote"; } + +class VoteColorConstants { + static const Color redGradient1 = Color(0xFF9E131F); + static const Color redGradient2 = Color(0xFF590512); +} diff --git a/lib/vote/ui/pages/admin_page/admin_page.dart b/lib/vote/ui/pages/admin_page/admin_page.dart index 2f2c4b9d13..8a78c03809 100644 --- a/lib/vote/ui/pages/admin_page/admin_page.dart +++ b/lib/vote/ui/pages/admin_page/admin_page.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:heroicons/heroicons.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:titan/amap/tools/constants.dart'; import 'package:titan/tools/constants.dart'; import 'package:titan/tools/ui/layouts/card_layout.dart'; import 'package:titan/tools/ui/widgets/align_left_text.dart'; @@ -402,8 +401,8 @@ class AdminPage extends HookConsumerWidget { ), margin: const EdgeInsets.all(0), colors: const [ - AMAPColorConstants.redGradient1, - AMAPColorConstants.redGradient2, + VoteColorConstants.redGradient1, + VoteColorConstants.redGradient2, ], borderColor: Colors.white, child: child, @@ -479,8 +478,8 @@ class AdminPage extends HookConsumerWidget { ), margin: const EdgeInsets.all(0), colors: const [ - AMAPColorConstants.redGradient1, - AMAPColorConstants.redGradient2, + VoteColorConstants.redGradient1, + VoteColorConstants.redGradient2, ], borderColor: Colors.white, child: child, diff --git a/pubspec.yaml b/pubspec.yaml index 5be8687ba3..c2c39b826d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -107,7 +107,8 @@ flutter: - assets/web/Vote.webp - assets/my_document.pdf - assets/images/bird.png - - assets/images/pipe.png + - assets/images/pipe_day.png + - assets/images/pipe_night.png - assets/images/logo_flappybird.svg - assets/images/helloasso.svg diff --git a/web/index.html b/web/index.html index b3c893f3fe..78c615c180 100644 --- a/web/index.html +++ b/web/index.html @@ -27,6 +27,7 @@ display: flex; justify-content: center; align-items: center; + background: var(--primary); min-height: calc(100vh - 12px); } @@ -44,7 +45,6 @@ .dot-container { position: absolute; - border: 0px solid #fff; border-radius: 50px; } .dot-container:nth-child(2) { @@ -64,7 +64,7 @@ position: absolute; height: 10px; width: 10px; - background: #000000; + background: var(--onPrimary); border-radius: 5px; transform: translate(0, 0); } @@ -123,6 +123,16 @@ +