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: () {
@@ -124,7 +135,7 @@ class _DashboardPageState extends State<DashboardPage> {
124135 decoration: BoxDecoration (
125136 color: Colors .grey[300 ],
126137 borderRadius:
127- BorderRadius .circular (2 ),
138+ BorderRadius .circular (2 ),
128139 ),
129140 ),
130141 const SizedBox (
@@ -164,7 +175,8 @@ class _DashboardPageState extends State<DashboardPage> {
164175 Navigator .push (
165176 context,
166177 MaterialPageRoute (
167- builder: (context) => const AnalyticsPage ()));
178+ builder: (context) =>
179+ const AnalyticsPage ()));
168180 },
169181 ),
170182 DashboardButton (
@@ -174,7 +186,8 @@ class _DashboardPageState extends State<DashboardPage> {
174186 Navigator .push (
175187 context,
176188 MaterialPageRoute (
177- builder: (context) => const BudgetPage ()));
189+ builder: (context) =>
190+ const BudgetPage ()));
178191 },
179192 ),
180193 ],
@@ -198,9 +211,9 @@ class _DashboardPageState extends State<DashboardPage> {
198211 children: [
199212 Expanded (
200213 child: Text (
201- "Recent Transactions" ,
202- style: TextStyle (fontSize: 15 ),
203- )),
214+ "Recent Transactions" ,
215+ style: TextStyle (fontSize: 15 ),
216+ )),
204217 Icon (Icons .arrow_forward_ios)
205218 ],
206219 ),
@@ -215,11 +228,13 @@ class _DashboardPageState extends State<DashboardPage> {
215228 return const Center (
216229 child: CircularProgressIndicator (),
217230 );
218- } else if (transactionsState is TransactionsStateError ) {
231+ } else if (transactionsState
232+ is TransactionsStateError ) {
219233 return Center (
220234 child: Text (transactionsState.message),
221235 );
222- } else if (transactionsState is TransactionsStateLoaded ) {
236+ } else if (transactionsState
237+ is TransactionsStateLoaded ) {
223238 if (transactionsState.transactions.isEmpty) {
224239 return Center (
225240 child: Column (
@@ -248,9 +263,10 @@ class _DashboardPageState extends State<DashboardPage> {
248263 }
249264 return ListView .separated (
250265 padding: EdgeInsets .zero,
251- itemCount: transactionsState.transactions.length <= 30
252- ? transactionsState.transactions.length
253- : 30 ,
266+ itemCount:
267+ transactionsState.transactions.length <= 30
268+ ? transactionsState.transactions.length
269+ : 30 ,
254270 itemBuilder: (context, index) {
255271 var item = transactionsState.transactions[index];
256272 return Row (
@@ -259,25 +275,26 @@ class _DashboardPageState extends State<DashboardPage> {
259275 Container (
260276 padding: const EdgeInsets .all (10 ),
261277 decoration: BoxDecoration (
262- color: Theme .of (context).colorScheme.surfaceBright,
278+ color: Theme .of (context)
279+ .colorScheme
280+ .surfaceBright,
263281 borderRadius:
264- BorderRadius .circular (10 )),
282+ BorderRadius .circular (10 )),
265283 child: Icon (
266284 getCategoryIcon (
267285 item.category,
268286 defaultIcon:
269- item.type ==
270- TransactionType .expense
271- ? Icons .payments_rounded
272- : Icons .file_download_rounded,
287+ item.type == TransactionType .expense
288+ ? Icons .payments_rounded
289+ : Icons .file_download_rounded,
273290 ),
274291 size: 25 ,
275292 ),
276293 ),
277294 Expanded (
278295 child: Column (
279296 crossAxisAlignment:
280- CrossAxisAlignment .start,
297+ CrossAxisAlignment .start,
281298 children: [
282299 Text (item.name),
283300 Text (
@@ -289,17 +306,17 @@ class _DashboardPageState extends State<DashboardPage> {
289306 ],
290307 ),
291308 ),
292- if (item.type ==
293- TransactionType .expense)
309+ if (item.type == TransactionType .expense)
294310 Text (
295311 "-${formatMoneyWithContext (context , item .amount )}" ,
296312 style: TextStyle (
297- color: Theme .of (context).colorScheme.primary,
313+ color: Theme .of (context)
314+ .colorScheme
315+ .primary,
298316 fontSize: 17 ,
299317 fontWeight: FontWeight .bold),
300318 )
301- else if (item.type ==
302- TransactionType .income)
319+ else if (item.type == TransactionType .income)
303320 Text (
304321 "+${formatMoneyWithContext (context , item .amount )}" ,
305322 style: const TextStyle (
@@ -313,7 +330,10 @@ class _DashboardPageState extends State<DashboardPage> {
313330 separatorBuilder:
314331 (BuildContext context, int index) {
315332 return Divider (
316- color: Theme .of (context).colorScheme.surfaceBright, height: 20 );
333+ color: Theme .of (context)
334+ .colorScheme
335+ .surfaceBright,
336+ height: 20 );
317337 },
318338 );
319339 }
@@ -327,7 +347,7 @@ class _DashboardPageState extends State<DashboardPage> {
327347 )
328348 ],
329349 );
330- }
331- );
350+ });
351+ } );
332352 }
333353}
0 commit comments