Skip to content

Commit

Permalink
Merge pull request #2022 from jonataslaw/4.5.1
Browse files Browse the repository at this point in the history
bump to 4.5.1
  • Loading branch information
jonataslaw authored Nov 29, 2021
2 parents 4ef7589 + bc6a9e4 commit dc353e2
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [4.5.1] - Big Update
Fix Snackbar when it have action and icon the same time

## [4.5.0] - Big Update
To have a context-free, page-agnostic snackbar, we used OverlayRoute to display a partial route.
However this had several problems:
Expand Down
4 changes: 2 additions & 2 deletions lib/get_navigation/src/snackbar/snackbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ You need to either use message[String], or messageText[Widget] or define a userI
mainAxisSize: MainAxisSize.max,
children: [
_buildLeftBarIndicator(),
if (_rowStyle == RowStyle.icon)
if (_rowStyle == RowStyle.icon || _rowStyle == RowStyle.all)
ConstrainedBox(
constraints:
BoxConstraints.tightFor(width: 42.0 + iconPadding),
Expand Down Expand Up @@ -608,7 +608,7 @@ You need to either use message[String], or messageText[Widget] or define a userI
],
),
),
if (_rowStyle == RowStyle.action)
if (_rowStyle == RowStyle.action || _rowStyle == RowStyle.all)
Padding(
padding: EdgeInsets.only(right: buttonPadding),
child: widget.mainButton,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: get
description: Open screens/snackbars/dialogs without context, manage states and inject dependencies easily with GetX.
version: 4.5.0
version: 4.5.1
homepage: https://github.com/jonataslaw/getx

environment:
Expand Down
37 changes: 34 additions & 3 deletions test/navigation/snackbar_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ void main() {
onTap: () {
getBar = GetSnackBar(
message: 'bar1',
icon: Icon(Icons.alarm),
mainButton:
TextButton(onPressed: () {}, child: Text('button')),
duration: const Duration(seconds: 2),
isDismissible: true,
dismissDirection: dismissDirection,
Expand Down Expand Up @@ -212,4 +209,38 @@ void main() {
await tester.pump(const Duration(milliseconds: 3000));
await getBarController.close(withAnimations: false);
});

testWidgets("Get test actions and icon", (tester) async {
final icon = Icon(Icons.alarm);
final action = TextButton(onPressed: () {}, child: Text('button'));

late final GetSnackBar getBar;

await tester.pumpWidget(GetMaterialApp(home: Scaffold()));

expect(Get.isSnackbarOpen, false);
expect(find.text('bar1'), findsNothing);

getBar = GetSnackBar(
message: 'bar1',
icon: icon,
mainButton: action,
leftBarIndicatorColor: Colors.yellow,
showProgressIndicator: true,
// maxWidth: 100,
borderColor: Colors.red,
duration: const Duration(seconds: 1),
isDismissible: false,
);
Get.showSnackbar(getBar);

expect(Get.isSnackbarOpen, true);
await tester.pump(const Duration(milliseconds: 500));
expect(find.byWidget(getBar), findsOneWidget);
expect(find.byWidget(icon), findsOneWidget);
expect(find.byWidget(action), findsOneWidget);
await tester.pump(const Duration(milliseconds: 500));

expect(Get.isSnackbarOpen, false);
});
}

0 comments on commit dc353e2

Please sign in to comment.