Skip to content

Commit 2400b29

Browse files
committed
Add nonAnimationTypes feature, Optimize route monitor
1 parent b79da05 commit 2400b29

23 files changed

+376
-136
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1+
# [4.6.x]
2+
- Add bindWidget feature
3+
- Add nonAnimationTypes feature
4+
- Optimize route monitor
5+
6+
17
# [4.5.x]
8+
29
- Remove 'target' param(showAttach): please use 'targetBuilder' instead of 'target' param
310
- Optimize scalePointBuilder (showAttach)
411
- Optimize showAttach
@@ -30,6 +37,14 @@
3037
- Fix [#69](https://github.com/fluttercandies/flutter_smart_dialog/issues/69)
3138

3239

40+
# [4.2.x]
41+
42+
- Compatible with Flutter 2.0
43+
- Add bindWidget feature
44+
- Add nonAnimationTypes feature
45+
- Optimize route monitor
46+
47+
3348
# [4.0.9]
3449

3550
- Remove 'target' param(showAttach): please use 'targetBuilder' instead of 'target' param

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Language: English | [中文](https://juejin.cn/post/7026150456673959943)
44

55
Migrate doc:[3.x migrate 4.0](https://github.com/fluttercandies/flutter_smart_dialog/blob/master/docs/3.x%20migrate%204.0.md) | [3.x 迁移 4.0](https://juejin.cn/post/7093867453012246565)
66

7-
Flutter 2:Please use `flutter_smart_dialog: 4.2.0+3`
7+
Flutter 2:Please use `flutter_smart_dialog: 4.2.0+5`
88

99
Flutter 3:Please use the latest version
1010

example/lib/main.dart

Lines changed: 32 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -63,41 +63,21 @@ class SmartDialogPage extends StatelessWidget {
6363
}
6464

6565
void _show() async {
66-
//关闭多个相同tag dialog
67-
tagDialog(String tag) {
68-
SmartDialog.show(
69-
tag: tag,
70-
builder: (_) {
71-
return Container(
72-
height: 80,
73-
width: 180,
74-
decoration: BoxDecoration(
75-
color: Colors.black,
76-
borderRadius: BorderRadius.circular(10),
77-
),
78-
alignment: Alignment.center,
79-
child: Text(
80-
'easy custom dialog',
81-
style: TextStyle(color: Colors.white),
82-
),
83-
);
84-
},
66+
SmartDialog.show(builder: (_) {
67+
return Container(
68+
height: 80,
69+
width: 180,
70+
decoration: BoxDecoration(
71+
color: Colors.black,
72+
borderRadius: BorderRadius.circular(10),
73+
),
74+
alignment: Alignment.center,
75+
child: Text(
76+
'easy custom dialog',
77+
style: TextStyle(color: Colors.white),
78+
),
8579
);
86-
}
87-
var tag = "1";
88-
for (var i = 0; i < 3; i++) {
89-
tagDialog(tag);
90-
await Future.delayed(Duration(milliseconds: 300));
91-
}
92-
SmartDialog.dismiss(tag: tag, status: SmartStatus.allDialog);
93-
94-
//穿透遮罩
95-
SmartDialog.show(
96-
usePenetrate: true,
97-
builder: (_) {
98-
return Container(height: 80, width: 180, color: Colors.black);
99-
},
100-
);
80+
});
10181
}
10282

10383
void _showAttach(BuildContext ctx) {
@@ -139,7 +119,8 @@ class SmartDialogPage extends StatelessWidget {
139119
void _bindPage(BuildContext ctx) {
140120
//target widget
141121
SmartDialog.show(
142-
bindPage: true,
122+
// bindPage: true,
123+
// bindWidget: ctx,
143124
builder: (_) {
144125
return Container(
145126
height: 300,
@@ -151,14 +132,22 @@ class SmartDialogPage extends StatelessWidget {
151132
alignment: Alignment.center,
152133
child: ElevatedButton(
153134
onPressed: () {
154-
Navigator.push(ctx, MaterialPageRoute(builder: (_) {
155-
return Scaffold(
156-
appBar: AppBar(
157-
title: Text("New Page"),
158-
),
159-
body: Center(child: Text("New Page")),
160-
);
161-
}));
135+
SmartDialog.show(
136+
alignment: Alignment.bottomCenter,
137+
useSystem: true,
138+
builder: (_) {
139+
return Container(
140+
height: 30, width: 30, color: Colors.black);
141+
});
142+
143+
// Navigator.push(ctx, MaterialPageRoute(builder: (_) {
144+
// return Scaffold(
145+
// appBar: AppBar(
146+
// title: Text("New Page"),
147+
// ),
148+
// body: Center(child: Text("New Page")),
149+
// );
150+
// }));
162151
},
163152
child: Text('to new page'),
164153
),

lib/src/compatible/compatible_smart_dialog.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ class CompatibleSmartDialog {
126126
animationType: isLoadingTemp ?? config.isLoading
127127
? SmartAnimationType.centerFade_otherSlide
128128
: SmartAnimationType.centerScale_otherSlide,
129+
nonAnimationTypes: const [],
129130
animationBuilder: null,
130131
usePenetrate: isPenetrateTemp ?? config.isPenetrate,
131132
useAnimation: isUseAnimationTemp ?? config.isUseAnimation,
@@ -283,6 +284,7 @@ class CompatibleSmartDialog {
283284
animationType: isLoadingTemp ?? false
284285
? SmartAnimationType.fade
285286
: SmartAnimationType.scale,
287+
nonAnimationTypes: const [],
286288
animationBuilder: null,
287289
scalePointBuilder: null,
288290
usePenetrate: isPenetrateTemp ?? config.isPenetrate,
@@ -381,6 +383,7 @@ class CompatibleSmartDialog {
381383
animationType: isLoadingTemp ?? true
382384
? SmartAnimationType.fade
383385
: SmartAnimationType.scale,
386+
nonAnimationTypes: const [],
384387
animationBuilder: null,
385388
usePenetrate: isPenetrateTemp ?? false,
386389
useAnimation: isUseAnimationTemp ?? config.isUseAnimation,

lib/src/config/enum_config.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,34 @@ enum SmartMaskTriggerType {
140140
/// 点击到遮罩, 然后抬起手势时(up手势)触发
141141
up
142142
}
143+
144+
/// For different scenes, the pop-up animation can be dynamically closed.
145+
///
146+
/// 对于不同的场景, 可动态关闭弹窗动画
147+
enum SmartNonAnimationType {
148+
/// Open dialog, no dialog start animation
149+
///
150+
/// 打开dialog, 无弹窗开始动画
151+
openDialog_nonAnimation,
152+
153+
/// All scenes close dialog, no dialog end animation
154+
///
155+
/// 所有场景关闭弹窗, 无弹窗结束动画
156+
closeDialog_nonAnimation,
157+
158+
/// Route the pop event to close the dialog, no dialog end animation
159+
///
160+
/// 路由pop事件关闭弹窗, 无弹窗结束动画
161+
routeClose_nonAnimation,
162+
163+
/// Click the mask event to close the dialog, no dialog end animation
164+
///
165+
/// 点击遮罩事件关闭弹窗, 无弹窗结束动画
166+
maskClose_nonAnimation,
167+
168+
/// Back event close the dialog, no dialog end animation
169+
///
170+
/// 返回事件关闭弹窗, 无弹窗结束动画
171+
backClose_nonAnimation,
172+
}
173+

lib/src/config/smart_config_attach.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ class SmartConfigAttach {
2121
this.bindPage = true,
2222
this.awaitOverType = SmartAwaitOverType.dialogDismiss,
2323
this.maskTriggerType = SmartMaskTriggerType.up,
24+
this.nonAnimationTypes = const [
25+
SmartNonAnimationType.routeClose_nonAnimation,
26+
],
2427
this.isExist = false,
2528
});
2629

@@ -129,6 +132,12 @@ class SmartConfigAttach {
129132
/// 点击遮罩时, 被触发时机的类型 (具体请查看[SmartMaskTriggerType]注释)
130133
final SmartMaskTriggerType maskTriggerType;
131134

135+
/// For different scenes, the pop-up animation can be dynamically closed.
136+
/// For details, please refer to [SmartNonAnimationType]
137+
///
138+
/// 对于不同的场景, 可动态关闭弹窗动画, 具体请参照[SmartNonAnimationType]
139+
final List<SmartNonAnimationType> nonAnimationTypes;
140+
132141
/// whether attach dialog(showAttach()) exist on the screen
133142
///
134143
/// attach dialog(showAttach()),是否存在在界面上

lib/src/config/smart_config_custom.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ class SmartConfigCustom {
2121
this.bindPage = true,
2222
this.awaitOverType = SmartAwaitOverType.dialogDismiss,
2323
this.maskTriggerType = SmartMaskTriggerType.up,
24+
this.nonAnimationTypes = const [
25+
SmartNonAnimationType.routeClose_nonAnimation,
26+
],
2427
this.isExist = false,
2528
});
2629

@@ -129,6 +132,12 @@ class SmartConfigCustom {
129132
/// 点击遮罩时, 被触发时机的类型 (具体请查看[SmartMaskTriggerType]注释)
130133
final SmartMaskTriggerType maskTriggerType;
131134

135+
/// For different scenes, the pop-up animation can be dynamically closed.
136+
/// For details, please refer to [SmartNonAnimationType]
137+
///
138+
/// 对于不同的场景, 可动态关闭弹窗动画, 具体请参照[SmartNonAnimationType]
139+
final List<SmartNonAnimationType> nonAnimationTypes;
140+
132141
/// whether custom dialog(show()) exist on the screen
133142
///
134143
/// 自定义dialog(show()),是否存在在界面上

lib/src/config/smart_config_loading.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ class SmartConfigLoading {
1919
this.leastLoadingTime = const Duration(milliseconds: 0),
2020
this.awaitOverType = SmartAwaitOverType.dialogDismiss,
2121
this.maskTriggerType = SmartMaskTriggerType.up,
22+
this.nonAnimationTypes = const [
23+
SmartNonAnimationType.routeClose_nonAnimation,
24+
],
2225
this.isExist = false,
2326
});
2427

@@ -111,6 +114,12 @@ class SmartConfigLoading {
111114
/// 点击遮罩时, 被触发时机的类型 (具体请查看[SmartMaskTriggerType]注释)
112115
final SmartMaskTriggerType maskTriggerType;
113116

117+
/// For different scenes, the pop-up animation can be dynamically closed.
118+
/// For details, please refer to [SmartNonAnimationType]
119+
///
120+
/// 对于不同的场景, 可动态关闭弹窗动画, 具体请参照[SmartNonAnimationType]
121+
final List<SmartNonAnimationType> nonAnimationTypes;
122+
114123
/// whether loading(showLoading()) exist on the screen
115124
///
116125
/// loading(showLoading())是否存在在界面上

0 commit comments

Comments
 (0)