1+ import 'package:twoaxis_finance/app/theme_cubit.dart' ;
12import 'package:twoaxis_finance/features/dashboard/presentation/widgets/dashboard_button.dart' ;
23import 'package:twoaxis_finance/features/transactions/domain/transaction_type.dart' ;
34import 'package:twoaxis_finance/features/transactions/presentation/bloc/transactions_bloc.dart' ;
@@ -26,23 +27,26 @@ class _DashboardPageState extends State<DashboardPage> {
2627
2728 @override
2829 Widget build (BuildContext context) {
29- return BlocBuilder <UserCubit , UserState >(
30- builder: (context, userState) {
31-
32- if (userState is ! UserStateAuthenticated ) return const SizedBox ();
30+ return BlocBuilder <UserCubit , UserState >(builder: (context, userState) {
31+ var user = (userState as UserStateAuthenticated ).user;
3332
33+ return BlocBuilder <ThemeCubit , ThemeMode >(builder: (context, mode) {
3434 return Stack (
3535 children: [
36- Container (
37- height: 500 ,
38- decoration: BoxDecoration (
39- gradient: RadialGradient (
40- colors: [Theme .of (context).colorScheme.primary, Colors .transparent],
41- radius: 1 ,
42- center: Alignment .topCenter,
36+ if (mode == ThemeMode .dark)
37+ Container (
38+ height: 500 ,
39+ decoration: BoxDecoration (
40+ gradient: RadialGradient (
41+ colors: [
42+ Theme .of (context).colorScheme.primary,
43+ Colors .transparent
44+ ],
45+ radius: 1 ,
46+ center: Alignment .topCenter,
47+ ),
4348 ),
4449 ),
45- ),
4650 Container (
4751 padding: const EdgeInsets .all (20 ),
4852 child: Column (
@@ -68,7 +72,9 @@ class _DashboardPageState extends State<DashboardPage> {
6872 width: 120 ,
6973 height: 40 ,
7074 decoration: BoxDecoration (
71- color: Theme .of (context).colorScheme.surfaceContainer,
75+ color: Theme .of (context)
76+ .colorScheme
77+ .surfaceContainer,
7278 borderRadius: BorderRadius .circular (5 ),
7379 ),
7480 ),
@@ -77,10 +83,15 @@ class _DashboardPageState extends State<DashboardPage> {
7783 Text (
7884 formatMoneyWithContext (
7985 context,
80- userState.user.balances.fold <double >(
81- 0 , (sum, balance) => sum + balance.value)),
82- style: const TextStyle (
83- fontWeight: FontWeight .bold, fontSize: 40 ),
86+ user.balances.fold <double >(0 ,
87+ (sum, balance) => sum + balance.value)),
88+ style: TextStyle (
89+ fontWeight: FontWeight .bold,
90+ fontSize: 40 ,
91+ color: mode == ThemeMode .dark
92+ ? Theme .of (context).colorScheme.onSurface
93+ : Theme .of (context).colorScheme.primary,
94+ ),
8495 ),
8596 IconButton (
8697 onPressed: () {
@@ -91,7 +102,11 @@ class _DashboardPageState extends State<DashboardPage> {
91102 color: Colors .white,
92103 icon: Icon (isHidden
93104 ? Icons .visibility_outlined
94- : Icons .visibility_off_outlined),
105+ : Icons .visibility_off_outlined,
106+ color: Theme .of (context)
107+ .colorScheme
108+ .onSurface,
109+ ),
95110 ),
96111 ],
97112 ),
@@ -124,7 +139,7 @@ class _DashboardPageState extends State<DashboardPage> {
124139 decoration: BoxDecoration (
125140 color: Colors .grey[300 ],
126141 borderRadius:
127- BorderRadius .circular (2 ),
142+ BorderRadius .circular (2 ),
128143 ),
129144 ),
130145 const SizedBox (
@@ -164,7 +179,8 @@ class _DashboardPageState extends State<DashboardPage> {
164179 Navigator .push (
165180 context,
166181 MaterialPageRoute (
167- builder: (context) => const AnalyticsPage ()));
182+ builder: (context) =>
183+ const AnalyticsPage ()));
168184 },
169185 ),
170186 DashboardButton (
@@ -174,7 +190,8 @@ class _DashboardPageState extends State<DashboardPage> {
174190 Navigator .push (
175191 context,
176192 MaterialPageRoute (
177- builder: (context) => const BudgetPage ()));
193+ builder: (context) =>
194+ const BudgetPage ()));
178195 },
179196 ),
180197 ],
@@ -198,9 +215,9 @@ class _DashboardPageState extends State<DashboardPage> {
198215 children: [
199216 Expanded (
200217 child: Text (
201- "Recent Transactions" ,
202- style: TextStyle (fontSize: 15 ),
203- )),
218+ "Recent Transactions" ,
219+ style: TextStyle (fontSize: 15 ),
220+ )),
204221 Icon (Icons .arrow_forward_ios)
205222 ],
206223 ),
@@ -215,11 +232,13 @@ class _DashboardPageState extends State<DashboardPage> {
215232 return const Center (
216233 child: CircularProgressIndicator (),
217234 );
218- } else if (transactionsState is TransactionsStateError ) {
235+ } else if (transactionsState
236+ is TransactionsStateError ) {
219237 return Center (
220238 child: Text (transactionsState.message),
221239 );
222- } else if (transactionsState is TransactionsStateLoaded ) {
240+ } else if (transactionsState
241+ is TransactionsStateLoaded ) {
223242 if (transactionsState.transactions.isEmpty) {
224243 return Center (
225244 child: Column (
@@ -248,9 +267,10 @@ class _DashboardPageState extends State<DashboardPage> {
248267 }
249268 return ListView .separated (
250269 padding: EdgeInsets .zero,
251- itemCount: transactionsState.transactions.length <= 30
252- ? transactionsState.transactions.length
253- : 30 ,
270+ itemCount:
271+ transactionsState.transactions.length <= 30
272+ ? transactionsState.transactions.length
273+ : 30 ,
254274 itemBuilder: (context, index) {
255275 var item = transactionsState.transactions[index];
256276 return Row (
@@ -259,25 +279,26 @@ class _DashboardPageState extends State<DashboardPage> {
259279 Container (
260280 padding: const EdgeInsets .all (10 ),
261281 decoration: BoxDecoration (
262- color: Theme .of (context).colorScheme.surfaceBright,
282+ color: Theme .of (context)
283+ .colorScheme
284+ .surfaceBright,
263285 borderRadius:
264- BorderRadius .circular (10 )),
286+ BorderRadius .circular (10 )),
265287 child: Icon (
266288 getCategoryIcon (
267289 item.category,
268290 defaultIcon:
269- item.type ==
270- TransactionType .expense
271- ? Icons .payments_rounded
272- : Icons .file_download_rounded,
291+ item.type == TransactionType .expense
292+ ? Icons .payments_rounded
293+ : Icons .file_download_rounded,
273294 ),
274295 size: 25 ,
275296 ),
276297 ),
277298 Expanded (
278299 child: Column (
279300 crossAxisAlignment:
280- CrossAxisAlignment .start,
301+ CrossAxisAlignment .start,
281302 children: [
282303 Text (item.name),
283304 Text (
@@ -289,17 +310,17 @@ class _DashboardPageState extends State<DashboardPage> {
289310 ],
290311 ),
291312 ),
292- if (item.type ==
293- TransactionType .expense)
313+ if (item.type == TransactionType .expense)
294314 Text (
295315 "-${formatMoneyWithContext (context , item .amount )}" ,
296316 style: TextStyle (
297- color: Theme .of (context).colorScheme.primary,
317+ color: Theme .of (context)
318+ .colorScheme
319+ .primary,
298320 fontSize: 17 ,
299321 fontWeight: FontWeight .bold),
300322 )
301- else if (item.type ==
302- TransactionType .income)
323+ else if (item.type == TransactionType .income)
303324 Text (
304325 "+${formatMoneyWithContext (context , item .amount )}" ,
305326 style: const TextStyle (
@@ -313,7 +334,10 @@ class _DashboardPageState extends State<DashboardPage> {
313334 separatorBuilder:
314335 (BuildContext context, int index) {
315336 return Divider (
316- color: Theme .of (context).colorScheme.surfaceBright, height: 20 );
337+ color: Theme .of (context)
338+ .colorScheme
339+ .surfaceBright,
340+ height: 20 );
317341 },
318342 );
319343 }
@@ -327,7 +351,7 @@ class _DashboardPageState extends State<DashboardPage> {
327351 )
328352 ],
329353 );
330- }
331- );
354+ });
355+ } );
332356 }
333357}
0 commit comments