Skip to content

Commit

Permalink
rename rejectKey to modalKey
Browse files Browse the repository at this point in the history
  • Loading branch information
boyan01 committed May 22, 2019
1 parent 6adfc2f commit 24780ff
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/src/overlay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ typedef Widget AnimatedOverlayWidgetBuilder(
///
/// if the notification1 of step1 is showing, the step2 will dismiss previous notification1.
///
/// if you want notification1' exist to reject step2, please see [RejectKey]
/// if you want notification1' exist to prevent step2, please see [ModalKey]
///
///
OverlaySupportEntry showOverlay(
Expand All @@ -63,7 +63,7 @@ OverlaySupportEntry showOverlay(
final overlayKey = _OverlayKey(key);

final supportEntry = OverlaySupportEntry._entries[overlayKey];
if (supportEntry != null && key is RejectKey) {
if (supportEntry != null && key is ModalKey) {
//do nothing for reject key
return supportEntry;
}
Expand Down
14 changes: 7 additions & 7 deletions lib/src/overlay_key.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@ class _KeyedOverlay extends StatelessWidget {
}
}

///[showOverlay] with this key will be rejected if a overlay with the same key is being showing
///[showOverlay] with block other show with the same [ModalKey]
///
/// for example
/// ```dart
/// final rejectKey = RejectKey('simple');
/// final modalKey = ModalKey('simple');
///
/// //popup a simple message on top of screen
/// showSimpleNotification(context, Text('reject example'), key: rejectKey);
/// showSimpleNotification(context, Text('modal example'), key: modalKey);
///
/// //when previous notification is showing, popup again whit this key
/// //this notification will be rejected.
/// showSimpleNotification(context, Text('reject example 2'), key: rejectKey);
/// showSimpleNotification(context, Text('modal example 2'), key: modalKey);
///
/// ```
class RejectKey<T> extends ValueKey<T> {
RejectKey(T value) : super(value);
class ModalKey<T> extends ValueKey<T> {
ModalKey(T value) : super(value);

@override
bool operator ==(other) {
if (other.runtimeType != runtimeType) return false;
final RejectKey<T> typedOther = other;
final ModalKey<T> typedOther = other;
return value == typedOther.value;
}

Expand Down
6 changes: 3 additions & 3 deletions test/overlay_support_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void main() {
await tester.pump(const Duration(milliseconds: 1250));
});

testWidgets('overlay with the reject key', (tester) async {
testWidgets('overlay with the modal key', (tester) async {
kNotificationSlideDuration = Duration(milliseconds: 200);
kNotificationDuration = const Duration(milliseconds: 1000);
await tester.pumpWidget(_FakeOverlay(child: Builder(builder: (context) {
Expand All @@ -197,13 +197,13 @@ void main() {
FlatButton(
onPressed: () {
showSimpleNotification(context, Text('message'),
autoDismiss: false, key: RejectKey('hello'));
autoDismiss: false, key: ModalKey('hello'));
},
child: Text('notification')),
FlatButton(
onPressed: () {
showSimpleNotification(context, Text('message2'),
autoDismiss: false, key: RejectKey('hello'));
autoDismiss: false, key: ModalKey('hello'));
},
child: Text('notification2')),
],
Expand Down

0 comments on commit 24780ff

Please sign in to comment.