Skip to content

armgit / ente

Public Imported from GitHub
0

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

Polish bottom sheet illustrations

ashilknba247940f69c
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 e8ee9d2082..3841e7ea14 100644
--- a/mobile/apps/photos/lib/ui/components/action_sheet_widget.dart
+++ b/mobile/apps/photos/lib/ui/components/action_sheet_widget.dart
@@ -19,6 +19,7 @@ Future<ButtonResult?> showActionSheet({
bool isDismissible = true,
bool isCheckIconGreen = false,
String? title,
+ Widget? illustration,
Widget? bodyWidget,
String? body,
String? bodyHighlight,
@@ -36,6 +37,7 @@ Future<ButtonResult?> showActionSheet({
builder: (_) {
return ActionSheetWidget(
title: title,
+ illustration: illustration,
bodyWidget: bodyWidget,
body: body,
bodyHighlight: bodyHighlight,
@@ -49,6 +51,7 @@ Future<ButtonResult?> showActionSheet({
class ActionSheetWidget extends StatelessWidget {
final String? title;
+ final Widget? illustration;
final Widget? bodyWidget;
final String? body;
final String? bodyHighlight;
@@ -61,6 +64,7 @@ class ActionSheetWidget extends StatelessWidget {
required this.actionSheetType,
required this.isCheckIconGreen,
this.title,
+ this.illustration,
this.bodyWidget,
this.body,
this.bodyHighlight,
@@ -88,13 +92,15 @@ class ActionSheetWidget extends StatelessWidget {
return BottomSheetComponent(
title: title,
- illustration: actionSheetType == ActionSheetType.iconOnly
- ? Icon(
- Icons.check_outlined,
- size: 48,
- color: isCheckIconGreen ? colors.primary : colors.iconColor,
- )
- : null,
+ illustration:
+ illustration ??
+ (actionSheetType == ActionSheetType.iconOnly
+ ? Icon(
+ Icons.check_outlined,
+ size: 48,
+ color: isCheckIconGreen ? colors.primary : colors.iconColor,
+ )
+ : null),
content: hasDefaultContent
? _ActionSheetContent(
bodyWidget: bodyWidget,
diff --git a/mobile/apps/photos/lib/ui/components/alert_bottom_sheet.dart b/mobile/apps/photos/lib/ui/components/alert_bottom_sheet.dart
index cb8e45d0bd..b432c01552 100644
--- a/mobile/apps/photos/lib/ui/components/alert_bottom_sheet.dart
+++ b/mobile/apps/photos/lib/ui/components/alert_bottom_sheet.dart
@@ -74,8 +74,17 @@ class AlertBottomSheet<T> extends StatelessWidget {
),
SizedBox(height: showCloseButton ? 4 : 24),
if (assetPath != null) ...[
- Center(child: Image.asset(assetPath!)),
- const SizedBox(height: 24),
+ Center(
+ child: SizedBox(
+ width: 180,
+ height: 120,
+ child: FittedBox(
+ fit: BoxFit.scaleDown,
+ child: Image.asset(assetPath!),
+ ),
+ ),
+ ),
+ const SizedBox(height: 16),
],
Text(
title,
diff --git a/mobile/apps/photos/lib/ui/settings_page.dart b/mobile/apps/photos/lib/ui/settings_page.dart
index 315aacbfb9..571b248adc 100644
--- a/mobile/apps/photos/lib/ui/settings_page.dart
+++ b/mobile/apps/photos/lib/ui/settings_page.dart
@@ -495,6 +495,7 @@ class _SettingsBody extends StatelessWidget {
showChoiceActionSheet(
context,
title: AppLocalizations.of(context).areYouSureYouWantToLogout,
+ illustration: Image.asset("assets/warning-grey.png"),
firstButtonLabel: AppLocalizations.of(context).yesLogout,
isCritical: true,
firstButtonOnTap: () async {
diff --git a/mobile/apps/photos/lib/ui/tools/lock_screen.dart b/mobile/apps/photos/lib/ui/tools/lock_screen.dart
index 043f888b22..95a723cc0c 100644
--- a/mobile/apps/photos/lib/ui/tools/lock_screen.dart
+++ b/mobile/apps/photos/lib/ui/tools/lock_screen.dart
@@ -210,6 +210,7 @@ class _LockScreenState extends State<LockScreen>
showChoiceActionSheet(
context,
title: AppLocalizations.of(context).areYouSureYouWantToLogout,
+ illustration: Image.asset("assets/warning-grey.png"),
firstButtonLabel: AppLocalizations.of(context).yesLogout,
isCritical: true,
firstButtonOnTap: () async {
diff --git a/mobile/apps/photos/lib/utils/dialog_util.dart b/mobile/apps/photos/lib/utils/dialog_util.dart
index 461a417b73..93a72e092e 100644
--- a/mobile/apps/photos/lib/utils/dialog_util.dart
+++ b/mobile/apps/photos/lib/utils/dialog_util.dart
@@ -281,6 +281,7 @@ Future<ButtonResult?> showChoiceActionSheet(
BuildContext context, {
required String title,
String? body,
+ Widget? illustration,
required String firstButtonLabel,
String secondButtonLabel = "Cancel",
ButtonType firstButtonType = ButtonType.neutral,
@@ -314,6 +315,7 @@ Future<ButtonResult?> showChoiceActionSheet(
return showActionSheet(
context: context,
title: title,
+ illustration: illustration,
body: body,
buttons: buttons,
isDismissible: isDismissible,
diff --git a/mobile/packages/ente_components/lib/components/bottom_sheet/bottom_sheet_component.dart b/mobile/packages/ente_components/lib/components/bottom_sheet/bottom_sheet_component.dart
index d6ea691f1f..d7b5cd9ecc 100644
--- a/mobile/packages/ente_components/lib/components/bottom_sheet/bottom_sheet_component.dart
+++ b/mobile/packages/ente_components/lib/components/bottom_sheet/bottom_sheet_component.dart
@@ -281,7 +281,8 @@ class _CenteredHeader extends StatelessWidget {
),
if (showCloseButton && (illustration != null || title != null))
const SizedBox(height: Spacing.xs),
- if (illustration != null) Center(child: illustration!),
+ if (illustration != null)
+ _BottomSheetIllustrationSlot(child: illustration!),
if (title != null) ...[
SizedBox(height: illustration == null ? 0 : Spacing.lg),
Text(
@@ -297,6 +298,23 @@ class _CenteredHeader extends StatelessWidget {
}
}
+class _BottomSheetIllustrationSlot extends StatelessWidget {
+ const _BottomSheetIllustrationSlot({required this.child});
+
+ final Widget child;
+
+ @override
+ Widget build(BuildContext context) {
+ return Center(
+ child: SizedBox(
+ width: _illustrationSlotWidth,
+ height: _illustrationSlotHeight,
+ child: FittedBox(fit: BoxFit.scaleDown, child: child),
+ ),
+ );
+ }
+}
+
class _BottomSheetCloseButton extends StatelessWidget {
const _BottomSheetCloseButton({
required this.onClose,
@@ -357,3 +375,5 @@ class _BottomSheetActions extends StatelessWidget {
}
const double _headerHeight = 38;
+const double _illustrationSlotWidth = 180;
+const double _illustrationSlotHeight = 120;
diff --git a/mobile/packages/ente_components/test/components/bottom_sheet_component_test.dart b/mobile/packages/ente_components/test/components/bottom_sheet_component_test.dart
index 2927048f8c..2ff99ed87c 100644
--- a/mobile/packages/ente_components/test/components/bottom_sheet_component_test.dart
+++ b/mobile/packages/ente_components/test/components/bottom_sheet_component_test.dart
@@ -74,6 +74,16 @@ void main() {
expect(find.byKey(const ValueKey('warning-illustration')), findsOneWidget);
expect(find.text('Centered message'), findsOneWidget);
+ final illustrationSlot = find.ancestor(
+ of: find.byKey(const ValueKey('warning-illustration')),
+ matching: find.byType(FittedBox),
+ );
+ expect(illustrationSlot, findsOneWidget);
+ expect(tester.getSize(illustrationSlot), const Size(180, 120));
+ expect(
+ tester.getSize(find.byKey(const ValueKey('warning-illustration'))),
+ const Size(80, 80),
+ );
final message = tester.widget<Text>(find.text('Centered message'));
expect(message.textAlign, TextAlign.center);