Skip to content

Commit

Permalink
Fix barrier dismissible on required dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
zbarbuto committed Sep 20, 2024
1 parent 29981a1 commit abeaf08
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 3 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# manUp

## [9.2.1]

- Add missing `barrierDismissible` to required default dialogs

## [9.2.0]

- Add a new `error` ManUpStatus that can be handled via the `ManUpService` `ChangeNotifier`
Expand All @@ -9,7 +13,7 @@
- `ManUpService` now implements `ChangeNotifier` and the most recent status can be retrieved from the `status` getter
- `onComplete`, `onError` and `shouldShowAlert` on `ManUpWidget` are now optional (`shouldShowAlert` defaults to `() => true`)
- `ManUpWidget` now exposes an optional `onStatusChanged`
- "Kill switch" (`disabled`) and required update alert dialogs are no longer barrier dismissable.
- "Kill switch" (`disabled`) and required update alert dialogs are no longer barrier dismissible.
- Changes to status will now show updated dialogs
- Update examples

Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ packages:
path: ".."
relative: true
source: path
version: "9.2.0"
version: "9.2.1"
matcher:
dependency: transitive
description:
Expand Down
2 changes: 2 additions & 0 deletions lib/src/ui/man_up_app_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class ManUpAppDialog {
return Future.value(true);
case ManUpStatus.supported:
final confirmed = await ManUpAppDialog.showAlertDialog(
barrierDismissible: true,
context: context,
message: message,
trueText: "Update",
Expand Down Expand Up @@ -89,6 +90,7 @@ class ManUpAppDialog {
bool hasCancelText = falseText != null && falseText.isNotEmpty;
final route = DialogRoute<bool?>(
context: context,
barrierDismissible: barrierDismissible,
builder: (context) {
return PopScope(
onPopInvokedWithResult: (didPop, result) =>
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: manup
description: Mandatory update for Flutter Apps that prompts or forces app update by querying a hosted JSON file.
version: 9.2.0
version: 9.2.1
homepage: https://github.com/NextFaze/flutter_manup

environment:
Expand Down
44 changes: 44 additions & 0 deletions test/man_up_dialog_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:manup/manup.dart';

Expand Down Expand Up @@ -51,6 +52,25 @@ void main() {
expect(find.text('Later'), findsOneWidget);
});

testWidgets('optional dialog is dismissible', (tester) async {
await buildTestCase(tester, ManUpStatus.supported);

expect(find.text('This is the dialog'), findsOneWidget);

await tester.tapAt(const Offset(10.0, 10.0));
await tester.pumpAndSettle(const Duration(seconds: 1));

expect(find.text('This is the dialog'), findsNothing);

await buildTestCase(tester, ManUpStatus.supported);
expect(find.text('This is the dialog'), findsOneWidget);

await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle(const Duration(seconds: 1));

expect(find.text('This is the dialog'), findsNothing);
});

testWidgets('shows an update dialog for a required update', (tester) async {
await buildTestCase(tester, ManUpStatus.unsupported);

Expand All @@ -64,6 +84,18 @@ void main() {
expect(find.text('Later'), findsNothing);
});

testWidgets('required update dialog is not dismissible', (tester) async {
await buildTestCase(tester, ManUpStatus.unsupported);

expect(find.text('This is the dialog'), findsOneWidget);

await tester.tapAt(const Offset(10.0, 10.0));
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle(const Duration(seconds: 1));

expect(find.text('This is the dialog'), findsOneWidget);
});

testWidgets('shows a kill switch dialog', (tester) async {
await buildTestCase(tester, ManUpStatus.disabled);

Expand All @@ -77,4 +109,16 @@ void main() {
expect(find.text('Later'), findsNothing);
expect(find.text('OK'), findsOneWidget);
});

testWidgets('kill switch dialog is not dismissible', (tester) async {
await buildTestCase(tester, ManUpStatus.unsupported);

expect(find.text('This is the dialog'), findsOneWidget);

await tester.tapAt(const Offset(10.0, 10.0));
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle(const Duration(seconds: 1));

expect(find.text('This is the dialog'), findsOneWidget);
});
}

0 comments on commit abeaf08

Please sign in to comment.