111 lines
3.9 KiB
Dart
111 lines
3.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/widgets.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_images.dart';
|
|
import 'package:tanami_app/shared/components/loader.dart';
|
|
import 'package:tanami_app/shared/components/toast_message.dart';
|
|
|
|
import '../../../../Globalconst.dart';
|
|
import '../../../../core/routes/route_name.dart';
|
|
import '../../../../core/routes/routes.dart';
|
|
import '../../../../core/styles/app_color.dart';
|
|
import '../../../../core/styles/app_text.dart';
|
|
import '../../../../core/utils/language/localizations_delegate.dart';
|
|
import '../../../../shared/components/button_widget.dart';
|
|
import '../../../countrySelection/bloc/choose_country_bloc.dart';
|
|
import '../bloc/register_bloc.dart';
|
|
import '../bloc/register_event.dart';
|
|
import '../bloc/register_state.dart';
|
|
|
|
class RegisterBottomSection extends StatelessWidget {
|
|
const RegisterBottomSection({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
var localizations = AppLocalizations.of(context);
|
|
final radioBloc = context.read<RadioBloc>();
|
|
final loginBloc = context.read<RegisterBloc>();
|
|
|
|
return Column(
|
|
children: [
|
|
const Gap(90),
|
|
Image.asset(
|
|
AppImages.stage1Image,
|
|
width: 75,
|
|
height: 12,
|
|
),
|
|
const Gap(36),
|
|
BlocConsumer<RegisterBloc, RegisterState>(
|
|
listener: (context, state) {
|
|
if (state is RegisterLoading) {
|
|
Loader.loader(context);
|
|
} else if (state is RegisterSuccess) {
|
|
successToastMessage(
|
|
context, localizations.translate(AppText.successfulText));
|
|
goRouter.pop();
|
|
|
|
goRouter.pushNamed(RouteName.otpScreen,
|
|
pathParameters: {"fromScreen": "register"});
|
|
} else if (state is RegisterFailure) {
|
|
goRouter.pop();
|
|
errorToastMessage(
|
|
context,
|
|
state.error,
|
|
);
|
|
}
|
|
},
|
|
builder: (context, state) {
|
|
bool isButtonEnabled = false;
|
|
if (state is RegisterFieldsState) {
|
|
isButtonEnabled = state.areFieldsFilled;
|
|
} else if (state is RegisterSuccess || state is RegisterFailure) {
|
|
isButtonEnabled = true;
|
|
}
|
|
return Container(
|
|
margin: const EdgeInsets.symmetric(
|
|
horizontal: 16,
|
|
),
|
|
width: 1.sw,
|
|
height: 56.h,
|
|
child: ButtonWidget().elevatedBtn(
|
|
txtClr: isButtonEnabled
|
|
? AppColor.plainWhite
|
|
: AppColor.inactiveBtnTxtColor,
|
|
function: () {
|
|
Globalconst.phonenumber = loginBloc.phoneNumberTextField.text;
|
|
|
|
isButtonEnabled
|
|
? context.read<RegisterBloc>().add(
|
|
RegisterSubmitted(
|
|
loginBloc.phoneNumberTextField.text,
|
|
loginBloc.countrySelectionTextField.text,
|
|
loginBloc.isdcode,
|
|
loginBloc.countryId),
|
|
)
|
|
: null;
|
|
},
|
|
text: localizations.translate(AppText.nextText),
|
|
clr: isButtonEnabled
|
|
? AppColor.primaryColor2
|
|
: AppColor.inactiveBtnColor,
|
|
),
|
|
);
|
|
},
|
|
),
|
|
const Gap(10),
|
|
ButtonWidget().textBorderBtn(
|
|
clr: AppColor.plainWhite,
|
|
borderClr: AppColor.txtBorderColor,
|
|
function: () {
|
|
radioBloc.resetSelection();
|
|
goRouter.pop();
|
|
},
|
|
text: localizations.translate(AppText.backText),
|
|
)
|
|
],
|
|
);
|
|
}
|
|
}
|