Skip to content

armgit / ente

Public Imported from GitHub
0

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

refactor: Replace custom discard changes dialog with showAlertBottomSheet for consistency

AmanRajSinghMourya66882ebe2f04
diff --git a/mobile/apps/locker/lib/ui/pages/personal_note_page.dart b/mobile/apps/locker/lib/ui/pages/personal_note_page.dart
index b059be177d..89614162f7 100644
--- a/mobile/apps/locker/lib/ui/pages/personal_note_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/personal_note_page.dart
@@ -1,5 +1,6 @@
import 'dart:math' as math;
+import 'package:ente_ui/components/alert_bottom_sheet.dart';
import 'package:ente_ui/theme/ente_theme.dart';
import 'package:ente_ui/utils/toast_util.dart';
import 'package:flutter/material.dart';
@@ -467,87 +468,19 @@ class _PersonalNotePageState
}
Future<bool> _showDiscardChangesDialog() async {
- final result = await showDialog<bool>(
- context: context,
- barrierDismissible: false,
- builder: (dialogContext) {
- final colorScheme = getEnteColorScheme(dialogContext);
- final textTheme = getEnteTextTheme(dialogContext);
-
- return Dialog(
- backgroundColor: colorScheme.backgroundElevated2,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(24),
- ),
- insetPadding: const EdgeInsets.symmetric(
- horizontal: 24,
- vertical: 24,
- ),
- child: Container(
- decoration: BoxDecoration(
- color: colorScheme.backgroundElevated2,
- borderRadius: BorderRadius.circular(24),
- boxShadow: [
- BoxShadow(
- color: Colors.black.withValues(alpha: 0.08),
- blurRadius: 24,
- offset: const Offset(0, 12),
- ),
- ],
- ),
- padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 22),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Expanded(
- child: Text(
- context.l10n.unsavedNoteChangesTitle,
- style: textTheme.h3Bold,
- ),
- ),
- const SizedBox(width: 16),
- GestureDetector(
- onTap: () => Navigator.of(dialogContext).pop(false),
- child: Container(
- height: 36,
- width: 36,
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- color: colorScheme.backgroundElevated,
- ),
- child: const Icon(
- Icons.close_rounded,
- size: 20,
- ),
- ),
- ),
- ],
- ),
- const SizedBox(height: 16),
- Text(
- context.l10n.unsavedNoteChangesDescription,
- style: textTheme.body.copyWith(
- color: colorScheme.textMuted,
- ),
- ),
- const SizedBox(height: 28),
- SizedBox(
- width: double.infinity,
- child: GradientButton(
- text: context.l10n.discardChanges,
- backgroundColor: colorScheme.warning400,
- onTap: () => Navigator.of(dialogContext).pop(true),
- ),
- ),
- ],
- ),
- ),
- );
- },
+ final colorScheme = getEnteColorScheme(context);
+ final result = await showAlertBottomSheet<bool>(
+ context,
+ title: context.l10n.unsavedNoteChangesTitle,
+ message: context.l10n.unsavedNoteChangesDescription,
+ assetPath: 'assets/warning-grey.png',
+ buttons: [
+ GradientButton(
+ text: context.l10n.discardChanges,
+ backgroundColor: colorScheme.warning400,
+ onTap: () => Navigator.of(context).pop(true),
+ ),
+ ],
);
return result ?? false;
diff --git a/mobile/apps/locker/lib/ui/pages/save_page.dart b/mobile/apps/locker/lib/ui/pages/save_page.dart
index 16e3bfcfa8..6d5e29ac91 100644
--- a/mobile/apps/locker/lib/ui/pages/save_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/save_page.dart
@@ -1,7 +1,6 @@
import 'dart:async';
import "package:ente_ui/components/close_icon_button.dart";
-import "package:ente_ui/components/title_bar_title_widget.dart";
import "package:ente_ui/theme/colors.dart";
import 'package:ente_ui/theme/ente_theme.dart';
import "package:ente_ui/theme/text_style.dart";
@@ -93,8 +92,9 @@ class SaveBottomSheet extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- TitleBarTitleWidget(
- title: context.l10n.saveToLocker,
+ Text(
+ context.l10n.saveToLocker,
+ style: textTheme.largeBold,
),
const SizedBox(height: 12),
Text(
diff --git a/mobile/packages/ui/lib/components/alert_bottom_sheet.dart b/mobile/packages/ui/lib/components/alert_bottom_sheet.dart
index d25a41d5d5..a19b97c57c 100644
--- a/mobile/packages/ui/lib/components/alert_bottom_sheet.dart
+++ b/mobile/packages/ui/lib/components/alert_bottom_sheet.dart
@@ -2,16 +2,6 @@ import "package:ente_ui/components/close_icon_button.dart";
import "package:ente_ui/theme/ente_theme.dart";
import "package:flutter/material.dart";
-/// Shows a standardized alert bottom sheet with icon, title, message, and action buttons.
-///
-/// This is the standard pattern for alerts, warnings, confirmations, and error dialogs.
-///
-/// Standard configuration:
-/// - `isScrollControlled: true`
-/// - `isDismissible: true`
-/// - `backgroundColor: Colors.transparent` (Container handles decoration)
-/// - Container background: `colorScheme.backgroundElevated2`
-/// - Border radius: 24
Future<T?> showAlertBottomSheet<T>(
BuildContext context, {
required String title,
@@ -33,16 +23,6 @@ Future<T?> showAlertBottomSheet<T>(
);
}
-/// A standardized alert bottom sheet widget.
-///
-/// Use [showAlertBottomSheet] to display this widget.
-///
-/// Layout:
-/// - Close button (top right)
-/// - Icon/Image (centered)
-/// - Title (h3Bold, centered)
-/// - Message (body, textMuted, centered)
-/// - Action buttons (with 12px spacing between them)
class AlertBottomSheet<T> extends StatelessWidget {
final String title;
final String message;
diff --git a/mobile/packages/ui/lib/components/close_icon_button.dart b/mobile/packages/ui/lib/components/close_icon_button.dart
index bc77720ea7..14549da5d7 100644
--- a/mobile/packages/ui/lib/components/close_icon_button.dart
+++ b/mobile/packages/ui/lib/components/close_icon_button.dart
@@ -1,10 +1,6 @@
import "package:ente_ui/theme/ente_theme.dart";
import "package:flutter/material.dart";
-/// A reusable close button for bottom sheets and dialogs.
-///
-/// Displays a circular button with an X icon that calls [onTap] when pressed.
-/// If [onTap] is not provided, defaults to `Navigator.of(context).pop()`.
class CloseIconButton extends StatelessWidget {
final VoidCallback? onTap;
final double size;