Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Center illustrated action sheet body text

ashilknb9787d11d89e
diff --git a/mobile/apps/photos/lib/ui/components/action_sheet_widget.dart b/mobile/apps/photos/lib/ui/components/action_sheet_widget.dart
index 3841e7ea14..69dbb01107 100644
--- a/mobile/apps/photos/lib/ui/components/action_sheet_widget.dart
+++ b/mobile/apps/photos/lib/ui/components/action_sheet_widget.dart
@@ -89,23 +89,25 @@ class ActionSheetWidget extends StatelessWidget {
for (var index = 0; index < actionButtons.length; index++)
if (index != cancelButtonIndex) actionButtons[index],
];
+ final effectiveIllustration =
+ illustration ??
+ (actionSheetType == ActionSheetType.iconOnly
+ ? Icon(
+ Icons.check_outlined,
+ size: 48,
+ color: isCheckIconGreen ? colors.primary : colors.iconColor,
+ )
+ : null);
return BottomSheetComponent(
title: title,
- illustration:
- illustration ??
- (actionSheetType == ActionSheetType.iconOnly
- ? Icon(
- Icons.check_outlined,
- size: 48,
- color: isCheckIconGreen ? colors.primary : colors.iconColor,
- )
- : null),
+ illustration: effectiveIllustration,
content: hasDefaultContent
? _ActionSheetContent(
bodyWidget: bodyWidget,
body: body,
bodyHighlight: bodyHighlight,
+ textAlign: illustration == null ? null : TextAlign.center,
)
: null,
actions: [
@@ -118,7 +120,11 @@ class ActionSheetWidget extends StatelessWidget {
onClose: cancelButton == null
? null
: () => sheetCloseAction(context, cancelButton),
- actionsTopSpacing: hasContent ? Spacing.lg : 0,
+ actionsTopSpacing: illustration != null
+ ? null
+ : hasContent
+ ? Spacing.lg
+ : 0,
);
}
}
@@ -127,8 +133,14 @@ class _ActionSheetContent extends StatelessWidget {
final Widget? bodyWidget;
final String? body;
final String? bodyHighlight;
+ final TextAlign? textAlign;
- const _ActionSheetContent({this.bodyWidget, this.body, this.bodyHighlight});
+ const _ActionSheetContent({
+ this.bodyWidget,
+ this.body,
+ this.bodyHighlight,
+ this.textAlign,
+ });
@override
Widget build(BuildContext context) {
@@ -147,12 +159,14 @@ class _ActionSheetContent extends StatelessWidget {
bodyWidget ??
Text(
body!,
+ textAlign: textAlign,
style: TextStyles.body.copyWith(color: colors.textLight),
),
if (bodyHighlight != null) ...[
if (hasBody) const SizedBox(height: Spacing.lg),
Text(
bodyHighlight!,
+ textAlign: textAlign,
style: TextStyles.body.copyWith(color: colors.textBase),
),
],
diff --git a/mobile/apps/photos/lib/ui/settings_page.dart b/mobile/apps/photos/lib/ui/settings_page.dart
index 20cebe3d52..e6f013183c 100644
--- a/mobile/apps/photos/lib/ui/settings_page.dart
+++ b/mobile/apps/photos/lib/ui/settings_page.dart
@@ -494,7 +494,8 @@ class _SettingsBody extends StatelessWidget {
void _onLogoutTapped(BuildContext context) {
showChoiceActionSheet(
context,
- title: AppLocalizations.of(context).areYouSureYouWantToLogout,
+ title: AppLocalizations.of(context).warning,
+ body: AppLocalizations.of(context).areYouSureYouWantToLogout,
illustration: Image.asset("assets/warning-grey.png"),
firstButtonLabel: AppLocalizations.of(context).yes,
isCritical: true,
diff --git a/mobile/apps/photos/lib/ui/tools/lock_screen.dart b/mobile/apps/photos/lib/ui/tools/lock_screen.dart
index 091f76bb0f..1a3658b849 100644
--- a/mobile/apps/photos/lib/ui/tools/lock_screen.dart
+++ b/mobile/apps/photos/lib/ui/tools/lock_screen.dart
@@ -209,7 +209,8 @@ class _LockScreenState extends State<LockScreen>
void _onLogoutTapped(BuildContext context) {
showChoiceActionSheet(
context,
- title: AppLocalizations.of(context).areYouSureYouWantToLogout,
+ title: AppLocalizations.of(context).warning,
+ body: AppLocalizations.of(context).areYouSureYouWantToLogout,
illustration: Image.asset("assets/warning-grey.png"),
firstButtonLabel: AppLocalizations.of(context).yes,
isCritical: true,
diff --git a/mobile/apps/photos/test/ui/components/action_sheet_widget_test.dart b/mobile/apps/photos/test/ui/components/action_sheet_widget_test.dart
index 7fff7a26c4..e42c279f7a 100644
--- a/mobile/apps/photos/test/ui/components/action_sheet_widget_test.dart
+++ b/mobile/apps/photos/test/ui/components/action_sheet_widget_test.dart
@@ -251,6 +251,35 @@ void main() {
expect(find.text("Close"), findsOneWidget);
expect(find.byTooltip("Close"), findsNothing);
});
+
+ testWidgets("centers body text for illustrated sheets", (tester) async {
+ await _pumpLauncher(
+ tester,
+ (context) => showActionSheet(
+ context: context,
+ title: "Warning",
+ body: "Are you sure?",
+ illustration: const SizedBox(width: 80, height: 80),
+ buttons: const [
+ ButtonWidget(
+ buttonType: ButtonType.critical,
+ labelText: "Yes",
+ isInAlert: true,
+ buttonAction: ButtonAction.first,
+ ),
+ ],
+ ),
+ );
+
+ await _openLauncher(tester);
+
+ final body = tester.widget<Text>(find.text("Are you sure?"));
+ final bodyBottom = tester.getBottomLeft(find.text("Are you sure?")).dy;
+ final buttonTop = tester.getTopLeft(find.byType(ButtonComponent)).dy;
+
+ expect(body.textAlign, TextAlign.center);
+ expect(buttonTop - bodyBottom, 24);
+ });
});
}