Skip to content

Commit

Permalink
Merge pull request #46 from elvisun/master
Browse files Browse the repository at this point in the history
Expose duration to `showSimpleNotification`
  • Loading branch information
boyan01 authored Jul 19, 2020
2 parents 97a5968 + a4fc9b6 commit 9df63bd
Showing 1 changed file with 34 additions and 25 deletions.
59 changes: 34 additions & 25 deletions lib/src/notification/overlay_notification.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ OverlaySupportEntry showOverlayNotification(
}
return showOverlay((context, t) {
MainAxisAlignment alignment = MainAxisAlignment.start;
if (position == NotificationPosition.bottom) alignment = MainAxisAlignment.end;
if (position == NotificationPosition.bottom)
alignment = MainAxisAlignment.end;
return Column(
mainAxisAlignment: alignment,
children: <Widget>[
Expand Down Expand Up @@ -62,33 +63,41 @@ OverlaySupportEntry showSimpleNotification(Widget content,
Color background,
Color foreground,
double elevation = 16,
Duration duration,
Key key,
bool autoDismiss = true,
bool slideDismiss = false,
NotificationPosition position = NotificationPosition.top}) {
final entry = showOverlayNotification((context) {
return SlideDismissible(
enable: slideDismiss,
key: ValueKey(key),
child: Material(
color: background ?? Theme.of(context)?.accentColor,
elevation: elevation,
child: SafeArea(
bottom: position == NotificationPosition.bottom,
top: position == NotificationPosition.top,
child: ListTileTheme(
textColor: foreground ?? Theme.of(context)?.accentTextTheme?.title?.color,
iconColor: foreground ?? Theme.of(context)?.accentTextTheme?.title?.color,
child: ListTile(
leading: leading,
title: content,
subtitle: subtitle,
trailing: trailing,
contentPadding: contentPadding,
),
)),
),
);
}, duration: autoDismiss ? null : Duration.zero, key: key, position: position);
final entry = showOverlayNotification(
(context) {
return SlideDismissible(
enable: slideDismiss,
key: ValueKey(key),
child: Material(
color: background ?? Theme.of(context)?.accentColor,
elevation: elevation,
child: SafeArea(
bottom: position == NotificationPosition.bottom,
top: position == NotificationPosition.top,
child: ListTileTheme(
textColor: foreground ??
Theme.of(context)?.accentTextTheme?.title?.color,
iconColor: foreground ??
Theme.of(context)?.accentTextTheme?.title?.color,
child: ListTile(
leading: leading,
title: content,
subtitle: subtitle,
trailing: trailing,
contentPadding: contentPadding,
),
)),
),
);
},
duration: autoDismiss ? duration : Duration.zero,
key: key,
position: position,
);
return entry;
}

0 comments on commit 9df63bd

Please sign in to comment.