Skip to content

armgit / ente

Public Imported from GitHub
0

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

Add AlertBottomSheet component and remove ConfirmationBottomSheet

AmanRajSinghMourya31af66c26302
diff --git a/mobile/packages/legacy/lib/components/error_bottom_sheet.dart b/mobile/packages/legacy/lib/components/alert_bottom_sheet.dart
similarity index 55%
rename from mobile/packages/legacy/lib/components/error_bottom_sheet.dart
rename to mobile/packages/legacy/lib/components/alert_bottom_sheet.dart
index d3b810b85f..fcccb48a78 100644
--- a/mobile/packages/legacy/lib/components/error_bottom_sheet.dart
+++ b/mobile/packages/legacy/lib/components/alert_bottom_sheet.dart
@@ -1,33 +1,37 @@
import "package:ente_ui/theme/ente_theme.dart";
import "package:flutter/material.dart";
-Future<void> showErrorBottomSheet(
+Future<T?> showAlertBottomSheet<T>(
BuildContext context, {
required String title,
required String message,
required String assetPath,
+ List<Widget>? buttons,
}) {
- return showModalBottomSheet<void>(
+ return showModalBottomSheet<T>(
context: context,
isScrollControlled: true,
isDismissible: true,
- builder: (context) => ErrorBottomSheet(
+ builder: (context) => AlertBottomSheet<T>(
title: title,
message: message,
assetPath: assetPath,
+ buttons: buttons,
),
);
}
-class ErrorBottomSheet extends StatelessWidget {
+class AlertBottomSheet<T> extends StatelessWidget {
final String title;
final String message;
final String assetPath;
+ final List<Widget>? buttons;
- const ErrorBottomSheet({
+ const AlertBottomSheet({
required this.title,
required this.message,
required this.assetPath,
+ this.buttons,
super.key,
});
@@ -52,32 +56,10 @@ class ErrorBottomSheet extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
- SizedBox(
- width: double.infinity,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.end,
- children: [
- GestureDetector(
- onTap: () => Navigator.of(context).pop(),
- child: Container(
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- color: colorScheme.backgroundElevated,
- ),
- padding: const EdgeInsets.all(8),
- child: Icon(
- Icons.close,
- size: 24,
- color: colorScheme.textBase,
- ),
- ),
- ),
- ],
- ),
- ),
- const SizedBox(height: 8),
+ _buildCloseButton(context, colorScheme),
+ const SizedBox(height: 12),
Center(child: Image.asset(assetPath)),
- const SizedBox(height: 24),
+ const SizedBox(height: 20),
Text(
title,
style: textTheme.h3Bold,
@@ -91,10 +73,43 @@ class ErrorBottomSheet extends StatelessWidget {
),
textAlign: TextAlign.center,
),
+ if (buttons != null && buttons!.isNotEmpty) ...[
+ const SizedBox(height: 20),
+ for (int i = 0; i < buttons!.length; i++) ...[
+ buttons![i],
+ if (i < buttons!.length - 1) const SizedBox(height: 12),
+ ],
+ ],
],
),
),
),
);
}
+
+ Widget _buildCloseButton(BuildContext context, colorScheme) {
+ return SizedBox(
+ width: double.infinity,
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.end,
+ children: [
+ GestureDetector(
+ onTap: () => Navigator.of(context).pop(),
+ child: Container(
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ color: colorScheme.backgroundElevated,
+ ),
+ padding: const EdgeInsets.all(8),
+ child: Icon(
+ Icons.close,
+ size: 24,
+ color: colorScheme.textBase,
+ ),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
}
diff --git a/mobile/packages/legacy/lib/components/confirmation_bottom_sheet.dart b/mobile/packages/legacy/lib/components/confirmation_bottom_sheet.dart
deleted file mode 100644
index 658cca57b3..0000000000
--- a/mobile/packages/legacy/lib/components/confirmation_bottom_sheet.dart
+++ /dev/null
@@ -1,114 +0,0 @@
-import "package:ente_legacy/components/gradient_button.dart";
-import "package:ente_ui/theme/ente_theme.dart";
-import "package:flutter/material.dart";
-
-Future<bool?> showConfirmationBottomSheet(
- BuildContext context, {
- required String title,
- required String message,
- required String buttonText,
- required String assetPath,
-}) {
- return showModalBottomSheet<bool>(
- context: context,
- isScrollControlled: true,
- isDismissible: true,
- builder: (context) => ConfirmationBottomSheet(
- title: title,
- message: message,
- buttonText: buttonText,
- assetPath: assetPath,
- ),
- );
-}
-
-class ConfirmationBottomSheet extends StatelessWidget {
- final String title;
- final String message;
- final String buttonText;
- final String assetPath;
-
- const ConfirmationBottomSheet({
- required this.title,
- required this.message,
- required this.buttonText,
- required this.assetPath,
- super.key,
- });
-
- @override
- Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
-
- return Container(
- decoration: BoxDecoration(
- color: colorScheme.backdropBase,
- border: Border(top: BorderSide(color: colorScheme.strokeFaint)),
- borderRadius: const BorderRadius.only(
- topLeft: Radius.circular(24),
- topRight: Radius.circular(24),
- ),
- ),
- child: SafeArea(
- child: Padding(
- padding: const EdgeInsets.all(16),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- SizedBox(
- width: double.infinity,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.end,
- children: [
- GestureDetector(
- onTap: () => Navigator.of(context).pop(false),
- child: Container(
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- color: colorScheme.backgroundElevated,
- ),
- padding: const EdgeInsets.all(8),
- child: Icon(
- Icons.close,
- size: 24,
- color: colorScheme.textBase,
- ),
- ),
- ),
- ],
- ),
- ),
- const SizedBox(height: 8),
- Center(child: Image.asset(assetPath)),
- const SizedBox(height: 24),
- Text(
- title,
- style: textTheme.h3Bold,
- textAlign: TextAlign.center,
- ),
- const SizedBox(height: 12),
- Text(
- message,
- style: textTheme.body.copyWith(
- color: colorScheme.textMuted,
- ),
- textAlign: TextAlign.center,
- ),
- const SizedBox(height: 32),
- SizedBox(
- width: double.infinity,
- child: GradientButton(
- text: buttonText,
- backgroundColor: colorScheme.warning700,
- onTap: () => Navigator.of(context).pop(true),
- ),
- ),
- ],
- ),
- ),
- ),
- );
- }
-}