Skip to content

Commit 4eca11e

Browse files
authored
Added new themes; fixed theme issue in table tab (#347)
* Add green theme * Add orange theme * Add red theme * Fix wrong theme strength used for table icons * Linted code * Bump v0.9.3+48
1 parent cab80f2 commit 4eca11e

File tree

4 files changed

+154
-35
lines changed

4 files changed

+154
-35
lines changed

lib/core/theme.dart

+136-29
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,21 @@ class AppThemes {
1717
shadowColor: MaterialStateProperty.all(Colors.black.withOpacity(0.2)),
1818
),
1919
),
20-
// Add button themes for light mode
2120
elevatedButtonTheme: ElevatedButtonThemeData(
2221
style: ButtonStyle(
23-
backgroundColor:
24-
MaterialStateProperty.all(Colors.blue), // Background color
25-
foregroundColor: MaterialStateProperty.all(Colors.white), // Text color
22+
backgroundColor: MaterialStateProperty.all(Colors.blue),
23+
foregroundColor: MaterialStateProperty.all(Colors.white),
2624
),
2725
),
2826
textButtonTheme: TextButtonThemeData(
2927
style: ButtonStyle(
30-
foregroundColor: MaterialStateProperty.all(Colors.blue), // Text color
28+
foregroundColor: MaterialStateProperty.all(Colors.blue),
3129
),
3230
),
3331
outlinedButtonTheme: OutlinedButtonThemeData(
3432
style: ButtonStyle(
35-
foregroundColor: MaterialStateProperty.all(Colors.blue), // Text color
36-
side: MaterialStateProperty.all(
37-
BorderSide(color: Colors.blue)), // Border color
33+
foregroundColor: MaterialStateProperty.all(Colors.blue),
34+
side: MaterialStateProperty.all(BorderSide(color: Colors.blue)),
3835
),
3936
),
4037
);
@@ -52,24 +49,21 @@ class AppThemes {
5249
shadowColor: MaterialStateProperty.all(Colors.black.withOpacity(0.5)),
5350
),
5451
),
55-
// Add button themes for dark mode
5652
elevatedButtonTheme: ElevatedButtonThemeData(
5753
style: ButtonStyle(
58-
backgroundColor:
59-
MaterialStateProperty.all(Colors.purple), // Background color
60-
foregroundColor: MaterialStateProperty.all(Colors.white), // Text color
54+
backgroundColor: MaterialStateProperty.all(Colors.purple),
55+
foregroundColor: MaterialStateProperty.all(Colors.white),
6156
),
6257
),
6358
textButtonTheme: TextButtonThemeData(
6459
style: ButtonStyle(
65-
foregroundColor: MaterialStateProperty.all(Colors.purple), // Text color
60+
foregroundColor: MaterialStateProperty.all(Colors.purple),
6661
),
6762
),
6863
outlinedButtonTheme: OutlinedButtonThemeData(
6964
style: ButtonStyle(
70-
foregroundColor: MaterialStateProperty.all(Colors.purple), // Text color
71-
side: MaterialStateProperty.all(
72-
BorderSide(color: Colors.purple)), // Border color
65+
foregroundColor: MaterialStateProperty.all(Colors.purple),
66+
side: MaterialStateProperty.all(BorderSide(color: Colors.purple)),
7367
),
7468
),
7569
);
@@ -90,24 +84,126 @@ class AppThemes {
9084
shadowColor: MaterialStateProperty.all(Colors.pink.withOpacity(0.5)),
9185
),
9286
),
93-
// Add button themes for pink mode
9487
elevatedButtonTheme: ElevatedButtonThemeData(
9588
style: ButtonStyle(
96-
backgroundColor:
97-
MaterialStateProperty.all(Colors.pink), // Background color
98-
foregroundColor: MaterialStateProperty.all(Colors.white), // Text color
89+
backgroundColor: MaterialStateProperty.all(Colors.pink),
90+
foregroundColor: MaterialStateProperty.all(Colors.white),
9991
),
10092
),
10193
textButtonTheme: TextButtonThemeData(
10294
style: ButtonStyle(
103-
foregroundColor: MaterialStateProperty.all(Colors.pink), // Text color
95+
foregroundColor: MaterialStateProperty.all(Colors.pink),
10496
),
10597
),
10698
outlinedButtonTheme: OutlinedButtonThemeData(
10799
style: ButtonStyle(
108-
foregroundColor: MaterialStateProperty.all(Colors.pink), // Text color
109-
side: MaterialStateProperty.all(
110-
BorderSide(color: Colors.pink)), // Border color
100+
foregroundColor: MaterialStateProperty.all(Colors.pink),
101+
side: MaterialStateProperty.all(BorderSide(color: Colors.pink)),
102+
),
103+
),
104+
);
105+
106+
static ThemeData greenTheme = ThemeData(
107+
brightness: Brightness.light,
108+
primarySwatch: Colors.green,
109+
iconTheme: IconThemeData(color: Colors.green),
110+
colorScheme: ColorScheme.fromSeed(
111+
seedColor: Colors.green,
112+
primary: Colors.green,
113+
secondary: Colors.greenAccent,
114+
),
115+
dropdownMenuTheme: DropdownMenuThemeData(
116+
menuStyle: MenuStyle(
117+
backgroundColor: MaterialStateProperty.all(Colors.green.shade50),
118+
elevation: MaterialStateProperty.all(8.0),
119+
shadowColor: MaterialStateProperty.all(Colors.green.withOpacity(0.5)),
120+
),
121+
),
122+
elevatedButtonTheme: ElevatedButtonThemeData(
123+
style: ButtonStyle(
124+
backgroundColor: MaterialStateProperty.all(Colors.green),
125+
foregroundColor: MaterialStateProperty.all(Colors.white),
126+
),
127+
),
128+
textButtonTheme: TextButtonThemeData(
129+
style: ButtonStyle(
130+
foregroundColor: MaterialStateProperty.all(Colors.green),
131+
),
132+
),
133+
outlinedButtonTheme: OutlinedButtonThemeData(
134+
style: ButtonStyle(
135+
foregroundColor: MaterialStateProperty.all(Colors.green),
136+
side: MaterialStateProperty.all(BorderSide(color: Colors.green)),
137+
),
138+
),
139+
);
140+
141+
static ThemeData orangeTheme = ThemeData(
142+
brightness: Brightness.light,
143+
primarySwatch: Colors.orange,
144+
iconTheme: IconThemeData(color: Colors.orange),
145+
colorScheme: ColorScheme.fromSeed(
146+
seedColor: Colors.orange,
147+
primary: Colors.orange,
148+
secondary: Colors.orangeAccent,
149+
),
150+
dropdownMenuTheme: DropdownMenuThemeData(
151+
menuStyle: MenuStyle(
152+
backgroundColor: MaterialStateProperty.all(Colors.orange.shade50),
153+
elevation: MaterialStateProperty.all(8.0),
154+
shadowColor: MaterialStateProperty.all(Colors.orange.withOpacity(0.5)),
155+
),
156+
),
157+
elevatedButtonTheme: ElevatedButtonThemeData(
158+
style: ButtonStyle(
159+
backgroundColor: MaterialStateProperty.all(Colors.orange),
160+
foregroundColor: MaterialStateProperty.all(Colors.white),
161+
),
162+
),
163+
textButtonTheme: TextButtonThemeData(
164+
style: ButtonStyle(
165+
foregroundColor: MaterialStateProperty.all(Colors.orange),
166+
),
167+
),
168+
outlinedButtonTheme: OutlinedButtonThemeData(
169+
style: ButtonStyle(
170+
foregroundColor: MaterialStateProperty.all(Colors.orange),
171+
side: MaterialStateProperty.all(BorderSide(color: Colors.orange)),
172+
),
173+
),
174+
);
175+
176+
static ThemeData redTheme = ThemeData(
177+
brightness: Brightness.light,
178+
primarySwatch: Colors.red,
179+
iconTheme: IconThemeData(color: Colors.red),
180+
colorScheme: ColorScheme.fromSeed(
181+
seedColor: Colors.red,
182+
primary: Colors.red,
183+
secondary: Colors.redAccent,
184+
),
185+
dropdownMenuTheme: DropdownMenuThemeData(
186+
menuStyle: MenuStyle(
187+
backgroundColor: MaterialStateProperty.all(Colors.red.shade50),
188+
elevation: MaterialStateProperty.all(8.0),
189+
shadowColor: MaterialStateProperty.all(Colors.red.withOpacity(0.5)),
190+
),
191+
),
192+
elevatedButtonTheme: ElevatedButtonThemeData(
193+
style: ButtonStyle(
194+
backgroundColor: MaterialStateProperty.all(Colors.red),
195+
foregroundColor: MaterialStateProperty.all(Colors.white),
196+
),
197+
),
198+
textButtonTheme: TextButtonThemeData(
199+
style: ButtonStyle(
200+
foregroundColor: MaterialStateProperty.all(Colors.red),
201+
),
202+
),
203+
outlinedButtonTheme: OutlinedButtonThemeData(
204+
style: ButtonStyle(
205+
foregroundColor: MaterialStateProperty.all(Colors.red),
206+
side: MaterialStateProperty.all(BorderSide(color: Colors.red)),
111207
),
112208
),
113209
);
@@ -120,25 +216,36 @@ class AppThemes {
120216
return darkTheme;
121217
case AppTheme.pink:
122218
return pinkTheme;
219+
case AppTheme.green:
220+
return greenTheme;
221+
case AppTheme.orange:
222+
return orangeTheme;
223+
case AppTheme.red:
224+
return redTheme;
123225
case AppTheme.system:
124226
default:
125227
return brightness == Brightness.dark ? darkTheme : lightTheme;
126228
}
127229
}
128230
}
129231

130-
enum AppTheme { system, light, dark, pink }
232+
enum AppTheme { system, light, dark, pink, green, orange, red }
131233

132234
// Extension on ThemeData to include the primaryChartColor
133235
extension ChartColors on ThemeData {
134236
Color get primaryChartColor {
135-
// Use primary color or fallback to specific colors based on brightness
136237
if (brightness == Brightness.dark) {
137-
return colorScheme.primary; // Typically purple in dark mode
238+
return colorScheme.primary;
138239
} else if (colorScheme.primary == Colors.pink) {
139-
return Colors.pink; // Pink theme case
240+
return Colors.pink;
241+
} else if (colorScheme.primary == Colors.green) {
242+
return Colors.green;
243+
} else if (colorScheme.primary == Colors.orange) {
244+
return Colors.orange;
245+
} else if (colorScheme.primary == Colors.red) {
246+
return Colors.red;
140247
} else {
141-
return Colors.blue; // Default to blue in light mode
248+
return Colors.blue;
142249
}
143250
}
144251
}

lib/widgets/settings.dart

+12
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,18 @@ class _SettingsModalState extends State<SettingsModal> {
254254
value: AppTheme.pink,
255255
child: Text('Pink'),
256256
),
257+
DropdownMenuItem(
258+
value: AppTheme.green,
259+
child: Text('Green'),
260+
),
261+
DropdownMenuItem(
262+
value: AppTheme.red,
263+
child: Text('Red'),
264+
),
265+
DropdownMenuItem(
266+
value: AppTheme.orange,
267+
child: Text('Orange'),
268+
),
257269
],
258270
onChanged: _handleThemeChange,
259271
),

lib/widgets/table.dart

+5-5
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ class _TableWidgetState extends State<TableWidget> {
315315
Icon(
316316
_sortAscending ? Icons.arrow_upward : Icons.arrow_downward,
317317
size: 16,
318-
color: Theme.of(context).colorScheme.secondary,
318+
color: Theme.of(context).iconTheme.color,
319319
),
320320
],
321321
),
@@ -508,8 +508,8 @@ class _TableWidgetState extends State<TableWidget> {
508508
icon: Icon(Icons.edit,
509509
size: 18.0,
510510
color: Theme.of(context)
511-
.colorScheme
512-
.secondary),
511+
.iconTheme
512+
.color),
513513
onPressed: () {
514514
_showEditDialog(item);
515515
},
@@ -519,8 +519,8 @@ class _TableWidgetState extends State<TableWidget> {
519519
icon: Icon(Icons.delete,
520520
size: 18.0,
521521
color: Theme.of(context)
522-
.colorScheme
523-
.secondary),
522+
.iconTheme
523+
.color),
524524
onPressed: () async {
525525
await _deleteRow(
526526
'exercises', item['id'] ?? 0);

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
1616
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
1717
# In Windows, build-name is used as the major, minor, and patch parts
1818
# of the product and file versions while build-number is used as the build suffix.
19-
version: 0.9.2+47
19+
version: 0.9.3+48
2020

2121
environment:
2222
sdk: '>=3.4.3 <4.0.0'

0 commit comments

Comments
 (0)