Skip to content

Commit

Permalink
process #189
Browse files Browse the repository at this point in the history
  • Loading branch information
xdd666t committed May 21, 2024
1 parent 4f61b34 commit fd5b8b3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 23 deletions.
3 changes: 1 addition & 2 deletions lib/src/custom/custom_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ import 'package:flutter_smart_dialog/src/widget/attach_dialog_widget.dart';
import '../config/enum_config.dart';
import '../data/animation_param.dart';
import '../data/base_dialog.dart';
import '../data/notify_info.dart';
import '../smart_dialog.dart';
import '../kit/debounce_utils.dart';
import '../smart_dialog.dart';
import '../widget/helper/smart_overlay_entry.dart';

///main function : custom dialog
Expand Down
2 changes: 1 addition & 1 deletion lib/src/custom/custom_notify.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import '../config/enum_config.dart';
import '../data/animation_param.dart';
import '../data/base_dialog.dart';
import '../data/notify_info.dart';
import '../smart_dialog.dart';
import '../kit/debounce_utils.dart';
import '../smart_dialog.dart';
import '../widget/helper/smart_overlay_entry.dart';

///main function : notify dialog
Expand Down
36 changes: 19 additions & 17 deletions lib/src/helper/dialog_proxy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ class DialogProxy {
loadingWidget = CustomLoading(overlayEntry: entryLoading);
}


if (initType.contains(SmartInitType.notify)) {
entryNotify = SmartOverlayEntry(builder: (_) => const SizedBox.shrink());
}
Expand Down Expand Up @@ -127,7 +126,7 @@ class DialogProxy {
required BuildContext? bindWidget,
required Rect? ignoreArea,
}) async {
await beforeShow();
await _beforeShow();
CustomDialog? dialog;
var entry = SmartOverlayEntry(
builder: (BuildContext context) => dialog!.getWidget(),
Expand Down Expand Up @@ -180,7 +179,7 @@ class DialogProxy {
required bool keepSingle,
required SmartBackType backType,
}) async {
await beforeShow();
await _beforeShow();
CustomNotify? dialog;
var entry = SmartOverlayEntry(
builder: (BuildContext context) => dialog!.getWidget(),
Expand Down Expand Up @@ -238,7 +237,7 @@ class DialogProxy {
required bool bindPage,
required BuildContext? bindWidget,
}) async {
await beforeShow();
await _beforeShow();
CustomDialog? dialog;
var entry = SmartOverlayEntry(
builder: (BuildContext context) => dialog!.getWidget(),
Expand Down Expand Up @@ -293,7 +292,7 @@ class DialogProxy {
required bool backDismiss,
required Widget widget,
}) async {
await beforeShow();
await _beforeShow();
return loadingWidget.showLoading<T>(
alignment: alignment,
clickMaskDismiss: clickMaskDismiss,
Expand Down Expand Up @@ -332,7 +331,7 @@ class DialogProxy {
required SmartToastType displayType,
required Widget widget,
}) async {
await beforeShow();
await _beforeShow();
CustomToast? toast;
var entry = SmartOverlayEntry(
builder: (BuildContext context) => toast!.getWidget(),
Expand All @@ -358,17 +357,20 @@ class DialogProxy {
);
}

Completer<void>? showCompleter;

Future<void> beforeShow() async {
if (showCompleter?.isCompleted == false) {
showCompleter?.complete();
showCompleter = null;
}
Completer<void>? _showCompleter;

showCompleter = Completer();
Future<void> _beforeShow() async {
_beforeShowComplete();
_showCompleter = Completer();
await smartOverlayController.show();
showCompleter?.complete();
_beforeShowComplete();
}

void _beforeShowComplete() {
if (_showCompleter?.isCompleted == false) {
_showCompleter?.complete();
_showCompleter = null;
}
}

Future<void>? dismiss<T>({
Expand All @@ -378,8 +380,8 @@ class DialogProxy {
bool force = false,
CloseType closeType = CloseType.normal,
}) async {
if (showCompleter?.isCompleted == false) {
await showCompleter?.future;
if (_showCompleter?.isCompleted == false) {
await _showCompleter?.future;
}

if (status == SmartStatus.smart) {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/widget/helper/smart_overlay.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:async';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/src/widget/helper/smart_overlay_entry.dart';

import '../../../flutter_smart_dialog.dart';
import '../../helper/dialog_proxy.dart';
Expand Down Expand Up @@ -66,7 +66,7 @@ class _SmartOverlayState extends State<SmartOverlay> {

return Overlay(initialEntries: [
if (visible)
OverlayEntry(
SmartOverlayEntry(
builder: (BuildContext context) {
if (widget.initType.contains(SmartInitType.custom)) {
DialogProxy.contextCustom = context;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description:
An elegant Flutter Dialog solution,
Easily implement Toast, Loading and custom Dialog,
Make the use of the dialog easier!
version: 4.9.7+1
version: 4.9.7+2
homepage: https://github.com/fluttercandies/flutter_smart_dialog
# flutter pub publish --server=https://pub.dartlang.org
# flutter build web --release --base-href="/flutter_smart_dialog/web/"
Expand Down

0 comments on commit fd5b8b3

Please sign in to comment.