-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
183 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'package:nylo_framework/nylo_framework.dart'; | ||
|
||
/// ToastNotificationStyleMetaHelper is used to return | ||
/// the correct value for the [ToastNotificationStyleType] toast style. | ||
class NyToastNotificationStyleMetaHelper extends ToastNotificationStyleMetaHelper { | ||
|
||
NyToastNotificationStyleMetaHelper(ToastNotificationStyleType? style) : super(style); | ||
|
||
onSuccess() { | ||
return ToastMeta.success(); | ||
} | ||
|
||
onWarning() { | ||
return ToastMeta.warning(); | ||
} | ||
|
||
onInfo() { | ||
return ToastMeta.info(); | ||
} | ||
|
||
onDanger() { | ||
return ToastMeta.danger(); | ||
} | ||
|
||
// Example customizing a notification | ||
// onSuccess() { | ||
// return ToastMeta.success( | ||
// title: "Hello", | ||
// description: "World", | ||
// action: () {}, | ||
// backgroundColor: Colors.Yellow | ||
// ); | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
LabelStoreMax/lib/resources/widgets/toast_notification_widget.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import 'package:animate_do/animate_do.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:nylo_framework/nylo_framework.dart'; | ||
|
||
class ToastNotification extends StatelessWidget { | ||
const ToastNotification(ToastMeta toastMeta, {Function? onDismiss, Key? key}) : _toastMeta = toastMeta, _dismiss = onDismiss, super(key: key); | ||
|
||
final Function? _dismiss; | ||
final ToastMeta _toastMeta; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Stack(children: [ | ||
InkWell( | ||
onTap: () { | ||
if (_toastMeta.action != null) { | ||
_toastMeta.action!(); | ||
} | ||
}, | ||
child: Container( | ||
padding: EdgeInsets.symmetric(horizontal: 18.0), | ||
margin: EdgeInsets.symmetric(horizontal: 8.0), | ||
height: 100, | ||
decoration: ShapeDecoration( | ||
shape: RoundedRectangleBorder( | ||
borderRadius: BorderRadius.circular(4), | ||
), | ||
color: _toastMeta.color, | ||
), | ||
child: Row( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
crossAxisAlignment: CrossAxisAlignment.center, | ||
children: [ | ||
Pulse( | ||
child: Container( | ||
child: Center( | ||
child: IconButton( | ||
onPressed: () {}, | ||
icon: _toastMeta.icon ?? SizedBox.shrink(), | ||
padding: EdgeInsets.only(right: 16), | ||
), | ||
), | ||
), | ||
infinite: true, | ||
duration: Duration(milliseconds: 1500), | ||
), | ||
Expanded( | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
Text( | ||
_toastMeta.title.tr(), | ||
style: Theme.of(context) | ||
.textTheme | ||
.headlineSmall! | ||
.copyWith(color: Colors.white), | ||
), | ||
Text( | ||
_toastMeta.description.tr(), | ||
style: Theme.of(context) | ||
.textTheme | ||
.bodyLarge! | ||
.copyWith(color: Colors.white), | ||
), | ||
], | ||
), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
Positioned( | ||
top: 0, | ||
right: 0, | ||
child: IconButton( | ||
onPressed: () { | ||
if (_dismiss != null) { | ||
_dismiss!(); | ||
} | ||
}, | ||
icon: Icon( | ||
Icons.close, | ||
color: Colors.white, | ||
)), | ||
) | ||
]); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.