kYesNoSheet function

dynamic kYesNoSheet({
  1. required dynamic context,
  2. required Function yes,
  3. required Function no,
  4. required String heading,
  5. dynamic centerTextColor,
  6. dynamic btnTextYes,
  7. dynamic btnTextYesColor,
  8. dynamic btnTextNo,
  9. dynamic btnTextNoColor,
  10. dynamic btnColorYes,
  11. dynamic btnColorNo,
  12. bool showNoBtn = false,
  13. Function? onBackPress,
  14. bool simpleBackPress = true,
})

constant popup

Implementation

kYesNoSheet(
    {required context,
    required Function yes,
    required Function no,
    required String heading,
    centerTextColor,
    btnTextYes,
    btnTextYesColor,
    btnTextNo,
    btnTextNoColor,
    btnColorYes,
    btnColorNo,
    bool showNoBtn = false,
    Function? onBackPress,
    bool simpleBackPress = true}) {
  showModalBottomSheet(
      shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.vertical(top: Radius.circular(25.0))),
      backgroundColor: whiteColor,
      context: context,
      isScrollControlled: true,
      builder: (ctx) => WillPopScope(
          child: Padding(
              padding: const EdgeInsets.symmetric(horizontal: 18),
              child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  mainAxisSize: MainAxisSize.min,
                  children: <Widget>[
                    SizedBox(height: 8.0),
                    Padding(
                        padding: EdgeInsets.only(
                            bottom: MediaQuery.of(ctx).viewInsets.bottom),
                        child: Column(
                            mainAxisSize: MainAxisSize.min,
                            mainAxisAlignment: MainAxisAlignment.center,
                            crossAxisAlignment: CrossAxisAlignment.center,
                            children: [
                              SizedBox(height: 30.0),
                              CustomText(
                                  text: heading,
                                  fontSize: size18,
                                  color: centerTextColor ?? greyColor1),
                              SizedBox(height: kBodyPadding / 2),
                              SizedBox(height: 15.0),
                              Row(
                                  mainAxisSize: MainAxisSize.max,
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  mainAxisAlignment: MainAxisAlignment.center,
                                  children: [
                                    if (showNoBtn)
                                      CustomButton(
                                          textDecoration: TextDecoration.none,
                                          onTap: () {
                                            kHideKeyboard(context);
                                            goBack(context: ctx);
                                            return no();
                                          },
                                          text: btnTextNo ?? Strings.no,
                                          buttonColor: btnColorNo ?? greyColor1,
                                          textColor:
                                              btnTextNoColor ?? whiteColor,
                                          width: 94.0,
                                          height: 44.0),
                                    if (showNoBtn) SizedBox(width: 10.0),
                                    CustomButton(
                                        textDecoration: TextDecoration.none,
                                        onTap: () {
                                          kHideKeyboard(context);
                                          return yes();
                                        },
                                        text: btnTextYes ?? Strings.ok,
                                        buttonColor: btnColorYes ?? yellowColor,
                                        textColor:
                                            btnTextYesColor ?? whiteColor,
                                        width: 94.0,
                                        height: 44.0),
                                  ]),
                              SizedBox(height: 10.0)
                            ])),
                    SizedBox(height: 10)
                  ])),
          onWillPop: simpleBackPress
              ? () => Future.value(true)
              : () {
                  kHideKeyboard(context);
                  onBackPress!();
                  return Future.value(true);
                }));
}