Skip to content

Commit 8b71392

Browse files
committed
add onBack feature, delete CompatibleSmartDialog, delete SmartConfigCustom/SmartConfigAttach/SmartConfigLoading backDismiss
1 parent 716db55 commit 8b71392

18 files changed

+198
-731
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# [4.9.8+x]
22
* SmartDialog.config.checkExist() adjust to SmartDialog.checkExist()
33
* Fix [#209](https://github.com/fluttercandies/flutter_smart_dialog/issues/209)
4+
* Revert the initialization implementation
5+
* Add onBack feature
6+
* Break change
7+
* Delete CompatibleSmartDialog
8+
* Delete SmartConfigCustom/SmartConfigAttach/SmartConfigLoading backDismiss
49

510
* # [4.9.7+x]
611
* optimize bindWidget, when bindWidget is not null, bindPage will be automatically set to false.

lib/src/compatible/compatible_smart_dialog.dart

Lines changed: 0 additions & 556 deletions
This file was deleted.

lib/src/compatible/smart_config_compatible.dart

Lines changed: 0 additions & 100 deletions
This file was deleted.

lib/src/config/smart_config.dart

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
2-
import 'package:flutter_smart_dialog/src/compatible/smart_config_compatible.dart';
32

43
import '../kit/dialog_kit.dart';
54

@@ -48,12 +47,6 @@ class SmartConfig {
4847
return DialogKit.instance.checkExist(tag: tag, dialogTypes: dialogTypes);
4948
}
5049

51-
/// Compatible with older versions
52-
///
53-
/// 兼容老版本配置
54-
@Deprecated("5.0 will be deleted and is not recommended for continued use")
55-
SmartConfigCompatible compatible = SmartConfigCompatible();
56-
5750
/// whether custom dialog,attach and loading exist on the screen
5851
///
5952
/// 自定义dialog,attach或loading,是否存在在界面上

lib/src/config/smart_config_attach.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class SmartConfigAttach {
2626
SmartNonAnimationType.highlightMask_nonAnimation,
2727
],
2828
this.attachAlignmentType = SmartAttachAlignmentType.center,
29+
this.backType = SmartBackType.normal,
2930
this.isExist = false,
3031
});
3132

@@ -112,6 +113,7 @@ class SmartConfigAttach {
112113
///
113114
/// true(返回事件将关闭loading,但是不会关闭页面),false(返回事件不会关闭loading,也不会关闭页面),
114115
/// 你仍然可以使用dismiss方法来关闭dialog
116+
@Deprecated("please use backType")
115117
final bool backDismiss;
116118

117119
/// Bind the dialog to the current page, the bound page is not on the top of the stack,
@@ -144,6 +146,12 @@ class SmartConfigAttach {
144146
/// attach dialog选择不同alignment属性时的对齐效果, 具体说明请参照[SmartAttachAlignmentType]
145147
final SmartAttachAlignmentType attachAlignmentType;
146148

149+
/// For different processing types of return events,
150+
/// please refer to the description of [SmartBackType] for details
151+
///
152+
/// 对于返回事件不同的处理类型, 具体可参照[SmartBackType]说明
153+
final SmartBackType backType;
154+
147155
/// whether attach dialog(showAttach()) exist on the screen
148156
///
149157
/// attach dialog(showAttach()),是否存在在界面上

lib/src/config/smart_config_custom.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class SmartConfigCustom {
2424
this.nonAnimationTypes = const [
2525
SmartNonAnimationType.routeClose_nonAnimation,
2626
],
27+
this.backType = SmartBackType.normal,
2728
this.isExist = false,
2829
});
2930

@@ -110,6 +111,7 @@ class SmartConfigCustom {
110111
///
111112
/// true(返回事件将关闭loading,但是不会关闭页面),false(返回事件不会关闭loading,也不会关闭页面),
112113
/// 你仍然可以使用dismiss方法来关闭dialog
114+
@Deprecated("please use backType")
113115
final bool backDismiss;
114116

115117
/// Bind the dialog to the current page, the bound page is not on the top of the stack,
@@ -136,6 +138,12 @@ class SmartConfigCustom {
136138
/// 对于不同的场景, 可动态关闭弹窗动画, 具体请参照[SmartNonAnimationType]
137139
final List<SmartNonAnimationType> nonAnimationTypes;
138140

141+
/// For different processing types of return events,
142+
/// please refer to the description of [SmartBackType] for details
143+
///
144+
/// 对于返回事件不同的处理类型, 具体可参照[SmartBackType]说明
145+
final SmartBackType backType;
146+
139147
/// whether custom dialog(show()) exist on the screen
140148
///
141149
/// 自定义dialog(show()),是否存在在界面上

lib/src/config/smart_config_loading.dart

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ class SmartConfigLoading {
1414
this.usePenetrate = false,
1515
this.maskColor = const Color.fromRGBO(0, 0, 0, 0.46),
1616
this.maskWidget,
17-
this.backDismiss = true,
1817
this.clickMaskDismiss = false,
1918
this.leastLoadingTime = const Duration(milliseconds: 0),
2019
this.awaitOverType = SmartAwaitOverType.dialogDismiss,
@@ -23,6 +22,7 @@ class SmartConfigLoading {
2322
SmartNonAnimationType.routeClose_nonAnimation,
2423
SmartNonAnimationType.continueLoading_nonAnimation,
2524
],
25+
this.backType = SmartBackType.normal,
2626
this.isExist = false,
2727
});
2828

@@ -84,14 +84,6 @@ class SmartConfigLoading {
8484
/// 遮罩Widget,可高度自定义你自己的遮罩背景:[usePenetrate]设置为true,该参数失效
8585
final Widget? maskWidget;
8686

87-
/// true(the back event will close the loading but not close the page),
88-
/// false(the back event not close the loading and not close page),
89-
/// you still can use the dismiss method to close the loading
90-
///
91-
/// true(返回事件将关闭loading,但是不会关闭页面),false(返回事件不会关闭loading,也不会关闭页面),
92-
/// 你仍然可以使用dismiss方法来关闭loading
93-
final bool backDismiss;
94-
9587
/// true(dialog will be closed after click background),false(not close)
9688
///
9789
/// true(点击遮罩关闭dialog),false(不关闭)
@@ -119,6 +111,12 @@ class SmartConfigLoading {
119111
/// 对于不同的场景, 可动态关闭弹窗动画, 具体请参照[SmartNonAnimationType]
120112
final List<SmartNonAnimationType> nonAnimationTypes;
121113

114+
/// For different processing types of return events,
115+
/// please refer to the description of [SmartBackType] for details
116+
///
117+
/// 对于返回事件不同的处理类型, 具体可参照[SmartBackType]说明
118+
final SmartBackType backType;
119+
122120
/// whether loading(showLoading()) exist on the screen
123121
///
124122
/// loading(showLoading())是否存在在界面上

lib/src/custom/custom_dialog.dart

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import '../data/animation_param.dart';
1515
import '../data/base_dialog.dart';
1616
import '../data/notify_info.dart';
1717
import '../kit/debounce_utils.dart';
18+
import '../kit/typedef.dart';
1819
import '../smart_dialog.dart';
1920
import '../widget/helper/smart_overlay_entry.dart';
2021

@@ -39,21 +40,21 @@ class CustomDialog extends BaseDialog {
3940
required VoidCallback? onMask,
4041
required Duration? displayTime,
4142
required String? tag,
42-
required bool backDismiss,
4343
required bool keepSingle,
4444
required bool permanent,
4545
required bool useSystem,
4646
required bool bindPage,
4747
required BuildContext? bindWidget,
4848
required Rect? ignoreArea,
49+
required SmartBackType? backType,
50+
required SmartOnBack? onBack,
4951
}) {
5052
if (DebounceUtils.instance.banContinue(DebounceType.custom, debounce)) {
5153
return Future.value(null);
5254
}
5355

5456
final dialogInfo = _handleMustOperate(
5557
tag: tag,
56-
backDismiss: backDismiss,
5758
keepSingle: keepSingle,
5859
debounce: debounce,
5960
type: DialogType.custom,
@@ -62,6 +63,8 @@ class CustomDialog extends BaseDialog {
6263
bindPage: bindPage,
6364
bindWidget: bindWidget,
6465
displayTime: displayTime,
66+
backType: backType,
67+
onBack: onBack,
6568
);
6669
return mainDialog.show<T>(
6770
widget: widget,
@@ -116,20 +119,20 @@ class CustomDialog extends BaseDialog {
116119
required VoidCallback? onDismiss,
117120
required Duration? displayTime,
118121
required String? tag,
119-
required bool backDismiss,
120122
required bool keepSingle,
121123
required bool permanent,
122124
required bool useSystem,
123125
required bool bindPage,
124126
required BuildContext? bindWidget,
127+
required SmartBackType? backType,
128+
required SmartOnBack? onBack,
125129
}) {
126130
if (DebounceUtils.instance.banContinue(DebounceType.attach, debounce)) {
127131
return Future.value(null);
128132
}
129133

130134
final dialogInfo = _handleMustOperate(
131135
tag: tag,
132-
backDismiss: backDismiss,
133136
keepSingle: keepSingle,
134137
debounce: debounce,
135138
type: DialogType.attach,
@@ -138,6 +141,8 @@ class CustomDialog extends BaseDialog {
138141
bindPage: bindPage,
139142
bindWidget: bindWidget,
140143
displayTime: displayTime,
144+
backType: backType,
145+
onBack: onBack,
141146
);
142147
return mainDialog.showAttach<T>(
143148
targetContext: targetContext,
@@ -197,7 +202,6 @@ class CustomDialog extends BaseDialog {
197202

198203
DialogInfo _handleMustOperate({
199204
required String? tag,
200-
required bool backDismiss,
201205
required bool keepSingle,
202206
required bool debounce,
203207
required DialogType type,
@@ -206,6 +210,8 @@ class CustomDialog extends BaseDialog {
206210
required bool bindPage,
207211
required BuildContext? bindWidget,
208212
required Duration? displayTime,
213+
required SmartBackType? backType,
214+
required SmartOnBack? onBack,
209215
}) {
210216
SmartDialog.config.custom.isExist = DialogType.custom == type;
211217
SmartDialog.config.attach.isExist = DialogType.attach == type;
@@ -216,14 +222,15 @@ class CustomDialog extends BaseDialog {
216222
if (singleDialogInfo == null) {
217223
singleDialogInfo = DialogInfo(
218224
dialog: this,
219-
backDismiss: backDismiss,
220225
type: type,
221226
tag: tag ?? SmartTag.keepSingle,
222227
permanent: permanent,
223228
useSystem: useSystem,
224229
bindPage: bindPage,
225230
route: RouteRecord.curRoute,
226231
bindWidget: bindWidget,
232+
backType: backType,
233+
onBack: onBack,
227234
);
228235
_pushDialog(singleDialogInfo);
229236
}
@@ -235,14 +242,15 @@ class CustomDialog extends BaseDialog {
235242
// handle dialog stack
236243
dialogInfo = DialogInfo(
237244
dialog: this,
238-
backDismiss: backDismiss,
239245
type: type,
240246
tag: tag,
241247
permanent: permanent,
242248
useSystem: useSystem,
243249
bindPage: bindPage,
244250
route: RouteRecord.curRoute,
245251
bindWidget: bindWidget,
252+
backType: backType,
253+
onBack: onBack,
246254
);
247255
_pushDialog(dialogInfo);
248256
}
@@ -419,11 +427,6 @@ class CustomDialog extends BaseDialog {
419427
}
420428
}
421429

422-
//handle prohibiting back event
423-
if (info != null && (!info.backDismiss && closeType == CloseType.back)) {
424-
return null;
425-
}
426-
427430
return info;
428431
}
429432
}

0 commit comments

Comments
 (0)