Skip to content

Commit

Permalink
Add nonAnimationTypes feature, Optimize route monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
xdd666t committed Oct 16, 2022
1 parent b79da05 commit 2400b29
Show file tree
Hide file tree
Showing 23 changed files with 376 additions and 136 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# [4.6.x]
- Add bindWidget feature
- Add nonAnimationTypes feature
- Optimize route monitor


# [4.5.x]

- Remove 'target' param(showAttach): please use 'targetBuilder' instead of 'target' param
- Optimize scalePointBuilder (showAttach)
- Optimize showAttach
Expand Down Expand Up @@ -30,6 +37,14 @@
- Fix [#69](https://github.com/fluttercandies/flutter_smart_dialog/issues/69)


# [4.2.x]

- Compatible with Flutter 2.0
- Add bindWidget feature
- Add nonAnimationTypes feature
- Optimize route monitor


# [4.0.9]

- Remove 'target' param(showAttach): please use 'targetBuilder' instead of 'target' param
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Language: English | [中文](https://juejin.cn/post/7026150456673959943)

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)

Flutter 2:Please use `flutter_smart_dialog: 4.2.0+3`
Flutter 2:Please use `flutter_smart_dialog: 4.2.0+5`

Flutter 3:Please use the latest version

Expand Down
75 changes: 32 additions & 43 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,41 +63,21 @@ class SmartDialogPage extends StatelessWidget {
}

void _show() async {
//关闭多个相同tag dialog
tagDialog(String tag) {
SmartDialog.show(
tag: tag,
builder: (_) {
return Container(
height: 80,
width: 180,
decoration: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadius.circular(10),
),
alignment: Alignment.center,
child: Text(
'easy custom dialog',
style: TextStyle(color: Colors.white),
),
);
},
SmartDialog.show(builder: (_) {
return Container(
height: 80,
width: 180,
decoration: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadius.circular(10),
),
alignment: Alignment.center,
child: Text(
'easy custom dialog',
style: TextStyle(color: Colors.white),
),
);
}
var tag = "1";
for (var i = 0; i < 3; i++) {
tagDialog(tag);
await Future.delayed(Duration(milliseconds: 300));
}
SmartDialog.dismiss(tag: tag, status: SmartStatus.allDialog);

//穿透遮罩
SmartDialog.show(
usePenetrate: true,
builder: (_) {
return Container(height: 80, width: 180, color: Colors.black);
},
);
});
}

void _showAttach(BuildContext ctx) {
Expand Down Expand Up @@ -139,7 +119,8 @@ class SmartDialogPage extends StatelessWidget {
void _bindPage(BuildContext ctx) {
//target widget
SmartDialog.show(
bindPage: true,
// bindPage: true,
// bindWidget: ctx,
builder: (_) {
return Container(
height: 300,
Expand All @@ -151,14 +132,22 @@ class SmartDialogPage extends StatelessWidget {
alignment: Alignment.center,
child: ElevatedButton(
onPressed: () {
Navigator.push(ctx, MaterialPageRoute(builder: (_) {
return Scaffold(
appBar: AppBar(
title: Text("New Page"),
),
body: Center(child: Text("New Page")),
);
}));
SmartDialog.show(
alignment: Alignment.bottomCenter,
useSystem: true,
builder: (_) {
return Container(
height: 30, width: 30, color: Colors.black);
});

// Navigator.push(ctx, MaterialPageRoute(builder: (_) {
// return Scaffold(
// appBar: AppBar(
// title: Text("New Page"),
// ),
// body: Center(child: Text("New Page")),
// );
// }));
},
child: Text('to new page'),
),
Expand Down
3 changes: 3 additions & 0 deletions lib/src/compatible/compatible_smart_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class CompatibleSmartDialog {
animationType: isLoadingTemp ?? config.isLoading
? SmartAnimationType.centerFade_otherSlide
: SmartAnimationType.centerScale_otherSlide,
nonAnimationTypes: const [],
animationBuilder: null,
usePenetrate: isPenetrateTemp ?? config.isPenetrate,
useAnimation: isUseAnimationTemp ?? config.isUseAnimation,
Expand Down Expand Up @@ -283,6 +284,7 @@ class CompatibleSmartDialog {
animationType: isLoadingTemp ?? false
? SmartAnimationType.fade
: SmartAnimationType.scale,
nonAnimationTypes: const [],
animationBuilder: null,
scalePointBuilder: null,
usePenetrate: isPenetrateTemp ?? config.isPenetrate,
Expand Down Expand Up @@ -381,6 +383,7 @@ class CompatibleSmartDialog {
animationType: isLoadingTemp ?? true
? SmartAnimationType.fade
: SmartAnimationType.scale,
nonAnimationTypes: const [],
animationBuilder: null,
usePenetrate: isPenetrateTemp ?? false,
useAnimation: isUseAnimationTemp ?? config.isUseAnimation,
Expand Down
31 changes: 31 additions & 0 deletions lib/src/config/enum_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,34 @@ enum SmartMaskTriggerType {
/// 点击到遮罩, 然后抬起手势时(up手势)触发
up
}

/// For different scenes, the pop-up animation can be dynamically closed.
///
/// 对于不同的场景, 可动态关闭弹窗动画
enum SmartNonAnimationType {
/// Open dialog, no dialog start animation
///
/// 打开dialog, 无弹窗开始动画
openDialog_nonAnimation,

/// All scenes close dialog, no dialog end animation
///
/// 所有场景关闭弹窗, 无弹窗结束动画
closeDialog_nonAnimation,

/// Route the pop event to close the dialog, no dialog end animation
///
/// 路由pop事件关闭弹窗, 无弹窗结束动画
routeClose_nonAnimation,

/// Click the mask event to close the dialog, no dialog end animation
///
/// 点击遮罩事件关闭弹窗, 无弹窗结束动画
maskClose_nonAnimation,

/// Back event close the dialog, no dialog end animation
///
/// 返回事件关闭弹窗, 无弹窗结束动画
backClose_nonAnimation,
}

9 changes: 9 additions & 0 deletions lib/src/config/smart_config_attach.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class SmartConfigAttach {
this.bindPage = true,
this.awaitOverType = SmartAwaitOverType.dialogDismiss,
this.maskTriggerType = SmartMaskTriggerType.up,
this.nonAnimationTypes = const [
SmartNonAnimationType.routeClose_nonAnimation,
],
this.isExist = false,
});

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

/// For different scenes, the pop-up animation can be dynamically closed.
/// For details, please refer to [SmartNonAnimationType]
///
/// 对于不同的场景, 可动态关闭弹窗动画, 具体请参照[SmartNonAnimationType]
final List<SmartNonAnimationType> nonAnimationTypes;

/// whether attach dialog(showAttach()) exist on the screen
///
/// attach dialog(showAttach()),是否存在在界面上
Expand Down
9 changes: 9 additions & 0 deletions lib/src/config/smart_config_custom.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class SmartConfigCustom {
this.bindPage = true,
this.awaitOverType = SmartAwaitOverType.dialogDismiss,
this.maskTriggerType = SmartMaskTriggerType.up,
this.nonAnimationTypes = const [
SmartNonAnimationType.routeClose_nonAnimation,
],
this.isExist = false,
});

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

/// For different scenes, the pop-up animation can be dynamically closed.
/// For details, please refer to [SmartNonAnimationType]
///
/// 对于不同的场景, 可动态关闭弹窗动画, 具体请参照[SmartNonAnimationType]
final List<SmartNonAnimationType> nonAnimationTypes;

/// whether custom dialog(show()) exist on the screen
///
/// 自定义dialog(show()),是否存在在界面上
Expand Down
9 changes: 9 additions & 0 deletions lib/src/config/smart_config_loading.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class SmartConfigLoading {
this.leastLoadingTime = const Duration(milliseconds: 0),
this.awaitOverType = SmartAwaitOverType.dialogDismiss,
this.maskTriggerType = SmartMaskTriggerType.up,
this.nonAnimationTypes = const [
SmartNonAnimationType.routeClose_nonAnimation,
],
this.isExist = false,
});

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

/// For different scenes, the pop-up animation can be dynamically closed.
/// For details, please refer to [SmartNonAnimationType]
///
/// 对于不同的场景, 可动态关闭弹窗动画, 具体请参照[SmartNonAnimationType]
final List<SmartNonAnimationType> nonAnimationTypes;

/// whether loading(showLoading()) exist on the screen
///
/// loading(showLoading())是否存在在界面上
Expand Down
Loading

0 comments on commit 2400b29

Please sign in to comment.