Skip to content

Commit

Permalink
fancier snackbar
Browse files Browse the repository at this point in the history
  • Loading branch information
Codel1417 committed Jun 10, 2024
1 parent 062594e commit f154861
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
13 changes: 12 additions & 1 deletion lib/Frontend/Widgets/back_button_to_close.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';

import 'package:awesome_snackbar_content/awesome_snackbar_content.dart';
import 'package:back_button_interceptor/back_button_interceptor.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
Expand Down Expand Up @@ -42,7 +43,17 @@ class _BackButtonToCloseState extends ConsumerState<BackButtonToClose> {
timer = Timer(const Duration(seconds: 1), () {});
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(doubleBackToClose()),
/// need to set following properties for best effect of awesome_snackbar_content
elevation: 0,
behavior: SnackBarBehavior.floating,
backgroundColor: Colors.transparent,
content: AwesomeSnackbarContent(
title: doubleBackToCloseTitle(),
message: doubleBackToClose(),

/// change contentType to ContentType.success, ContentType.warning or ContentType.help for variants
contentType: ContentType.help,
),
),
);
return true;
Expand Down
4 changes: 3 additions & 1 deletion lib/Frontend/translation_string_definitions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,9 @@ String onboardingDoneButtonLabel() => Intl.message("Done", name: 'onboardingDone

String onboardingCompletedTitle() => Intl.message("Happy Wagging!", name: 'onboardingCompletedTitle', desc: 'Title of the final page of the onboarding screen');

String doubleBackToClose() => Intl.message("Press again to exit ", name: 'doubleBackToClose', desc: 'Snackbar message which appears when the back button is pressed at the main screen');
String doubleBackToClose() => Intl.message("Press again to exit", name: 'doubleBackToClose', desc: 'Snackbar message which appears when the back button is pressed at the main screen');

String doubleBackToCloseTitle() => Intl.message("Gear is still connected", name: 'doubleBackToCloseTitle', desc: 'Snackbar message which appears when the back button is pressed at the main screen');

String noLongerSupported() => Intl.message("This gear is no longer supported. Some app features may not work", name: 'noLongerSupported', desc: 'Warning message which appears for unsupported gear on the manage gear page');

Expand Down
24 changes: 24 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.9.3"
awesome_snackbar_content:
dependency: "direct main"
description:
name: awesome_snackbar_content
sha256: a94407ad596ac4b2f925b032c11f390cd3b3e640a9799f4983b86be0bc17f62b
url: "https://pub.dev"
source: hosted
version: "0.1.3"
back_button_interceptor:
dependency: "direct main"
description:
Expand Down Expand Up @@ -712,6 +720,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.0.2"
flutter_svg:
dependency: transitive
description:
name: flutter_svg
sha256: "7b4ca6cf3304575fe9c8ec64813c8d02ee41d2afe60bcfe0678bcb5375d596a2"
url: "https://pub.dev"
source: hosted
version: "2.0.10+1"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down Expand Up @@ -1839,6 +1855,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.4.0"
vector_graphics:
dependency: transitive
description:
name: vector_graphics
sha256: "32c3c684e02f9bc0afb0ae0aa653337a2fe022e8ab064bcd7ffda27a74e288e3"
url: "https://pub.dev"
source: hosted
version: "1.1.11+1"
vector_graphics_codec:
dependency: transitive
description:
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ dependencies:
url: https://github.com/davigmacode/flutter_choice
feedback: ^3.1.0
accessibility_tools: ^2.1.0

awesome_snackbar_content: ^0.1.3

# Dio HTTP
dio: ^5.4.3+1
native_dio_adapter: ^1.3.0
Expand Down

0 comments on commit f154861

Please sign in to comment.