showResendBottomSheet function

Future<String> showResendBottomSheet({
  1. required BuildContext context,
  2. required String phoneNo,
  3. required Widget loader,
  4. required Function? resetTimer,
  5. required Function generateOtpFunc,
  6. required dynamic appWrapperContext,
  7. required dynamic client,
  8. required Function retrySendOtpEndpoint,
  9. Client? httpClient,
})

Displays a modal bottom sheet allowing users to resend an OTP code.

This function creates and displays a modal bottom sheet that provides options for resending an OTP code. Users can choose to resend the code or cancel the action. Depending on the user's choice, appropriate feedback is displayed using a feedback bottom sheet. The function returns a Future<String> that completes with either a success message or an error indicator.

Implementation

Future<String> showResendBottomSheet({
  required BuildContext context,
  required String phoneNo,
  required Widget loader,
  required Function? resetTimer,
  required Function generateOtpFunc,
  required dynamic appWrapperContext,
  required dynamic client,
  required Function retrySendOtpEndpoint,
  Client? httpClient,
}) async {
  final dynamic res = await showModalBottomSheet<dynamic>(
    context: context,
    builder: (BuildContext context) {
      return Column(
        mainAxisAlignment: MainAxisAlignment.center,
        mainAxisSize: MainAxisSize.min,
        children: <Widget>[
          Container(
            height: 50,
            decoration: BoxDecoration(
                border: Border(
              bottom: BorderSide(color: Colors.grey.withOpacity(0.3)),
            )),
            child: Stack(
              children: <Widget>[
                Padding(
                  padding: const EdgeInsets.only(left: 20.0),
                  child: Align(
                    alignment: Alignment.centerLeft,
                    child: Text(
                      'Resend code',
                      style: defaultTextTheme.titleLarge!.copyWith(
                          fontWeight: fontWeightMedium,
                          color: Theme.of(context).primaryColor),
                    ),
                  ),
                ),
                GestureDetector(
                  onTap: () {
                    Navigator.pop(context);
                  },
                  child: Padding(
                    padding: const EdgeInsets.only(right: 20.0),
                    child: Align(
                      alignment: Alignment.centerRight,
                      child: Text(
                        'Cancel',
                        style: defaultTextTheme.labelMedium,
                        key: cancelResendOtp,
                      ),
                    ),
                  ),
                ),
              ],
            ),
          ),
          // ---
          size15VerticalSizedBox,
          SILResendPhoneCode(
              phoneNumber: phoneNo,
              resetTimer: resetTimer ?? () {},
              loader: loader,
              appWrapperContext: appWrapperContext,
              client: client,
              retrySendOtpEndpoint: retrySendOtpEndpoint,
              httpClient: httpClient,
              generateOtpFunc: generateOtpFunc),
          size15VerticalSizedBox
        ],
      );
    },
  );
  if (res.runtimeType == String) {
    await showFeedbackBottomSheet(
      context: context,
      modalContent: '$codeSent $phoneNo',
      imageAssetPath: infoIconUrl,
    );
    return res as String;
  }

  await showFeedbackBottomSheet(
    context: context,
    modalContent: resendCancel,
    imageAssetPath: errorIconUrl,
  );
  return 'err';
}