diff --git a/lib/app/modules/about/views/about_page_app_bar.dart b/lib/app/modules/about/views/about_page_app_bar.dart index 9667860a..1a20a113 100644 --- a/lib/app/modules/about/views/about_page_app_bar.dart +++ b/lib/app/modules/about/views/about_page_app_bar.dart @@ -1,7 +1,5 @@ import 'package:flutter/material.dart'; import 'package:taskwarrior/app/modules/about/controllers/about_controller.dart'; - - import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; import 'package:taskwarrior/app/utils/gen/fonts.gen.dart'; import 'package:taskwarrior/app/utils/language/sentence_manager.dart'; diff --git a/lib/app/modules/about/views/about_page_body.dart b/lib/app/modules/about/views/about_page_body.dart index e068912d..17047ae8 100644 --- a/lib/app/modules/about/views/about_page_body.dart +++ b/lib/app/modules/about/views/about_page_body.dart @@ -7,11 +7,10 @@ import 'package:taskwarrior/app/modules/about/controllers/about_controller.dart' import 'package:taskwarrior/app/utils/gen/assets.gen.dart'; import 'package:taskwarrior/app/utils/gen/fonts.gen.dart'; import 'package:taskwarrior/app/utils/language/sentence_manager.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; import 'package:url_launcher/url_launcher.dart'; -import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart'; -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; class AboutPageBody extends StatelessWidget { final AboutController aboutController; @@ -19,6 +18,7 @@ class AboutPageBody extends StatelessWidget { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; String introduction = SentenceManager(currentLanguage: aboutController.selectedLanguage.value) .sentences @@ -51,9 +51,7 @@ class AboutPageBody extends StatelessWidget { fontFamily: FontFamily.poppins, fontWeight: TaskWarriorFonts.bold, fontSize: TaskWarriorFonts.fontSizeExtraLarge, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), SizedBox( @@ -84,9 +82,7 @@ class AboutPageBody extends StatelessWidget { fontFamily: FontFamily.poppins, fontWeight: TaskWarriorFonts.bold, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), TextSpan( @@ -94,9 +90,7 @@ class AboutPageBody extends StatelessWidget { style: TextStyle( fontFamily: FontFamily.poppins, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ], @@ -116,9 +110,7 @@ class AboutPageBody extends StatelessWidget { fontWeight: TaskWarriorFonts.bold, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), TextSpan( @@ -127,9 +119,7 @@ class AboutPageBody extends StatelessWidget { fontFamily: FontFamily.poppins, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ], @@ -154,9 +144,7 @@ class AboutPageBody extends StatelessWidget { fontFamily: FontFamily.poppins, fontWeight: TaskWarriorFonts.medium, fontSize: TaskWarriorFonts.fontSizeSmall, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), SizedBox( @@ -170,9 +158,7 @@ class AboutPageBody extends StatelessWidget { height: Get.height * 0.05, child: ElevatedButton.icon( style: ElevatedButton.styleFrom( - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.kLightSecondaryBackgroundColor - : TaskWarriorColors.ksecondaryBackgroundColor, + backgroundColor: tColors.secondaryTextColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), @@ -190,9 +176,7 @@ class AboutPageBody extends StatelessWidget { width: 20, height: 20, colorFilter: ColorFilter.mode( - AppSettings.isDarkMode - ? TaskWarriorColors.black - : TaskWarriorColors.white, + tColors.secondaryBackgroundColor!, BlendMode.srcIn)), label: Text( "GitHub", @@ -200,9 +184,7 @@ class AboutPageBody extends StatelessWidget { fontFamily: FontFamily.poppins, fontWeight: TaskWarriorFonts.medium, fontSize: TaskWarriorFonts.fontSizeSmall, - color: AppSettings.isDarkMode - ? TaskWarriorColors.black - : TaskWarriorColors.white, + color: tColors.secondaryBackgroundColor, ), ), ), @@ -212,9 +194,7 @@ class AboutPageBody extends StatelessWidget { height: Get.height * 0.05, child: ElevatedButton.icon( style: ElevatedButton.styleFrom( - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.kLightSecondaryBackgroundColor - : TaskWarriorColors.ksecondaryBackgroundColor, + backgroundColor: tColors.secondaryTextColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), @@ -229,19 +209,17 @@ class AboutPageBody extends StatelessWidget { width: 20, height: 20, colorFilter: ColorFilter.mode( - AppSettings.isDarkMode - ? TaskWarriorColors.black - : TaskWarriorColors.white, - BlendMode.srcIn)), + tColors.secondaryBackgroundColor!, + BlendMode.srcIn + ) + ), label: Text( "CCExtractor", style: TextStyle( fontFamily: FontFamily.poppins, fontWeight: TaskWarriorFonts.medium, fontSize: TaskWarriorFonts.fontSizeSmall, - color: AppSettings.isDarkMode - ? TaskWarriorColors.black - : TaskWarriorColors.white, + color: tColors.secondaryBackgroundColor, ), ), ), @@ -261,9 +239,7 @@ class AboutPageBody extends StatelessWidget { fontFamily: FontFamily.poppins, fontWeight: TaskWarriorFonts.semiBold, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), SizedBox( diff --git a/lib/app/modules/about/views/about_view.dart b/lib/app/modules/about/views/about_view.dart index b8062c5d..d7e832f8 100644 --- a/lib/app/modules/about/views/about_view.dart +++ b/lib/app/modules/about/views/about_view.dart @@ -4,20 +4,18 @@ import 'package:get/get.dart'; import 'package:taskwarrior/app/modules/about/views/about_page_app_bar.dart'; import 'package:taskwarrior/app/modules/about/views/about_page_body.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; import '../controllers/about_controller.dart'; -import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; class AboutView extends GetView { const AboutView({super.key}); @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Scaffold( appBar: AboutPageAppBar(aboutController: controller,), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryBackgroundColor - : TaskWarriorColors.white, + backgroundColor: tColors.primaryBackgroundColor, body: AboutPageBody( aboutController: controller, ), diff --git a/lib/app/modules/detailRoute/views/dateTimePicker.dart b/lib/app/modules/detailRoute/views/dateTimePicker.dart index 944c5c7a..fe28aa24 100644 --- a/lib/app/modules/detailRoute/views/dateTimePicker.dart +++ b/lib/app/modules/detailRoute/views/dateTimePicker.dart @@ -6,7 +6,7 @@ import 'package:intl/intl.dart'; import 'package:taskwarrior/app/utils/constants/constants.dart'; import 'package:taskwarrior/app/utils/gen/fonts.gen.dart'; -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class DateTimeWidget extends StatelessWidget { const DateTimeWidget({ @@ -25,15 +25,12 @@ class DateTimeWidget extends StatelessWidget { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Card( key: globalKey, - color: AppSettings.isDarkMode - ? const Color.fromARGB(255, 57, 57, 57) - : Colors.white, + color: tColors.secondaryBackgroundColor, child: ListTile( - textColor: AppSettings.isDarkMode - ? Colors.white - : const Color.fromARGB(255, 48, 46, 46), + textColor: tColors.primaryTextColor, title: SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( @@ -54,9 +51,7 @@ class DateTimeWidget extends StatelessWidget { fontFamily: FontFamily.poppins, fontWeight: TaskWarriorFonts.bold, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), TextSpan( @@ -70,9 +65,7 @@ class DateTimeWidget extends StatelessWidget { style: TextStyle( fontFamily: FontFamily.poppins, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ], @@ -170,14 +163,10 @@ class DateTimeWidget extends StatelessWidget { content: Text( "Can't set times in the past", style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor, + color: tColors.primaryTextColor, ), ), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, + backgroundColor: tColors.primaryBackgroundColor, duration: const Duration(seconds: 2), ), ); @@ -208,14 +197,11 @@ class StartWidget extends StatelessWidget { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Card( - color: AppSettings.isDarkMode - ? const Color.fromARGB(255, 57, 57, 57) - : Colors.white, + color: tColors.secondaryBackgroundColor, child: ListTile( - textColor: AppSettings.isDarkMode - ? Colors.white - : const Color.fromARGB(255, 48, 46, 46), + textColor: tColors.secondaryBackgroundColor, title: SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( @@ -236,9 +222,7 @@ class StartWidget extends StatelessWidget { fontFamily: FontFamily.poppins, fontWeight: TaskWarriorFonts.bold, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), TextSpan( @@ -252,9 +236,7 @@ class StartWidget extends StatelessWidget { style: TextStyle( fontFamily: FontFamily.poppins, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ], diff --git a/lib/app/modules/detailRoute/views/description_widget.dart b/lib/app/modules/detailRoute/views/description_widget.dart index e4018a75..74997ad4 100644 --- a/lib/app/modules/detailRoute/views/description_widget.dart +++ b/lib/app/modules/detailRoute/views/description_widget.dart @@ -5,7 +5,7 @@ import 'package:loggy/loggy.dart'; import 'package:taskwarrior/app/utils/constants/constants.dart'; import 'package:taskwarrior/app/utils/constants/utilites.dart'; import 'package:taskwarrior/app/utils/gen/fonts.gen.dart'; -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class DescriptionWidget extends StatelessWidget { const DescriptionWidget( @@ -20,14 +20,11 @@ class DescriptionWidget extends StatelessWidget { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Card( - color: AppSettings.isDarkMode - ? const Color.fromARGB(255, 57, 57, 57) - : Colors.white, + color: tColors.secondaryBackgroundColor, child: ListTile( - textColor: AppSettings.isDarkMode - ? Colors.white - : const Color.fromARGB(255, 48, 46, 46), + textColor: tColors.primaryTextColor, title: SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( @@ -48,9 +45,7 @@ class DescriptionWidget extends StatelessWidget { fontFamily: FontFamily.poppins, fontWeight: TaskWarriorFonts.bold, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), TextSpan( @@ -64,9 +59,7 @@ class DescriptionWidget extends StatelessWidget { style: TextStyle( fontFamily: FontFamily.poppins, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ], @@ -86,16 +79,12 @@ class DescriptionWidget extends StatelessWidget { title: Text( 'Edit description', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), content: TextField( style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), autofocus: true, maxLines: null, @@ -110,9 +99,7 @@ class DescriptionWidget extends StatelessWidget { child: Text( 'Cancel', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ), @@ -129,9 +116,7 @@ class DescriptionWidget extends StatelessWidget { child: Text( 'Submit', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.black - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ), @@ -157,14 +142,11 @@ class ProjectWidget extends StatelessWidget { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Card( - color: AppSettings.isDarkMode - ? const Color.fromARGB(255, 57, 57, 57) - : Colors.white, + color: tColors.secondaryBackgroundColor, child: ListTile( - textColor: AppSettings.isDarkMode - ? Colors.white - : const Color.fromARGB(255, 48, 46, 46), + textColor: tColors.primaryTextColor, title: SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( @@ -185,9 +167,7 @@ class ProjectWidget extends StatelessWidget { fontFamily: FontFamily.poppins, fontWeight: TaskWarriorFonts.bold, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), TextSpan( @@ -201,9 +181,7 @@ class ProjectWidget extends StatelessWidget { style: TextStyle( fontFamily: FontFamily.poppins, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ], @@ -223,16 +201,12 @@ class ProjectWidget extends StatelessWidget { title: Text( 'Edit project', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), content: TextField( style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), autofocus: true, maxLines: null, @@ -247,9 +221,7 @@ class ProjectWidget extends StatelessWidget { child: Text( 'Cancel', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ), @@ -267,9 +239,7 @@ class ProjectWidget extends StatelessWidget { child: Text( 'Submit', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.black - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ), diff --git a/lib/app/modules/detailRoute/views/detail_route_view.dart b/lib/app/modules/detailRoute/views/detail_route_view.dart index 478da44f..efb3da6e 100644 --- a/lib/app/modules/detailRoute/views/detail_route_view.dart +++ b/lib/app/modules/detailRoute/views/detail_route_view.dart @@ -14,6 +14,7 @@ import 'package:taskwarrior/app/utils/constants/constants.dart'; import 'package:taskwarrior/app/utils/gen/fonts.gen.dart'; import 'package:taskwarrior/app/utils/language/sentence_manager.dart'; import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class DetailRouteView extends GetView { const DetailRouteView({super.key}); @@ -22,6 +23,7 @@ class DetailRouteView extends GetView { Widget build(BuildContext context) { controller.initDetailsPageTour(); controller.showDetailsPageTour(context); + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return WillPopScope( onWillPop: () async { if (!controller.onEdit.value) { @@ -35,15 +37,11 @@ class DetailRouteView extends GetView { context: context, builder: (context) { return AlertDialog( - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.kdialogBackGroundColor - : TaskWarriorColors.kLightDialogBackGroundColor, + backgroundColor: tColors.dialogBackgroundColor, title: Text( 'Do you want to save changes?', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), actions: [ @@ -57,9 +55,7 @@ class DetailRouteView extends GetView { child: Text( 'Yes', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ), @@ -72,9 +68,7 @@ class DetailRouteView extends GetView { child: Text( 'No', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ), @@ -85,9 +79,7 @@ class DetailRouteView extends GetView { child: Text( 'Cancel', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ), @@ -98,9 +90,7 @@ class DetailRouteView extends GetView { return save == true; }, child: Scaffold( - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryBackgroundColor - : TaskWarriorColors.kLightPrimaryBackgroundColor, + backgroundColor: tColors.primaryBackgroundColor, appBar: AppBar( leading: BackButton(color: TaskWarriorColors.white), backgroundColor: Palette.kToDark, @@ -148,15 +138,9 @@ class DetailRouteView extends GetView { floatingActionButton: controller.modify.changes.isEmpty ? const SizedBox.shrink() : FloatingActionButton( - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.black - : TaskWarriorColors.white, - foregroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, - splashColor: AppSettings.isDarkMode - ? TaskWarriorColors.black - : TaskWarriorColors.white, + backgroundColor: tColors.primaryTextColor, + foregroundColor: tColors.secondaryBackgroundColor, + splashColor: tColors.primaryTextColor, heroTag: "btn1", onPressed: () { showDialog( @@ -167,9 +151,7 @@ class DetailRouteView extends GetView { title: Text( 'Review changes:', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), content: SingleChildScrollView( @@ -182,9 +164,7 @@ class DetailRouteView extends GetView { .toList() .join('\n'), style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ), @@ -196,9 +176,7 @@ class DetailRouteView extends GetView { child: Text( 'Cancel', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ), @@ -209,9 +187,7 @@ class DetailRouteView extends GetView { child: Text( 'Submit', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.black - : TaskWarriorColors.black, + color: tColors.primaryBackgroundColor, ), ), ), @@ -251,7 +227,7 @@ class AttributeWidget extends StatelessWidget { var localValue = (value is DateTime) ? DateFormat.yMEd().add_jms().format(value.toLocal()) : ((value is BuiltList) ? (value).toBuilder() : value); - + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; switch (name) { case 'description': return DescriptionWidget( @@ -313,13 +289,9 @@ class AttributeWidget extends StatelessWidget { ); default: return Card( - color: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, + color: tColors.secondaryBackgroundColor, child: ListTile( - textColor: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightSecondaryTextColor, + textColor: tColors.primaryTextColor, title: SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( @@ -327,17 +299,18 @@ class AttributeWidget extends StatelessWidget { Text( '$name:'.padRight(13), style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + fontFamily: FontFamily.poppins, + fontWeight: TaskWarriorFonts.bold, + fontSize: TaskWarriorFonts.fontSizeMedium, + color: tColors.primaryTextColor, ), ), Text( localValue?.toString() ?? "not selected", style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + fontFamily: FontFamily.poppins, + fontSize: TaskWarriorFonts.fontSizeMedium, + color: tColors.primaryTextColor, ), ), ], @@ -362,14 +335,11 @@ class TagsWidget extends StatelessWidget { final void Function(dynamic) callback; @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Card( - color: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, + color: tColors.secondaryBackgroundColor, child: ListTile( - textColor: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.ksecondaryTextColor, + textColor: tColors.primaryTextColor, title: SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( @@ -381,10 +351,9 @@ class TagsWidget extends StatelessWidget { text: '$name:'.padRight(13), style: TextStyle( fontFamily: FontFamily.poppins, + fontWeight: FontWeight.bold, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ) // style: GoogleFonts.poppins( // fontWeight: TaskWarriorFonts.bold, @@ -398,9 +367,7 @@ class TagsWidget extends StatelessWidget { text: '${(value as ListBuilder?)?.build() ?? 'not selected'}', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ], diff --git a/lib/app/modules/detailRoute/views/priority_widget.dart b/lib/app/modules/detailRoute/views/priority_widget.dart index 945afec1..56438497 100644 --- a/lib/app/modules/detailRoute/views/priority_widget.dart +++ b/lib/app/modules/detailRoute/views/priority_widget.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:taskwarrior/app/utils/constants/constants.dart'; -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class PriorityWidget extends StatelessWidget { const PriorityWidget( @@ -18,15 +18,12 @@ class PriorityWidget extends StatelessWidget { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Card( key: globalKey, - color: AppSettings.isDarkMode - ? const Color.fromARGB(255, 57, 57, 57) - : Colors.white, + color: tColors.secondaryBackgroundColor, child: ListTile( - textColor: AppSettings.isDarkMode - ? Colors.white - : const Color.fromARGB(255, 48, 46, 46), + textColor: tColors.primaryTextColor, title: SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( @@ -39,18 +36,14 @@ class PriorityWidget extends StatelessWidget { style: GoogleFonts.poppins( fontWeight: TaskWarriorFonts.bold, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? Colors.white - : Colors.black, + color: tColors.primaryTextColor, ), ), TextSpan( text: value ?? "not selected", style: GoogleFonts.poppins( fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? Colors.white - : Colors.black, + color: tColors.primaryTextColor, ), ), ], diff --git a/lib/app/modules/detailRoute/views/status_widget.dart b/lib/app/modules/detailRoute/views/status_widget.dart index 87bc6d8f..ff80c40d 100644 --- a/lib/app/modules/detailRoute/views/status_widget.dart +++ b/lib/app/modules/detailRoute/views/status_widget.dart @@ -4,7 +4,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:taskwarrior/app/utils/constants/constants.dart'; -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class StatusWidget extends StatelessWidget { @@ -20,14 +20,11 @@ class StatusWidget extends StatelessWidget { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Card( - color: AppSettings.isDarkMode - ? const Color.fromARGB(255, 57, 57, 57) - : Colors.white, + color: tColors.secondaryBackgroundColor, child: ListTile( - textColor: AppSettings.isDarkMode - ? Colors.white - : const Color.fromARGB(255, 48, 46, 46), + textColor: tColors.primaryTextColor, title: SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( @@ -40,18 +37,14 @@ class StatusWidget extends StatelessWidget { style: GoogleFonts.poppins( fontWeight: TaskWarriorFonts.bold, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? Colors.white - : Colors.black, + color: tColors.primaryTextColor, ), ), TextSpan( text: value ?? "not selected", style: GoogleFonts.poppins( fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? Colors.white - : Colors.black, + color: tColors.primaryTextColor, ), ), ], diff --git a/lib/app/modules/detailRoute/views/tags_widget.dart b/lib/app/modules/detailRoute/views/tags_widget.dart index c4906d59..81e9207c 100644 --- a/lib/app/modules/detailRoute/views/tags_widget.dart +++ b/lib/app/modules/detailRoute/views/tags_widget.dart @@ -11,7 +11,7 @@ import 'package:taskwarrior/app/modules/home/controllers/home_controller.dart'; import 'package:taskwarrior/app/utils/constants/constants.dart'; import 'package:taskwarrior/app/utils/constants/utilites.dart'; import 'package:taskwarrior/app/utils/taskfunctions/validate.dart'; -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class TagsWidget extends StatelessWidget { const TagsWidget({ @@ -27,14 +27,11 @@ class TagsWidget extends StatelessWidget { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Card( child: ListTile( - tileColor: AppSettings.isDarkMode - ? const Color.fromARGB(255, 55, 54, 54) - : TaskWarriorColors.white, - textColor: AppSettings.isDarkMode - ? TaskWarriorColors.white - : const Color.fromARGB(255, 48, 46, 46), + tileColor: tColors.secondaryBackgroundColor, + textColor: tColors.primaryTextColor, title: SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( @@ -116,6 +113,7 @@ class TagsRouteState extends State { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Scaffold( appBar: AppBar( backgroundColor: TaskWarriorColors.kprimaryBackgroundColor, @@ -127,9 +125,7 @@ class TagsRouteState extends State { color: TaskWarriorColors.white, ), ), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryBackgroundColor - : TaskWarriorColors.kLightPrimaryBackgroundColor, + backgroundColor: tColors.secondaryBackgroundColor, body: SafeArea( child: Padding( padding: const EdgeInsets.all(4), @@ -156,15 +152,12 @@ class TagsRouteState extends State { 'Added tags will appear here', style: GoogleFonts.poppins( fontStyle: FontStyle.italic, - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor), + color: tColors.primaryTextColor + ), ), ), Divider( - color: AppSettings.isDarkMode - ? const Color.fromARGB(255, 192, 192, 192) - : TaskWarriorColors.kprimaryBackgroundColor, + color: tColors.dividerColor, ), if (_pendingTags != null) for (var tag in _pendingTags!.entries.where((tag) => @@ -182,15 +175,9 @@ class TagsRouteState extends State { ), ), floatingActionButton: FloatingActionButton( - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.black - : TaskWarriorColors.white, - foregroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, - splashColor: AppSettings.isDarkMode - ? TaskWarriorColors.black - : TaskWarriorColors.white, + backgroundColor: tColors.primaryTextColor, + foregroundColor: tColors.secondaryBackgroundColor, + splashColor: tColors.primaryTextColor, heroTag: "btn4", onPressed: () { final formKey = GlobalKey(); @@ -202,18 +189,14 @@ class TagsRouteState extends State { title: Text( 'Add tag', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), content: Form( key: formKey, child: TextFormField( style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), validator: (value) { if (value != null) { @@ -236,9 +219,7 @@ class TagsRouteState extends State { child: Text( 'Cancel', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ), @@ -258,9 +239,7 @@ class TagsRouteState extends State { child: Text( 'Submit', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.black - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ), diff --git a/lib/app/modules/home/controllers/home_controller.dart b/lib/app/modules/home/controllers/home_controller.dart index 53074874..09c98b77 100644 --- a/lib/app/modules/home/controllers/home_controller.dart +++ b/lib/app/modules/home/controllers/home_controller.dart @@ -32,6 +32,7 @@ import 'package:taskwarrior/app/utils/taskfunctions/projects.dart'; import 'package:taskwarrior/app/utils/taskfunctions/query.dart'; import 'package:taskwarrior/app/utils/taskfunctions/tags.dart'; import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; import 'package:tutorial_coach_mark/tutorial_coach_mark.dart'; class HomeController extends GetxController { @@ -322,19 +323,16 @@ class HomeController extends GetxController { Future synchronize(BuildContext context, bool isDialogNeeded) async { try { final connectivityResult = await Connectivity().checkConnectivity(); + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; if (connectivityResult == ConnectivityResult.none) { ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text( 'You are not connected to the internet. Please check your network connection.', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor, + color: tColors.primaryTextColor, ), ), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, + backgroundColor: tColors.secondaryBackgroundColor, duration: const Duration(seconds: 2))); } else { if (isDialogNeeded) { @@ -386,14 +384,10 @@ class HomeController extends GetxController { content: Text( '${header['code']}: ${header['status']}', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor, + color: tColors.primaryTextColor, ), ), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, + backgroundColor: tColors.secondaryBackgroundColor, duration: const Duration(seconds: 2))); if (isDialogNeeded) { diff --git a/lib/app/modules/home/views/add_task_bottom_sheet.dart b/lib/app/modules/home/views/add_task_bottom_sheet.dart index 9e08077e..ff990b4b 100644 --- a/lib/app/modules/home/views/add_task_bottom_sheet.dart +++ b/lib/app/modules/home/views/add_task_bottom_sheet.dart @@ -13,28 +13,22 @@ import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart'; import 'package:taskwarrior/app/utils/language/sentence_manager.dart'; import 'package:taskwarrior/app/utils/taskfunctions/taskparser.dart'; -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class AddTaskBottomSheet extends StatelessWidget { final HomeController homeController; const AddTaskBottomSheet({required this.homeController, super.key}); - @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Scaffold( backgroundColor: Colors.transparent, body: Center( child: SingleChildScrollView( child: AlertDialog( - surfaceTintColor: AppSettings.isDarkMode - ? TaskWarriorColors.kdialogBackGroundColor - : TaskWarriorColors.kLightDialogBackGroundColor, - shadowColor: AppSettings.isDarkMode - ? TaskWarriorColors.kdialogBackGroundColor - : TaskWarriorColors.kLightDialogBackGroundColor, - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.kdialogBackGroundColor - : TaskWarriorColors.kLightDialogBackGroundColor, + surfaceTintColor: tColors.dialogBackgroundColor, + shadowColor: tColors.dialogBackgroundColor, + backgroundColor: tColors.dialogBackgroundColor, title: Center( child: Text( SentenceManager( @@ -42,10 +36,8 @@ class AddTaskBottomSheet extends StatelessWidget { .sentences .addTaskTitle, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, - ), + color: tColors.primaryTextColor + ), ), ), content: Form( @@ -56,18 +48,18 @@ class AddTaskBottomSheet extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ const SizedBox(height: 8), - buildName(), + buildName(tColors), const SizedBox(height: 12), - buildDueDate(context), + buildDueDate(context, tColors), const SizedBox(height: 8), - buildPriority(), - buildTags(), + buildPriority(tColors), + buildTags(tColors), ], ), ), ), actions: [ - buildCancelButton(context, homeController), + buildCancelButton(context, homeController, tColors), buildAddButton(context), ], ), @@ -76,7 +68,7 @@ class AddTaskBottomSheet extends StatelessWidget { ); } - Widget buildTags() { + Widget buildTags(TaskwarriorColorTheme tColors){ return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -92,11 +84,11 @@ class AddTaskBottomSheet extends StatelessWidget { Expanded( child: TextFormField( controller: homeController.tagcontroller, - style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, - ), + style: + TextStyle( + color: tColors.primaryTextColor + ) + , decoration: InputDecoration( hintText: SentenceManager( currentLanguage: @@ -104,9 +96,7 @@ class AddTaskBottomSheet extends StatelessWidget { .sentences .addTaskAddTags, hintStyle: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor ), ), onFieldSubmitted: (tag) { @@ -144,13 +134,11 @@ class AddTaskBottomSheet extends StatelessWidget { }).toList(); } - Widget buildName() => TextFormField( + Widget buildName(TaskwarriorColorTheme tColors) => TextFormField( autofocus: true, controller: homeController.namecontroller, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), decoration: InputDecoration( hintText: SentenceManager( @@ -158,9 +146,7 @@ class AddTaskBottomSheet extends StatelessWidget { .sentences .addTaskEnterTask, hintStyle: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), validator: (name) => name != null && name.isEmpty @@ -171,7 +157,7 @@ class AddTaskBottomSheet extends StatelessWidget { : null, ); - Widget buildDueDate(BuildContext context) => Row( + Widget buildDueDate(BuildContext context, TaskwarriorColorTheme tColors) => Row( children: [ Text( SentenceManager( @@ -179,9 +165,7 @@ class AddTaskBottomSheet extends StatelessWidget { .sentences .addTaskDue, style: GoogleFonts.poppins( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, fontWeight: TaskWarriorFonts.bold, height: 3.3, ), @@ -193,9 +177,7 @@ class AddTaskBottomSheet extends StatelessWidget { style: homeController.inThePast.value ? TextStyle(color: TaskWarriorColors.red) : TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor ), readOnly: true, controller: @@ -208,11 +190,7 @@ class AddTaskBottomSheet extends StatelessWidget { .addTaskTitle, hintStyle: homeController.inThePast.value ? TextStyle(color: TaskWarriorColors.red) - : TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, - ), + : Theme.of(context).textTheme.bodyLarge, contentPadding: const EdgeInsets.symmetric( horizontal: 12.0, vertical: 16.0), ), @@ -220,31 +198,7 @@ class AddTaskBottomSheet extends StatelessWidget { var date = await showDatePicker( builder: (BuildContext context, Widget? child) { return Theme( - data: Theme.of(context).copyWith( - colorScheme: AppSettings.isDarkMode - ? ColorScheme( - brightness: Brightness.dark, - primary: TaskWarriorColors.white, - onPrimary: TaskWarriorColors.black, - secondary: TaskWarriorColors.black, - onSecondary: TaskWarriorColors.white, - error: TaskWarriorColors.red, - onError: TaskWarriorColors.black, - surface: TaskWarriorColors.black, - onSurface: TaskWarriorColors.white, - ) - : ColorScheme( - brightness: Brightness.light, - primary: TaskWarriorColors.black, - onPrimary: TaskWarriorColors.white, - secondary: TaskWarriorColors.white, - onSecondary: TaskWarriorColors.black, - error: TaskWarriorColors.red, - onError: TaskWarriorColors.white, - surface: TaskWarriorColors.white, - onSurface: TaskWarriorColors.black, - ), - ), + data: Theme.of(context), child: child!, ); }, @@ -260,29 +214,7 @@ class AddTaskBottomSheet extends StatelessWidget { return Theme( data: Theme.of(context).copyWith( textTheme: const TextTheme(), - colorScheme: AppSettings.isDarkMode - ? ColorScheme( - brightness: Brightness.dark, - primary: TaskWarriorColors.white, - onPrimary: TaskWarriorColors.black, - secondary: TaskWarriorColors.grey, - onSecondary: TaskWarriorColors.white, - error: TaskWarriorColors.red, - onError: TaskWarriorColors.black, - surface: TaskWarriorColors.black, - onSurface: TaskWarriorColors.white, - ) - : ColorScheme( - brightness: Brightness.light, - primary: TaskWarriorColors.black, - onPrimary: TaskWarriorColors.white, - secondary: TaskWarriorColors.grey, - onSecondary: TaskWarriorColors.black, - error: TaskWarriorColors.red, - onError: TaskWarriorColors.white, - surface: TaskWarriorColors.white, - onSurface: TaskWarriorColors.black, - ), + colorScheme: Theme.of(context).colorScheme ), child: Obx(() => MediaQuery( data: MediaQuery.of(context).copyWith( @@ -324,15 +256,10 @@ class AddTaskBottomSheet extends StatelessWidget { .sentences .addTaskTimeInPast, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor, + color: tColors.primaryTextColor ), ), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors - .kLightSecondaryBackgroundColor, + backgroundColor: tColors.secondaryBackgroundColor, duration: const Duration(seconds: 2))); } else { homeController.inThePast.value = false; @@ -348,7 +275,7 @@ class AddTaskBottomSheet extends StatelessWidget { ], ); - Widget buildPriority() => Column( + Widget buildPriority(TaskwarriorColorTheme tColors) => Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.start, @@ -361,9 +288,7 @@ class AddTaskBottomSheet extends StatelessWidget { .addTaskPriority} :", style: GoogleFonts.poppins( fontWeight: TaskWarriorFonts.bold, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), textAlign: TextAlign.left, ), @@ -388,12 +313,8 @@ class AddTaskBottomSheet extends StatelessWidget { borderRadius: BorderRadius.circular(8), border: Border.all( color: homeController.priority.value == homeController.priorityList[i] - ? AppSettings.isDarkMode - ? TaskWarriorColors.kLightPrimaryBackgroundColor - : TaskWarriorColors.kprimaryBackgroundColor - : AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryBackgroundColor - : TaskWarriorColors.kLightPrimaryBackgroundColor, + ? tColors.primaryTextColor! + : tColors.primaryBackgroundColor!, ) ), child: Center( @@ -421,7 +342,7 @@ class AddTaskBottomSheet extends StatelessWidget { ); Widget buildCancelButton( - BuildContext context, HomeController homeController) => + BuildContext context, HomeController homeController, TaskwarriorColorTheme tColors) => TextButton( child: Text( SentenceManager( @@ -429,9 +350,7 @@ class AddTaskBottomSheet extends StatelessWidget { .sentences .addTaskCancel, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), onPressed: () { @@ -446,6 +365,7 @@ class AddTaskBottomSheet extends StatelessWidget { ); Widget buildAddButton(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return TextButton( child: Text( SentenceManager( @@ -453,9 +373,7 @@ class AddTaskBottomSheet extends StatelessWidget { .sentences .addTaskAdd, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), onPressed: () async { @@ -500,14 +418,10 @@ class AddTaskBottomSheet extends StatelessWidget { .sentences .addTaskTaskAddedSuccessfully, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor, + color: tColors.primaryTextColor, ), ), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, + backgroundColor: tColors.secondaryBackgroundColor, duration: const Duration(seconds: 2))); final SharedPreferences prefs = @@ -525,14 +439,10 @@ class AddTaskBottomSheet extends StatelessWidget { content: Text( e.message, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor, + color: tColors.primaryTextColor, ), ), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, + backgroundColor: tColors.secondaryBackgroundColor, duration: const Duration(seconds: 2))); log(e.toString()); } diff --git a/lib/app/modules/home/views/add_task_to_taskc_bottom_sheet.dart b/lib/app/modules/home/views/add_task_to_taskc_bottom_sheet.dart index ae29a077..47071cf5 100644 --- a/lib/app/modules/home/views/add_task_to_taskc_bottom_sheet.dart +++ b/lib/app/modules/home/views/add_task_to_taskc_bottom_sheet.dart @@ -6,8 +6,7 @@ import 'package:taskwarrior/api_service.dart'; import 'package:taskwarrior/app/modules/home/controllers/home_controller.dart'; import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart'; - -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class AddTaskToTaskcBottomSheet extends StatelessWidget { final HomeController homeController; @@ -16,27 +15,20 @@ class AddTaskToTaskcBottomSheet extends StatelessWidget { @override Widget build(BuildContext context) { const title = 'Add Task'; + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Scaffold( backgroundColor: Colors.transparent, body: Center( child: SingleChildScrollView( child: AlertDialog( - surfaceTintColor: AppSettings.isDarkMode - ? TaskWarriorColors.kdialogBackGroundColor - : TaskWarriorColors.kLightDialogBackGroundColor, - shadowColor: AppSettings.isDarkMode - ? TaskWarriorColors.kdialogBackGroundColor - : TaskWarriorColors.kLightDialogBackGroundColor, - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.kdialogBackGroundColor - : TaskWarriorColors.kLightDialogBackGroundColor, + surfaceTintColor: tColors.dialogBackgroundColor, + shadowColor: tColors.dialogBackgroundColor, + backgroundColor: tColors.dialogBackgroundColor, title: Center( child: Text( title, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ), @@ -48,20 +40,20 @@ class AddTaskToTaskcBottomSheet extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ const SizedBox(height: 8), - buildName(), + buildName(context, tColors), const SizedBox(height: 8), - buildProject(), + buildProject(context, tColors), const SizedBox(height: 12), - buildDueDate(context), + buildDueDate(context, tColors), const SizedBox(height: 8), - buildPriority(), + buildPriority(context, tColors), ], ), ), ), actions: [ - buildCancelButton(context), - buildAddButton(context), + buildCancelButton(context, tColors), + buildAddButton(context, tColors), ], ), ), @@ -69,20 +61,16 @@ class AddTaskToTaskcBottomSheet extends StatelessWidget { ); } - Widget buildName() => TextFormField( + Widget buildName(BuildContext context,TaskwarriorColorTheme tColors) => TextFormField( autofocus: true, controller: homeController.namecontroller, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), decoration: InputDecoration( hintText: 'Enter Task', hintStyle: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), validator: (name) => name != null && name.isEmpty @@ -90,32 +78,26 @@ class AddTaskToTaskcBottomSheet extends StatelessWidget { : null, ); - Widget buildProject() => TextFormField( + Widget buildProject(BuildContext context, TaskwarriorColorTheme tColors) => TextFormField( autofocus: true, controller: homeController.projectcontroller, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), decoration: InputDecoration( hintText: 'Enter Project', hintStyle: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ); - Widget buildDueDate(BuildContext context) => Row( + Widget buildDueDate(BuildContext context, TaskwarriorColorTheme tColors) => Row( children: [ Text( "Due : ", style: GoogleFonts.poppins( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, fontWeight: TaskWarriorFonts.bold, height: 3.3, ), @@ -126,9 +108,7 @@ class AddTaskToTaskcBottomSheet extends StatelessWidget { style: homeController.inThePast.value ? TextStyle(color: TaskWarriorColors.red) : TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), readOnly: true, controller: TextEditingController( @@ -141,40 +121,14 @@ class AddTaskToTaskcBottomSheet extends StatelessWidget { hintStyle: homeController.inThePast.value ? TextStyle(color: TaskWarriorColors.red) : TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), onTap: () async { var date = await showDatePicker( builder: (BuildContext context, Widget? child) { return Theme( - data: Theme.of(context).copyWith( - colorScheme: AppSettings.isDarkMode - ? ColorScheme( - brightness: Brightness.dark, - primary: TaskWarriorColors.white, - onPrimary: TaskWarriorColors.black, - secondary: TaskWarriorColors.black, - onSecondary: TaskWarriorColors.white, - error: TaskWarriorColors.red, - onError: TaskWarriorColors.black, - surface: TaskWarriorColors.black, - onSurface: TaskWarriorColors.white, - ) - : ColorScheme( - brightness: Brightness.light, - primary: TaskWarriorColors.black, - onPrimary: TaskWarriorColors.white, - secondary: TaskWarriorColors.white, - onSecondary: TaskWarriorColors.black, - error: TaskWarriorColors.red, - onError: TaskWarriorColors.white, - surface: TaskWarriorColors.white, - onSurface: TaskWarriorColors.black, - ), - ), + data: Theme.of(context), child: child!, ); }, @@ -190,29 +144,7 @@ class AddTaskToTaskcBottomSheet extends StatelessWidget { return Theme( data: Theme.of(context).copyWith( textTheme: const TextTheme(), - colorScheme: AppSettings.isDarkMode - ? ColorScheme( - brightness: Brightness.dark, - primary: TaskWarriorColors.white, - onPrimary: TaskWarriorColors.black, - secondary: TaskWarriorColors.black, - onSecondary: TaskWarriorColors.white, - error: TaskWarriorColors.red, - onError: TaskWarriorColors.black, - surface: TaskWarriorColors.black, - onSurface: TaskWarriorColors.white, - ) - : ColorScheme( - brightness: Brightness.light, - primary: TaskWarriorColors.black, - onPrimary: TaskWarriorColors.white, - secondary: TaskWarriorColors.white, - onSecondary: TaskWarriorColors.black, - error: TaskWarriorColors.red, - onError: TaskWarriorColors.white, - surface: TaskWarriorColors.white, - onSurface: TaskWarriorColors.black, - ), + colorScheme: Theme.of(context).colorScheme ), child: MediaQuery( data: MediaQuery.of(context).copyWith( @@ -243,15 +175,10 @@ class AddTaskToTaskcBottomSheet extends StatelessWidget { content: Text( "The selected time is in the past.", style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor, + color: tColors.primaryTextColor, ), ), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors - .kLightSecondaryBackgroundColor, + backgroundColor: tColors.secondaryBackgroundColor, duration: const Duration(seconds: 2))); } else { homeController.inThePast.value = false; @@ -265,7 +192,7 @@ class AddTaskToTaskcBottomSheet extends StatelessWidget { ], ); - Widget buildPriority() => Column( + Widget buildPriority(BuildContext context, TaskwarriorColorTheme tColors) => Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.start, @@ -275,28 +202,20 @@ class AddTaskToTaskcBottomSheet extends StatelessWidget { 'Priority : ', style: GoogleFonts.poppins( fontWeight: TaskWarriorFonts.bold, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), textAlign: TextAlign.left, ), DropdownButton( - dropdownColor: AppSettings.isDarkMode - ? TaskWarriorColors.kdialogBackGroundColor - : TaskWarriorColors.kLightDialogBackGroundColor, + dropdownColor: tColors.dialogBackgroundColor, value: homeController.priority.value, elevation: 16, style: GoogleFonts.poppins( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), underline: Container( height: 1.5, - color: AppSettings.isDarkMode - ? TaskWarriorColors.kdialogBackGroundColor - : TaskWarriorColors.kLightDialogBackGroundColor, + color: tColors.dialogBackgroundColor, ), onChanged: (String? newValue) { homeController.priority.value = newValue!; @@ -314,26 +233,22 @@ class AddTaskToTaskcBottomSheet extends StatelessWidget { ], ); - Widget buildCancelButton(BuildContext context) => TextButton( + Widget buildCancelButton(BuildContext context, TaskwarriorColorTheme tColors) => TextButton( child: Text( 'Cancel', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), onPressed: () => Navigator.of(context).pop("cancel"), ); - Widget buildAddButton(BuildContext context) { + Widget buildAddButton(BuildContext context, TaskwarriorColorTheme tColors) { return TextButton( child: Text( "Add", style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), onPressed: () async { @@ -360,14 +275,10 @@ class AddTaskToTaskcBottomSheet extends StatelessWidget { content: Text( 'Task Added Successfully!', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor, + color: tColors.primaryTextColor, ), ), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, + backgroundColor: tColors.primaryBackgroundColor, duration: const Duration(seconds: 2))); Navigator.of(context).pop(); } diff --git a/lib/app/modules/home/views/filter_drawer_home_page.dart b/lib/app/modules/home/views/filter_drawer_home_page.dart index fe2f95a3..329de674 100644 --- a/lib/app/modules/home/views/filter_drawer_home_page.dart +++ b/lib/app/modules/home/views/filter_drawer_home_page.dart @@ -12,6 +12,7 @@ import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart'; import 'package:taskwarrior/app/utils/gen/fonts.gen.dart'; import 'package:taskwarrior/app/utils/language/sentence_manager.dart'; import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class FilterDrawer extends StatelessWidget { final Filters filters; @@ -23,16 +24,13 @@ class FilterDrawer extends StatelessWidget { Widget build(BuildContext context) { homeController.initFilterDrawerTour(); homeController.showFilterDrawerTour(context); + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; var tileColor = AppSettings.isDarkMode ? TaskWarriorColors.ksecondaryBackgroundColor : TaskWarriorColors.kLightPrimaryBackgroundColor; return Drawer( - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryBackgroundColor - : TaskWarriorColors.kLightPrimaryBackgroundColor, - surfaceTintColor: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryBackgroundColor - : TaskWarriorColors.kLightPrimaryBackgroundColor, + backgroundColor: tColors.dialogBackgroundColor, + surfaceTintColor: tColors.primaryBackgroundColor, child: SafeArea( child: Padding( padding: const EdgeInsets.all(8), @@ -63,9 +61,7 @@ class FilterDrawer extends StatelessWidget { style: TextStyle( fontFamily: FontFamily.poppins, fontWeight: TaskWarriorFonts.bold, - color: (AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor), + color: tColors.primaryTextColor, fontSize: TaskWarriorFonts.fontSizeExtraLarge, ), ), @@ -97,9 +93,7 @@ class FilterDrawer extends StatelessWidget { style: TextStyle( fontFamily: FontFamily.poppins, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, )), TextSpan( text: filters.pendingFilter @@ -116,17 +110,13 @@ class FilterDrawer extends StatelessWidget { style: TextStyle( fontFamily: FontFamily.poppins, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, )), ], ), ), onTap: filters.togglePendingFilter, - textColor: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightSecondaryTextColor, + textColor: tColors.primaryTextColor, ), ), const Divider( @@ -158,9 +148,7 @@ class FilterDrawer extends StatelessWidget { style: TextStyle( fontFamily: FontFamily.poppins, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightSecondaryTextColor, + color: tColors.primaryTextColor, )), Switch( value: filters.waitingFilter, @@ -262,9 +250,7 @@ class FilterDrawer extends StatelessWidget { style: TextStyle( fontFamily: FontFamily.poppins, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightSecondaryTextColor, + color: tColors.primaryTextColor, ), ), ), @@ -321,9 +307,7 @@ class FilterDrawer extends StatelessWidget { style: TextStyle( fontFamily: FontFamily.poppins, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, )), ), const Divider( @@ -445,9 +429,7 @@ class FilterDrawer extends StatelessWidget { style: TextStyle( fontFamily: FontFamily.poppins, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, )), ), ), diff --git a/lib/app/modules/home/views/home_page_app_bar.dart b/lib/app/modules/home/views/home_page_app_bar.dart index f5aac06d..295075d5 100644 --- a/lib/app/modules/home/views/home_page_app_bar.dart +++ b/lib/app/modules/home/views/home_page_app_bar.dart @@ -10,7 +10,7 @@ import 'package:taskwarrior/app/utils/language/sentence_manager.dart'; import 'package:taskwarrior/app/utils/taskchampion/credentials_storage.dart'; import 'package:taskwarrior/app/utils/taskchampion/taskchampion.dart'; import 'package:taskwarrior/app/utils/taskserver/taskserver.dart'; -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; import '../controllers/home_controller.dart'; @@ -26,6 +26,7 @@ class HomePageAppBar extends StatelessWidget implements PreferredSizeWidget { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return AppBar( backgroundColor: TaskWarriorColors.kprimaryBackgroundColor, surfaceTintColor: TaskWarriorColors.kprimaryBackgroundColor, @@ -83,9 +84,7 @@ class HomePageAppBar extends StatelessWidget implements PreferredSizeWidget { } catch (e) { ScaffoldMessenger.of(context).showSnackBar( SnackBar( - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, + backgroundColor: tColors.secondaryBackgroundColor, content: Text( SentenceManager( currentLanguage: @@ -93,9 +92,7 @@ class HomePageAppBar extends StatelessWidget implements PreferredSizeWidget { .sentences .homePageTaskWarriorNotConfigured, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), action: SnackBarAction( @@ -119,9 +116,7 @@ class HomePageAppBar extends StatelessWidget implements PreferredSizeWidget { } else if (c == null || e == null) { ScaffoldMessenger.of(context).showSnackBar( SnackBar( - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, + backgroundColor: tColors.secondaryBackgroundColor, content: Text( SentenceManager( currentLanguage: @@ -129,9 +124,7 @@ class HomePageAppBar extends StatelessWidget implements PreferredSizeWidget { .sentences .homePageTaskWarriorNotConfigured, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), action: SnackBarAction( @@ -158,6 +151,7 @@ class HomePageAppBar extends StatelessWidget implements PreferredSizeWidget { } else { ScaffoldMessenger.of(context).showSnackBar( SnackBar( + backgroundColor: tColors.secondaryBackgroundColor, content: Obx( () => Text( SentenceManager( @@ -166,9 +160,7 @@ class HomePageAppBar extends StatelessWidget implements PreferredSizeWidget { .sentences .homePageTaskWarriorNotConfigured, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ), diff --git a/lib/app/modules/home/views/home_page_body.dart b/lib/app/modules/home/views/home_page_body.dart index 5f1a3700..cd0c5517 100644 --- a/lib/app/modules/home/views/home_page_body.dart +++ b/lib/app/modules/home/views/home_page_body.dart @@ -1,14 +1,10 @@ import 'package:double_back_to_close_app/double_back_to_close_app.dart'; import 'package:flutter/material.dart'; - import 'package:get/get.dart'; import 'package:taskwarrior/app/modules/home/views/show_tasks.dart'; - import 'package:taskwarrior/app/modules/home/views/tasks_builder.dart'; -import 'package:taskwarrior/app/utils/constants/palette.dart'; import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; - +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; import '../controllers/home_controller.dart'; class HomePageBody extends StatelessWidget { @@ -19,12 +15,11 @@ class HomePageBody extends StatelessWidget { Widget build(BuildContext context) { controller.initInAppTour(); controller.showInAppTour(context); + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return DoubleBackToCloseApp( snackBar: const SnackBar(content: Text('Tap back again to exit')), child: Container( - color: AppSettings.isDarkMode - ? Palette.kToDark.shade200 - : TaskWarriorColors.white, + color: tColors.dialogBackgroundColor, child: Padding( padding: const EdgeInsets.only(left: 8.0, right: 8.0), child: Obx( @@ -36,9 +31,9 @@ class HomePageBody extends StatelessWidget { horizontal: 10, vertical: 10), child: SearchBar( backgroundColor: WidgetStateProperty.all( - (TaskWarriorColors.kLightPrimaryBackgroundColor)), + (tColors.primaryBackgroundColor!)), surfaceTintColor: WidgetStateProperty.all( - (TaskWarriorColors.kLightPrimaryBackgroundColor)), + (tColors.primaryBackgroundColor!)), controller: controller.searchController, // shape:, onChanged: (value) { @@ -51,7 +46,7 @@ class HomePageBody extends StatelessWidget { return RoundedRectangleBorder( borderRadius: BorderRadius.circular(12.0), side: BorderSide( - color: TaskWarriorColors.black, + color: tColors.primaryTextColor!, width: 2.0, ), ); @@ -59,7 +54,7 @@ class HomePageBody extends StatelessWidget { return RoundedRectangleBorder( borderRadius: BorderRadius.circular(12.0), side: BorderSide( - color: TaskWarriorColors.black, + color: tColors.primaryTextColor!, width: 1.5, ), ); diff --git a/lib/app/modules/home/views/home_page_floating_action_button.dart b/lib/app/modules/home/views/home_page_floating_action_button.dart index 8a0c32aa..bc76d36f 100644 --- a/lib/app/modules/home/views/home_page_floating_action_button.dart +++ b/lib/app/modules/home/views/home_page_floating_action_button.dart @@ -1,11 +1,7 @@ import 'package:flutter/material.dart'; - import 'package:taskwarrior/app/modules/home/views/add_task_bottom_sheet.dart'; import 'package:taskwarrior/app/modules/home/views/add_task_to_taskc_bottom_sheet.dart'; - -import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; - +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; import '../controllers/home_controller.dart'; class HomePageFloatingActionButton extends StatelessWidget { @@ -14,19 +10,16 @@ class HomePageFloatingActionButton extends StatelessWidget { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return FloatingActionButton( key: controller.addKey, heroTag: "btn3", - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.kLightPrimaryBackgroundColor - : TaskWarriorColors.kprimaryBackgroundColor, + backgroundColor: tColors.primaryTextColor, child: Tooltip( message: 'Add Task', child: Icon( Icons.add, - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryBackgroundColor - : TaskWarriorColors.white, + color: tColors.secondaryBackgroundColor, ), ), onPressed: () => (controller.taskchampion.value) diff --git a/lib/app/modules/home/views/home_page_nav_drawer_menu_item.dart b/lib/app/modules/home/views/home_page_nav_drawer_menu_item.dart index 22d0f0a9..435a54a6 100644 --- a/lib/app/modules/home/views/home_page_nav_drawer_menu_item.dart +++ b/lib/app/modules/home/views/home_page_nav_drawer_menu_item.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; -import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; +import 'package:taskwarrior/app/utils/constants/constants.dart'; import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class NavDrawerMenuItem extends StatelessWidget { final IconData icon; @@ -17,28 +17,23 @@ class NavDrawerMenuItem extends StatelessWidget { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return InkWell( onTap: onTap, child: Container( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryBackgroundColor - : TaskWarriorColors.kLightPrimaryBackgroundColor, + color: tColors.dialogBackgroundColor, padding: const EdgeInsets.symmetric(vertical: 18, horizontal: 10), child: Row( children: [ Icon( icon, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), const SizedBox(width: 10), Text( text, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, fontSize: TaskWarriorFonts.fontSizeMedium, ), ), diff --git a/lib/app/modules/home/views/nav_drawer.dart b/lib/app/modules/home/views/nav_drawer.dart index 0a3d36dc..d1f71cf5 100644 --- a/lib/app/modules/home/views/nav_drawer.dart +++ b/lib/app/modules/home/views/nav_drawer.dart @@ -8,11 +8,14 @@ import 'package:taskwarrior/app/modules/home/views/home_page_nav_drawer_menu_ite import 'package:taskwarrior/app/modules/home/views/theme_clipper.dart'; import 'package:taskwarrior/app/modules/reports/views/reports_view_taskc.dart'; import 'package:taskwarrior/app/routes/app_pages.dart'; -import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; +import 'package:taskwarrior/app/utils/constants/constants.dart'; import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart'; import 'package:taskwarrior/app/utils/constants/utilites.dart'; import 'package:taskwarrior/app/utils/language/sentence_manager.dart'; import 'package:taskwarrior/app/utils/taskchampion/taskchampion.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; +import 'package:taskwarrior/app/utils/themes/dark_theme.dart'; +import 'package:taskwarrior/app/utils/themes/light_theme.dart'; class NavDrawer extends StatelessWidget { final HomeController homeController; @@ -20,24 +23,17 @@ class NavDrawer extends StatelessWidget { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Drawer( - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryBackgroundColor - : TaskWarriorColors.kLightPrimaryBackgroundColor, - surfaceTintColor: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryBackgroundColor - : TaskWarriorColors.kLightPrimaryBackgroundColor, + backgroundColor: tColors.dialogBackgroundColor, + surfaceTintColor: tColors.dialogBackgroundColor, child: Container( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryBackgroundColor - : TaskWarriorColors.kLightPrimaryBackgroundColor, + color: tColors.dialogBackgroundColor, child: ListView( padding: EdgeInsets.zero, children: [ Container( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryBackgroundColor - : TaskWarriorColors.kLightPrimaryBackgroundColor, + color: tColors.dialogBackgroundColor, padding: const EdgeInsets.only(top: 50, left: 15, right: 10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -51,9 +47,7 @@ class NavDrawer extends StatelessWidget { style: TextStyle( fontSize: TaskWarriorFonts.fontSizeExtraLarge, fontWeight: TaskWarriorFonts.bold, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), Padding( @@ -61,18 +55,16 @@ class NavDrawer extends StatelessWidget { child: ThemeSwitcherClipper( isDarkMode: AppSettings.isDarkMode, onTap: (bool newMode) async { + Get.changeThemeMode(newMode ? ThemeMode.dark : ThemeMode.light); AppSettings.isDarkMode = newMode; await SelectedTheme.saveMode(AppSettings.isDarkMode); // Get.back(); homeController.initLanguageAndDarkMode(); + Get.changeTheme(AppSettings.isDarkMode ? darkTheme : lightTheme); }, child: Icon( - AppSettings.isDarkMode - ? Icons.dark_mode - : Icons.light_mode, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + tColors.icons, + color: tColors.primaryTextColor, size: 15, ), ), @@ -81,9 +73,7 @@ class NavDrawer extends StatelessWidget { ), ), Container( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryBackgroundColor - : TaskWarriorColors.kLightPrimaryBackgroundColor, + color: tColors.dialogBackgroundColor, height: Get.height * 0.03, ), Visibility( @@ -120,9 +110,7 @@ class NavDrawer extends StatelessWidget { homeController.selectedLanguage.value, ).sentences.deleteTaskConfirmation, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), content: Text( @@ -131,9 +119,7 @@ class NavDrawer extends StatelessWidget { homeController.selectedLanguage.value, ).sentences.deleteTaskWarning, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryDisabledTextColor, ), ), actions: [ @@ -141,9 +127,7 @@ class NavDrawer extends StatelessWidget { child: Text( 'Cancel', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), onPressed: () { @@ -154,9 +138,7 @@ class NavDrawer extends StatelessWidget { child: Text( 'Confirm', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), onPressed: () { @@ -263,6 +245,7 @@ class NavDrawer extends StatelessWidget { } Future _showExitConfirmationDialog(BuildContext context) async { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return showDialog( context: context, barrierDismissible: @@ -275,9 +258,7 @@ class NavDrawer extends StatelessWidget { .sentences .homePageExitApp, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), content: Text( @@ -286,9 +267,7 @@ class NavDrawer extends StatelessWidget { .sentences .homePageAreYouSureYouWantToExit, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), actions: [ @@ -299,9 +278,7 @@ class NavDrawer extends StatelessWidget { .sentences .homePageCancel, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), onPressed: () { @@ -315,9 +292,7 @@ class NavDrawer extends StatelessWidget { .sentences .homePageExit, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), onPressed: () { diff --git a/lib/app/modules/home/views/project_column_home_page.dart b/lib/app/modules/home/views/project_column_home_page.dart index bfc1c665..9c371f19 100644 --- a/lib/app/modules/home/views/project_column_home_page.dart +++ b/lib/app/modules/home/views/project_column_home_page.dart @@ -2,11 +2,10 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart'; import 'package:taskwarrior/app/utils/gen/fonts.gen.dart'; import 'package:taskwarrior/app/utils/taskfunctions/projects.dart'; -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class ProjectsColumn extends StatelessWidget { const ProjectsColumn({ @@ -22,6 +21,7 @@ class ProjectsColumn extends StatelessWidget { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Column( children: [ Padding( @@ -36,9 +36,7 @@ class ProjectsColumn extends StatelessWidget { fontFamily: FontFamily.poppins, fontWeight: TaskWarriorFonts.bold, fontSize: TaskWarriorFonts.fontSizeSmall, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), SizedBox( @@ -53,9 +51,7 @@ class ProjectsColumn extends StatelessWidget { style: TextStyle( fontFamily: FontFamily.poppins, fontSize: TaskWarriorFonts.fontSizeSmall, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ], @@ -74,9 +70,7 @@ class ProjectsColumn extends StatelessWidget { style: TextStyle( fontFamily: FontFamily.poppins, fontSize: TaskWarriorFonts.fontSizeSmall, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, )), ], ), @@ -98,9 +92,7 @@ class ProjectsColumn extends StatelessWidget { style: TextStyle( fontFamily: FontFamily.poppins, fontSize: TaskWarriorFonts.fontSizeSmall, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), SizedBox( @@ -129,6 +121,8 @@ class ProjectTile extends StatelessWidget { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; + var node = projects[project]!; var title = Row( @@ -138,30 +132,24 @@ class ProjectTile extends StatelessWidget { child: Text( project, style: GoogleFonts.poppins( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black), - ), + color: tColors.primaryTextColor, + ), + ) ), Text( (node.children.isEmpty) ? '${node.subtasks}' : '(${node.tasks}) ${node.subtasks}', style: GoogleFonts.poppins( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black), + color: tColors.primaryTextColor + ), ) ], ); var radio = Radio( - activeColor: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.ksecondaryBackgroundColor, - focusColor: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.ksecondaryBackgroundColor, + activeColor: tColors.primaryTextColor, + focusColor: tColors.secondaryTextColor, toggleable: true, value: project, groupValue: projectFilter, @@ -198,9 +186,7 @@ class ProjectTile extends StatelessWidget { : '(${node.tasks}) ${node.subtasks}', maxLines: 1, style: GoogleFonts.poppins( - color: AppSettings.isDarkMode - ? TaskWarriorColors.black - : TaskWarriorColors.white, + color: tColors.primaryTextColor, ), ), ), @@ -212,12 +198,8 @@ class ProjectTile extends StatelessWidget { key: PageStorageKey(project), leading: radio, title: title, - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.ksecondaryBackgroundColor, - textColor: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.ksecondaryBackgroundColor, + backgroundColor: tColors.primaryTextColor, + textColor: tColors.primaryTextColor, children: node.children .map((childProject) => ProjectTile( project: childProject, diff --git a/lib/app/modules/home/views/show_details.dart b/lib/app/modules/home/views/show_details.dart index b85daeb2..0c433621 100644 --- a/lib/app/modules/home/views/show_details.dart +++ b/lib/app/modules/home/views/show_details.dart @@ -6,7 +6,7 @@ import 'package:intl/intl.dart'; import 'package:taskwarrior/api_service.dart'; import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; import 'package:taskwarrior/app/utils/constants/utilites.dart'; -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class TaskDetails extends StatefulWidget { final Tasks task; @@ -50,6 +50,7 @@ class _TaskDetailsState extends State { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return WillPopScope( onWillPop: () async { if (hasChanges) { @@ -63,9 +64,7 @@ class _TaskDetailsState extends State { return Future.value(true); }, child: Scaffold( - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryBackgroundColor - : TaskWarriorColors.kLightPrimaryBackgroundColor, + backgroundColor: tColors.primaryBackgroundColor, appBar: AppBar( foregroundColor: TaskWarriorColors.lightGrey, backgroundColor: TaskWarriorColors.kprimaryBackgroundColor, @@ -167,21 +166,7 @@ class _TaskDetailsState extends State { lastDate: DateTime(2101), builder: (BuildContext context, Widget? child) { return Theme( - data: Theme.of(context).copyWith( - colorScheme: AppSettings.isDarkMode - ? ColorScheme.dark( - primary: TaskWarriorColors.white, - onPrimary: TaskWarriorColors.black, - surface: TaskWarriorColors.black, - onSurface: TaskWarriorColors.white, - ) - : ColorScheme.light( - primary: TaskWarriorColors.black, - onPrimary: TaskWarriorColors.white, - surface: TaskWarriorColors.white, - onSurface: TaskWarriorColors.black, - ), - ), + data: Theme.of(context), child: child!, ); }, @@ -208,12 +193,11 @@ class _TaskDetailsState extends State { } Widget _buildDetail(String label, String value) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Container( width: double.infinity, decoration: BoxDecoration( - color: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, + color: tColors.secondaryBackgroundColor, borderRadius: BorderRadius.circular(8.0), boxShadow: const [ BoxShadow( @@ -234,9 +218,7 @@ class _TaskDetailsState extends State { style: TextStyle( fontWeight: FontWeight.bold, fontSize: 18, - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightSecondaryTextColor, + color: tColors.primaryTextColor, ), ), const SizedBox(width: 8), @@ -245,9 +227,7 @@ class _TaskDetailsState extends State { value, style: TextStyle( fontSize: 18, - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightSecondaryTextColor, + color: tColors.primaryTextColor, ), ), ), @@ -258,6 +238,7 @@ class _TaskDetailsState extends State { Future _showEditDialog( BuildContext context, String label, String initialValue) async { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; final TextEditingController controller = TextEditingController(text: initialValue); return await showDialog( @@ -267,22 +248,19 @@ class _TaskDetailsState extends State { title: Text( 'Edit $label', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor), + color: tColors.primaryTextColor + ), ), content: TextField( style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor), + color: tColors.primaryTextColor + ), controller: controller, decoration: InputDecoration( hintText: 'Enter new $label', hintStyle: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor), + color: tColors.primaryTextColor + ), ), ), actions: [ @@ -293,9 +271,8 @@ class _TaskDetailsState extends State { child: Text( 'Cancel', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor), + color: tColors.primaryTextColor + ), ), ), TextButton( @@ -305,9 +282,8 @@ class _TaskDetailsState extends State { child: Text( 'Save', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor), + color: tColors.primaryTextColor + ), ), ), ], @@ -318,6 +294,7 @@ class _TaskDetailsState extends State { Future _showSelectDialog(BuildContext context, String label, String initialValue, List options) async { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return await showDialog( context: context, builder: (context) { @@ -325,9 +302,8 @@ class _TaskDetailsState extends State { title: Text( 'Select $label', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor), + color: tColors.primaryTextColor + ), ), content: Column( mainAxisSize: MainAxisSize.min, @@ -336,9 +312,8 @@ class _TaskDetailsState extends State { title: Text( option, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor), + color: tColors.primaryTextColor + ), ), value: option, groupValue: initialValue, @@ -369,6 +344,7 @@ class _TaskDetailsState extends State { Future _showUnsavedChangesDialog( BuildContext context) async { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return showDialog( context: context, barrierDismissible: false, @@ -377,16 +353,13 @@ class _TaskDetailsState extends State { title: Text( 'Unsaved Changes', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor), + color: tColors.primaryTextColor), ), content: Text( 'You have unsaved changes. What would you like to do?', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor), + color: tColors.primaryTextColor + ), ), actions: [ TextButton( diff --git a/lib/app/modules/home/views/show_tasks.dart b/lib/app/modules/home/views/show_tasks.dart index da694964..f32076e2 100644 --- a/lib/app/modules/home/views/show_tasks.dart +++ b/lib/app/modules/home/views/show_tasks.dart @@ -5,11 +5,9 @@ import 'package:google_fonts/google_fonts.dart'; import 'package:taskwarrior/api_service.dart'; import 'package:taskwarrior/app/modules/home/controllers/home_controller.dart'; import 'package:taskwarrior/app/modules/home/views/show_details.dart'; -import 'package:taskwarrior/app/utils/constants/palette.dart'; import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart'; - -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class TaskViewBuilder extends StatelessWidget { const TaskViewBuilder({ @@ -26,7 +24,8 @@ class TaskViewBuilder extends StatelessWidget { @override Widget build(BuildContext context) { final HomeController taskController = Get.find(); - + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; + return Obx(() { List tasks = List.from(taskController.tasks); // Filter tasks based on the selected project @@ -79,9 +78,7 @@ class TaskViewBuilder extends StatelessWidget { }); return Scaffold( - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryBackgroundColor - : TaskWarriorColors.kLightPrimaryBackgroundColor, + backgroundColor: tColors.dialogBackgroundColor, body: tasks.isEmpty ? Padding( padding: const EdgeInsets.all(16.0), @@ -91,9 +88,7 @@ class TaskViewBuilder extends StatelessWidget { textAlign: TextAlign.center, style: GoogleFonts.poppins( fontSize: TaskWarriorFonts.fontSizeLarge, - color: AppSettings.isDarkMode - ? TaskWarriorColors.kLightPrimaryBackgroundColor - : TaskWarriorColors.kprimaryBackgroundColor, + color: tColors.primaryTextColor, ), ), ), @@ -121,10 +116,7 @@ class TaskViewBuilder extends StatelessWidget { content: Text( 'Task Marked As Completed. Refresh to view changes!', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors - .kLightPrimaryTextColor, + color: tColors.primaryTextColor, ), ), ), @@ -147,10 +139,7 @@ class TaskViewBuilder extends StatelessWidget { content: Text( 'Task Marked As Deleted. Refresh to view changes!', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors - .kLightPrimaryTextColor, + color: tColors.primaryTextColor, ), ), ), @@ -163,13 +152,9 @@ class TaskViewBuilder extends StatelessWidget { ], ), child: Card( - color: AppSettings.isDarkMode - ? Palette.kToDark - : TaskWarriorColors.white, + color: tColors.secondaryBackgroundColor, child: InkWell( - splashColor: AppSettings.isDarkMode - ? TaskWarriorColors.black - : TaskWarriorColors.borderColor, + splashColor: tColors.primaryBackgroundColor, onTap: () => Navigator.push( context, MaterialPageRoute( @@ -179,13 +164,9 @@ class TaskViewBuilder extends StatelessWidget { child: Container( decoration: BoxDecoration( border: Border.all( - color: AppSettings.isDarkMode - ? TaskWarriorColors.borderColor - : TaskWarriorColors.black, + color: tColors.primaryTextColor!, ), - color: AppSettings.isDarkMode - ? Palette.kToDark - : TaskWarriorColors.white, + color: tColors.primaryBackgroundColor, borderRadius: BorderRadius.circular(8.0), boxShadow: const [ BoxShadow( @@ -206,19 +187,13 @@ class TaskViewBuilder extends StatelessWidget { maxLines: 1, overflow: TextOverflow.ellipsis, style: GoogleFonts.poppins( - color: AppSettings.isDarkMode - ? TaskWarriorColors - .kLightDialogBackGroundColor - : TaskWarriorColors.kprimaryBackgroundColor, + color: tColors.dialogBackgroundColor, ), ), subtitle: Text( 'Urgency: ${task.urgency!.floorToDouble()} | Status: ${task.status}', style: GoogleFonts.poppins( - color: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryTextColor - : TaskWarriorColors - .kLightSecondaryTextColor, + color: tColors.secondaryTextColor, ), ), ), diff --git a/lib/app/modules/home/views/tas_list_item.dart b/lib/app/modules/home/views/tas_list_item.dart index 38911a47..e8420b81 100644 --- a/lib/app/modules/home/views/tas_list_item.dart +++ b/lib/app/modules/home/views/tas_list_item.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:taskwarrior/app/models/json/task.dart'; -import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart'; import 'package:taskwarrior/app/utils/gen/fonts.gen.dart'; import 'package:taskwarrior/app/utils/language/sentence_manager.dart'; @@ -8,7 +7,7 @@ import 'package:taskwarrior/app/utils/language/supported_language.dart'; import 'package:taskwarrior/app/utils/taskfunctions/datetime_differences.dart'; import 'package:taskwarrior/app/utils/taskfunctions/modify.dart'; import 'package:taskwarrior/app/utils/taskfunctions/urgency.dart'; -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class TaskListItem extends StatelessWidget { const TaskListItem( @@ -16,7 +15,6 @@ class TaskListItem extends StatelessWidget { this.pendingFilter = false, this.waitingFilter = false, super.key, - required this.darkmode, required this.useDelayTask, required this.modify, required this.selectedLanguage, @@ -25,13 +23,13 @@ class TaskListItem extends StatelessWidget { final Task task; final bool pendingFilter; final bool waitingFilter; - final bool darkmode; final Modify modify; final bool useDelayTask; final SupportedLanguage selectedLanguage; @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; // ignore: unused_element void saveChanges() async { var now = DateTime.now().toUtc(); @@ -42,14 +40,10 @@ class TaskListItem extends StatelessWidget { content: Text( 'Task Updated', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor, + color: tColors.primaryTextColor, ), ), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, + backgroundColor: tColors.secondaryBackgroundColor, duration: const Duration(seconds: 2))); } @@ -60,11 +54,8 @@ class TaskListItem extends StatelessWidget { } MaterialColor colours = Colors.grey; - var colour = darkmode ? Colors.white : Colors.black; - var dimColor = darkmode - ? const Color.fromARGB(137, 248, 248, 248) - : const Color.fromARGB(136, 17, 17, 17); - + Color colour =tColors.primaryTextColor!; + Color dimColor = tColors.dimCol!; if (task.priority == 'H') { colours = Colors.red; } else if (task.priority == 'M') { diff --git a/lib/app/modules/home/views/tasks_builder.dart b/lib/app/modules/home/views/tasks_builder.dart index d17c5875..5b165118 100644 --- a/lib/app/modules/home/views/tasks_builder.dart +++ b/lib/app/modules/home/views/tasks_builder.dart @@ -11,14 +11,13 @@ import 'package:taskwarrior/app/modules/home/controllers/widget.controller.dart' import 'package:taskwarrior/app/modules/home/views/tas_list_item.dart'; import 'package:taskwarrior/app/routes/app_pages.dart'; import 'package:taskwarrior/app/services/notification_services.dart'; -import 'package:taskwarrior/app/utils/constants/palette.dart'; import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart'; import 'package:taskwarrior/app/utils/gen/fonts.gen.dart'; import 'package:taskwarrior/app/utils/language/sentence_manager.dart'; import 'package:taskwarrior/app/utils/language/supported_language.dart'; import 'package:taskwarrior/app/utils/taskfunctions/modify.dart'; -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class TasksBuilder extends StatelessWidget { const TasksBuilder({ @@ -41,7 +40,6 @@ class TasksBuilder extends StatelessWidget { final SupportedLanguage selectedLanguage; final ScrollController scrollController; final bool showbtn; - void setStatus(BuildContext context, String newValue, String id) { var storageWidget = Get.find(); Modify modify = Modify( @@ -55,23 +53,19 @@ class TasksBuilder extends StatelessWidget { void saveChanges( BuildContext context, Modify modify, String id, String newValue) async { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; var now = DateTime.now().toUtc(); modify.save( modified: () => now, ); - ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text( 'Task Updated', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor, + color: tColors.primaryTextColor, ), ), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, + backgroundColor: tColors.secondaryBackgroundColor, duration: const Duration(seconds: 2), action: SnackBarAction( label: 'Undo', @@ -115,11 +109,12 @@ class TasksBuilder extends StatelessWidget { @override Widget build(BuildContext context) { // print(taskData); + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; var storageWidget = Get.find(); return Scaffold( floatingActionButtonLocation: FloatingActionButtonLocation.miniStartFloat, - floatingActionButton: AnimatedOpacity( + floatingActionButton: showbtn ? AnimatedOpacity( duration: const Duration(milliseconds: 100), //show/hide animation opacity: showbtn ? 1.0 : 0.0, //set obacity to 1 on visible, or hide child: FloatingActionButton( @@ -133,17 +128,13 @@ class TasksBuilder extends StatelessWidget { curve: Curves.fastLinearToSlowEaseIn //scroll type ); }, - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.kLightPrimaryBackgroundColor - : TaskWarriorColors.kprimaryBackgroundColor, + backgroundColor: tColors.primaryTextColor, child: Icon( Icons.arrow_upward, - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryBackgroundColor - : TaskWarriorColors.kLightPrimaryBackgroundColor, + color: tColors.secondaryBackgroundColor, ), ), - ), + ) : null, backgroundColor: Colors.transparent, body: Obx( () => taskData.isEmpty @@ -160,9 +151,8 @@ class TasksBuilder extends StatelessWidget { style: TextStyle( fontFamily: FontFamily.poppins, fontSize: TaskWarriorFonts.fontSizeLarge, - color: AppSettings.isDarkMode - ? TaskWarriorColors.kLightPrimaryBackgroundColor - : TaskWarriorColors.kprimaryBackgroundColor), + color: tColors.primaryTextColor + ), // style: GoogleFonts.poppins( // fontSize: TaskWarriorFonts.fontSizeLarge, // color: AppSettings.isDarkMode @@ -231,13 +221,9 @@ class TasksBuilder extends StatelessWidget { ], ), child: Card( - color: AppSettings.isDarkMode - ? Palette.kToDark - : TaskWarriorColors.white, + color: tColors.secondaryBackgroundColor, child: InkWell( - splashColor: AppSettings.isDarkMode - ? TaskWarriorColors.black - : TaskWarriorColors.borderColor, + splashColor: tColors.secondaryBackgroundColor, onTap: () { Get.toNamed(Routes.DETAIL_ROUTE, arguments: ["uuid", task.uuid]); @@ -252,7 +238,6 @@ class TasksBuilder extends StatelessWidget { child: TaskListItem( task, pendingFilter: pendingFilter, - darkmode: AppSettings.isDarkMode, useDelayTask: useDelayTask, modify: Modify( getTask: storageWidget.getTask, @@ -265,13 +250,9 @@ class TasksBuilder extends StatelessWidget { ), ) : Card( - color: AppSettings.isDarkMode - ? Palette.kToDark - : TaskWarriorColors.white, + color: tColors.secondaryBackgroundColor, child: InkWell( - splashColor: AppSettings.isDarkMode - ? TaskWarriorColors.black - : TaskWarriorColors.borderColor, + splashColor: tColors.secondaryBackgroundColor, onTap: () { Get.toNamed(Routes.DETAIL_ROUTE, arguments: ["uuid", task.uuid]); @@ -280,7 +261,6 @@ class TasksBuilder extends StatelessWidget { child: TaskListItem( task, pendingFilter: pendingFilter, - darkmode: AppSettings.isDarkMode, useDelayTask: useDelayTask, modify: Modify( getTask: storageWidget.getTask, diff --git a/lib/app/modules/manageTaskServer/views/manage_task_server_page_app_bar.dart b/lib/app/modules/manageTaskServer/views/manage_task_server_page_app_bar.dart index a7ab40c1..edeab819 100644 --- a/lib/app/modules/manageTaskServer/views/manage_task_server_page_app_bar.dart +++ b/lib/app/modules/manageTaskServer/views/manage_task_server_page_app_bar.dart @@ -16,6 +16,7 @@ import 'package:taskwarrior/app/utils/gen/fonts.gen.dart'; import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; import 'package:taskwarrior/app/utils/language/sentence_manager.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -28,6 +29,7 @@ class ManageTaskServerPageAppBar extends StatelessWidget @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return AppBar( backgroundColor: TaskWarriorColors.kprimaryBackgroundColor, titleSpacing: 0, @@ -96,9 +98,7 @@ class ManageTaskServerPageAppBar extends StatelessWidget title: Text( 'Fetching statistics...', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), content: Column( @@ -109,9 +109,7 @@ class ManageTaskServerPageAppBar extends StatelessWidget Text( 'Please wait...', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ], @@ -155,9 +153,7 @@ class ManageTaskServerPageAppBar extends StatelessWidget Text( '${'$key:'.padRight(maxKeyLength + 1)} ${header[key]}', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ], @@ -169,9 +165,7 @@ class ManageTaskServerPageAppBar extends StatelessWidget ElevatedButton( style: ButtonStyle( backgroundColor: WidgetStateProperty.all( - AppSettings.isDarkMode - ? TaskWarriorColors.kLightSecondaryBackgroundColor - : TaskWarriorColors.ksecondaryBackgroundColor, + tColors.secondaryTextColor!, ), ), onPressed: () { @@ -181,9 +175,7 @@ class ManageTaskServerPageAppBar extends StatelessWidget child: Text( 'Ok', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.black - : TaskWarriorColors.white, + color: tColors.secondaryBackgroundColor, ), ), ), @@ -202,14 +194,10 @@ class ManageTaskServerPageAppBar extends StatelessWidget ? "Please set up your TaskServer." : e.toString(), style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor, + color: tColors.primaryTextColor, ), ), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, + backgroundColor: tColors.secondaryBackgroundColor, duration: const Duration(seconds: 2))); // Log the error and trace logError(e, trace); diff --git a/lib/app/modules/manageTaskServer/views/manage_task_server_page_body.dart b/lib/app/modules/manageTaskServer/views/manage_task_server_page_body.dart index 25e2a76d..ee5d0457 100644 --- a/lib/app/modules/manageTaskServer/views/manage_task_server_page_body.dart +++ b/lib/app/modules/manageTaskServer/views/manage_task_server_page_body.dart @@ -11,6 +11,7 @@ import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart'; import 'package:taskwarrior/app/utils/language/sentence_manager.dart'; import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class ManageTaskServerPageBody extends StatelessWidget { final ManageTaskServerController controller; @@ -20,6 +21,7 @@ class ManageTaskServerPageBody extends StatelessWidget { Widget build(BuildContext context) { controller.initManageTaskServerPageTour(); controller.showManageTaskServerPageTour(context); + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Padding( padding: const EdgeInsets.only(left: 20, right: 20), child: ListView( @@ -41,9 +43,7 @@ class ManageTaskServerPageBody extends StatelessWidget { .sentences .manageTaskServerPageConfigureTASKRC, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), const SizedBox(height: 10), @@ -52,9 +52,7 @@ class ManageTaskServerPageBody extends StatelessWidget { showModalBottomSheet( context: context, isScrollControlled: true, - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.kdialogBackGroundColor - : TaskWarriorColors.kLightDialogBackGroundColor, + backgroundColor: tColors.dialogBackgroundColor, builder: (context) { return StatefulBuilder( builder: @@ -89,9 +87,7 @@ class ManageTaskServerPageBody extends StatelessWidget { .manageTaskServerPageConfigureTaskRCDialogueBoxTitle, style: TextStyle( fontWeight: TaskWarriorFonts.bold, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), Text( @@ -101,9 +97,7 @@ class ManageTaskServerPageBody extends StatelessWidget { .sentences .manageTaskServerPageConfigureTaskRCDialogueBoxSubtitle, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), const SizedBox(height: 16.0), @@ -113,21 +107,15 @@ class ManageTaskServerPageBody extends StatelessWidget { height: Get.height * 0.15, child: TextField( style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors - .black), + color: tColors.primaryTextColor + ), controller: controller .taskrcContentController, maxLines: 8, decoration: InputDecoration( counterStyle: TextStyle( - color: - AppSettings.isDarkMode - ? TaskWarriorColors - .white - : TaskWarriorColors - .black), + color: tColors.primaryTextColor + ), suffixIconConstraints: const BoxConstraints( maxHeight: 24, @@ -143,18 +131,15 @@ class ManageTaskServerPageBody extends StatelessWidget { Icons.content_paste), ), border: - const OutlineInputBorder(), - labelStyle: GoogleFonts.poppins( - color: - AppSettings.isDarkMode - ? TaskWarriorColors - .white - : TaskWarriorColors - .black), + const OutlineInputBorder(), + labelStyle: GoogleFonts.poppins( + color:tColors.primaryTextColor, + ), labelText: SentenceManager( currentLanguage: AppSettings - .selectedLanguage) + .selectedLanguage + ) .sentences .manageTaskServerPageConfigureTaskRCDialogueBoxInputFieldText, ), @@ -168,21 +153,13 @@ class ManageTaskServerPageBody extends StatelessWidget { .sentences .manageTaskServerPageConfigureTaskRCDialogueBoxOr, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), FilledButton.tonal( style: ButtonStyle( - backgroundColor: AppSettings - .isDarkMode - ? WidgetStateProperty.all< - Color>( - TaskWarriorColors.black) - : WidgetStateProperty.all< - Color>( - TaskWarriorColors.white)), + backgroundColor: WidgetStateProperty.all(tColors.secondaryBackgroundColor!) + ), onPressed: () async { await setConfig( storage: controller.storage, @@ -198,9 +175,7 @@ class ManageTaskServerPageBody extends StatelessWidget { .sentences .manageTaskServerPageConfigureTaskRCDialogueBoxSelectTaskRC, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ), @@ -240,19 +215,14 @@ class ManageTaskServerPageBody extends StatelessWidget { .sentences .manageTaskServerPageTaskRCFileIsVerified, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), Container( height: 30, width: 30, decoration: BoxDecoration( - color: AppSettings.isDarkMode - ? TaskWarriorColors - .kLightSecondaryBackgroundColor - : TaskWarriorColors.ksecondaryBackgroundColor, + color: tColors.secondaryTextColor, shape: BoxShape.circle, ), child: Center( @@ -264,9 +234,7 @@ class ManageTaskServerPageBody extends StatelessWidget { ) : Icon( Icons.chevron_right_rounded, - color: AppSettings.isDarkMode - ? TaskWarriorColors.black - : TaskWarriorColors.white, + color: tColors.secondaryBackgroundColor, ), ), ), @@ -293,9 +261,7 @@ class ManageTaskServerPageBody extends StatelessWidget { Text( "TaskD Server Info", style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), const SizedBox(height: 10), @@ -319,28 +285,20 @@ class ManageTaskServerPageBody extends StatelessWidget { ? Text( 'Not Configured', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ) : Text( '${controller.server}', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), Container( height: 30, width: 30, decoration: BoxDecoration( - color: AppSettings.isDarkMode - ? TaskWarriorColors - .kLightSecondaryBackgroundColor - : TaskWarriorColors - .ksecondaryBackgroundColor, + color: tColors.secondaryTextColor, shape: BoxShape.circle, ), child: Center( @@ -351,9 +309,7 @@ class ManageTaskServerPageBody extends StatelessWidget { ) : Icon( Icons.chevron_right_rounded, - color: AppSettings.isDarkMode - ? TaskWarriorColors.black - : TaskWarriorColors.white, + color: tColors.secondaryBackgroundColor, ), ), ), @@ -376,9 +332,7 @@ class ManageTaskServerPageBody extends StatelessWidget { Text( "TaskD Server Credentials", style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), const SizedBox(height: 10), @@ -401,9 +355,7 @@ class ManageTaskServerPageBody extends StatelessWidget { ? Text( 'Not Configured', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ) : SizedBox( @@ -415,9 +367,7 @@ class ManageTaskServerPageBody extends StatelessWidget { child: Text( controller.credentialsString!.value, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ), @@ -431,27 +381,19 @@ class ManageTaskServerPageBody extends StatelessWidget { height: 30, width: 30, decoration: BoxDecoration( - color: AppSettings.isDarkMode - ? TaskWarriorColors - .kLightPrimaryBackgroundColor - : TaskWarriorColors - .kprimaryBackgroundColor, + color: tColors.primaryTextColor, shape: BoxShape.circle, ), child: controller.credentials == null ? Icon( Icons.chevron_right_rounded, - color: AppSettings.isDarkMode - ? TaskWarriorColors.black - : TaskWarriorColors.white, + color: tColors.primaryBackgroundColor, ) : Icon( controller.hideKey.value ? Icons.visibility_off : Icons.visibility, - color: AppSettings.isDarkMode - ? TaskWarriorColors.green - : TaskWarriorColors.green, + color: TaskWarriorColors.green, ), ), ), diff --git a/lib/app/modules/manageTaskServer/views/manage_task_server_view.dart b/lib/app/modules/manageTaskServer/views/manage_task_server_view.dart index ea49a3d1..4e2f5703 100644 --- a/lib/app/modules/manageTaskServer/views/manage_task_server_view.dart +++ b/lib/app/modules/manageTaskServer/views/manage_task_server_view.dart @@ -6,9 +6,7 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:taskwarrior/app/modules/manageTaskServer/views/manage_task_server_page_app_bar.dart'; import 'package:taskwarrior/app/modules/manageTaskServer/views/manage_task_server_page_body.dart'; -import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; - -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; import '../controllers/manage_task_server_controller.dart'; @@ -16,11 +14,10 @@ class ManageTaskServerView extends GetView { const ManageTaskServerView({super.key}); @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Scaffold( appBar: ManageTaskServerPageAppBar(controller: controller), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryBackgroundColor - : TaskWarriorColors.kLightPrimaryBackgroundColor, + backgroundColor: tColors.primaryBackgroundColor, body: ManageTaskServerPageBody(controller: controller), ); } diff --git a/lib/app/modules/manageTaskServer/views/pem_widget.dart b/lib/app/modules/manageTaskServer/views/pem_widget.dart index e84f7a31..9806ffc0 100644 --- a/lib/app/modules/manageTaskServer/views/pem_widget.dart +++ b/lib/app/modules/manageTaskServer/views/pem_widget.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import 'package:pem/pem.dart'; import 'package:taskwarrior/app/models/storage.dart'; import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class PemWidget extends StatelessWidget { const PemWidget({ @@ -29,6 +29,7 @@ class PemWidget extends StatelessWidget { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; String fingerprint(String pemContents) { var firstCertificateBlock = decodePemBlocks( PemLabel.certificate, @@ -49,9 +50,7 @@ class PemWidget extends StatelessWidget { debugPrint(e.toString()); } - var tileColor = AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor; + var tileColor = tColors.primaryBackgroundColor; return Padding( key: globalKey, padding: const EdgeInsets.only( @@ -65,9 +64,7 @@ class PemWidget extends StatelessWidget { Text( optionString, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), const SizedBox( @@ -135,9 +132,7 @@ class PemWidget extends StatelessWidget { ? '' : "$name = ", style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), Text( @@ -147,9 +142,7 @@ class PemWidget extends StatelessWidget { : "" : identifier, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ], @@ -160,18 +153,14 @@ class PemWidget extends StatelessWidget { height: 30, width: 30, decoration: BoxDecoration( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kLightSecondaryBackgroundColor - : TaskWarriorColors.ksecondaryBackgroundColor, + color: tColors.secondaryTextColor, shape: BoxShape.circle, ), child: Center( child: name == null ? Icon( Icons.chevron_right_rounded, - color: AppSettings.isDarkMode - ? TaskWarriorColors.black - : TaskWarriorColors.white, + color: tColors.secondaryBackgroundColor, ) : Icon( Icons.check, diff --git a/lib/app/modules/profile/views/deleteprofiledialog.dart b/lib/app/modules/profile/views/deleteprofiledialog.dart index 9a762eea..1e860146 100644 --- a/lib/app/modules/profile/views/deleteprofiledialog.dart +++ b/lib/app/modules/profile/views/deleteprofiledialog.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:taskwarrior/app/modules/splash/controllers/splash_controller.dart'; -import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; import 'package:taskwarrior/app/utils/constants/utilites.dart'; import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; import 'package:taskwarrior/app/utils/language/sentence_manager.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class DeleteProfileDialog extends StatelessWidget { const DeleteProfileDialog({ @@ -18,6 +18,7 @@ class DeleteProfileDialog extends StatelessWidget { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Center( child: SingleChildScrollView( child: Center( @@ -29,9 +30,7 @@ class DeleteProfileDialog extends StatelessWidget { .sentences .profilePageDeleteProfile, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), // content: TextField(controller: controller), @@ -44,13 +43,11 @@ class DeleteProfileDialog extends StatelessWidget { child: Text( 'Cancel', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ), - ElevatedButton( + TextButton( onPressed: () { try { Get.find().deleteProfile(profile); @@ -60,38 +57,25 @@ class DeleteProfileDialog extends StatelessWidget { content: Text( 'Profile: ${profile.characters} Deleted Successfully', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor, + color: tColors.primaryTextColor, ), ), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, + backgroundColor: tColors.secondaryBackgroundColor, duration: const Duration(seconds: 2))); } catch (e) { ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text( 'Profile: ${profile.characters} Deletion Failed', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor, + color: tColors.primaryTextColor, ), ), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, + backgroundColor: tColors.secondaryBackgroundColor, duration: const Duration(seconds: 2))); } }, - child: Text( - 'Confirm', - style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.black - : TaskWarriorColors.black, - ), + child: const Text( + 'Confirm' ), ), ], diff --git a/lib/app/modules/profile/views/manageprofile.dart b/lib/app/modules/profile/views/manageprofile.dart index b5b40a3a..bcd70501 100644 --- a/lib/app/modules/profile/views/manageprofile.dart +++ b/lib/app/modules/profile/views/manageprofile.dart @@ -1,12 +1,12 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart'; import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; import 'package:taskwarrior/app/utils/language/sentence_manager.dart'; import 'package:tuple/tuple.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class ManageProfile extends StatelessWidget { const ManageProfile( @@ -28,6 +28,7 @@ class ManageProfile extends StatelessWidget { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; var triples = [ Tuple3( Icons.edit, @@ -68,21 +69,11 @@ class ManageProfile extends StatelessWidget { return ExpansionTile( key: manageSelectedProfileKey, - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, - iconColor: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, - collapsedIconColor: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, - collapsedTextColor: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.ksecondaryBackgroundColor, - textColor: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + backgroundColor: tColors.secondaryBackgroundColor, + iconColor: tColors.primaryTextColor, + collapsedIconColor: tColors.primaryTextColor, + collapsedTextColor: tColors.primaryTextColor, + textColor: tColors.primaryTextColor, title: Text( SentenceManager(currentLanguage: AppSettings.selectedLanguage) .sentences @@ -90,20 +81,14 @@ class ManageProfile extends StatelessWidget { style: GoogleFonts.poppins( fontWeight: TaskWarriorFonts.bold, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), children: [ for (var triple in triples) ListTile( - textColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryTextColor - : TaskWarriorColors.kLightSecondaryTextColor, - iconColor: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.kLightSecondaryTextColor, + textColor: tColors.secondaryTextColor, + iconColor: tColors.secondaryTextColor, leading: Padding( padding: const EdgeInsets.all(12), child: Icon(triple.item1), diff --git a/lib/app/modules/profile/views/profile_view.dart b/lib/app/modules/profile/views/profile_view.dart index 8a224b6d..9a869767 100644 --- a/lib/app/modules/profile/views/profile_view.dart +++ b/lib/app/modules/profile/views/profile_view.dart @@ -8,12 +8,12 @@ import 'package:taskwarrior/app/modules/profile/views/manageprofile.dart'; import 'package:taskwarrior/app/modules/profile/views/renameprofiledialog.dart'; import 'package:taskwarrior/app/modules/profile/views/selectprofile.dart'; import 'package:taskwarrior/app/routes/app_pages.dart'; -import 'package:taskwarrior/app/utils/constants/palette.dart'; import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; import 'package:taskwarrior/app/utils/constants/utilites.dart'; import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; import 'package:taskwarrior/app/utils/language/sentence_manager.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; import '../controllers/profile_controller.dart'; @@ -23,9 +23,10 @@ class ProfileView extends GetView { Widget build(BuildContext context) { controller.initProfilePageTour(); controller.showProfilePageTour(context); + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Scaffold( appBar: AppBar( - backgroundColor: Palette.kToDark.shade200, + backgroundColor: TaskWarriorColors.appBarColor, title: Obx(() => Text( controller.profilesMap.length == 1 ? SentenceManager( @@ -54,9 +55,7 @@ class ProfileView extends GetView { ), ), //primary: false, - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryBackgroundColor - : TaskWarriorColors.kLightPrimaryBackgroundColor, + backgroundColor: tColors.primaryBackgroundColor, body: SingleChildScrollView( child: Column( children: [ @@ -108,9 +107,7 @@ class ProfileView extends GetView { .sentences .profilePageExportTasksDialogueTitle, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), content: Text( @@ -119,9 +116,7 @@ class ProfileView extends GetView { .sentences .profilePageExportTasksDialogueSubtitle, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), actions: [ @@ -129,9 +124,7 @@ class ProfileView extends GetView { child: Text( "JSON", style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), onPressed: () { @@ -147,9 +140,7 @@ class ProfileView extends GetView { child: Text( "TXT", style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), onPressed: () { @@ -175,28 +166,20 @@ class ProfileView extends GetView { content: Text( 'Profile Config Copied', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, + backgroundColor: tColors.secondaryBackgroundColor, duration: const Duration(seconds: 2))); } catch (e) { ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text( 'Profile Config Copy Failed', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, + backgroundColor: tColors.secondaryBackgroundColor, duration: const Duration(seconds: 2))); } }, @@ -248,6 +231,7 @@ class ProfilesColumn extends StatelessWidget { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Padding( padding: const EdgeInsets.only(top: 10.0), child: Column( @@ -283,14 +267,10 @@ class ProfilesColumn extends StatelessWidget { content: Text( 'Profile Added Successfully', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor, + color: tColors.primaryTextColor, ), ), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, + backgroundColor: tColors.secondaryBackgroundColor, duration: const Duration(seconds: 2)), ); // Get.find().update(); @@ -300,14 +280,10 @@ class ProfilesColumn extends StatelessWidget { content: Text( 'Profile Additon Failed', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor, + color: tColors.primaryTextColor, ), ), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, + backgroundColor: tColors.secondaryBackgroundColor, duration: const Duration(seconds: 2), ), ); @@ -315,15 +291,12 @@ class ProfilesColumn extends StatelessWidget { }, style: ButtonStyle( backgroundColor: WidgetStateProperty.all( - AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, + tColors.secondaryBackgroundColor!, ), ), icon: Icon(Icons.add, - color: AppSettings.isDarkMode - ? TaskWarriorColors.deepPurpleAccent - : TaskWarriorColors.deepPurple), + color: tColors.purpleShade + ), label: Text( SentenceManager( currentLanguage: AppSettings.selectedLanguage) @@ -331,9 +304,7 @@ class ProfilesColumn extends StatelessWidget { .profilePageAddNewProfile, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ) diff --git a/lib/app/modules/profile/views/renameprofiledialog.dart b/lib/app/modules/profile/views/renameprofiledialog.dart index b74a3350..7930d9b1 100644 --- a/lib/app/modules/profile/views/renameprofiledialog.dart +++ b/lib/app/modules/profile/views/renameprofiledialog.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:taskwarrior/app/modules/splash/controllers/splash_controller.dart'; -import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; import 'package:taskwarrior/app/utils/constants/utilites.dart'; import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; import 'package:taskwarrior/app/utils/language/sentence_manager.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class RenameProfileDialog extends StatelessWidget { const RenameProfileDialog({ @@ -22,7 +22,7 @@ class RenameProfileDialog extends StatelessWidget { @override Widget build(BuildContext context) { var controller = TextEditingController(text: alias); - + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return SingleChildScrollView( child: Center( child: Utils.showAlertDialog( @@ -33,16 +33,12 @@ class RenameProfileDialog extends StatelessWidget { .sentences .profilePageRenameAliasDialogueBoxTitle, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), content: TextField( style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), controller: controller), actions: [ @@ -56,13 +52,11 @@ class RenameProfileDialog extends StatelessWidget { .sentences .profilePageRenameAliasDialogueBoxCancel, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ), - ElevatedButton( + TextButton( onPressed: () { Get.find().renameProfile( profile: profile, @@ -75,11 +69,6 @@ class RenameProfileDialog extends StatelessWidget { SentenceManager(currentLanguage: AppSettings.selectedLanguage) .sentences .profilePageRenameAliasDialogueBoxSubmit, - style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.black - : TaskWarriorColors.black, - ), ), ), ], diff --git a/lib/app/modules/profile/views/selectprofile.dart b/lib/app/modules/profile/views/selectprofile.dart index 4b192cc8..683272e3 100644 --- a/lib/app/modules/profile/views/selectprofile.dart +++ b/lib/app/modules/profile/views/selectprofile.dart @@ -3,11 +3,11 @@ import 'package:get/get.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:taskwarrior/app/modules/home/controllers/home_controller.dart'; -import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart'; import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; import 'package:taskwarrior/app/utils/language/sentence_manager.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class SelectProfile extends StatelessWidget { const SelectProfile( @@ -25,23 +25,14 @@ class SelectProfile extends StatelessWidget { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Obx(() => ExpansionTile( // key: currentProfileKey, - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, - iconColor: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, - collapsedIconColor: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, - collapsedTextColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryTextColor - : TaskWarriorColors.kLightSecondaryTextColor, - textColor: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + backgroundColor: tColors.secondaryBackgroundColor, + iconColor: tColors.primaryTextColor, + collapsedIconColor: tColors.primaryTextColor, + collapsedTextColor: tColors.secondaryTextColor, + textColor: tColors.primaryTextColor, title: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -55,9 +46,7 @@ class SelectProfile extends StatelessWidget { style: GoogleFonts.poppins( fontWeight: TaskWarriorFonts.bold, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), SizedBox( @@ -66,9 +55,7 @@ class SelectProfile extends StatelessWidget { Text(currentProfile, style: GoogleFonts.poppins( fontSize: TaskWarriorFonts.fontSizeSmall, - color: AppSettings.isDarkMode - ? TaskWarriorColors.grey - : TaskWarriorColors.lightGrey, + color: tColors.greyShade, )) ], ), @@ -87,9 +74,7 @@ class SelectProfile extends StatelessWidget { fontWeight: TaskWarriorFonts.bold, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ], @@ -126,6 +111,7 @@ class SelectProfileListTile extends StatelessWidget { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, @@ -141,25 +127,17 @@ class SelectProfileListTile extends StatelessWidget { content: Text( 'Switched to Profile ${alias ?? uuid}', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor, + color: tColors.primaryTextColor, ), ), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, + backgroundColor: tColors.secondaryBackgroundColor, duration: const Duration(seconds: 2), ), ); Get.find().refreshTaskWithNewProfile(); }, - activeColor: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.ksecondaryBackgroundColor, - focusColor: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.ksecondaryBackgroundColor, + activeColor: tColors.primaryTextColor, + focusColor: tColors.primaryTextColor, ), Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -176,9 +154,7 @@ class SelectProfileListTile extends StatelessWidget { alias!, overflow: TextOverflow.fade, style: GoogleFonts.poppins( - color: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryTextColor - : TaskWarriorColors.kLightSecondaryTextColor, + color: tColors.secondaryTextColor, fontSize: TaskWarriorFonts.fontSizeMedium ), ), @@ -190,9 +166,7 @@ class SelectProfileListTile extends StatelessWidget { child: Text( uuid, style: GoogleFonts.poppins( - color: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryTextColor - : TaskWarriorColors.kLightSecondaryTextColor, + color: tColors.secondaryTextColor, fontSize: TaskWarriorFonts.fontSizeSmall ), ), diff --git a/lib/app/modules/reports/views/burn_down_daily.dart b/lib/app/modules/reports/views/burn_down_daily.dart index e57096a8..08b5cc6b 100644 --- a/lib/app/modules/reports/views/burn_down_daily.dart +++ b/lib/app/modules/reports/views/burn_down_daily.dart @@ -9,6 +9,7 @@ import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart'; import 'package:taskwarrior/app/utils/gen/fonts.gen.dart'; import 'package:taskwarrior/app/utils/language/sentence_manager.dart'; import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class BurnDownDaily extends StatelessWidget { final ReportsController reportsController; @@ -17,7 +18,7 @@ class BurnDownDaily extends StatelessWidget { @override Widget build(BuildContext context) { double height = MediaQuery.of(context).size.height; - + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, @@ -36,9 +37,7 @@ class BurnDownDaily extends StatelessWidget { textStyle: TextStyle( fontFamily: FontFamily.poppins, fontWeight: TaskWarriorFonts.bold, - color: AppSettings.isDarkMode - ? Colors.white - : Colors.black, + color: tColors.primaryTextColor, fontSize: TaskWarriorFonts.fontSizeSmall, ), ), @@ -49,9 +48,7 @@ class BurnDownDaily extends StatelessWidget { textStyle: TextStyle( fontFamily: FontFamily.poppins, fontWeight: TaskWarriorFonts.bold, - color: AppSettings.isDarkMode - ? Colors.white - : Colors.black, + color: tColors.primaryTextColor, fontSize: TaskWarriorFonts.fontSizeSmall, ), ), diff --git a/lib/app/modules/reports/views/burn_down_daily_taskc.dart b/lib/app/modules/reports/views/burn_down_daily_taskc.dart index afdb5395..a7bc81e2 100644 --- a/lib/app/modules/reports/views/burn_down_daily_taskc.dart +++ b/lib/app/modules/reports/views/burn_down_daily_taskc.dart @@ -7,8 +7,7 @@ import 'package:taskwarrior/app/modules/reports/views/common_chart_indicator.dar import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart'; import 'package:taskwarrior/app/utils/constants/utilites.dart'; - -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class BurnDownDailyTaskc extends StatelessWidget { BurnDownDailyTaskc({super.key}); @@ -82,7 +81,7 @@ class BurnDownDailyTaskc extends StatelessWidget { @override Widget build(BuildContext context) { double height = MediaQuery.of(context).size.height; // Screen height - + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return FutureBuilder>>( future: fetchDailyInfo(), builder: (context, snapshot) { @@ -109,9 +108,7 @@ class BurnDownDailyTaskc extends StatelessWidget { text: 'Day - Month', textStyle: GoogleFonts.poppins( fontWeight: TaskWarriorFonts.bold, - color: AppSettings.isDarkMode - ? Colors.white - : Colors.black, + color: tColors.primaryTextColor, fontSize: TaskWarriorFonts.fontSizeSmall, ), ), @@ -122,9 +119,7 @@ class BurnDownDailyTaskc extends StatelessWidget { textStyle: GoogleFonts.poppins( fontWeight: TaskWarriorFonts.bold, fontSize: TaskWarriorFonts.fontSizeSmall, - color: AppSettings.isDarkMode - ? Colors.white - : Colors.black, + color: tColors.primaryTextColor, ), ), ), diff --git a/lib/app/modules/reports/views/burn_down_monthly.dart b/lib/app/modules/reports/views/burn_down_monthly.dart index 86a055ca..36f5e61f 100644 --- a/lib/app/modules/reports/views/burn_down_monthly.dart +++ b/lib/app/modules/reports/views/burn_down_monthly.dart @@ -8,6 +8,7 @@ import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart'; import 'package:taskwarrior/app/utils/gen/fonts.gen.dart'; import 'package:taskwarrior/app/utils/language/sentence_manager.dart'; import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class BurnDownMonthly extends StatelessWidget { final ReportsController reportsController; @@ -16,6 +17,7 @@ class BurnDownMonthly extends StatelessWidget { @override Widget build(BuildContext context) { var height = Get.height; + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, @@ -35,7 +37,7 @@ class BurnDownMonthly extends StatelessWidget { fontWeight: TaskWarriorFonts.bold, fontSize: TaskWarriorFonts.fontSizeSmall, color: - AppSettings.isDarkMode ? Colors.white : Colors.black, + tColors.primaryTextColor, )), ), primaryYAxis: NumericAxis( @@ -49,7 +51,7 @@ class BurnDownMonthly extends StatelessWidget { fontWeight: TaskWarriorFonts.bold, fontSize: TaskWarriorFonts.fontSizeSmall, color: - AppSettings.isDarkMode ? Colors.white : Colors.black, + tColors.primaryTextColor, )), ), tooltipBehavior: diff --git a/lib/app/modules/reports/views/burn_down_monthly_taskc.dart b/lib/app/modules/reports/views/burn_down_monthly_taskc.dart index 852dd9ea..d62061cc 100644 --- a/lib/app/modules/reports/views/burn_down_monthly_taskc.dart +++ b/lib/app/modules/reports/views/burn_down_monthly_taskc.dart @@ -7,8 +7,7 @@ import 'package:taskwarrior/app/modules/reports/views/common_chart_indicator.dar import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart'; import 'package:taskwarrior/app/utils/constants/utilites.dart'; - -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class BurnDownMonthlyTaskc extends StatelessWidget { BurnDownMonthlyTaskc({super.key}); @@ -89,7 +88,7 @@ class BurnDownMonthlyTaskc extends StatelessWidget { @override Widget build(BuildContext context) { final double height = MediaQuery.of(context).size.height; - + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return FutureBuilder>>( future: fetchMonthlyInfo(), builder: (context, snapshot) { @@ -116,9 +115,7 @@ class BurnDownMonthlyTaskc extends StatelessWidget { textStyle: GoogleFonts.poppins( fontWeight: TaskWarriorFonts.bold, fontSize: TaskWarriorFonts.fontSizeSmall, - color: AppSettings.isDarkMode - ? Colors.white - : Colors.black, + color: tColors.primaryTextColor, ), ), ), @@ -128,9 +125,7 @@ class BurnDownMonthlyTaskc extends StatelessWidget { textStyle: GoogleFonts.poppins( fontWeight: TaskWarriorFonts.bold, fontSize: TaskWarriorFonts.fontSizeSmall, - color: AppSettings.isDarkMode - ? Colors.white - : Colors.black, + color: tColors.primaryTextColor, ), ), ), diff --git a/lib/app/modules/reports/views/burn_down_weekly.dart b/lib/app/modules/reports/views/burn_down_weekly.dart index 9b4b2d55..fb6ca614 100644 --- a/lib/app/modules/reports/views/burn_down_weekly.dart +++ b/lib/app/modules/reports/views/burn_down_weekly.dart @@ -11,6 +11,7 @@ import 'package:taskwarrior/app/utils/constants/utilites.dart'; import 'package:taskwarrior/app/utils/gen/fonts.gen.dart'; import 'package:taskwarrior/app/utils/language/sentence_manager.dart'; import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class BurnDownWeekly extends StatelessWidget { final ReportsController reportsController; @@ -18,6 +19,7 @@ class BurnDownWeekly extends StatelessWidget { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; var height = Get.height; return Column( mainAxisAlignment: MainAxisAlignment.center, @@ -38,7 +40,7 @@ class BurnDownWeekly extends StatelessWidget { fontWeight: TaskWarriorFonts.bold, fontSize: TaskWarriorFonts.fontSizeSmall, color: - AppSettings.isDarkMode ? Colors.white : Colors.black, + tColors.primaryTextColor, )), ), primaryYAxis: NumericAxis( @@ -49,7 +51,7 @@ class BurnDownWeekly extends StatelessWidget { fontWeight: TaskWarriorFonts.bold, fontSize: TaskWarriorFonts.fontSizeSmall, color: - AppSettings.isDarkMode ? Colors.white : Colors.black, + tColors.primaryTextColor, )), ), tooltipBehavior: reportsController.weeklyBurndownTooltipBehaviour, diff --git a/lib/app/modules/reports/views/burn_down_weekly_taskc.dart b/lib/app/modules/reports/views/burn_down_weekly_taskc.dart index eec58af8..8987a2bb 100644 --- a/lib/app/modules/reports/views/burn_down_weekly_taskc.dart +++ b/lib/app/modules/reports/views/burn_down_weekly_taskc.dart @@ -7,8 +7,7 @@ import 'package:taskwarrior/app/modules/reports/views/common_chart_indicator.dar import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart'; import 'package:taskwarrior/app/utils/constants/utilites.dart'; - -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class BurnDownWeeklyTask extends StatelessWidget { BurnDownWeeklyTask({super.key}); @@ -96,6 +95,7 @@ class BurnDownWeeklyTask extends StatelessWidget { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; double height = MediaQuery.of(context).size.height; // Screen height return FutureBuilder>>( future: fetchWeeklyInfo(), @@ -124,9 +124,7 @@ class BurnDownWeeklyTask extends StatelessWidget { textStyle: GoogleFonts.poppins( fontWeight: TaskWarriorFonts.bold, fontSize: TaskWarriorFonts.fontSizeSmall, - color: AppSettings.isDarkMode - ? Colors.white - : Colors.black, + color: tColors.primaryTextColor, ), ), ), @@ -135,9 +133,7 @@ class BurnDownWeeklyTask extends StatelessWidget { text: 'Tasks', textStyle: GoogleFonts.poppins( fontWeight: TaskWarriorFonts.bold, - color: AppSettings.isDarkMode - ? Colors.white - : Colors.black, + color: tColors.primaryTextColor, fontSize: TaskWarriorFonts.fontSizeSmall, ), ), diff --git a/lib/app/modules/reports/views/common_chart_indicator.dart b/lib/app/modules/reports/views/common_chart_indicator.dart index d7202e0f..bd5b90f9 100644 --- a/lib/app/modules/reports/views/common_chart_indicator.dart +++ b/lib/app/modules/reports/views/common_chart_indicator.dart @@ -4,6 +4,7 @@ import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart'; import 'package:taskwarrior/app/utils/gen/fonts.gen.dart'; import 'package:taskwarrior/app/utils/language/sentence_manager.dart'; import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class CommonChartIndicator extends StatelessWidget { final String title; @@ -11,6 +12,7 @@ class CommonChartIndicator extends StatelessWidget { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Column( children: [ Row( @@ -21,7 +23,7 @@ class CommonChartIndicator extends StatelessWidget { style: TextStyle( fontFamily: FontFamily.poppins, fontWeight: TaskWarriorFonts.bold, - color: AppSettings.isDarkMode ? Colors.white : Colors.black, + color: tColors.primaryTextColor, fontSize: TaskWarriorFonts.fontSizeMedium, ), ) @@ -47,7 +49,7 @@ class CommonChartIndicator extends StatelessWidget { style: TextStyle( fontFamily: FontFamily.poppins, fontWeight: TaskWarriorFonts.regular, - color: AppSettings.isDarkMode ? Colors.white : Colors.black, + color: tColors.primaryTextColor, fontSize: TaskWarriorFonts.fontSizeSmall, ), ), @@ -67,7 +69,7 @@ class CommonChartIndicator extends StatelessWidget { style: TextStyle( fontFamily: FontFamily.poppins, fontWeight: TaskWarriorFonts.regular, - color: AppSettings.isDarkMode ? Colors.white : Colors.black, + color: tColors.primaryTextColor, fontSize: TaskWarriorFonts.fontSizeSmall, ), ), diff --git a/lib/app/modules/reports/views/reports_view.dart b/lib/app/modules/reports/views/reports_view.dart index 2d240d68..55c59608 100644 --- a/lib/app/modules/reports/views/reports_view.dart +++ b/lib/app/modules/reports/views/reports_view.dart @@ -9,6 +9,7 @@ import 'package:taskwarrior/app/utils/constants/constants.dart'; import 'package:taskwarrior/app/utils/gen/fonts.gen.dart'; import 'package:taskwarrior/app/utils/language/sentence_manager.dart'; import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; import '../controllers/reports_controller.dart'; @@ -20,7 +21,7 @@ class ReportsView extends GetView { controller.initReportsTour(); controller.showReportsTour(context); double height = MediaQuery.of(context).size.height; - + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Scaffold( appBar: AppBar( backgroundColor: TaskWarriorColors.kprimaryBackgroundColor, @@ -43,14 +44,12 @@ class ReportsView extends GetView { preferredSize: Size.fromHeight(height * 0.1), child: TabBar( controller: controller.tabController, - labelColor: TaskWarriorColors.white, - labelStyle: GoogleFonts.poppins( - fontWeight: TaskWarriorFonts.medium, - fontSize: TaskWarriorFonts.fontSizeSmall, - ), unselectedLabelStyle: GoogleFonts.poppins( fontWeight: TaskWarriorFonts.light, + color: TaskWarriorColors.appBarUnSelectedIconsColorForReports ), + indicatorColor: tColors.purpleShade, + labelColor: TaskWarriorColors.white, onTap: (value) { controller.selectedIndex.value = value; }, @@ -86,9 +85,7 @@ class ReportsView extends GetView { ), ), ), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryBackgroundColor - : TaskWarriorColors.white, + backgroundColor: tColors.primaryBackgroundColor, body: Obx( () => controller.allData.isEmpty ? Column( @@ -97,9 +94,7 @@ class ReportsView extends GetView { children: [ Icon( Icons.heart_broken, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), Row( mainAxisAlignment: MainAxisAlignment.center, @@ -113,9 +108,7 @@ class ReportsView extends GetView { fontFamily: FontFamily.poppins, fontWeight: TaskWarriorFonts.medium, fontSize: TaskWarriorFonts.fontSizeSmall, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ], @@ -132,9 +125,7 @@ class ReportsView extends GetView { fontFamily: FontFamily.poppins, fontWeight: TaskWarriorFonts.light, fontSize: TaskWarriorFonts.fontSizeSmall, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ], diff --git a/lib/app/modules/reports/views/reports_view_taskc.dart b/lib/app/modules/reports/views/reports_view_taskc.dart index 5056e4e1..33be9a7c 100644 --- a/lib/app/modules/reports/views/reports_view_taskc.dart +++ b/lib/app/modules/reports/views/reports_view_taskc.dart @@ -7,9 +7,8 @@ import 'package:taskwarrior/app/modules/reports/views/burn_down_monthly_taskc.da import 'package:taskwarrior/app/modules/reports/views/burn_down_weekly_taskc.dart'; import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart'; - -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; import 'package:taskwarrior/api_service.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class ReportsHomeTaskc extends StatelessWidget { final ReportsController reportsController = Get.put(ReportsController()); @@ -31,7 +30,7 @@ class ReportsHomeTaskc extends StatelessWidget { future: fetchTasks(), builder: (context, snapshot) { List allTasks = snapshot.data ?? []; - + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Scaffold( appBar: AppBar( backgroundColor: TaskWarriorColors.kprimaryBackgroundColor, @@ -86,9 +85,7 @@ class ReportsHomeTaskc extends StatelessWidget { ), ), ), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryBackgroundColor - : TaskWarriorColors.white, + backgroundColor: tColors.primaryBackgroundColor, body: snapshot.connectionState == ConnectionState.waiting ? const Center(child: CircularProgressIndicator()) : allTasks.isEmpty @@ -98,9 +95,7 @@ class ReportsHomeTaskc extends StatelessWidget { children: [ Icon( Icons.heart_broken, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), Row( mainAxisAlignment: MainAxisAlignment.center, @@ -110,9 +105,7 @@ class ReportsHomeTaskc extends StatelessWidget { style: GoogleFonts.poppins( fontWeight: TaskWarriorFonts.medium, fontSize: TaskWarriorFonts.fontSizeSmall, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ], @@ -125,9 +118,7 @@ class ReportsHomeTaskc extends StatelessWidget { style: GoogleFonts.poppins( fontWeight: TaskWarriorFonts.light, fontSize: TaskWarriorFonts.fontSizeSmall, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ], diff --git a/lib/app/modules/settings/controllers/settings_controller.dart b/lib/app/modules/settings/controllers/settings_controller.dart index 15987b3e..44752a0a 100644 --- a/lib/app/modules/settings/controllers/settings_controller.dart +++ b/lib/app/modules/settings/controllers/settings_controller.dart @@ -19,6 +19,7 @@ import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; import 'package:path/path.dart' as path; import 'package:taskwarrior/app/modules/splash/controllers/splash_controller.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class SettingsController extends GetxController { RxBool isMovingDirectory = false.obs; @@ -45,6 +46,7 @@ class SettingsController extends GetxController { } void pickDirectory(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; FilePicker.platform.getDirectoryPath().then((value) async { if (value != null) { isMovingDirectory.value = true; @@ -73,9 +75,7 @@ class SettingsController extends GetxController { style: GoogleFonts.poppins( fontWeight: FontWeight.bold, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), content: Text( @@ -97,9 +97,7 @@ class SettingsController extends GetxController { child: Text( 'OK', style: GoogleFonts.poppins( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ) diff --git a/lib/app/modules/settings/views/settings_page_body.dart b/lib/app/modules/settings/views/settings_page_body.dart index 4e956ebd..0fb45153 100644 --- a/lib/app/modules/settings/views/settings_page_body.dart +++ b/lib/app/modules/settings/views/settings_page_body.dart @@ -7,11 +7,8 @@ import 'package:google_fonts/google_fonts.dart'; import 'package:taskwarrior/app/modules/settings/views/settings_page_taskchampion.dart'; import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart'; import 'package:taskwarrior/app/utils/language/sentence_manager.dart'; - +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; import '../controllers/settings_controller.dart'; - -import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; - import 'package:taskwarrior/app/modules/settings/views/settings_page_enable_24hr_format_list_tile_trailing.dart'; import 'package:taskwarrior/app/modules/settings/views/settings_page_highlist_task_list_tile_trailing.dart'; import 'package:taskwarrior/app/modules/settings/views/settings_page_list_tile.dart'; @@ -20,8 +17,6 @@ import 'package:taskwarrior/app/modules/settings/views/settings_page_on_task_sta import 'package:taskwarrior/app/modules/settings/views/settings_page_select_directory_list_tile.dart'; import 'package:taskwarrior/app/modules/settings/views/settings_page_select_the_language_trailing.dart'; -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; - class SettingsPageBody extends StatelessWidget { final SettingsController controller; @@ -29,6 +24,7 @@ class SettingsPageBody extends StatelessWidget { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Obx(() { if (controller.isMovingDirectory.value) { return Center( @@ -44,9 +40,7 @@ class SettingsPageBody extends StatelessWidget { style: GoogleFonts.poppins( fontWeight: FontWeight.bold, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ], diff --git a/lib/app/modules/settings/views/settings_page_list_tile.dart b/lib/app/modules/settings/views/settings_page_list_tile.dart index ac65c626..9b01228a 100644 --- a/lib/app/modules/settings/views/settings_page_list_tile.dart +++ b/lib/app/modules/settings/views/settings_page_list_tile.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart'; -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class SettingsPageListTile extends StatelessWidget { @@ -21,15 +21,14 @@ class SettingsPageListTile extends StatelessWidget { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return ListTile( title: Text( title, style: GoogleFonts.poppins( fontWeight: FontWeight.bold, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), subtitle: Text( diff --git a/lib/app/modules/settings/views/settings_page_select_directory_list_tile.dart b/lib/app/modules/settings/views/settings_page_select_directory_list_tile.dart index ae7f7cd5..2e30b2ba 100644 --- a/lib/app/modules/settings/views/settings_page_select_directory_list_tile.dart +++ b/lib/app/modules/settings/views/settings_page_select_directory_list_tile.dart @@ -12,6 +12,7 @@ import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart'; import 'package:taskwarrior/app/utils/constants/utilites.dart'; import 'package:taskwarrior/app/utils/language/sentence_manager.dart'; import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; import '../controllers/settings_controller.dart'; @@ -24,6 +25,7 @@ class SettingsPageSelectDirectoryListTile extends StatelessWidget { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return ListTile( title: Text( SentenceManager(currentLanguage: AppSettings.selectedLanguage) @@ -32,9 +34,7 @@ class SettingsPageSelectDirectoryListTile extends StatelessWidget { style: GoogleFonts.poppins( fontWeight: FontWeight.bold, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), subtitle: Column( @@ -57,9 +57,7 @@ class SettingsPageSelectDirectoryListTile extends StatelessWidget { TextButton( style: ButtonStyle( backgroundColor: WidgetStateProperty.all( - AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, + tColors.secondaryBackgroundColor!, ), ), onPressed: () async { @@ -68,14 +66,10 @@ class SettingsPageSelectDirectoryListTile extends StatelessWidget { content: Text( 'Already default', style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.kprimaryTextColor - : TaskWarriorColors.kLightPrimaryTextColor, + color: tColors.primaryTextColor, ), ), - backgroundColor: AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, + backgroundColor: tColors.secondaryBackgroundColor, duration: const Duration(seconds: 2))); } else { showDialog( @@ -87,9 +81,7 @@ class SettingsPageSelectDirectoryListTile extends StatelessWidget { style: GoogleFonts.poppins( fontWeight: FontWeight.bold, fontSize: TaskWarriorFonts.fontSizeMedium, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), content: Text( @@ -107,9 +99,7 @@ class SettingsPageSelectDirectoryListTile extends StatelessWidget { child: Text( 'No', style: GoogleFonts.poppins( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ), @@ -142,9 +132,7 @@ class SettingsPageSelectDirectoryListTile extends StatelessWidget { child: Text( 'Yes', style: GoogleFonts.poppins( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ), @@ -160,9 +148,7 @@ class SettingsPageSelectDirectoryListTile extends StatelessWidget { .sentences .settingsPageSetToDefault, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.deepPurple, + color: tColors.purpleShade, ), ), ), @@ -171,9 +157,7 @@ class SettingsPageSelectDirectoryListTile extends StatelessWidget { TextButton( style: ButtonStyle( backgroundColor: WidgetStateProperty.all( - AppSettings.isDarkMode - ? TaskWarriorColors.ksecondaryBackgroundColor - : TaskWarriorColors.kLightSecondaryBackgroundColor, + tColors.secondaryBackgroundColor!, ), ), onPressed: () { @@ -185,9 +169,7 @@ class SettingsPageSelectDirectoryListTile extends StatelessWidget { .sentences .settingsPageChangeDirectory, style: TextStyle( - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.deepPurple, + color: tColors.purpleShade, ), ), ), diff --git a/lib/app/modules/settings/views/settings_page_select_the_language_trailing.dart b/lib/app/modules/settings/views/settings_page_select_the_language_trailing.dart index 09c5d835..da7e155b 100644 --- a/lib/app/modules/settings/views/settings_page_select_the_language_trailing.dart +++ b/lib/app/modules/settings/views/settings_page_select_the_language_trailing.dart @@ -5,6 +5,7 @@ import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; import 'package:taskwarrior/app/utils/gen/fonts.gen.dart'; import 'package:taskwarrior/app/utils/language/supported_language.dart'; import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class SettingsPageSelectTheLanguageTrailing extends StatelessWidget { final SettingsController controller; @@ -14,6 +15,7 @@ class SettingsPageSelectTheLanguageTrailing extends StatelessWidget { @override Widget build(BuildContext context) { + TaskwarriorColorTheme tColors = Theme.of(context).extension()!; return Obx( () => DropdownButton( value: controller.selectedLanguage.value, @@ -27,9 +29,7 @@ class SettingsPageSelectTheLanguageTrailing extends StatelessWidget { _getLanguageName(language), style: TextStyle( fontFamily: FontFamily.poppins, - color: AppSettings.isDarkMode - ? TaskWarriorColors.white - : TaskWarriorColors.black, + color: tColors.primaryTextColor, ), ), ); diff --git a/lib/app/utils/constants/taskwarrior_colors.dart b/lib/app/utils/constants/taskwarrior_colors.dart index d9417ed3..19110e2f 100644 --- a/lib/app/utils/constants/taskwarrior_colors.dart +++ b/lib/app/utils/constants/taskwarrior_colors.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:taskwarrior/app/utils/constants/palette.dart'; +import 'package:taskwarrior/app/utils/themes/theme_extension.dart'; class TaskWarriorColors { // Normal Colors @@ -17,6 +18,11 @@ class TaskWarriorColors { static Color deepPurpleAccent = Colors.deepPurpleAccent; static Color deepPurple = Colors.deepPurple; + // colors irrespective of theme + static Color appBarColor = const Color(0xFF000000); + static Color appBarTextColor = white; + static Color appBarUnSelectedIconsColorForReports = const Color(0xFF48454E); + // Dark Theme Color Palette static Color kprimaryBackgroundColor = Palette.kToDark.shade200; static Color ksecondaryBackgroundColor = @@ -34,4 +40,30 @@ class TaskWarriorColors { static Color kLightSecondaryTextColor = const Color.fromARGB(255, 48, 46, 46); static Color kLightPrimaryDisabledTextColor = const Color(0xffACACAB); static Color kLightDialogBackGroundColor = Colors.white; + static TaskwarriorColorTheme darkTheme = TaskwarriorColorTheme( + dialogBackgroundColor: kdialogBackGroundColor, + primaryBackgroundColor: kprimaryBackgroundColor, + primaryDisabledTextColor: kprimaryDisabledTextColor, + primaryTextColor: kprimaryTextColor, + secondaryBackgroundColor: ksecondaryBackgroundColor, + secondaryTextColor: ksecondaryTextColor, + dividerColor: const Color.fromARGB(255, 192, 192, 192), + purpleShade: deepPurpleAccent, + greyShade: grey, + icons: Icons.dark_mode, + dimCol: const Color.fromARGB(137, 248, 248, 248) + ); + static TaskwarriorColorTheme lightTheme = TaskwarriorColorTheme( + dialogBackgroundColor: kLightDialogBackGroundColor, + primaryBackgroundColor: kLightPrimaryBackgroundColor, + primaryDisabledTextColor: kLightPrimaryDisabledTextColor, + primaryTextColor: kLightPrimaryTextColor, + secondaryBackgroundColor: kLightSecondaryBackgroundColor, + secondaryTextColor: kLightSecondaryTextColor, + dividerColor: kprimaryBackgroundColor, + purpleShade: deepPurple, + greyShade: lightGrey, + icons: Icons.light_mode, + dimCol: const Color.fromARGB(136, 17, 17, 17) + ); } diff --git a/lib/app/utils/themes/dark_theme.dart b/lib/app/utils/themes/dark_theme.dart index 91bcf93b..b9685067 100644 --- a/lib/app/utils/themes/dark_theme.dart +++ b/lib/app/utils/themes/dark_theme.dart @@ -1,5 +1,24 @@ import 'package:flutter/material.dart'; +import 'package:taskwarrior/app/utils/constants/constants.dart'; ThemeData darkTheme = ThemeData( brightness: Brightness.dark, + dialogBackgroundColor: TaskWarriorColors.kdialogBackGroundColor, + colorScheme: ColorScheme( + brightness: Brightness.dark, + primary: TaskWarriorColors.white, + onPrimary: TaskWarriorColors.black, + secondary: TaskWarriorColors.grey, + onSecondary: TaskWarriorColors.white, + error: TaskWarriorColors.red, + onError: TaskWarriorColors.black, + surface: TaskWarriorColors.black, + onSurface: TaskWarriorColors.white, + ), + timePickerTheme: TimePickerThemeData( + dayPeriodColor: TaskWarriorColors.lightGrey + ), + extensions: [ + TaskWarriorColors.darkTheme + ] ); \ No newline at end of file diff --git a/lib/app/utils/themes/light_theme.dart b/lib/app/utils/themes/light_theme.dart index 604edfad..bd90fe09 100644 --- a/lib/app/utils/themes/light_theme.dart +++ b/lib/app/utils/themes/light_theme.dart @@ -1,5 +1,24 @@ import 'package:flutter/material.dart'; +import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart'; ThemeData lightTheme = ThemeData( brightness: Brightness.light, + dialogBackgroundColor: TaskWarriorColors.kLightDialogBackGroundColor, + colorScheme: ColorScheme( + brightness: Brightness.light, + primary: TaskWarriorColors.black, + onPrimary: TaskWarriorColors.white, + secondary: TaskWarriorColors.white, + onSecondary: TaskWarriorColors.black, + error: TaskWarriorColors.red, + onError: TaskWarriorColors.white, + surface: TaskWarriorColors.white, + onSurface: TaskWarriorColors.black, + ), + timePickerTheme: TimePickerThemeData( + dayPeriodColor: TaskWarriorColors.grey + ), + extensions: [ + TaskWarriorColors.lightTheme + ] ); diff --git a/lib/app/utils/themes/theme_extension.dart b/lib/app/utils/themes/theme_extension.dart new file mode 100644 index 00000000..3c9c7e79 --- /dev/null +++ b/lib/app/utils/themes/theme_extension.dart @@ -0,0 +1,85 @@ +import 'package:flutter/material.dart'; + + +class TaskwarriorColorTheme extends ThemeExtension{ + final Color? dialogBackgroundColor; + final Color? primaryBackgroundColor; + final Color? secondaryBackgroundColor; + final Color? primaryTextColor; + final Color? secondaryTextColor; + final Color? primaryDisabledTextColor; + final Color? dividerColor; + final Color? purpleShade; + final Color? greyShade; + final Color? dimCol; + final IconData? icons; + + const TaskwarriorColorTheme({ + required this.dialogBackgroundColor, + required this.primaryBackgroundColor, + required this.primaryDisabledTextColor, + required this.primaryTextColor, + required this.secondaryBackgroundColor, + required this.secondaryTextColor, + required this.dividerColor, + required this.purpleShade, + required this.greyShade, + required this.icons, + required this.dimCol + }); + + @override + ThemeExtension copyWith({ + Color? dialogBackgroundColor, + Color? primaryBackgroundColor, + Color? secondaryBackgroundColor, + Color? primaryTextColor, + Color? secondaryTextColor, + Color? primaryDisabledTextColor, + Color? dividerColor, + Color? greyShade, + Color? dimCol, + IconData? icons, + }) { + return TaskwarriorColorTheme( + dialogBackgroundColor: dialogBackgroundColor ?? dialogBackgroundColor, + primaryBackgroundColor: primaryBackgroundColor ?? primaryBackgroundColor, + primaryDisabledTextColor: primaryDisabledTextColor ?? primaryDisabledTextColor, + primaryTextColor: primaryTextColor ?? primaryTextColor, + secondaryBackgroundColor: secondaryBackgroundColor ?? secondaryBackgroundColor, + secondaryTextColor: secondaryTextColor ?? secondaryTextColor, + dividerColor: dividerColor ?? dividerColor, + purpleShade: purpleShade ?? purpleShade, + greyShade: greyShade ?? greyShade, + icons: icons ?? icons, + dimCol: dimCol ?? dimCol + ); + } + + @override + ThemeExtension lerp( + covariant ThemeExtension? other, double t) { + if (other is! TaskwarriorColorTheme) { + return this; + } + return TaskwarriorColorTheme( + dialogBackgroundColor: Color.lerp( + dialogBackgroundColor, other.dialogBackgroundColor, t), + primaryBackgroundColor: Color.lerp( + primaryBackgroundColor, other.primaryBackgroundColor, t), + primaryDisabledTextColor: Color.lerp( + primaryDisabledTextColor, other.primaryDisabledTextColor, t), + primaryTextColor: + Color.lerp(primaryTextColor, other.primaryTextColor, t), + secondaryBackgroundColor: Color.lerp( + secondaryBackgroundColor, other.secondaryBackgroundColor, t), + secondaryTextColor: + Color.lerp(secondaryTextColor, other.secondaryTextColor, t), + dividerColor: Color.lerp(dividerColor, other.dividerColor, t), + purpleShade: Color.lerp(purpleShade, other.purpleShade, t), + greyShade: Color.lerp(greyShade, other.greyShade, t), + dimCol: Color.lerp(dimCol, other.dimCol, t), + icons: icons + ); + } +} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index a88ff580..cfdc63d3 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; import 'package:taskwarrior/app/utils/permissions/permissions_manager.dart'; +import 'package:taskwarrior/app/utils/themes/dark_theme.dart'; +import 'package:taskwarrior/app/utils/themes/light_theme.dart'; import 'app/routes/app_pages.dart'; void main() async { @@ -13,9 +15,12 @@ void main() async { runApp( GetMaterialApp( + darkTheme: darkTheme, + theme: lightTheme, title: "Application", initialRoute: AppPages.INITIAL, getPages: AppPages.routes, + themeMode: AppSettings.isDarkMode ? ThemeMode.dark : ThemeMode.light, ), ); }