From c430c43fd00e26086ddb7f2116241bc77f28c8b5 Mon Sep 17 00:00:00 2001 From: nada Date: Fri, 6 Feb 2026 22:04:44 +0200 Subject: [PATCH 1/5] feat: add account setup page 2 and localized strings --- lib/core/l10n/app_ar.arb | 4 +- lib/core/l10n/app_en.arb | 3 +- .../account_setup/screen/page2.dart | 55 +++++++++++++++++++ pubspec.lock | 44 +++++++++------ 4 files changed, 86 insertions(+), 20 deletions(-) create mode 100644 lib/presentation/account_setup/screen/page2.dart diff --git a/lib/core/l10n/app_ar.arb b/lib/core/l10n/app_ar.arb index 750407ca..476492e9 100644 --- a/lib/core/l10n/app_ar.arb +++ b/lib/core/l10n/app_ar.arb @@ -71,5 +71,7 @@ "currencyCode": "دينار", "spendingTrend": "اتجاه الإنفاق", - "noDataAvailable": "لا توجد بيانات متاحة" + "noDataAvailable": "لا توجد بيانات متاحة", + "how_much_money": "ما مقدار المال المتوفر لديك حاليًا؟" + } diff --git a/lib/core/l10n/app_en.arb b/lib/core/l10n/app_en.arb index 2e4d0a1f..9dd07fc6 100644 --- a/lib/core/l10n/app_en.arb +++ b/lib/core/l10n/app_en.arb @@ -107,5 +107,6 @@ "current": {}, "total": {} } - } + }, + "how_much_money": "How much money do you have right now?" } \ No newline at end of file diff --git a/lib/presentation/account_setup/screen/page2.dart b/lib/presentation/account_setup/screen/page2.dart new file mode 100644 index 00000000..eca0b824 --- /dev/null +++ b/lib/presentation/account_setup/screen/page2.dart @@ -0,0 +1,55 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter_svg/svg.dart'; +import '../../../core/l10n/app_localizations.dart'; +import '../../../design_system/assets/app_assets.dart'; +import '../../../design_system/theme/money_extension_context.dart'; +import '../../../design_system/widgets/text_field.dart'; + +class Page2 extends StatelessWidget { + final String currency; + const Page2({super.key, required this.currency}); + + @override + Widget build(BuildContext context) { + final l10n = AppLocalizations.of(context)!; + final TextEditingController controller = TextEditingController(); + + return Column( + children: [ + Text(l10n.how_much_money,style: context.typography.body.small.copyWith( + color: context.colors.body,),), + SizedBox(height: 24,), + MTextField( + hint: l10n.currency, + leading: Padding( + padding: const EdgeInsetsDirectional.only(top: 14,bottom: 14,end: 8), + child: SvgPicture.asset(AppAssets.iconMoney), + ), + trailing: Padding( + padding: const EdgeInsetsDirectional.only(top: 14,bottom: 14,end: 8), + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(100), + color: context.colors.surface, + ), + child: Padding( + padding: const EdgeInsetsDirectional.symmetric(vertical: 4,horizontal: 8), + child: Text( + currency, + style: context.typography.label.small.copyWith( + color: context.colors.body, + ), + ), + ), + ), + ), + keyboardType: TextInputType.number, + value: controller.text, + onChanged: (value) { + controller.text = value; + }, + ), + ], + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index 5190c57c..ffd3f3bf 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,10 +5,10 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: "5b7468c326d2f8a4f630056404ca0d291ade42918f4a3c6233618e724f39da8e" + sha256: c209688d9f5a5f26b2fb47a188131a6fb9e876ae9e47af3737c0b4f58a93470d url: "https://pub.dev" source: hosted - version: "92.0.0" + version: "91.0.0" adaptive_number: dependency: transitive description: @@ -21,10 +21,10 @@ packages: dependency: transitive description: name: analyzer - sha256: "70e4b1ef8003c64793a9e268a551a82869a8a96f39deb73dea28084b0e8bf75e" + sha256: f51c8499b35f9b26820cfe914828a6a98a94efd5cc78b37bb7d03debae3a1d08 url: "https://pub.dev" source: hosted - version: "9.0.0" + version: "8.4.1" ansicolor: dependency: transitive description: @@ -165,10 +165,10 @@ packages: dependency: transitive description: name: characters - sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b + sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 url: "https://pub.dev" source: hosted - version: "1.4.1" + version: "1.4.0" checked_yaml: dependency: transitive description: @@ -597,6 +597,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.5" + js: + dependency: transitive + description: + name: js + sha256: "53385261521cc4a0c4658fd0ad07a7d14591cf8fc33abbceae306ddb974888dc" + url: "https://pub.dev" + source: hosted + version: "0.7.2" json_annotation: dependency: transitive description: @@ -657,18 +665,18 @@ packages: dependency: transitive description: name: matcher - sha256: "12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6" + sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 url: "https://pub.dev" source: hosted - version: "0.12.18" + version: "0.12.17" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b" + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec url: "https://pub.dev" source: hosted - version: "0.13.0" + version: "0.11.1" meta: dependency: transitive description: @@ -1006,10 +1014,10 @@ packages: dependency: transitive description: name: source_helper - sha256: "4a85e90b50694e652075cbe4575665539d253e6ec10e46e76b45368ab5e3caae" + sha256: "6a3c6cc82073a8797f8c4dc4572146114a39652851c157db37e964d9c7038723" url: "https://pub.dev" source: hosted - version: "1.3.10" + version: "1.3.8" source_map_stack_trace: dependency: transitive description: @@ -1110,26 +1118,26 @@ packages: dependency: transitive description: name: test - sha256: "77cc98ea27006c84e71a7356cf3daf9ddbde2d91d84f77dbfe64cf0e4d9611ae" + sha256: "75906bf273541b676716d1ca7627a17e4c4070a3a16272b7a3dc7da3b9f3f6b7" url: "https://pub.dev" source: hosted - version: "1.28.0" + version: "1.26.3" test_api: dependency: transitive description: name: test_api - sha256: "19a78f63e83d3a61f00826d09bc2f60e191bf3504183c001262be6ac75589fb8" + sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55 url: "https://pub.dev" source: hosted - version: "0.7.8" + version: "0.7.7" test_core: dependency: transitive description: name: test_core - sha256: f1072617a6657e5fc09662e721307f7fb009b4ed89b19f47175d11d5254a62d4 + sha256: "0cc24b5ff94b38d2ae73e1eb43cc302b77964fbf67abad1e296025b78deb53d0" url: "https://pub.dev" source: hosted - version: "0.6.14" + version: "0.6.12" typed_data: dependency: transitive description: From 4145bf6639c83ec124e60796e866df66f646cfb6 Mon Sep 17 00:00:00 2001 From: nada Date: Mon, 9 Feb 2026 22:57:30 +0200 Subject: [PATCH 2/5] feat: Implement current balance in step 2 in account setup --- lib/core/l10n/app_ar.arb | 1 + lib/core/l10n/app_en.arb | 1 + .../account_setup/screen/page2.dart | 43 +++++++++++++------ 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/lib/core/l10n/app_ar.arb b/lib/core/l10n/app_ar.arb index 476492e9..24c4a39b 100644 --- a/lib/core/l10n/app_ar.arb +++ b/lib/core/l10n/app_ar.arb @@ -72,6 +72,7 @@ "spendingTrend": "اتجاه الإنفاق", "noDataAvailable": "لا توجد بيانات متاحة", + "current_balance":"الرصيد الحالي", "how_much_money": "ما مقدار المال المتوفر لديك حاليًا؟" } diff --git a/lib/core/l10n/app_en.arb b/lib/core/l10n/app_en.arb index 9dd07fc6..d941dce7 100644 --- a/lib/core/l10n/app_en.arb +++ b/lib/core/l10n/app_en.arb @@ -108,5 +108,6 @@ "total": {} } }, + "current_balance":"Current balance", "how_much_money": "How much money do you have right now?" } \ No newline at end of file diff --git a/lib/presentation/account_setup/screen/page2.dart b/lib/presentation/account_setup/screen/page2.dart index eca0b824..52cc80a7 100644 --- a/lib/presentation/account_setup/screen/page2.dart +++ b/lib/presentation/account_setup/screen/page2.dart @@ -1,39 +1,58 @@ import 'package:flutter/cupertino.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_svg/svg.dart'; + import '../../../core/l10n/app_localizations.dart'; import '../../../design_system/assets/app_assets.dart'; import '../../../design_system/theme/money_extension_context.dart'; import '../../../design_system/widgets/text_field.dart'; +import '../cubit/account_setup_cubit.dart'; class Page2 extends StatelessWidget { final String currency; - const Page2({super.key, required this.currency}); + final String currentBalanceState; + + const Page2({super.key, required this.currency, required this.currentBalanceState}); @override Widget build(BuildContext context) { final l10n = AppLocalizations.of(context)!; - final TextEditingController controller = TextEditingController(); return Column( children: [ - Text(l10n.how_much_money,style: context.typography.body.small.copyWith( - color: context.colors.body,),), - SizedBox(height: 24,), + Text( + l10n.how_much_money, + style: context.typography.body.small.copyWith( + color: context.colors.body, + ), + ), + SizedBox(height: 24), MTextField( - hint: l10n.currency, + hint: l10n.current_balance, leading: Padding( - padding: const EdgeInsetsDirectional.only(top: 14,bottom: 14,end: 8), + padding: const EdgeInsetsDirectional.only( + top: 14, + bottom: 14, + end: 8, + ), child: SvgPicture.asset(AppAssets.iconMoney), ), - trailing: Padding( - padding: const EdgeInsetsDirectional.only(top: 14,bottom: 14,end: 8), + trailing: Padding( + padding: const EdgeInsetsDirectional.only( + top: 14, + bottom: 14, + end: 8, + ), child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(100), color: context.colors.surface, ), child: Padding( - padding: const EdgeInsetsDirectional.symmetric(vertical: 4,horizontal: 8), + padding: const EdgeInsetsDirectional.symmetric( + vertical: 4, + horizontal: 8, + ), child: Text( currency, style: context.typography.label.small.copyWith( @@ -44,9 +63,9 @@ class Page2 extends StatelessWidget { ), ), keyboardType: TextInputType.number, - value: controller.text, + value: currentBalanceState, onChanged: (value) { - controller.text = value; + context.read().onCurrentBalanceChanged(value); }, ), ], From 2130f57617b056e3fb4fd76c16fd0636a03e618b Mon Sep 17 00:00:00 2001 From: nada Date: Mon, 9 Feb 2026 22:57:37 +0200 Subject: [PATCH 3/5] feat: implement logic of account setup screen in cubit --- lib/money_app.dart | 6 +- .../cubit/account_setup_cubit.dart | 65 +++++++- .../cubit/account_setup_state.dart | 30 +++- .../screen/account_setup_screen.dart | 142 ++++++++++-------- .../screen/currency_bottom_sheet.dart | 6 +- .../account_setup/screen/page1.dart | 73 ++++++--- 6 files changed, 220 insertions(+), 102 deletions(-) diff --git a/lib/money_app.dart b/lib/money_app.dart index dcff974c..316a06fa 100644 --- a/lib/money_app.dart +++ b/lib/money_app.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:go_router/go_router.dart'; import 'package:moneyplus/design_system/theme/money_theme.dart'; +import 'package:moneyplus/presentation/account_setup/screen/account_setup_screen.dart'; import 'package:moneyplus/presentation/navigation/routes.dart'; import 'core/l10n/app_localizations.dart'; @@ -17,7 +18,7 @@ class MoneyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { - return MaterialApp.router( + return MaterialApp( debugShowCheckedModeBanner: false, title: 'Money++', localizationsDelegates: const [ @@ -31,7 +32,8 @@ class MoneyApp extends StatelessWidget { Locale('ar'), ], theme: MoneyTheme.lightTheme, - routerConfig: _router, + // routerConfig: _router, + home: AccountSetupScreen(), ); } } diff --git a/lib/presentation/account_setup/cubit/account_setup_cubit.dart b/lib/presentation/account_setup/cubit/account_setup_cubit.dart index 546a2a83..86b43a62 100644 --- a/lib/presentation/account_setup/cubit/account_setup_cubit.dart +++ b/lib/presentation/account_setup/cubit/account_setup_cubit.dart @@ -1,6 +1,7 @@ +import 'package:flutter_bloc/flutter_bloc.dart'; + import '../../../domain/repository/account_repository.dart'; import 'account_setup_state.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; class AccountSetupCubit extends Cubit { final AccountRepository _accountSetupRepository; @@ -8,13 +9,67 @@ class AccountSetupCubit extends Cubit { AccountSetupCubit(this._accountSetupRepository) : super(AccountSetupState()); Future fetchCurrencies() async { - try{ + try { final currencies = await _accountSetupRepository.getCurrencies(); - emit(state.copyWith(currencies : currencies,isLoading: false)); - }catch(e){ + emit(state.copyWith(currencies: currencies, isLoading: false)); + } catch (e) { emit(state.copyWith(isLoading: false, errorMessage: e.toString())); } } -} \ No newline at end of file + bool _accountSetUpStep1ValidationInput() { + return state.currency.isNotEmpty && state.salary.isNotEmpty && state.salaryDay.isNotEmpty; + } + + bool _accountSetUpStep2ValidationInput() { + return state.currentBalance.isNotEmpty; + } + + void onSalaryChanged(String salary){ + emit(state.copyWith(salary: salary)); + _updateButtonEnabledState(); + } + + void onCurrencyChanged(String currency){ + emit(state.copyWith(currency: currency)); + _updateButtonEnabledState(); + } + + void onSalaryDayChanged(String salaryDay){ + emit(state.copyWith(salaryDay: salaryDay)); + _updateButtonEnabledState(); + } + + void onCurrentBalanceChanged(String currentBalance) { + emit(state.copyWith(currentBalance: currentBalance)); + _updateButtonEnabledState(); + } + + void _updateButtonEnabledState() { + + bool isButtonEnable = switch (state.accountStep) { + AccountStep.step1 => _accountSetUpStep1ValidationInput(), + AccountStep.step2 => _accountSetUpStep2ValidationInput(), + AccountStep.step3 => false, + }; + emit(state.copyWith(isButtonEnabled: isButtonEnable)); + } + + void onNextStep() { + switch (state.accountStep) { + case AccountStep.step1: + emit(state.copyWith(accountStep: AccountStep.step2)); + _updateButtonEnabledState(); + break; + case AccountStep.step2: + emit(state.copyWith(accountStep: AccountStep.step3)); + _updateButtonEnabledState(); + break; + case AccountStep.step3: + // submit account setup date + emit(state.copyWith(navigateToHome: true)); + break; + } + } +} diff --git a/lib/presentation/account_setup/cubit/account_setup_state.dart b/lib/presentation/account_setup/cubit/account_setup_state.dart index 40a4a0e9..1da74e6c 100644 --- a/lib/presentation/account_setup/cubit/account_setup_state.dart +++ b/lib/presentation/account_setup/cubit/account_setup_state.dart @@ -1,36 +1,51 @@ import 'package:moneyplus/domain/entity/currency.dart'; +enum AccountStep { + step1, + step2, + step3, +} + class AccountSetupState { final String currency; - final double salary; - final int salaryDay; + final String salary; + final String salaryDay; final String query; final bool isButtonEnabled; final List currencies; final bool isLoading; final String errorMessage; + final AccountStep accountStep; + final String currentBalance; + final bool navigateToHome; AccountSetupState({ this.currency = "", - this.salary = 0.0, - this.salaryDay = 0, + this.salary = "", + this.salaryDay = "", this.query = "", this.isButtonEnabled = false, this.currencies = const [], this.isLoading = true, this.errorMessage = "", + this.accountStep = AccountStep.step1, + this.currentBalance = "", + this.navigateToHome = false, }); AccountSetupState copyWith({ String? currency, - double? salary, - int? salaryDay, + String? salary, + String? salaryDay, String? query, bool? isButtonEnabled, List? currencies, String? errorMessage, bool? isLoading, + AccountStep? accountStep, + String? currentBalance, + bool? navigateToHome, }) { return AccountSetupState( currency: currency ?? this.currency, @@ -41,6 +56,9 @@ class AccountSetupState { currencies: currencies?? this.currencies, errorMessage: errorMessage?? this.errorMessage, isLoading: isLoading?? this.isLoading, + accountStep: accountStep?? this.accountStep, + currentBalance: currentBalance?? this.currentBalance, + navigateToHome: navigateToHome?? this.navigateToHome, ); } } diff --git a/lib/presentation/account_setup/screen/account_setup_screen.dart b/lib/presentation/account_setup/screen/account_setup_screen.dart index a461d3d6..14c1f77a 100644 --- a/lib/presentation/account_setup/screen/account_setup_screen.dart +++ b/lib/presentation/account_setup/screen/account_setup_screen.dart @@ -4,6 +4,7 @@ import 'package:flutter_svg/svg.dart'; import 'package:moneyplus/design_system/assets/app_assets.dart'; import 'package:moneyplus/design_system/widgets/app_bar.dart'; import 'package:moneyplus/presentation/account_setup/screen/page1.dart'; +import 'package:moneyplus/presentation/account_setup/screen/page2.dart'; import '../../../core/l10n/app_localizations.dart'; import '../../../design_system/theme/money_extension_context.dart'; @@ -42,74 +43,91 @@ class _AccountSetupScreenState extends State { return BlocProvider( create: (context) => cubit..fetchCurrencies(), - child: BlocBuilder( - builder: (context, state) { - return Scaffold( - backgroundColor: context.colors.surface, - body: SafeArea( - child: Padding( - padding: const EdgeInsetsDirectional.all(16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CustomAppBar( - leading: AppBarCircleButton( - assetPath: AppAssets.icArrowLeft, onTap: () {}), - title: l10n.accountSetup, - trailing: SvgPicture.asset(AppAssets.appBrand,), - ), - SizedBox(height: 36,), - Indicator(currentIndex: currentIndex), - SizedBox(height: 16,), - Text( - l10n.stepOfTotal(currentIndex + 1, 3), - style: context.typography.label.small.copyWith( - color: context.colors.body, + child: BlocListener( + listener: (context, state) { + if (state.accountStep.index != currentIndex) { + pageController.animateToPage( + state.accountStep.index, + duration: const Duration(milliseconds: 300), + curve: Curves.easeInOut, + ); + setState(() { + currentIndex = state.accountStep.index; + }); + } + if (state.navigateToHome) { + // navigate to home + } + }, + child: BlocBuilder( + builder: (context, state) { + return Scaffold( + backgroundColor: context.colors.surface, + body: SafeArea( + child: Padding( + padding: const EdgeInsetsDirectional.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CustomAppBar( + leading: AppBarCircleButton( + assetPath: AppAssets.icArrowLeft, + onTap: () { + Navigator.pop(context); + }, + ), + title: l10n.accountSetup, + trailing: SvgPicture.asset(AppAssets.appBrand), + ), + SizedBox(height: 36), + Indicator(currentIndex: currentIndex), + SizedBox(height: 16), + Text( + l10n.stepOfTotal(currentIndex + 1, 3), + style: context.typography.label.small.copyWith( + color: context.colors.body, + ), + ), + SizedBox(height: 4), + Text( + l10n.setUpYourAccount, + style: context.typography.headline.medium.copyWith( + color: context.colors.title, + ), ), - ), - SizedBox(height: 4), - Text( - l10n.setUpYourAccount, - style: context.typography.headline.medium.copyWith( - color: context.colors.title, + SizedBox(height: 4), + Expanded( + child: PageView( + controller: pageController, + physics: const NeverScrollableScrollPhysics(), + onPageChanged: (index) { + setState(() { + currentIndex = index; + }); + }, + children: [ + SingleChildScrollView(child: Page1(state: state,)), + SingleChildScrollView(child: Page2(currency: state.currency, currentBalanceState: state.currentBalance)), + // page3() + ], + ), ), - ), - SizedBox(height: 4), - Expanded( - child: PageView( - controller: pageController, - onPageChanged: (index) { - setState(() { - currentIndex = index; - }); + DefaultButton( + text: state.accountStep == AccountStep.step3 + ? l10n.finishSetup + : l10n.next, + isEnabled: state.isButtonEnabled, + onPressed: () { + context.read().onNextStep(); }, - children: [ - SingleChildScrollView(child: Page1(state: state)) - // page2() - // page3() - ], ), - ), - DefaultButton( - text: currentIndex == 2 ? l10n.finishSetup : l10n.next, - isEnabled: false, - onPressed: () { - if (currentIndex < 2) { - pageController.nextPage( - duration: const Duration(milliseconds: 300), - curve: Curves.easeInOut, - ); - } else { - // Navigate to home - } - }, - ), - ], + ], + ), ), ), - ), - ); - }, + ); + }, + ), ), ); } diff --git a/lib/presentation/account_setup/screen/currency_bottom_sheet.dart b/lib/presentation/account_setup/screen/currency_bottom_sheet.dart index 14c866a5..a407e90c 100644 --- a/lib/presentation/account_setup/screen/currency_bottom_sheet.dart +++ b/lib/presentation/account_setup/screen/currency_bottom_sheet.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:moneyplus/design_system/assets/app_assets.dart'; import 'package:moneyplus/design_system/theme/money_extension_context.dart'; @@ -6,6 +7,7 @@ import 'package:moneyplus/design_system/widgets/text_field.dart'; import '../../../core/l10n/app_localizations.dart'; import '../../../design_system/widgets/buttons/button/default_button.dart'; +import '../cubit/account_setup_cubit.dart'; import '../cubit/account_setup_state.dart'; import 'currency_list.dart'; @@ -65,9 +67,9 @@ class _CurrencyBottomSheetState extends State { ), child: MTextField( hint: l10n.search, - value: searchController.text, + value: widget.state.query, onChanged: (value) { - searchController.text = value; + context.read().onCurrencyChanged(value); }, leading: Padding( padding: const EdgeInsetsDirectional.only( diff --git a/lib/presentation/account_setup/screen/page1.dart b/lib/presentation/account_setup/screen/page1.dart index 6eec6bce..3d06b200 100644 --- a/lib/presentation/account_setup/screen/page1.dart +++ b/lib/presentation/account_setup/screen/page1.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:moneyplus/design_system/assets/app_assets.dart'; import 'package:moneyplus/design_system/widgets/text_field.dart'; @@ -6,10 +7,12 @@ import 'package:moneyplus/presentation/account_setup/cubit/account_setup_state.d import '../../../core/l10n/app_localizations.dart'; import '../../../design_system/theme/money_extension_context.dart'; +import '../cubit/account_setup_cubit.dart'; import 'currency_bottom_sheet.dart'; class Page1 extends StatefulWidget { final AccountSetupState state; + const Page1({super.key, required this.state}); @override @@ -18,10 +21,6 @@ class Page1 extends StatefulWidget { class _Page1State extends State { - final TextEditingController currencyController = TextEditingController(); - final TextEditingController salaryController = TextEditingController(); - final TextEditingController dayController = TextEditingController(); - @override Widget build(BuildContext context) { final l10n = AppLocalizations.of(context)!; @@ -37,55 +36,83 @@ class _Page1State extends State { ), SizedBox(height: 24), MTextField( + key: ValueKey(widget.state.currency), hint: l10n.currency, leading: Padding( - padding: const EdgeInsetsDirectional.only(top: 14,bottom: 14,end: 8), + padding: const EdgeInsetsDirectional.only( + top: 14, + bottom: 14, + end: 8, + ), child: SvgPicture.asset(AppAssets.iconMoney), ), trailing: Padding( - padding: const EdgeInsetsDirectional.only(top: 14,bottom: 14,end: 8), + padding: const EdgeInsetsDirectional.only( + top: 14, + bottom: 14, + end: 8, + ), child: GestureDetector( onTap: () { - _openCurrencyBottomSheet(widget.state); + _openCurrencyBottomSheet(widget.state); }, - child: SvgPicture.asset(AppAssets.icArrowDownRound, height: 20,width: 20,), + child: SvgPicture.asset( + AppAssets.icArrowDownRound, + height: 20, + width: 20, + ), ), ), keyboardType: TextInputType.number, - value: currencyController.text, + value: widget.state.currency, onChanged: (value) { - currencyController.text = value; + context.read().onCurrencyChanged(value); }, ), SizedBox(height: 12), MTextField( hint: l10n.salary, leading: Padding( - padding: const EdgeInsetsDirectional.only(top: 14,bottom: 14,end: 8), + padding: const EdgeInsetsDirectional.only( + top: 14, + bottom: 14, + end: 8, + ), child: SvgPicture.asset(AppAssets.iconMoney), ), keyboardType: TextInputType.number, - value: salaryController.text, + value: widget.state.salary, onChanged: (value) { - salaryController.text = value; + context.read().onSalaryChanged(value); }, ), SizedBox(height: 12), MTextField( hint: l10n.salaryDay, leading: Padding( - padding: const EdgeInsetsDirectional.only(top: 14,bottom: 14,end: 8), + padding: const EdgeInsetsDirectional.only( + top: 14, + bottom: 14, + end: 8, + ), child: SvgPicture.asset(AppAssets.iconCalender), ), trailing: Padding( - padding: const EdgeInsetsDirectional.only(top: 14,bottom: 14,end: 8), + padding: const EdgeInsetsDirectional.only( + top: 14, + bottom: 14, + end: 8, + ), child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(100), color: context.colors.surface, ), child: Padding( - padding: const EdgeInsetsDirectional.symmetric(vertical: 4,horizontal: 8), + padding: const EdgeInsetsDirectional.symmetric( + vertical: 4, + horizontal: 8, + ), child: Text( l10n.fromEachMonth, style: context.typography.label.small.copyWith( @@ -96,15 +123,16 @@ class _Page1State extends State { ), ), keyboardType: TextInputType.number, - value: dayController.text , + value: widget.state.salaryDay, onChanged: (value) { - dayController.text = value; + context.read().onSalaryDayChanged(value); }, ), - SizedBox(height: 16,) + SizedBox(height: 16), ], ); } + Future _openCurrencyBottomSheet(AccountSetupState state) async { final result = await showModalBottomSheet( context: context, @@ -118,12 +146,7 @@ class _Page1State extends State { ); if (result != null) { - setState(() { - currencyController.text = result; - }); + context.read().onCurrencyChanged(result); } } - } - - From a97278f52a308b4cdc772cd2e7b82098abde2b66 Mon Sep 17 00:00:00 2001 From: nada Date: Mon, 9 Feb 2026 22:58:41 +0200 Subject: [PATCH 4/5] revert commit of money app to use router config --- lib/money_app.dart | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/money_app.dart b/lib/money_app.dart index 316a06fa..dcff974c 100644 --- a/lib/money_app.dart +++ b/lib/money_app.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:go_router/go_router.dart'; import 'package:moneyplus/design_system/theme/money_theme.dart'; -import 'package:moneyplus/presentation/account_setup/screen/account_setup_screen.dart'; import 'package:moneyplus/presentation/navigation/routes.dart'; import 'core/l10n/app_localizations.dart'; @@ -18,7 +17,7 @@ class MoneyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { - return MaterialApp( + return MaterialApp.router( debugShowCheckedModeBanner: false, title: 'Money++', localizationsDelegates: const [ @@ -32,8 +31,7 @@ class MoneyApp extends StatelessWidget { Locale('ar'), ], theme: MoneyTheme.lightTheme, - // routerConfig: _router, - home: AccountSetupScreen(), + routerConfig: _router, ); } } From 99f6d58e33e00604fefebe786382ee147e6cd56d Mon Sep 17 00:00:00 2001 From: mohamedshemees <72915905+mohamedshemees@users.noreply.github.com> Date: Fri, 13 Feb 2026 06:09:19 +0200 Subject: [PATCH 5/5] Apply suggestion from @mohamedshemees --- lib/core/l10n/app_en.arb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/l10n/app_en.arb b/lib/core/l10n/app_en.arb index 70daa5b7..aac1dbdc 100644 --- a/lib/core/l10n/app_en.arb +++ b/lib/core/l10n/app_en.arb @@ -123,7 +123,7 @@ } }, "current_balance":"Current balance", - "how_much_money": "How much money do you have right now?" + "how_much_money": "How much money do you have right now?", "no_spending_categories": "No spending categories available", "month_january": "January", "month_february": "February",