Skip to content

Commit

Permalink
reduced duplication and improving maintainability using ThemeData
Browse files Browse the repository at this point in the history
  • Loading branch information
D-extremity committed Dec 16, 2024
1 parent 7d42718 commit e2557bd
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 44 deletions.
5 changes: 2 additions & 3 deletions lib/app/modules/detailRoute/views/tags_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ 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/themes.dart';

class TagsWidget extends StatelessWidget {
const TagsWidget({
Expand Down Expand Up @@ -127,9 +128,7 @@ class TagsRouteState extends State<TagsRoute> {
color: TaskWarriorColors.white,
),
),
backgroundColor: AppSettings.isDarkMode
? TaskWarriorColors.kprimaryBackgroundColor
: TaskWarriorColors.kLightPrimaryBackgroundColor,
backgroundColor: AppColor.currentAppThemeColor,
body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(4),
Expand Down
9 changes: 3 additions & 6 deletions lib/app/modules/home/views/filter_drawer_home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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/themes.dart';

class FilterDrawer extends StatelessWidget {
final Filters filters;
Expand All @@ -27,12 +28,8 @@ class FilterDrawer extends StatelessWidget {
? TaskWarriorColors.ksecondaryBackgroundColor
: TaskWarriorColors.kLightPrimaryBackgroundColor;
return Drawer(
backgroundColor: AppSettings.isDarkMode
? TaskWarriorColors.kprimaryBackgroundColor
: TaskWarriorColors.kLightPrimaryBackgroundColor,
surfaceTintColor: AppSettings.isDarkMode
? TaskWarriorColors.kprimaryBackgroundColor
: TaskWarriorColors.kLightPrimaryBackgroundColor,
backgroundColor: AppColor.currentAppThemeColor,
surfaceTintColor: AppColor.currentAppThemeColor,
child: SafeArea(
child: Padding(
padding: const EdgeInsets.all(8),
Expand Down
9 changes: 3 additions & 6 deletions lib/app/modules/home/views/nav_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,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/taskchampion/taskchampion.dart';
import 'package:taskwarrior/app/utils/themes/themes.dart';

class NavDrawer extends StatelessWidget {
final HomeController homeController;
Expand All @@ -21,12 +22,8 @@ class NavDrawer extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Drawer(
backgroundColor: AppSettings.isDarkMode
? TaskWarriorColors.kprimaryBackgroundColor
: TaskWarriorColors.kLightPrimaryBackgroundColor,
surfaceTintColor: AppSettings.isDarkMode
? TaskWarriorColors.kprimaryBackgroundColor
: TaskWarriorColors.kLightPrimaryBackgroundColor,
backgroundColor: AppColor.currentAppThemeColor,
surfaceTintColor: AppColor.currentAppThemeColor,
child: Container(
color: AppSettings.isDarkMode
? TaskWarriorColors.kprimaryBackgroundColor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
// ignore_for_file: use_build_context_synchronously


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/themes.dart';

import '../controllers/manage_task_server_controller.dart';

Expand All @@ -18,9 +16,7 @@ class ManageTaskServerView extends GetView<ManageTaskServerController> {
Widget build(BuildContext context) {
return Scaffold(
appBar: ManageTaskServerPageAppBar(controller: controller),
backgroundColor: AppSettings.isDarkMode
? TaskWarriorColors.kprimaryBackgroundColor
: TaskWarriorColors.kLightPrimaryBackgroundColor,
backgroundColor: AppColor.currentAppThemeColor,
body: ManageTaskServerPageBody(controller: controller),
);
}
Expand Down
25 changes: 11 additions & 14 deletions lib/app/modules/profile/views/profile_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ 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/themes.dart';

import '../controllers/profile_controller.dart';

Expand Down Expand Up @@ -54,9 +55,7 @@ class ProfileView extends GetView<ProfileController> {
),
),
//primary: false,
backgroundColor: AppSettings.isDarkMode
? TaskWarriorColors.kprimaryBackgroundColor
: TaskWarriorColors.kLightPrimaryBackgroundColor,
backgroundColor: AppColor.currentAppThemeColor,
body: SingleChildScrollView(
child: Column(
children: [
Expand Down Expand Up @@ -104,9 +103,9 @@ class ProfileView extends GetView<ProfileController> {
return Utils.showAlertDialog(
title: Text(
SentenceManager(
currentLanguage: AppSettings.selectedLanguage)
.sentences
.profilePageExportTasksDialogueTitle,
currentLanguage: AppSettings.selectedLanguage)
.sentences
.profilePageExportTasksDialogueTitle,
style: TextStyle(
color: AppSettings.isDarkMode
? TaskWarriorColors.white
Expand All @@ -115,9 +114,9 @@ class ProfileView extends GetView<ProfileController> {
),
content: Text(
SentenceManager(
currentLanguage: AppSettings.selectedLanguage)
.sentences
.profilePageExportTasksDialogueSubtitle,
currentLanguage: AppSettings.selectedLanguage)
.sentences
.profilePageExportTasksDialogueSubtitle,
style: TextStyle(
color: AppSettings.isDarkMode
? TaskWarriorColors.white
Expand Down Expand Up @@ -325,11 +324,9 @@ class ProfilesColumn extends StatelessWidget {
? TaskWarriorColors.deepPurpleAccent
: TaskWarriorColors.deepPurple),
label: Text(
SentenceManager(
currentLanguage: AppSettings.selectedLanguage)
.sentences
.profilePageAddNewProfile,

SentenceManager(currentLanguage: AppSettings.selectedLanguage)
.sentences
.profilePageAddNewProfile,
style: TextStyle(
color: AppSettings.isDarkMode
? TaskWarriorColors.white
Expand Down
7 changes: 2 additions & 5 deletions lib/app/modules/settings/views/settings_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:taskwarrior/app/modules/settings/views/settings_page_app_bar.dart';
import 'package:taskwarrior/app/modules/settings/views/settings_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/themes.dart';

import '../controllers/settings_controller.dart';

Expand All @@ -18,9 +17,7 @@ class SettingsView extends GetView<SettingsController> {
appBar: SettingsPageAppBar(
controller: controller,
),
backgroundColor: AppSettings.isDarkMode
? TaskWarriorColors.kprimaryBackgroundColor
: TaskWarriorColors.kLightPrimaryBackgroundColor,
backgroundColor: AppColor.currentAppThemeColor,
body: SettingsPageBody(
controller: controller,
),
Expand Down
5 changes: 2 additions & 3 deletions lib/app/utils/taskchampion/taskchampion.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:shared_preferences/shared_preferences.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/taskwarrior_fonts.dart';
import 'package:taskwarrior/app/utils/themes/themes.dart';

import 'package:url_launcher/url_launcher.dart';

Expand Down Expand Up @@ -70,9 +71,7 @@ class ManageTaskChampionCreds extends StatelessWidget {
color: TaskWarriorColors.white,
),
),
backgroundColor: AppSettings.isDarkMode
? TaskWarriorColors.kprimaryBackgroundColor
: TaskWarriorColors.kLightPrimaryBackgroundColor,
backgroundColor: AppColor.currentAppThemeColor,
body: Padding(
padding: const EdgeInsets.only(left: 20, right: 20),
child: ListView(
Expand Down
15 changes: 14 additions & 1 deletion lib/app/utils/themes/themes.dart
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
import 'dart:ui';

import 'package:taskwarrior/app/utils/app_settings/app_settings.dart';
import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart';

export 'dark_theme.dart';
export 'light_theme.dart';
export 'light_theme.dart';

class AppColor {
static Color currentAppThemeColor=
AppSettings.isDarkMode
?TaskWarriorColors.kprimaryBackgroundColor
: TaskWarriorColors.kLightPrimaryBackgroundColor;

}

0 comments on commit e2557bd

Please sign in to comment.