From c7aedc33836d1fb64f2b33852ed761000db08a49 Mon Sep 17 00:00:00 2001 From: jayesh Date: Thu, 20 Jun 2024 16:03:44 +0530 Subject: [PATCH 1/2] ui fixing --- .../widgets/key_investment_section.dart | 31 +-- .../pages/deposit/depositScreen.dart | 133 +---------- .../widgets/deposit_pay_method_section.dart | 217 ++++++++++++++++++ .../widgets/otp_fill_section.dart | 2 + .../components/form_label_textfield.dart | 4 +- 5 files changed, 242 insertions(+), 145 deletions(-) create mode 100644 lib/features/MainScreens/Wallet/presentation/widgets/deposit_pay_method_section.dart diff --git a/lib/features/MainScreens/Invest/presentation/widgets/key_investment_section.dart b/lib/features/MainScreens/Invest/presentation/widgets/key_investment_section.dart index 6a09209..c3d5968 100644 --- a/lib/features/MainScreens/Invest/presentation/widgets/key_investment_section.dart +++ b/lib/features/MainScreens/Invest/presentation/widgets/key_investment_section.dart @@ -15,6 +15,7 @@ class KeyInvestmentSection extends StatelessWidget { Widget build(BuildContext context) { return Container( width: double.infinity, + padding: const EdgeInsets.symmetric(horizontal: 5), decoration: BoxDecoration( color: AppColor.documentCardBgColor, borderRadius: const BorderRadius.all(Radius.circular(20.0)), @@ -79,20 +80,22 @@ Widget investmentSectionCardText( children: [ SvgPicture.asset(icon), const Gap(8), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - TextWidget().text14W700( - title, - clr: AppColor.textLabelColor, - txtAlign: TextAlign.start, - ), - TextWidget().text14W400( - subtitle, - clr: AppColor.textLabelColor, - txtAlign: TextAlign.start, - ), - ], + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextWidget().text14W700( + title, + clr: AppColor.textLabelColor, + txtAlign: TextAlign.start, + ), + TextWidget().text14W400( + subtitle, + clr: AppColor.textLabelColor, + txtAlign: TextAlign.start, + ), + ], + ), ) ], ); diff --git a/lib/features/MainScreens/Wallet/presentation/pages/deposit/depositScreen.dart b/lib/features/MainScreens/Wallet/presentation/pages/deposit/depositScreen.dart index b4ebfca..39eba87 100644 --- a/lib/features/MainScreens/Wallet/presentation/pages/deposit/depositScreen.dart +++ b/lib/features/MainScreens/Wallet/presentation/pages/deposit/depositScreen.dart @@ -2,17 +2,14 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:flutter_svg/svg.dart'; import 'package:gap/gap.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:tanami_app/core/routes/route_name.dart'; import 'package:tanami_app/core/routes/routes.dart'; -import 'package:tanami_app/core/styles/app_color.dart'; -import 'package:tanami_app/core/styles/app_images.dart'; import 'package:tanami_app/core/styles/app_text.dart'; import 'package:tanami_app/features/countrySelection/presentation/bloc/choose_country_bloc.dart'; -import 'package:tanami_app/features/countrySelection/presentation/bloc/choose_country_event.dart'; -import 'package:tanami_app/shared/components/text_widget.dart'; + +import '../../widgets/deposit_pay_method_section.dart'; class DepositScreen extends StatefulWidget { const DepositScreen({super.key}); @@ -288,131 +285,7 @@ class _DepositScreenState extends State { ), ), const Gap(30), - TextWidget().text15W700(AppText.choosePaymentMethodText, - clr: AppColor.plainBlack), - const Gap(16), - GestureDetector( - onTap: () { - radioBloc.add(const RadioSelected(0)); - }, - child: Container( - padding: const EdgeInsets.all(12), - decoration: ShapeDecoration( - color: Colors.white, - shape: RoundedRectangleBorder( - side: const BorderSide(color: Color(0xFFD8D8D8)), - borderRadius: BorderRadius.circular(22), - ), - shadows: const [ - BoxShadow( - color: Color(0x14000000), - blurRadius: 8, - offset: Offset(-2, -2), - spreadRadius: 0.50, - ), - BoxShadow( - color: Color(0x3391978E), - blurRadius: 8, - offset: Offset(2, 2), - spreadRadius: 1, - ) - ], - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Radio( - activeColor: AppColor.radioActiveColor, - value: 0, - groupValue: selectedIndex, - onChanged: (int? value) { - if (value != null) { - radioBloc.add(RadioSelected(value)); - } - }, - ), - SvgPicture.asset(AppImages.walletIcon), - const Gap(5), - TextWidget().text14W700(AppText.bankTransfer, - clr: AppColor.textLabelColor), - ], - ), - TextWidget().text14W500( - "Directly transfer funds from your bank account into your Tanami wallet.", - clr: AppColor.textLabelColor, - txtAlign: TextAlign.left, - ), - const Gap(12), - ], - ), - ), - ), - const Gap(12), - GestureDetector( - onTap: () { - radioBloc.add(const RadioSelected(1)); - }, - child: Container( - padding: const EdgeInsets.all(12), - decoration: ShapeDecoration( - color: Colors.white, - shape: RoundedRectangleBorder( - side: const BorderSide(color: Color(0xFFD8D8D8)), - borderRadius: BorderRadius.circular(22), - ), - shadows: const [ - BoxShadow( - color: Color(0x14000000), - blurRadius: 8, - offset: Offset(-2, -2), - spreadRadius: 0.2, - ), - BoxShadow( - color: Color(0x3391978E), - blurRadius: 8, - offset: Offset(2, 2), - spreadRadius: 1, - ) - ], - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - Radio( - activeColor: AppColor.radioActiveColor, - value: 1, - groupValue: selectedIndex, - onChanged: (int? value) { - if (value != null) { - radioBloc.add(RadioSelected(value)); - } - }, - ), - SvgPicture.asset(AppImages.applePayIcon), - const Gap(5), - TextWidget().text14W700(AppText.applePayText, - clr: AppColor.textLabelColor), - ], - ), - ], - ), - TextWidget().text14W500( - AppText.instantTransferFundsApplePayText, - clr: AppColor.textLabelColor, - txtAlign: TextAlign.left, - ), - const Gap(12), - ], - ), - ), - ), + const DepositPayMethodSection(), const Gap(16), ], ), diff --git a/lib/features/MainScreens/Wallet/presentation/widgets/deposit_pay_method_section.dart b/lib/features/MainScreens/Wallet/presentation/widgets/deposit_pay_method_section.dart new file mode 100644 index 0000000..42dad10 --- /dev/null +++ b/lib/features/MainScreens/Wallet/presentation/widgets/deposit_pay_method_section.dart @@ -0,0 +1,217 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:gap/gap.dart'; +import 'package:google_fonts/google_fonts.dart'; +import 'package:tanami_app/core/styles/app_images.dart'; +import 'package:tanami_app/core/styles/app_text.dart'; +import 'package:tanami_app/shared/components/text_widget.dart'; + +import '../../../../../../core/styles/app_color.dart'; +import '../../../../countrySelection/presentation/bloc/choose_country_bloc.dart'; +import '../../../../countrySelection/presentation/bloc/choose_country_event.dart'; +import '../../../../countrySelection/presentation/bloc/choose_country_state.dart'; + +class DepositPayMethodSection extends StatelessWidget { + const DepositPayMethodSection({super.key}); + + @override + Widget build(BuildContext context) { + final radioBloc = context.read(); + return BlocBuilder( + builder: (context, state) { + int selectedIndex = 0; + if (state is RadioSelectionChanged) { + selectedIndex = state.selectedIndex; + } + + return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + TextWidget().text15W700(AppText.choosePaymentMethodText, + clr: AppColor.plainBlack), + const Gap(16), + GestureDetector( + onTap: () { + radioBloc.add(const RadioSelected(0)); + }, + child: Container( + clipBehavior: Clip.antiAlias, + // padding: const EdgeInsets.all(12), + decoration: ShapeDecoration( + color: Colors.white, + shape: RoundedRectangleBorder( + side: const BorderSide(color: Color(0xFFD8D8D8)), + borderRadius: BorderRadius.circular(22), + ), + shadows: const [ + BoxShadow( + color: Color(0x14000000), + blurRadius: 8, + offset: Offset(-2, -2), + spreadRadius: 0.50, + ), + BoxShadow( + color: Color(0x3391978E), + blurRadius: 8, + offset: Offset(2, 2), + spreadRadius: 1, + ) + ], + ), + child: Column( + children: [ + Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: selectedIndex == 0 + ? const Color(0xFFE4F5E9) + : const Color(0xCCE2E2E2), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Radio( + activeColor: AppColor.radioActiveColor, + value: 0, + groupValue: selectedIndex, + onChanged: (int? value) { + if (value != null) { + radioBloc.add(RadioSelected(value)); + } + }, + ), + const Gap(5), + SvgPicture.asset(AppImages.walletIcon), + const Gap(5), + TextWidget().text14W700(AppText.walletText, + clr: AppColor.textLabelColor), + ], + ), + Row( + children: [ + RichText( + text: TextSpan( + children: [ + TextSpan( + text: '${AppText.balanceText}: ', + style: GoogleFonts.dmSans( + color: Colors.grey, + fontSize: 12.0, + fontWeight: FontWeight.bold, + ), + ), + TextSpan( + text: 'SAR 178,000', + style: GoogleFonts.dmSans( + color: Colors.black, + fontSize: 14.0, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + // const Icon( + // Icons.arrow_forward, + // color: Colors.grey, + // size: 15, + // ) + ], + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(12), + child: TextWidget().text14W500( + "condimentum ac, vestibulum eu nisl.torquent per conubia nostra, per inceptos himenaeos.", + clr: AppColor.textLabelColor, + txtAlign: TextAlign.start, + ), + ), + const Gap(12), + ], + ), + ), + ), + const Gap(12), + GestureDetector( + onTap: () { + radioBloc.add(const RadioSelected(1)); + }, + child: Container( + clipBehavior: Clip.antiAlias, + // padding: const EdgeInsets.all(12), + decoration: ShapeDecoration( + color: Colors.white, + shape: RoundedRectangleBorder( + side: const BorderSide(color: Color(0xFFD8D8D8)), + borderRadius: BorderRadius.circular(22), + ), + shadows: const [ + BoxShadow( + color: Color(0x14000000), + blurRadius: 8, + offset: Offset(-2, -2), + spreadRadius: 0.2, + ), + BoxShadow( + color: Color(0x3391978E), + blurRadius: 8, + offset: Offset(2, 2), + spreadRadius: 1, + ) + ], + ), + child: Column( + children: [ + Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: selectedIndex == 1 + ? const Color(0xFFE4F5E9) + : const Color(0xCCE2E2E2), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Radio( + activeColor: AppColor.radioActiveColor, + value: 1, + groupValue: selectedIndex, + onChanged: (int? value) { + if (value != null) { + radioBloc.add(RadioSelected(value)); + } + }, + ), + const Gap(5), + SvgPicture.asset(AppImages.applePayIcon), + const Gap(5), + TextWidget().text14W700(AppText.applePayText, + clr: AppColor.textLabelColor), + ], + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(12.0), + child: TextWidget().text14W500( + AppText.instantTransferFundsApplePayText, + clr: AppColor.textLabelColor), + ), + const Gap(12), + ], + ), + ), + ), + // const Gap(16), + ]); + }, + ); + } +} diff --git a/lib/features/otpVerification/presentation/widgets/otp_fill_section.dart b/lib/features/otpVerification/presentation/widgets/otp_fill_section.dart index a3213df..6220d39 100644 --- a/lib/features/otpVerification/presentation/widgets/otp_fill_section.dart +++ b/lib/features/otpVerification/presentation/widgets/otp_fill_section.dart @@ -25,9 +25,11 @@ class OtpFillSection extends StatelessWidget { return BlocConsumer( listener: (context, state) { if (state is OtpSubmitting) { + FocusScope.of(context).unfocus(); Loader.loader(context); } else if (state is OtpSubmissionSuccess) { goRouter.pop(); + successToastMessage( context, AppText.otpVerifiedSucessfully, diff --git a/lib/shared/components/form_label_textfield.dart b/lib/shared/components/form_label_textfield.dart index c7a8f84..c6f8acb 100644 --- a/lib/shared/components/form_label_textfield.dart +++ b/lib/shared/components/form_label_textfield.dart @@ -71,7 +71,9 @@ class FormLabelTextField extends StatelessWidget { maxlines: type == "description" ? 6 : 1, texttype: type == "phone number" ? TextInputType.phone - : TextInputType.name, + : type == "Email" + ? TextInputType.emailAddress + : TextInputType.name, textEditingController: textEditingController, readonly: type == "country selection" ? true : false, hintText: hintText, From 1fa37a1c3e481834045734678a580541c31f225b Mon Sep 17 00:00:00 2001 From: jayesh Date: Thu, 20 Jun 2024 17:26:36 +0530 Subject: [PATCH 2/2] ui fixing --- .../bloc/payment/invest_payment_bloc.dart | 27 ++++++++ .../bloc/payment/invest_payment_event.dart | 17 +++++ .../bloc/payment/invest_payment_state.dart | 16 +++++ .../pages/payment/invest_payment_layout.dart | 4 ++ .../pages/payment/invest_payment_screen.dart | 12 +++- .../payment/invest_pay_bottom_section.dart | 39 +++++++---- .../payment/invest_pay_method_section.dart | 66 ++++++++----------- .../payment/invest_pay_top_section.dart | 55 ++++++++++------ 8 files changed, 165 insertions(+), 71 deletions(-) create mode 100644 lib/features/MainScreens/Invest/presentation/bloc/payment/invest_payment_bloc.dart create mode 100644 lib/features/MainScreens/Invest/presentation/bloc/payment/invest_payment_event.dart create mode 100644 lib/features/MainScreens/Invest/presentation/bloc/payment/invest_payment_state.dart diff --git a/lib/features/MainScreens/Invest/presentation/bloc/payment/invest_payment_bloc.dart b/lib/features/MainScreens/Invest/presentation/bloc/payment/invest_payment_bloc.dart new file mode 100644 index 0000000..b736b3d --- /dev/null +++ b/lib/features/MainScreens/Invest/presentation/bloc/payment/invest_payment_bloc.dart @@ -0,0 +1,27 @@ +import 'package:bloc/bloc.dart'; +import 'package:flutter/material.dart'; + +import 'invest_payment_event.dart'; +import 'invest_payment_state.dart'; + +class InvestPaymentBloc extends Bloc { + final GlobalKey formKey = GlobalKey(); + TextEditingController amountController = TextEditingController(); + + GlobalKey getFormKey() { + return formKey; + } + + InvestPaymentBloc() : super(const InvestPaymentState(isFormValid: false)) { + on((event, emit) { + emit(state.copyWith(isFormValid: event.text.isNotEmpty)); + }); + } + + @override + Future close() { + amountController.dispose(); + + return super.close(); + } +} diff --git a/lib/features/MainScreens/Invest/presentation/bloc/payment/invest_payment_event.dart b/lib/features/MainScreens/Invest/presentation/bloc/payment/invest_payment_event.dart new file mode 100644 index 0000000..9999fe4 --- /dev/null +++ b/lib/features/MainScreens/Invest/presentation/bloc/payment/invest_payment_event.dart @@ -0,0 +1,17 @@ +import 'package:equatable/equatable.dart'; + +abstract class InvestPaymentEvent extends Equatable { + const InvestPaymentEvent(); + + @override + List get props => []; +} + +class FormTextChanged extends InvestPaymentEvent { + final String text; + + const FormTextChanged({required this.text}); + + @override + List get props => [text]; +} diff --git a/lib/features/MainScreens/Invest/presentation/bloc/payment/invest_payment_state.dart b/lib/features/MainScreens/Invest/presentation/bloc/payment/invest_payment_state.dart new file mode 100644 index 0000000..e12ba65 --- /dev/null +++ b/lib/features/MainScreens/Invest/presentation/bloc/payment/invest_payment_state.dart @@ -0,0 +1,16 @@ +import 'package:equatable/equatable.dart'; + +class InvestPaymentState extends Equatable { + final bool isFormValid; + + const InvestPaymentState({required this.isFormValid}); + + InvestPaymentState copyWith({bool? isFormValid}) { + return InvestPaymentState( + isFormValid: isFormValid ?? this.isFormValid, + ); + } + + @override + List get props => [isFormValid]; +} diff --git a/lib/features/MainScreens/Invest/presentation/pages/payment/invest_payment_layout.dart b/lib/features/MainScreens/Invest/presentation/pages/payment/invest_payment_layout.dart index 7faf170..9c5c334 100644 --- a/lib/features/MainScreens/Invest/presentation/pages/payment/invest_payment_layout.dart +++ b/lib/features/MainScreens/Invest/presentation/pages/payment/invest_payment_layout.dart @@ -11,6 +11,10 @@ class InvestPaymentLayout extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( + // bottomNavigationBar: const Padding( + // padding: EdgeInsets.all(8.0), + // child: InvestPayBottomSection(), + // ), backgroundColor: AppColor.plainWhite, body: ListView( children: const [ diff --git a/lib/features/MainScreens/Invest/presentation/pages/payment/invest_payment_screen.dart b/lib/features/MainScreens/Invest/presentation/pages/payment/invest_payment_screen.dart index 19c53ad..d0abe10 100644 --- a/lib/features/MainScreens/Invest/presentation/pages/payment/invest_payment_screen.dart +++ b/lib/features/MainScreens/Invest/presentation/pages/payment/invest_payment_screen.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:google_fonts/google_fonts.dart'; +import 'package:tanami_app/features/MainScreens/Invest/presentation/bloc/payment/invest_payment_bloc.dart'; import '../../../../../../core/styles/app_color.dart'; import '../../../../../../core/styles/app_text.dart'; @@ -27,7 +29,15 @@ class InvestPaymentScreen extends StatelessWidget { ), ), ), - body: InvestPaymentLayout(), + body: MultiBlocProvider( + providers: [ + BlocProvider( + // Create an instance of the OnboardingBloc + create: (context) => InvestPaymentBloc(), + ), + ], + child: const InvestPaymentLayout(), + ), ); } } diff --git a/lib/features/MainScreens/Invest/presentation/widgets/payment/invest_pay_bottom_section.dart b/lib/features/MainScreens/Invest/presentation/widgets/payment/invest_pay_bottom_section.dart index c11cf76..c08d786 100644 --- a/lib/features/MainScreens/Invest/presentation/widgets/payment/invest_pay_bottom_section.dart +++ b/lib/features/MainScreens/Invest/presentation/widgets/payment/invest_pay_bottom_section.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:gap/gap.dart'; import 'package:tanami_app/core/routes/route_name.dart'; @@ -7,6 +8,8 @@ import '../../../../../../core/routes/routes.dart'; import '../../../../../../core/styles/app_color.dart'; import '../../../../../../core/styles/app_text.dart'; import '../../../../../../shared/components/button_widget.dart'; +import '../../bloc/payment/invest_payment_bloc.dart'; +import '../../bloc/payment/invest_payment_state.dart'; class InvestPayBottomSection extends StatelessWidget { const InvestPayBottomSection({super.key}); @@ -16,19 +19,29 @@ class InvestPayBottomSection extends StatelessWidget { return Column( mainAxisSize: MainAxisSize.min, children: [ - Container( - margin: const EdgeInsets.symmetric( - horizontal: 16, - ), - width: 1.sw, - height: 56.h, - child: ButtonWidget().elevatedBtn( - txtClr: AppColor.plainWhite, - function: () { - goRouter.pushNamed(RouteName.confirmInvestScreen); - }, - text: AppText.nextText, - clr: AppColor.primaryColor2), + BlocBuilder( + builder: (context, state) { + return Container( + margin: const EdgeInsets.symmetric( + horizontal: 16, + ), + width: 1.sw, + height: 56.h, + child: ButtonWidget().elevatedBtn( + txtClr: state.isFormValid + ? AppColor.plainWhite + : AppColor.inactiveBtnTxtColor, + function: () { + if (state.isFormValid) { + goRouter.pushNamed(RouteName.confirmInvestScreen); + } + }, + text: AppText.nextText, + clr: state.isFormValid + ? AppColor.primaryColor2 + : AppColor.inactiveBtnColor), + ); + }, ), const Gap(5), ButtonWidget().textBorderBtn( diff --git a/lib/features/MainScreens/Invest/presentation/widgets/payment/invest_pay_method_section.dart b/lib/features/MainScreens/Invest/presentation/widgets/payment/invest_pay_method_section.dart index 868d0ce..2435763 100644 --- a/lib/features/MainScreens/Invest/presentation/widgets/payment/invest_pay_method_section.dart +++ b/lib/features/MainScreens/Invest/presentation/widgets/payment/invest_pay_method_section.dart @@ -92,46 +92,36 @@ class InvestPayMethodSection extends StatelessWidget { clr: AppColor.textLabelColor), ], ), - Container( - decoration: const BoxDecoration( - border: Border( - bottom: BorderSide( - width: 1, - color: Colors.grey, + Row( + children: [ + RichText( + text: TextSpan( + children: [ + TextSpan( + text: '${AppText.balanceText}: ', + style: GoogleFonts.dmSans( + color: Colors.grey, + fontSize: 12.0, + fontWeight: FontWeight.bold, + ), + ), + TextSpan( + text: 'SAR 178,000', + style: GoogleFonts.dmSans( + color: Colors.black, + fontSize: 14.0, + fontWeight: FontWeight.bold, + ), + ), + ], ), ), - ), - child: Row( - children: [ - RichText( - text: TextSpan( - children: [ - TextSpan( - text: '${AppText.balanceText}: ', - style: GoogleFonts.dmSans( - color: Colors.grey, - fontSize: 12.0, - fontWeight: FontWeight.bold, - ), - ), - TextSpan( - text: 'SAR 178,000', - style: GoogleFonts.dmSans( - color: Colors.black, - fontSize: 14.0, - fontWeight: FontWeight.bold, - ), - ), - ], - ), - ), - const Icon( - Icons.arrow_forward, - color: Colors.grey, - size: 15, - ) - ], - ), + const Icon( + Icons.arrow_forward, + color: Colors.grey, + size: 15, + ) + ], ), ], ), diff --git a/lib/features/MainScreens/Invest/presentation/widgets/payment/invest_pay_top_section.dart b/lib/features/MainScreens/Invest/presentation/widgets/payment/invest_pay_top_section.dart index 027d0e9..b1c02d6 100644 --- a/lib/features/MainScreens/Invest/presentation/widgets/payment/invest_pay_top_section.dart +++ b/lib/features/MainScreens/Invest/presentation/widgets/payment/invest_pay_top_section.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:gap/gap.dart'; import 'package:tanami_app/core/styles/app_color.dart'; @@ -7,13 +8,16 @@ import 'package:tanami_app/core/styles/app_text.dart'; import 'package:tanami_app/shared/components/text_widget.dart'; import '../../../../../../shared/components/text_from_field_widget.dart'; +import '../../bloc/payment/invest_payment_bloc.dart'; +import '../../bloc/payment/invest_payment_event.dart'; class InvestPayTopSection extends StatelessWidget { const InvestPayTopSection({super.key}); @override Widget build(BuildContext context) { - TextEditingController amountController = TextEditingController(); + final investPaymentBloc = context.read(); + return Padding( padding: const EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 0.0), child: Column( @@ -92,24 +96,37 @@ class InvestPayTopSection extends StatelessWidget { ), const Gap(12), Expanded( - child: Column( - children: [ - textFormField( - txtAlign: TextAlign.center, - readonly: false, - validator: (value) { - if (amountController.text.isEmpty) { - return AppText - .pleaseEnterAmountText; - } - return null; - }, - texttype: TextInputType.number, - textEditingController: amountController, - hintText: AppText.enterAmountText, - suffixIcon: const SizedBox(), - ), - ], + child: Form( + child: Column( + children: [ + textFormField( + txtAlign: TextAlign.center, + readonly: false, + validator: (value) { + if (investPaymentBloc + .amountController + .text + .isEmpty) { + return AppText + .pleaseEnterAmountText; + } + return null; + }, + onInput: (value) { + context + .read() + .add(FormTextChanged( + text: value)); + }, + texttype: TextInputType.number, + textEditingController: + investPaymentBloc + .amountController, + hintText: AppText.enterAmountText, + suffixIcon: const SizedBox(), + ), + ], + ), ), ), ],