Skip to content

Commit

Permalink
Updated styles and example app
Browse files Browse the repository at this point in the history
  • Loading branch information
deb-sahu committed Apr 29, 2024
1 parent 293c032 commit 3f2c520
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 15 deletions.
23 changes: 20 additions & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,45 +33,62 @@ class ExamplePage extends StatelessWidget {
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
// Custom snackbar with only text
ElevatedButton(
onPressed: () {
CustomTopSnackbar.show(
context, 'This is an example of a custom snackbar');
},
child: const Text("Custom Snackbar"),
),

// Custom snackbar with icon and text
ElevatedButton(
onPressed: () {
CustomTopSnackbar.show(context,
'This is an example of a custom snackbar with an icon',
leadingIcon: CupertinoIcons.checkmark_alt_circle_fill,
backgroundColor: Colors.blue,
borderColor: Colors.blueAccent);
leadingIcon: CupertinoIcons.checkmark_alt_circle_fill);
},
child: const Text("Custom Snackbar with Icon"),
),

// Custom snackbar with info style
ElevatedButton(
onPressed: () {
CustomTopSnackbar.showInfo(
context, 'This is an example of an info snackbar');
},
child: const Text("Info Snackbar"),
),

// Custom snackbar with success style
ElevatedButton(
onPressed: () {
CustomTopSnackbar.showSuccess(
context, 'This is an example of a success snackbar');
},
child: const Text("Success Snackbar"),
),

// Custom snackbar with warning style
ElevatedButton(
onPressed: () {
CustomTopSnackbar.showWarning(
context, 'This is an example of a warning snackbar');
},
child: const Text("Warning Snackbar"),
),

// Custom snackbar with error style
ElevatedButton(
onPressed: () {
CustomTopSnackbar.showError(
context, 'This is an example of an error snackbar');
},
child: const Text("Error Snackbar"),
),
],
),
),
Expand Down
28 changes: 16 additions & 12 deletions lib/top_snackbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class CustomTopSnackbar {
/// **Optional**
/// - [IconData] leadingIcon (default: null)
/// - [Duration] duration (default: 3 seconds)
/// - [Color] backgroundColor (default: 0xFF1273eb) i.e. blue color
/// - [Color] borderColor (default: 0xFF3860be) i.e. blue color
/// - [Color] shadowColor (default: black)
/// - [Color] backgroundColor (default: blue)
/// - [Color] borderColor (default: blue)
/// - [Color] shadowColor (default: blue)
/// - [Color] iconColor (default: white)
/// - [Color] textColor (default: white)
/// - [FontWeight] fontWeight (default: FontWeight.w600)
Expand Down Expand Up @@ -44,9 +44,9 @@ class CustomTopSnackbar {
String message, {
IconData? leadingIcon,
Duration duration = const Duration(seconds: 3),
Color backgroundColor = const Color(0xFF1273eb),
Color borderColor = const Color(0xFF3860be),
Color shadowColor = Colors.black,
Color backgroundColor = Colors.blue,
Color borderColor = Colors.blue,
Color shadowColor = Colors.blue,
Color iconColor = Colors.white,
Color textColor = Colors.white,
FontWeight fontWeight = FontWeight.w600,
Expand Down Expand Up @@ -79,8 +79,8 @@ class CustomTopSnackbar {
boxShadow: [
BoxShadow(
color: shadowColor.withOpacity(0.5),
blurRadius: 0.5,
spreadRadius: 0.5,
blurRadius: 0.1,
spreadRadius: 0.1,
),
],
),
Expand Down Expand Up @@ -142,7 +142,8 @@ class CustomTopSnackbar {
context,
message,
backgroundColor: Colors.blue,
borderColor: Colors.blueAccent,
borderColor: Colors.blue,
shadowColor: Colors.blue,
leadingIcon: Icons.info_outline,
duration: duration,
);
Expand Down Expand Up @@ -171,7 +172,8 @@ class CustomTopSnackbar {
context,
message,
backgroundColor: Colors.green,
borderColor: Colors.greenAccent,
borderColor: Colors.green,
shadowColor: Colors.green,
leadingIcon: Icons.check_circle_outline,
duration: duration,
);
Expand Down Expand Up @@ -201,7 +203,8 @@ class CustomTopSnackbar {
context,
message,
backgroundColor: Colors.red,
borderColor: Colors.redAccent,
borderColor: Colors.red,
shadowColor: Colors.red,
leadingIcon: Icons.error_outline,
duration: duration,
);
Expand Down Expand Up @@ -231,7 +234,8 @@ class CustomTopSnackbar {
context,
message,
backgroundColor: Colors.amber,
borderColor: Colors.amberAccent,
borderColor: Colors.amber,
shadowColor: Colors.amber,
leadingIcon: Icons.warning_amber_outlined,
duration: duration,
);
Expand Down

0 comments on commit 3f2c520

Please sign in to comment.