109 lines
4.2 KiB
Dart
109 lines
4.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:tanami_app/core/styles/app_color.dart';
|
|
import 'package:tanami_app/core/styles/app_text.dart';
|
|
import 'package:tanami_app/shared/components/text_widget.dart';
|
|
import 'package:tanami_app/shared/components/toast_message.dart';
|
|
|
|
import '../../../../Globalconst.dart';
|
|
import '../../../../core/routes/routes.dart';
|
|
import '../../../../core/utils/language/localizations_delegate.dart';
|
|
import '../../../../shared/components/loader.dart';
|
|
import '../../../register/presentation/bloc/register_bloc.dart';
|
|
import '../../../register/presentation/bloc/register_event.dart';
|
|
import '../../../register/presentation/bloc/register_state.dart';
|
|
import '../bloc/timer/timer_bloc.dart';
|
|
import '../bloc/timer/timer_state.dart';
|
|
|
|
class ResendOtpSection extends StatelessWidget {
|
|
const ResendOtpSection({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
String token = "";
|
|
var loginBloc = context.read<RegisterBloc>();
|
|
loginBloc.isdcode = Globalconst.isdcode;
|
|
loginBloc.phoneNumberTextField.text = Globalconst.phonenumber;
|
|
loginBloc.countrySelectionTextField.text = Globalconst.name;
|
|
var localizations = AppLocalizations.of(context);
|
|
return BlocBuilder<TimerBloc, TimerState>(
|
|
builder: (context, state) {
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
TextWidget().text14W500(
|
|
state.formattedDuration,
|
|
clr: AppColor.plainBlack,
|
|
),
|
|
BlocConsumer<RegisterBloc, RegisterState>(
|
|
listener: (context, state) {
|
|
print(loginBloc.state);
|
|
if (state is RegisterLoading) {
|
|
Loader.loader(context);
|
|
} else if (state is RegisterSuccess) {
|
|
successToastMessage(context, "OTP Resend Sucessfully !");
|
|
goRouter.pop();
|
|
} 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 GestureDetector(
|
|
onTap: () {
|
|
loginBloc.add(
|
|
Resendotp(Globalconst.token),
|
|
);
|
|
print("///");
|
|
|
|
// successToastMessage(context, "OTP Resend Sucessfully !");
|
|
},
|
|
child: TextWidget().text14W500(
|
|
localizations.translate(AppText.resendSms),
|
|
clr: isButtonEnabled
|
|
? AppColor.plainBlack
|
|
: AppColor.indicatorInactiveColor,
|
|
textDecoration: TextDecoration.underline,
|
|
),
|
|
);
|
|
},
|
|
),
|
|
/* GestureDetector(
|
|
onTap: () {
|
|
regbloc.add(
|
|
RegisterSubmitted(
|
|
loginBloc.phoneNumberTextField.text,
|
|
loginBloc.countrySelectionTextField.text,
|
|
loginBloc.isdcode
|
|
),
|
|
);
|
|
print("///");
|
|
// successToastMessage(context, "OTP Resend Sucessfully !");
|
|
},
|
|
child: TextWidget().text14W500(
|
|
localizations.translate(AppText.resendSms),
|
|
clr: AppColor.plainBlack,
|
|
textDecoration: TextDecoration.underline,
|
|
),
|
|
) */
|
|
],
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|