ui fixing

This commit is contained in:
jayesh
2024-06-20 17:26:36 +05:30
parent 38c0c60bd1
commit 1fa37a1c3e
8 changed files with 165 additions and 71 deletions

View File

@@ -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<InvestPaymentEvent, InvestPaymentState> {
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
TextEditingController amountController = TextEditingController();
GlobalKey<FormState> getFormKey() {
return formKey;
}
InvestPaymentBloc() : super(const InvestPaymentState(isFormValid: false)) {
on<FormTextChanged>((event, emit) {
emit(state.copyWith(isFormValid: event.text.isNotEmpty));
});
}
@override
Future<void> close() {
amountController.dispose();
return super.close();
}
}

View File

@@ -0,0 +1,17 @@
import 'package:equatable/equatable.dart';
abstract class InvestPaymentEvent extends Equatable {
const InvestPaymentEvent();
@override
List<Object> get props => [];
}
class FormTextChanged extends InvestPaymentEvent {
final String text;
const FormTextChanged({required this.text});
@override
List<Object> get props => [text];
}

View File

@@ -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<Object> get props => [isFormValid];
}

View File

@@ -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 [

View File

@@ -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(),
),
);
}
}

View File

@@ -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<InvestPaymentBloc, InvestPaymentState>(
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(

View File

@@ -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,
)
],
),
],
),

View File

@@ -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<InvestPaymentBloc>();
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<InvestPaymentBloc>()
.add(FormTextChanged(
text: value));
},
texttype: TextInputType.number,
textEditingController:
investPaymentBloc
.amountController,
hintText: AppText.enterAmountText,
suffixIcon: const SizedBox(),
),
],
),
),
),
],