diff --git a/CHANGELOG.md b/CHANGELOG.md index 083b8c5..e0d5131 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` @@ -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 diff --git a/example/pubspec.lock b/example/pubspec.lock index 558feae..ab054ba 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -222,7 +222,7 @@ packages: path: ".." relative: true source: path - version: "9.2.0" + version: "9.2.1" matcher: dependency: transitive description: diff --git a/lib/src/ui/man_up_app_dialog.dart b/lib/src/ui/man_up_app_dialog.dart index eb1c758..251918e 100644 --- a/lib/src/ui/man_up_app_dialog.dart +++ b/lib/src/ui/man_up_app_dialog.dart @@ -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", @@ -89,6 +90,7 @@ class ManUpAppDialog { bool hasCancelText = falseText != null && falseText.isNotEmpty; final route = DialogRoute( context: context, + barrierDismissible: barrierDismissible, builder: (context) { return PopScope( onPopInvokedWithResult: (didPop, result) => diff --git a/pubspec.yaml b/pubspec.yaml index 2906a32..88dd1fd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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: diff --git a/test/man_up_dialog_test.dart b/test/man_up_dialog_test.dart index 15b7404..d072410 100644 --- a/test/man_up_dialog_test.dart +++ b/test/man_up_dialog_test.dart @@ -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'; @@ -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); @@ -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); @@ -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); + }); }