Skip to content

Commit

Permalink
adjust monitor_pop_route.dart
Browse files Browse the repository at this point in the history
  • Loading branch information
xdd666t committed Nov 16, 2024
1 parent ce3af28 commit 5722db8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 31 deletions.
32 changes: 3 additions & 29 deletions lib/src/helper/pop_monitor/boost_route_monitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'package:flutter_smart_dialog/src/helper/dialog_proxy.dart';
import 'package:flutter_smart_dialog/src/kit/log.dart';
import 'package:flutter_smart_dialog/src/kit/view_utils.dart';

import 'monitor_pop_route.dart';

class BoostRouteMonitor {
static BoostRouteMonitor? _instance;

Expand Down Expand Up @@ -34,7 +36,7 @@ class BoostRouteMonitor {

if (route is ModalRoute) {
willPopCallback() async {
if (_handleSmartDialog()) {
if (MonitorPopRoute.handleSmartDialog()) {
DialogProxy.instance.dismiss(
status: SmartStatus.smart,
closeType: CloseType.back,
Expand All @@ -54,32 +56,4 @@ class BoostRouteMonitor {
_monitorRouteMount(route, ++count);
}
}

bool _handleSmartDialog() {
bool shouldHandle = false;
try {
//handle loading
if (SmartDialog.config.loading.isExist) {
return true;
}

//handle dialog
var dialogQueue = DialogProxy.instance.dialogQueue;

if (dialogQueue.isEmpty) {
return false;
}

for (var item in DialogProxy.instance.dialogQueue) {
if (!item.permanent) {
shouldHandle = true;
}
}
} catch (e) {
shouldHandle = false;
debugPrint('SmartDialog back event error:${e.toString()}');
}

return shouldHandle;
}
}
4 changes: 2 additions & 2 deletions lib/src/helper/pop_monitor/monitor_pop_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class MonitorPopRoute with WidgetsBindingObserver {
}

// handle contain system dialog and common condition
if (handleSmartDialog()) {
if (MonitorPopRoute.handleSmartDialog()) {
var lastDialog = DialogProxy.instance.dialogQueue.last;
if (lastDialog.backType == SmartBackType.normal &&
await lastDialog.onBack?.call() != true) {
Expand All @@ -78,7 +78,7 @@ class MonitorPopRoute with WidgetsBindingObserver {
return super.didPopRoute();
}

bool handleSmartDialog() {
static bool handleSmartDialog() {
bool shouldHandle = true;
var routeQueue = RouteRecord.instance.routeQueue;
try {
Expand Down

0 comments on commit 5722db8

Please sign in to comment.