Skip to content

Commit

Permalink
Merge pull request #11 from cb-cloud/patch_dismiss_timing
Browse files Browse the repository at this point in the history
Fix: the notification doesn't appear when swiping previous one.
  • Loading branch information
Kurogoma4D authored Jun 25, 2021
2 parents 643f13d + e49067e commit 5989f28
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.1
### FIX
- Fixed a bug that the notification doesn't apppear when swiping previous one.

## 1.0.0
### FEAT
- Added horizontal swipe gesture to dismiss notifications.
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.0.0"
version: "1.0.1"
matcher:
dependency: transitive
description:
Expand Down
6 changes: 4 additions & 2 deletions lib/src/in_app_notification.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class _InAppNotificationState extends State<InAppNotification>
Size _notificationSize = Size.zero;
Completer<Size> _notificationSizeCompleter = Completer();
Size _screenSize = Size.zero;
bool _isDismissedByHorizontalSwipe = false;

@override
void initState() {
Expand All @@ -129,7 +130,7 @@ class _InAppNotificationState extends State<InAppNotification>
VoidCallback? onTap,
Curve curve = Curves.ease,
}) async {
await dismiss();
await dismiss(animationFrom: _isDismissedByHorizontalSwipe ? 0.0 : 1.0);

_verticalDragDistance = 0.0;
_horizontalDragDistance = 0.0;
Expand Down Expand Up @@ -190,6 +191,7 @@ class _InAppNotificationState extends State<InAppNotification>
_overlay?.remove();
_overlay = null;
_notificationSizeCompleter = Completer();
_isDismissedByHorizontalSwipe = false;
}

void _onTapNotification() {
Expand Down Expand Up @@ -244,8 +246,8 @@ class _InAppNotificationState extends State<InAppNotification>
.animate(_horizontalAnimationController);
_horizontalDragDistance = 0.0;

_isDismissedByHorizontalSwipe = true;
await _horizontalAnimationController.forward(from: 0.0);
await dismiss();
} else {
final endValue = 0.0;
_horizontalAnimation =
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: in_app_notification
description: A Flutter package to show custom in-app notification with any Widgets.
version: 1.0.0
version: 1.0.1
repository: https://github.com/cb-cloud/flutter_in_app_notification

environment:
Expand Down

0 comments on commit 5989f28

Please sign in to comment.