-
Notifications
You must be signed in to change notification settings - Fork 6
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
1 parent
831bca0
commit 4d73ede
Showing
34 changed files
with
1,134 additions
and
386 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,86 @@ | ||
import 'dart:io'; | ||
import 'package:cloud_gallery/domain/extensions/app_error_extensions.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:fluttertoast/fluttertoast.dart'; | ||
import 'package:style/extensions/context_extensions.dart'; | ||
import 'package:style/text/app_text_style.dart'; | ||
|
||
void showErrorSnackBar({required BuildContext context, required Object error}) { | ||
final message = error.l10nMessage(context); | ||
showSnackBar( | ||
context: context, | ||
text: message, | ||
icon: Icon( | ||
Icons.warning_amber_rounded, | ||
color: context.colorScheme.alert, | ||
)); | ||
} | ||
|
||
final _toast = FToast(); | ||
|
||
void showSnackBar({ | ||
required BuildContext context, | ||
required String text, | ||
Widget? icon, | ||
Duration duration = const Duration(seconds: 4), | ||
}) { | ||
if (Platform.isIOS || Platform.isMacOS) { | ||
_toast.init(context); | ||
_toast.removeCustomToast(); | ||
_toast.showToast( | ||
fadeDuration: const Duration(milliseconds: 100), | ||
toastDuration: duration, | ||
child: Container( | ||
padding: const EdgeInsets.all(16), | ||
decoration: BoxDecoration( | ||
color: context.colorScheme.containerNormalOnSurface, | ||
borderRadius: BorderRadius.circular(12), | ||
), | ||
child: Row( | ||
children: [ | ||
if (icon != null) icon, | ||
if (icon != null) const SizedBox(width: 10), | ||
Flexible( | ||
child: Text( | ||
text, | ||
style: AppTextStyles.body2.copyWith( | ||
color: context.colorScheme.textPrimary, | ||
), | ||
overflow: TextOverflow.visible, | ||
), | ||
), | ||
], | ||
), | ||
), | ||
gravity: ToastGravity.TOP, | ||
); | ||
} else { | ||
final snackBar = SnackBar( | ||
elevation: 0, | ||
margin: const EdgeInsets.all(16), | ||
content: Row( | ||
children: [ | ||
if (icon != null) icon, | ||
if (icon != null) const SizedBox(width: 10), | ||
Flexible( | ||
child: Text( | ||
text, | ||
style: AppTextStyles.body2.copyWith( | ||
color: context.colorScheme.textPrimary, | ||
), | ||
overflow: TextOverflow.visible, | ||
), | ||
), | ||
], | ||
), | ||
backgroundColor: context.colorScheme.containerNormalOnSurface, | ||
shape: RoundedRectangleBorder( | ||
borderRadius: BorderRadius.circular(12), | ||
), | ||
behavior: SnackBarBehavior.floating, | ||
duration: duration, | ||
); | ||
ScaffoldMessenger.of(context).removeCurrentSnackBar(); | ||
ScaffoldMessenger.of(context).showSnackBar(snackBar); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,21 +1,6 @@ | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | ||
import 'package:style/theme/theme.dart'; | ||
|
||
extension BuildContextExtensions on BuildContext { | ||
AppLocalizations get l10n => AppLocalizations.of(this); | ||
|
||
EdgeInsets get systemPadding => MediaQuery.of(this).padding; | ||
|
||
Size get mediaQuerySize => MediaQuery.of(this).size; | ||
|
||
AppColorScheme get colorScheme => appColorSchemeOf(this); | ||
|
||
Brightness get brightness => MediaQuery.of(this).platformBrightness; | ||
|
||
bool get isDarkMode => brightness == Brightness.dark; | ||
|
||
FocusScopeNode get focusScope => FocusScope.of(this); | ||
|
||
bool get use24Hour => MediaQuery.of(this).alwaysUse24HourFormat; | ||
} |
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
Oops, something went wrong.