Skip to content

armgit / ente

Public Imported from GitHub
0

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

refactor: Remove new_account_dialog and recovery_key_dialog components; update usages to use alert_bottom_sheet

AmanRajSinghMourya846b6bb9f2d9
diff --git a/mobile/apps/locker/lib/ui/components/new_account_dialog.dart b/mobile/apps/locker/lib/ui/components/new_account_dialog.dart
deleted file mode 100644
index ef53377c0d..0000000000
--- a/mobile/apps/locker/lib/ui/components/new_account_dialog.dart
+++ /dev/null
@@ -1,117 +0,0 @@
-import "package:ente_ui/components/buttons/button_widget.dart";
-import "package:ente_ui/components/buttons/models/button_result.dart";
-import "package:ente_ui/components/close_icon_button.dart";
-import "package:ente_ui/theme/ente_theme.dart";
-import "package:flutter/material.dart";
-import "package:hugeicons/hugeicons.dart";
-import "package:locker/ui/components/gradient_button.dart";
-
-Future<ButtonResult?> showCreateNewAccountDialog(
- BuildContext context, {
- required String title,
- required String body,
- required String buttonLabel,
- required String assetPath,
- HugeIcon? icon,
-}) {
- return showModalBottomSheet<ButtonResult>(
- context: context,
- isScrollControlled: true,
- isDismissible: true,
- builder: (context) {
- return _CreateNewAccountBottomSheet(
- title: title,
- body: body,
- buttonLabel: buttonLabel,
- assetPath: assetPath,
- icon: icon,
- );
- },
- );
-}
-
-class _CreateNewAccountBottomSheet extends StatelessWidget {
- final String title;
- final String body;
- final String buttonLabel;
- final String assetPath;
- final HugeIcon? icon;
-
- const _CreateNewAccountBottomSheet({
- required this.title,
- required this.body,
- required this.buttonLabel,
- required this.assetPath,
- this.icon,
- });
-
- @override
- Widget build(BuildContext context) {
- return Theme(
- data: ThemeData(
- brightness: Brightness.light,
- useMaterial3: false,
- ),
- child: Builder(
- builder: (context) {
- final textTheme = getEnteTextTheme(context);
- final colorScheme = getEnteColorScheme(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.symmetric(horizontal: 16),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- const SizedBox(height: 8),
- const Row(
- mainAxisAlignment: MainAxisAlignment.end,
- children: [
- CloseIconButton(),
- ],
- ),
- const SizedBox(height: 8),
- Image.asset(assetPath),
- const SizedBox(height: 24),
- Text(
- title,
- style: textTheme.h3Bold,
- textAlign: TextAlign.center,
- ),
- const SizedBox(height: 12),
- Text(
- body,
- style: textTheme.body.copyWith(
- color: colorScheme.textMuted,
- ),
- textAlign: TextAlign.center,
- ),
- const SizedBox(height: 32),
- GradientButton(
- text: buttonLabel,
- hugeIcon: icon,
- onTap: () {
- Navigator.of(context).pop(
- ButtonResult(ButtonAction.first),
- );
- },
- ),
- ],
- ),
- ),
- ),
- );
- },
- ),
- );
- }
-}
diff --git a/mobile/apps/locker/lib/ui/components/recovery_key_dialog.dart b/mobile/apps/locker/lib/ui/components/recovery_key_dialog.dart
deleted file mode 100644
index 179bf6a8d6..0000000000
--- a/mobile/apps/locker/lib/ui/components/recovery_key_dialog.dart
+++ /dev/null
@@ -1,128 +0,0 @@
-import "package:ente_ui/components/buttons/button_widget.dart";
-import "package:ente_ui/components/buttons/models/button_result.dart";
-import "package:ente_ui/components/close_icon_button.dart";
-import "package:ente_ui/theme/ente_theme.dart";
-import "package:flutter/material.dart";
-import "package:hugeicons/hugeicons.dart";
-
-Future<ButtonResult?> showRecoveryKeyDialog(
- BuildContext context, {
- required String title,
- required String body,
- required String buttonLabel,
- required String assetPath,
- Widget? icon,
-}) {
- return showModalBottomSheet<ButtonResult>(
- context: context,
- isScrollControlled: true,
- isDismissible: true,
- builder: (context) {
- return _RecoveryKeyBottomSheet(
- title: title,
- body: body,
- buttonLabel: buttonLabel,
- assetPath: assetPath,
- icon: icon,
- );
- },
- );
-}
-
-class _RecoveryKeyBottomSheet extends StatelessWidget {
- final String title;
- final String body;
- final String buttonLabel;
- final String assetPath;
- final Widget? icon;
-
- const _RecoveryKeyBottomSheet({
- required this.title,
- required this.body,
- required this.buttonLabel,
- required this.assetPath,
- this.icon,
- });
-
- @override
- Widget build(BuildContext context) {
- final textTheme = getEnteTextTheme(context);
- final colorScheme = getEnteColorScheme(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.symmetric(horizontal: 16),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- const SizedBox(height: 8),
- const Row(
- mainAxisAlignment: MainAxisAlignment.end,
- children: [
- CloseIconButton(),
- ],
- ),
- const SizedBox(height: 8),
- Image.asset(assetPath),
- const SizedBox(height: 24),
- Text(
- title,
- style: textTheme.h3Bold,
- textAlign: TextAlign.center,
- ),
- const SizedBox(height: 12),
- Text(
- body,
- style: textTheme.body.copyWith(
- color: colorScheme.textMuted,
- ),
- textAlign: TextAlign.center,
- ),
- const SizedBox(height: 32),
- SizedBox(
- width: double.infinity,
- height: 56,
- child: ElevatedButton.icon(
- onPressed: () {
- Navigator.of(context).pop(
- ButtonResult(ButtonAction.first),
- );
- },
- style: ElevatedButton.styleFrom(
- backgroundColor: colorScheme.warning400,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(12),
- ),
- elevation: 0,
- ),
- icon: icon ??
- const HugeIcon(
- icon: HugeIcons.strokeRoundedFileUpload,
- color: Colors.white,
- size: 20,
- strokeWidth: 1.9,
- ),
- label: Text(
- buttonLabel,
- style: textTheme.bodyBold.copyWith(
- color: Colors.white,
- ),
- ),
- ),
- ),
- ],
- ),
- ),
- ),
- );
- }
-}
diff --git a/mobile/apps/locker/lib/ui/pages/login_page.dart b/mobile/apps/locker/lib/ui/pages/login_page.dart
index e197ea5155..f62d7451a7 100644
--- a/mobile/apps/locker/lib/ui/pages/login_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/login_page.dart
@@ -3,6 +3,7 @@ import 'package:email_validator/email_validator.dart';
import 'package:ente_accounts/ente_accounts.dart';
import 'package:ente_accounts/models/errors.dart';
import "package:ente_crypto_dart/ente_crypto_dart.dart";
+import 'package:ente_ui/components/alert_bottom_sheet.dart';
import 'package:ente_ui/components/buttons/button_widget.dart';
import 'package:ente_ui/theme/ente_theme.dart';
import 'package:ente_ui/utils/dialog_util.dart';
@@ -10,7 +11,6 @@ import 'package:flutter/material.dart';
import 'package:locker/l10n/l10n.dart';
import 'package:locker/services/configuration.dart';
import "package:locker/ui/components/gradient_button.dart";
-import 'package:locker/ui/components/new_account_dialog.dart';
import 'package:logging/logging.dart';
import 'package:url_launcher/url_launcher.dart';
@@ -245,11 +245,10 @@ class _LoginPageState extends State<LoginPage> {
}
void _handleSignUp() {
- showCreateNewAccountDialog(
+ showAlertBottomSheet(
context,
title: context.l10n.unlockLockerNewUserTitle,
- body: context.l10n.unlockLockerNewUserBody,
- buttonLabel: context.l10n.okay,
+ message: context.l10n.unlockLockerNewUserBody,
assetPath: "assets/file_lock.png",
);
}
diff --git a/mobile/apps/locker/lib/ui/pages/onboarding_page.dart b/mobile/apps/locker/lib/ui/pages/onboarding_page.dart
index e855b2b25d..6acd51d288 100644
--- a/mobile/apps/locker/lib/ui/pages/onboarding_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/onboarding_page.dart
@@ -4,7 +4,9 @@ import 'package:dots_indicator/dots_indicator.dart';
import 'package:ente_accounts/pages/login_page.dart';
import 'package:ente_accounts/pages/password_entry_page.dart';
import 'package:ente_accounts/pages/password_reentry_page.dart';
+import 'package:ente_ui/components/alert_bottom_sheet.dart';
import 'package:ente_ui/components/buttons/button_widget.dart';
+import "package:ente_ui/components/buttons/models/button_result.dart";
import "package:ente_ui/pages/developer_settings_page.dart";
import "package:ente_ui/pages/web_page.dart";
import "package:ente_ui/theme/ente_theme.dart";
@@ -14,7 +16,6 @@ import 'package:flutter/rendering.dart';
import 'package:locker/l10n/l10n.dart';
import 'package:locker/services/configuration.dart';
import "package:locker/ui/components/gradient_button.dart";
-import "package:locker/ui/components/new_account_dialog.dart";
import 'package:locker/ui/pages/home_page.dart';
class OnboardingPage extends StatefulWidget {
@@ -198,12 +199,20 @@ class _OnboardingPageState extends State<OnboardingPage> {
Center(
child: TextButton(
onPressed: () async {
- final result = await showCreateNewAccountDialog(
+ final result =
+ await showAlertBottomSheet<ButtonResult>(
context,
title: l10n.unlockLockerNewUserTitle,
- body: l10n.unlockLockerNewUserBody,
- buttonLabel: l10n.checkoutEntePhotos,
+ message: l10n.unlockLockerNewUserBody,
assetPath: "assets/file_lock.png",
+ buttons: [
+ GradientButton(
+ text: l10n.checkoutEntePhotos,
+ onTap: () => Navigator.of(context).pop(
+ ButtonResult(ButtonAction.first),
+ ),
+ ),
+ ],
);
if (result?.action == ButtonAction.first) {