Fix can not show saving dialog anymore when click on back system button
This commit is contained in:
@@ -23,6 +23,7 @@ mixin MessageDialogActionMixin {
|
|||||||
bool alignCenter = false,
|
bool alignCenter = false,
|
||||||
bool outsideDismissible = true,
|
bool outsideDismissible = true,
|
||||||
bool autoPerformPopBack = true,
|
bool autoPerformPopBack = true,
|
||||||
|
bool usePopScope = false,
|
||||||
List<TextSpan>? listTextSpan,
|
List<TextSpan>? listTextSpan,
|
||||||
Widget? icon,
|
Widget? icon,
|
||||||
TextStyle? titleStyle,
|
TextStyle? titleStyle,
|
||||||
@@ -32,102 +33,109 @@ mixin MessageDialogActionMixin {
|
|||||||
Color? actionButtonColor,
|
Color? actionButtonColor,
|
||||||
Color? cancelButtonColor,
|
Color? cancelButtonColor,
|
||||||
EdgeInsetsGeometry? marginIcon,
|
EdgeInsetsGeometry? marginIcon,
|
||||||
|
PopInvokedCallback? onPopInvoked,
|
||||||
}
|
}
|
||||||
) async {
|
) async {
|
||||||
final responsiveUtils = Get.find<ResponsiveUtils>();
|
final responsiveUtils = Get.find<ResponsiveUtils>();
|
||||||
final imagePaths = Get.find<ImagePaths>();
|
final imagePaths = Get.find<ImagePaths>();
|
||||||
|
|
||||||
if (alignCenter) {
|
if (alignCenter) {
|
||||||
|
final childWidget = PointerInterceptor(
|
||||||
|
child: (ConfirmDialogBuilder(imagePaths, listTextSpan: listTextSpan)
|
||||||
|
..key(const Key('confirm_dialog_action'))
|
||||||
|
..title(title ?? '')
|
||||||
|
..content(message)
|
||||||
|
..addIcon(icon)
|
||||||
|
..colorConfirmButton(actionButtonColor ?? AppColor.colorTextButton)
|
||||||
|
..colorCancelButton(cancelButtonColor ?? AppColor.colorCancelButton)
|
||||||
|
..marginIcon(icon != null ? (marginIcon ?? const EdgeInsets.only(top: 24)) : null)
|
||||||
|
..paddingTitle(icon != null
|
||||||
|
? const EdgeInsetsDirectional.only(top: 24, start: 24, end: 24)
|
||||||
|
: const EdgeInsetsDirectional.symmetric(horizontal: 24)
|
||||||
|
)
|
||||||
|
..radiusButton(12)
|
||||||
|
..paddingContent(const EdgeInsets.only(left: 24, right: 24, bottom: 24, top: 12))
|
||||||
|
..paddingButton(hasCancelButton ? null : const EdgeInsets.only(bottom: 24, left: 24, right: 24))
|
||||||
|
..styleTitle(titleStyle ?? const TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.black))
|
||||||
|
..styleContent(messageStyle ?? const TextStyle(fontSize: 14, fontWeight: FontWeight.normal, color: AppColor.colorContentEmail))
|
||||||
|
..styleTextCancelButton(cancelStyle ?? const TextStyle(fontSize: 17, fontWeight: FontWeight.w500, color: AppColor.colorTextButton))
|
||||||
|
..styleTextConfirmButton(actionStyle ?? const TextStyle(fontSize: 17, fontWeight: FontWeight.w500, color: Colors.white))
|
||||||
|
..onConfirmButtonAction(actionName, () {
|
||||||
|
if (autoPerformPopBack) {
|
||||||
|
popBack();
|
||||||
|
}
|
||||||
|
onConfirmAction?.call();
|
||||||
|
})
|
||||||
|
..onCancelButtonAction(
|
||||||
|
hasCancelButton ? cancelTitle ?? AppLocalizations.of(context).cancel : '',
|
||||||
|
() {
|
||||||
|
if (autoPerformPopBack) {
|
||||||
|
popBack();
|
||||||
|
}
|
||||||
|
onCancelAction?.call();
|
||||||
|
}
|
||||||
|
)
|
||||||
|
..onCloseButtonAction(onCloseButtonAction)
|
||||||
|
).build()
|
||||||
|
);
|
||||||
return await Get.dialog(
|
return await Get.dialog(
|
||||||
PointerInterceptor(
|
usePopScope && PlatformInfo.isMobile
|
||||||
child: (ConfirmDialogBuilder(imagePaths, listTextSpan: listTextSpan)
|
? PopScope(onPopInvoked: onPopInvoked, canPop: false, child: childWidget)
|
||||||
|
: childWidget,
|
||||||
|
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
|
||||||
|
barrierDismissible: outsideDismissible
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
if (responsiveUtils.isMobile(context)) {
|
||||||
|
final childWidget = PointerInterceptor(
|
||||||
|
child: (ConfirmDialogBuilder(
|
||||||
|
imagePaths,
|
||||||
|
showAsBottomSheet: true,
|
||||||
|
listTextSpan: listTextSpan,
|
||||||
|
maxWith: responsiveUtils.getSizeScreenShortestSide(context) - 16
|
||||||
|
)
|
||||||
..key(const Key('confirm_dialog_action'))
|
..key(const Key('confirm_dialog_action'))
|
||||||
..title(title ?? '')
|
..title(title ?? '')
|
||||||
..content(message)
|
..content(message)
|
||||||
..addIcon(icon)
|
..addIcon(icon)
|
||||||
|
..margin(const EdgeInsets.only(bottom: 42))
|
||||||
|
..widthDialog(responsiveUtils.getSizeScreenWidth(context))
|
||||||
..colorConfirmButton(actionButtonColor ?? AppColor.colorTextButton)
|
..colorConfirmButton(actionButtonColor ?? AppColor.colorTextButton)
|
||||||
..colorCancelButton(cancelButtonColor ?? AppColor.colorCancelButton)
|
..colorCancelButton(cancelButtonColor ?? AppColor.colorCancelButton)
|
||||||
..marginIcon(icon != null ? (marginIcon ?? const EdgeInsets.only(top: 24)) : null)
|
|
||||||
..paddingTitle(icon != null
|
..paddingTitle(icon != null
|
||||||
? const EdgeInsetsDirectional.only(top: 24, start: 24, end: 24)
|
? const EdgeInsetsDirectional.only(top: 24, start: 24, end: 24)
|
||||||
: const EdgeInsetsDirectional.symmetric(horizontal: 24)
|
: const EdgeInsetsDirectional.symmetric(horizontal: 24)
|
||||||
)
|
)
|
||||||
..radiusButton(12)
|
..marginIcon(EdgeInsets.zero)
|
||||||
..paddingContent(const EdgeInsets.only(left: 24, right: 24, bottom: 24, top: 12))
|
..paddingContent(const EdgeInsets.only(left: 44, right: 44, bottom: 24, top: 12))
|
||||||
..paddingButton(hasCancelButton ? null : const EdgeInsets.only(bottom: 24, left: 24, right: 24))
|
..paddingButton(hasCancelButton ? null : const EdgeInsets.only(bottom: 16, left: 44, right: 44))
|
||||||
..styleTitle(titleStyle ?? const TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.black))
|
..styleTitle(titleStyle ?? const TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.black))
|
||||||
..styleContent(messageStyle ?? const TextStyle(fontSize: 14, fontWeight: FontWeight.normal, color: AppColor.colorContentEmail))
|
..styleContent(messageStyle ?? const TextStyle(fontSize: 14, fontWeight: FontWeight.normal, color: AppColor.colorContentEmail))
|
||||||
..styleTextCancelButton(cancelStyle ?? const TextStyle(fontSize: 17, fontWeight: FontWeight.w500, color: AppColor.colorTextButton))
|
..styleTextCancelButton(cancelStyle ?? const TextStyle(fontSize: 17, fontWeight: FontWeight.w500, color: AppColor.colorTextButton))
|
||||||
..styleTextConfirmButton(actionStyle ?? const TextStyle(fontSize: 17, fontWeight: FontWeight.w500, color: Colors.white))
|
..styleTextConfirmButton(actionStyle ?? const TextStyle(fontSize: 17, fontWeight: FontWeight.w500, color: Colors.white))
|
||||||
..onConfirmButtonAction(actionName, () {
|
..onConfirmButtonAction(actionName, () {
|
||||||
if (autoPerformPopBack) {
|
if (autoPerformPopBack) {
|
||||||
popBack();
|
popBack();
|
||||||
}
|
}
|
||||||
onConfirmAction?.call();
|
onConfirmAction?.call();
|
||||||
})
|
})
|
||||||
..onCancelButtonAction(
|
..onCancelButtonAction(
|
||||||
hasCancelButton ? cancelTitle ?? AppLocalizations.of(context).cancel : '',
|
hasCancelButton ? cancelTitle ?? AppLocalizations.of(context).cancel : '',
|
||||||
() {
|
() {
|
||||||
if (autoPerformPopBack) {
|
if (autoPerformPopBack) {
|
||||||
popBack();
|
popBack();
|
||||||
}
|
}
|
||||||
onCancelAction?.call();
|
onCancelAction?.call();
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
..onCloseButtonAction(onCloseButtonAction)
|
..onCloseButtonAction(onCloseButtonAction ?? () => popBack())
|
||||||
).build()
|
).build()
|
||||||
),
|
);
|
||||||
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
|
|
||||||
barrierDismissible: outsideDismissible
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
if (responsiveUtils.isMobile(context)) {
|
|
||||||
if (showAsBottomSheet) {
|
if (showAsBottomSheet) {
|
||||||
return await Get.bottomSheet(
|
return await Get.bottomSheet(
|
||||||
PointerInterceptor(
|
usePopScope && PlatformInfo.isMobile
|
||||||
child: (ConfirmDialogBuilder(
|
? PopScope(onPopInvoked: onPopInvoked, canPop: false, child: childWidget)
|
||||||
imagePaths,
|
: childWidget,
|
||||||
showAsBottomSheet: true,
|
|
||||||
listTextSpan: listTextSpan,
|
|
||||||
maxWith: responsiveUtils.getSizeScreenShortestSide(context) - 16
|
|
||||||
)
|
|
||||||
..key(const Key('confirm_dialog_action'))
|
|
||||||
..title(title ?? '')
|
|
||||||
..content(message)
|
|
||||||
..addIcon(icon)
|
|
||||||
..margin(const EdgeInsets.only(bottom: 42))
|
|
||||||
..widthDialog(responsiveUtils.getSizeScreenWidth(context))
|
|
||||||
..colorConfirmButton(actionButtonColor ?? AppColor.colorTextButton)
|
|
||||||
..colorCancelButton(cancelButtonColor ?? AppColor.colorCancelButton)
|
|
||||||
..paddingTitle(icon != null
|
|
||||||
? const EdgeInsetsDirectional.only(top: 24, start: 24, end: 24)
|
|
||||||
: const EdgeInsetsDirectional.symmetric(horizontal: 24)
|
|
||||||
)
|
|
||||||
..marginIcon(EdgeInsets.zero)
|
|
||||||
..paddingContent(const EdgeInsets.only(left: 44, right: 44, bottom: 24, top: 12))
|
|
||||||
..paddingButton(hasCancelButton ? null : const EdgeInsets.only(bottom: 16, left: 44, right: 44))
|
|
||||||
..styleTitle(titleStyle ?? const TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.black))
|
|
||||||
..styleContent(messageStyle ?? const TextStyle(fontSize: 14, fontWeight: FontWeight.normal, color: AppColor.colorContentEmail))
|
|
||||||
..styleTextCancelButton(cancelStyle ?? const TextStyle(fontSize: 17, fontWeight: FontWeight.w500, color: AppColor.colorTextButton))
|
|
||||||
..styleTextConfirmButton(actionStyle ?? const TextStyle(fontSize: 17, fontWeight: FontWeight.w500, color: Colors.white))
|
|
||||||
..onConfirmButtonAction(actionName, () {
|
|
||||||
if (autoPerformPopBack) {
|
|
||||||
popBack();
|
|
||||||
}
|
|
||||||
onConfirmAction?.call();
|
|
||||||
})
|
|
||||||
..onCancelButtonAction(
|
|
||||||
hasCancelButton ? cancelTitle ?? AppLocalizations.of(context).cancel : '',
|
|
||||||
() {
|
|
||||||
if (autoPerformPopBack) {
|
|
||||||
popBack();
|
|
||||||
}
|
|
||||||
onCancelAction?.call();
|
|
||||||
}
|
|
||||||
)
|
|
||||||
..onCloseButtonAction(onCloseButtonAction ?? () => popBack()))
|
|
||||||
.build()
|
|
||||||
),
|
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
|
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
@@ -159,44 +167,47 @@ mixin MessageDialogActionMixin {
|
|||||||
})).show();
|
})).show();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return await Get.dialog(
|
final childWidget = PointerInterceptor(
|
||||||
PointerInterceptor(
|
child: (ConfirmDialogBuilder(imagePaths, listTextSpan: listTextSpan)
|
||||||
child: (ConfirmDialogBuilder(imagePaths, listTextSpan: listTextSpan)
|
..key(const Key('confirm_dialog_action'))
|
||||||
..key(const Key('confirm_dialog_action'))
|
..title(title ?? '')
|
||||||
..title(title ?? '')
|
..content(message)
|
||||||
..content(message)
|
..addIcon(icon)
|
||||||
..addIcon(icon)
|
..colorConfirmButton(actionButtonColor ?? AppColor.colorTextButton)
|
||||||
..colorConfirmButton(actionButtonColor ?? AppColor.colorTextButton)
|
..colorCancelButton(cancelButtonColor ?? AppColor.colorCancelButton)
|
||||||
..colorCancelButton(cancelButtonColor ?? AppColor.colorCancelButton)
|
..marginIcon(icon != null ? const EdgeInsets.only(top: 24) : null)
|
||||||
..marginIcon(icon != null ? const EdgeInsets.only(top: 24) : null)
|
..paddingTitle(icon != null
|
||||||
..paddingTitle(icon != null
|
? const EdgeInsetsDirectional.only(top: 24, start: 24, end: 24)
|
||||||
? const EdgeInsetsDirectional.only(top: 24, start: 24, end: 24)
|
: const EdgeInsetsDirectional.symmetric(horizontal: 24))
|
||||||
: const EdgeInsetsDirectional.symmetric(horizontal: 24))
|
..marginIcon(EdgeInsets.zero)
|
||||||
..marginIcon(EdgeInsets.zero)
|
..paddingContent(const EdgeInsets.only(left: 44, right: 44, bottom: 24, top: 12))
|
||||||
..paddingContent(const EdgeInsets.only(left: 44, right: 44, bottom: 24, top: 12))
|
..paddingButton(hasCancelButton ? null : const EdgeInsets.only(bottom: 16, left: 44, right: 44))
|
||||||
..paddingButton(hasCancelButton ? null : const EdgeInsets.only(bottom: 16, left: 44, right: 44))
|
..styleTitle(titleStyle ?? const TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.black))
|
||||||
..styleTitle(titleStyle ?? const TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.black))
|
..styleContent(messageStyle ?? const TextStyle(fontSize: 14, fontWeight: FontWeight.normal, color: AppColor.colorContentEmail))
|
||||||
..styleContent(messageStyle ?? const TextStyle(fontSize: 14, fontWeight: FontWeight.normal, color: AppColor.colorContentEmail))
|
..styleTextCancelButton(cancelStyle ?? const TextStyle(fontSize: 17, fontWeight: FontWeight.w500, color: AppColor.colorTextButton))
|
||||||
..styleTextCancelButton(cancelStyle ?? const TextStyle(fontSize: 17, fontWeight: FontWeight.w500, color: AppColor.colorTextButton))
|
..styleTextConfirmButton(actionStyle ?? const TextStyle(fontSize: 17, fontWeight: FontWeight.w500, color: Colors.white))
|
||||||
..styleTextConfirmButton(actionStyle ?? const TextStyle(fontSize: 17, fontWeight: FontWeight.w500, color: Colors.white))
|
..onConfirmButtonAction(actionName, () {
|
||||||
..onConfirmButtonAction(actionName, () {
|
if (autoPerformPopBack) {
|
||||||
if (autoPerformPopBack) {
|
popBack();
|
||||||
popBack();
|
}
|
||||||
}
|
onConfirmAction?.call();
|
||||||
onConfirmAction?.call();
|
})
|
||||||
})
|
..onCancelButtonAction(
|
||||||
..onCancelButtonAction(
|
hasCancelButton ? cancelTitle ?? AppLocalizations.of(context).cancel : '',
|
||||||
hasCancelButton ? cancelTitle ?? AppLocalizations.of(context).cancel : '',
|
() {
|
||||||
() {
|
if (autoPerformPopBack) {
|
||||||
if (autoPerformPopBack) {
|
popBack();
|
||||||
popBack();
|
|
||||||
}
|
|
||||||
onCancelAction?.call();
|
|
||||||
}
|
}
|
||||||
)
|
onCancelAction?.call();
|
||||||
..onCloseButtonAction(onCloseButtonAction ?? () => popBack()))
|
}
|
||||||
.build()
|
)
|
||||||
),
|
..onCloseButtonAction(onCloseButtonAction ?? () => popBack())
|
||||||
|
).build()
|
||||||
|
);
|
||||||
|
return await Get.dialog(
|
||||||
|
usePopScope && PlatformInfo.isMobile
|
||||||
|
? PopScope(onPopInvoked: onPopInvoked, canPop: false, child: childWidget)
|
||||||
|
: childWidget,
|
||||||
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
|
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
|
||||||
barrierDismissible: outsideDismissible
|
barrierDismissible: outsideDismissible
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1923,6 +1923,7 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
|||||||
alignCenter: true,
|
alignCenter: true,
|
||||||
outsideDismissible: false,
|
outsideDismissible: false,
|
||||||
autoPerformPopBack: false,
|
autoPerformPopBack: false,
|
||||||
|
usePopScope: true,
|
||||||
onConfirmAction: () => _handleSaveMessageToDraft(context),
|
onConfirmAction: () => _handleSaveMessageToDraft(context),
|
||||||
onCancelAction: () {
|
onCancelAction: () {
|
||||||
_closeComposerButtonState = ButtonState.enabled;
|
_closeComposerButtonState = ButtonState.enabled;
|
||||||
@@ -1933,6 +1934,14 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
|||||||
popBack();
|
popBack();
|
||||||
_autoFocusFieldWhenLauncher();
|
_autoFocusFieldWhenLauncher();
|
||||||
},
|
},
|
||||||
|
onPopInvoked: (didPop) {
|
||||||
|
log('ComposerController::_showConfirmDialogSaveMessage: didPop = $didPop');
|
||||||
|
if (!didPop) {
|
||||||
|
_closeComposerButtonState = ButtonState.enabled;
|
||||||
|
popBack();
|
||||||
|
_autoFocusFieldWhenLauncher();
|
||||||
|
}
|
||||||
|
},
|
||||||
marginIcon: EdgeInsets.zero,
|
marginIcon: EdgeInsets.zero,
|
||||||
icon: SvgPicture.asset(
|
icon: SvgPicture.asset(
|
||||||
imagePaths.icQuotasWarning,
|
imagePaths.icQuotasWarning,
|
||||||
|
|||||||
Reference in New Issue
Block a user