Skip to content

Commit

Permalink
198 bug snackbar without action text positioning (#320)
Browse files Browse the repository at this point in the history
* app : delete l10n keys

* app : add json exemple in snackbar

* library : fix two lines content text

* app and library : add changelog
  • Loading branch information
Tayebsed93 authored Feb 12, 2024
1 parent e4ee508 commit 2dd9c3f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 24 deletions.
1 change: 1 addition & 0 deletions app/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Vertical Card customization updates ([#189](https://github.com/Orange-OpenSource/ods-flutter/issues/189))
- Update Copyright in files ([#303](https://github.com/Orange-OpenSource/ods-flutter/issues/303))
- Typographie flutter ios ([#293](https://github.com/Orange-OpenSource/ods-flutter/issues/293))
- [Bug]: Snackbar without action text positioning ([#198](https://github.com/Orange-OpenSource/ods-flutter/issues/198))

### [0.7.O](https://github.com/Orange-OpenSource/ods-flutter/compare/0.1.1...0.7.0) - 2023-02-02

Expand Down
3 changes: 0 additions & 3 deletions app/lib/l10n/ods_flutter_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,7 @@
"componentSnackbarsDescription": "There are two ways to show users short, non permanent messages giving system information or feedback about an operation.",
"componentSnackbarsDescriptionExampleText": "Customize the snackbar before displaying it",
"componentSnackbarsDescriptionExampleButton": "Show snackbar",
"componentSnackbarsSingleText": "Single line snackbar",
"componentSnackbarsTwoLineActionText": "Two lines snackbar with action",
"componentSnackbarsActionExampleButtonText": "Close",
"componentSnackbarsTwoLineLongerActionText": "Two lines snackbar with longer action",
"componentSnackbarsTwoLineLongerActionButton": "Longer action",
"componentSnackBarsCustomizeAction": "Action button",
"componentSnackBarsTwoLineCustomizeText": "Two Lines",
Expand Down
10 changes: 4 additions & 6 deletions app/lib/ui/components/snackbars/snackbars.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import 'package:ods_flutter/components/lists/ods_list_switch.dart';
import 'package:ods_flutter/components/sheets_bottom/ods_sheets_bottom.dart';
import 'package:ods_flutter/components/snackbars/ods_snackbar.dart';
import 'package:ods_flutter/guidelines/spacings.dart';
import 'package:ods_flutter_demo/main.dart';
import 'package:ods_flutter_demo/ui/components/snackbars/snackbars_customization.dart';
import 'package:ods_flutter_demo/ui/main_app_bar.dart';

Expand Down Expand Up @@ -89,8 +90,7 @@ class _SnackBarsVariants extends StatelessWidget {
customizationState?.hasLongerAction == false) {
OdsSnackbar.showSnackbarSingleLine(
context: context,
message: AppLocalizations.of(context)!
.componentSnackbarsSingleText,
message: OdsApplication.recipes[21].description,
actionLabel: customizationState?.hasActionButton == true
? AppLocalizations.of(context)!
.componentSnackbarsActionExampleButtonText
Expand All @@ -103,8 +103,7 @@ class _SnackBarsVariants extends StatelessWidget {
customizationState?.hasLongerAction == false) {
OdsSnackbar.showSnackbarTwoLines(
context: context,
message: AppLocalizations.of(context)!
.componentSnackbarsTwoLineActionText,
message: OdsApplication.recipes[7].description,
actionLabel: customizationState?.hasActionButton == true
? AppLocalizations.of(context)!
.componentSnackbarsActionExampleButtonText
Expand All @@ -117,8 +116,7 @@ class _SnackBarsVariants extends StatelessWidget {
if (customizationState?.hasLongerAction == true) {
OdsSnackbar.showSnackbarLongerAction(
context: context,
message: AppLocalizations.of(context)!
.componentSnackbarsTwoLineLongerActionText,
message: OdsApplication.recipes[7].description,
actionLabel: AppLocalizations.of(context)!
.componentSnackbarsTwoLineLongerActionButton,
onPressed: () {},
Expand Down
1 change: 1 addition & 0 deletions library/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Update Copyright in files ([#303](https://github.com/Orange-OpenSource/ods-flutter/issues/303))
- Vertical Card customization updates ([#189](https://github.com/Orange-OpenSource/ods-flutter/issues/189))
- Typographie flutter ios ([#293](https://github.com/Orange-OpenSource/ods-flutter/issues/293))
- [Bug]: Snackbar without action text positioning ([#198](https://github.com/Orange-OpenSource/ods-flutter/issues/198))

## [0.7.0](https://github.com/Orange-OpenSource/ods-flutter/compare/0.1.1...0.7.0) - 2023-02-02

Expand Down
28 changes: 13 additions & 15 deletions library/lib/components/snackbars/ods_snackbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ extension OdsSnackbarsSingleLineExtension on OdsSnackbar {
}) {
final snackbar = SnackBar(
width: double.infinity,
content: Text(message),
content: Text(message, maxLines: 1),
behavior: SnackBarBehavior.floating,
action: actionLabel != null && actionLabel.isNotEmpty && onPressed != null
? SnackBarAction(
Expand All @@ -91,17 +91,17 @@ extension OdsSnackbarsTwoLinesExtension on OdsSnackbar {
}) {
SnackBar snackbar = SnackBar(
width: double.infinity,
content: Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
children: [
SizedBox(
width: MediaQuery.of(context).size.width / 2.5,
child: Text(
message,
),
),
],
),
content: actionLabel != null
? Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
children: [
SizedBox(
width: MediaQuery.of(context).size.width / 2.5,
child: Text(message, maxLines: 2),
),
],
)
: Text(message, maxLines: 2),
action: actionLabel != null && actionLabel.isNotEmpty && onPressed != null
? SnackBarAction(
label: actionLabel,
Expand Down Expand Up @@ -135,9 +135,7 @@ extension OdsSnackbarsLongerActionExtension on OdsSnackbar {
children: [
SizedBox(
width: MediaQuery.of(context).size.width / 2.5,
child: Text(
message,
),
child: Text(message, maxLines: 2),
),
],
),
Expand Down

0 comments on commit 2dd9c3f

Please sign in to comment.