Skip to content

armgit / ente

Public Imported from GitHub
0

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

Enhance error bottom sheet functionality with asset path and improved UI elements

AmanRajSinghMouryaacc1e7fa183c
diff --git a/mobile/packages/legacy/lib/components/error_bottom_sheet.dart b/mobile/packages/legacy/lib/components/error_bottom_sheet.dart
index 2162836449..ea4a5afeca 100644
--- a/mobile/packages/legacy/lib/components/error_bottom_sheet.dart
+++ b/mobile/packages/legacy/lib/components/error_bottom_sheet.dart
@@ -1,22 +1,22 @@
import "package:ente_legacy/components/gradient_button.dart";
import "package:ente_strings/ente_strings.dart";
-import "package:ente_ui/theme/colors.dart";
import "package:ente_ui/theme/ente_theme.dart";
-import "package:ente_ui/theme/text_style.dart";
import "package:flutter/material.dart";
-/// Shows an error bottom sheet with the given title and message
Future<void> showErrorBottomSheet(
BuildContext context, {
required String title,
required String message,
+ required String assetPath,
}) {
return showModalBottomSheet<void>(
context: context,
isScrollControlled: true,
+ isDismissible: true,
builder: (context) => ErrorBottomSheet(
title: title,
message: message,
+ assetPath: assetPath,
),
);
}
@@ -24,10 +24,12 @@ Future<void> showErrorBottomSheet(
class ErrorBottomSheet extends StatelessWidget {
final String title;
final String message;
+ final String assetPath;
const ErrorBottomSheet({
required this.title,
required this.message,
+ required this.assetPath,
super.key,
});
@@ -38,79 +40,71 @@ class ErrorBottomSheet extends StatelessWidget {
return Container(
decoration: BoxDecoration(
- color: colorScheme.backgroundElevated2,
+ color: colorScheme.backdropBase,
+ border: Border(top: BorderSide(color: colorScheme.strokeFaint)),
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(24),
topRight: Radius.circular(24),
),
),
child: SafeArea(
- top: false,
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.center,
children: [
- _buildHeader(context, colorScheme, textTheme),
- const SizedBox(height: 20),
- _buildContent(context, colorScheme, textTheme),
+ 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),
+ 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: context.strings.ok,
+ onTap: () => Navigator.of(context).pop(),
+ ),
+ ),
],
),
),
),
);
}
-
- Widget _buildHeader(
- BuildContext context,
- EnteColorScheme colorScheme,
- EnteTextTheme textTheme,
- ) {
- return Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Text(
- title,
- style: textTheme.largeBold,
- ),
- GestureDetector(
- onTap: () => Navigator.of(context).pop(),
- child: Container(
- padding: const EdgeInsets.all(8),
- decoration: BoxDecoration(
- color: colorScheme.fillFaint,
- shape: BoxShape.circle,
- ),
- child: Icon(
- Icons.close,
- size: 20,
- color: colorScheme.textBase,
- ),
- ),
- ),
- ],
- );
- }
-
- Widget _buildContent(
- BuildContext context,
- EnteColorScheme colorScheme,
- EnteTextTheme textTheme,
- ) {
- return Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- message,
- style: textTheme.small.copyWith(color: colorScheme.textMuted),
- ),
- const SizedBox(height: 20),
- GradientButton(
- text: context.strings.ok,
- onTap: () => Navigator.of(context).pop(),
- ),
- ],
- );
- }
}
diff --git a/mobile/packages/legacy/lib/pages/emergency_page.dart b/mobile/packages/legacy/lib/pages/emergency_page.dart
index 3dab3ec609..5788e776b5 100644
--- a/mobile/packages/legacy/lib/pages/emergency_page.dart
+++ b/mobile/packages/legacy/lib/pages/emergency_page.dart
@@ -1,7 +1,9 @@
import "dart:async";
import "package:ente_configuration/base_configuration.dart";
+import "package:ente_legacy/components/confirmation_bottom_sheet.dart";
import "package:ente_legacy/components/gradient_button.dart";
+import "package:ente_legacy/components/trusted_contact_bottom_sheet.dart";
import "package:ente_legacy/models/emergency_models.dart";
import "package:ente_legacy/pages/other_contact_page.dart";
import "package:ente_legacy/pages/select_contact_page.dart"
@@ -377,78 +379,38 @@ class _EmergencyPageState extends State<EmergencyPage> {
BuildContext context,
EmergencyContact contact,
) async {
- if (contact.isPendingInvite()) {
- await showActionSheet(
- context: context,
- body:
- "You have invited ${contact.emergencyContact.email} to be a trusted contact",
- bodyHighlight: "They are yet to accept your invite",
- buttons: [
- ButtonWidget(
- labelText: context.strings.removeInvite,
- buttonType: ButtonType.critical,
- buttonSize: ButtonSize.large,
- buttonAction: ButtonAction.first,
- shouldStickToDarkTheme: true,
- shouldSurfaceExecutionStates: true,
- shouldShowSuccessConfirmation: false,
- onTap: () async {
- await EmergencyContactService.instance
- .updateContact(contact, ContactState.userRevokedContact);
- info?.contacts.remove(contact);
- if (mounted) {
- setState(() {});
- unawaited(_fetchData());
- }
- },
- isInAlert: true,
- ),
- ButtonWidget(
- labelText: context.strings.cancel,
- buttonType: ButtonType.tertiary,
- buttonSize: ButtonSize.large,
- buttonAction: ButtonAction.second,
- shouldStickToDarkTheme: true,
- isInAlert: true,
- ),
- ],
- );
- } else {
- await showActionSheet(
- context: context,
- body:
- "You have added ${contact.emergencyContact.email} as a trusted contact",
- bodyHighlight: "They have accepted your invite",
- buttons: [
- ButtonWidget(
- labelText: context.strings.remove,
- buttonType: ButtonType.critical,
- buttonSize: ButtonSize.large,
- buttonAction: ButtonAction.second,
- shouldStickToDarkTheme: true,
- shouldSurfaceExecutionStates: true,
- shouldShowSuccessConfirmation: false,
- onTap: () async {
- await EmergencyContactService.instance
- .updateContact(contact, ContactState.userRevokedContact);
- info?.contacts.remove(contact);
- if (mounted) {
- setState(() {});
- unawaited(_fetchData());
- }
- },
- isInAlert: true,
- ),
- ButtonWidget(
- labelText: context.strings.cancel,
- buttonType: ButtonType.tertiary,
- buttonSize: ButtonSize.large,
- buttonAction: ButtonAction.third,
- shouldStickToDarkTheme: true,
- isInAlert: true,
- ),
- ],
+ final result = await showTrustedContactBottomSheet(
+ context,
+ contact: contact,
+ );
+
+ if (result == TrustedContactAction.revoke) {
+ final isPending = contact.isPendingInvite();
+ final confirmed = await showConfirmationBottomSheet(
+ context,
+ title: isPending
+ ? context.strings.cancelInviteTitle
+ : context.strings.removeContactTitle,
+ message: isPending
+ ? context.strings.cancelInviteMessage
+ : context.strings.removeContactMessage,
+ buttonText: isPending
+ ? context.strings.revokeInvite
+ : context.strings.removeContact,
+ assetPath: "assets/warning-grey.png",
);
+
+ if (confirmed == true) {
+ await EmergencyContactService.instance
+ .updateContact(contact, ContactState.userRevokedContact);
+ info?.contacts.remove(contact);
+ if (mounted) {
+ setState(() {});
+ unawaited(_fetchData());
+ }
+ }
+ } else if (result == TrustedContactAction.updateTime) {
+ // TODO: Implement update time functionality when API is available
}
}
diff --git a/mobile/packages/legacy/lib/pages/select_contact_page.dart b/mobile/packages/legacy/lib/pages/select_contact_page.dart
index 2e85fdcfa1..0ec9d8a168 100644
--- a/mobile/packages/legacy/lib/pages/select_contact_page.dart
+++ b/mobile/packages/legacy/lib/pages/select_contact_page.dart
@@ -337,6 +337,7 @@ class _AddContactBottomSheetState extends State<AddContactBottomSheet> {
context,
title: context.strings.error,
message: context.strings.somethingWentWrong,
+ assetPath: "assets/warning-blue.png",
);
}
}
@@ -366,12 +367,11 @@ class _AddContactBottomSheetState extends State<AddContactBottomSheet> {
),
child: SafeArea(
child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
+ padding: const EdgeInsets.all(16),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
- const SizedBox(height: 8),
SizedBox(
width: double.infinity,
child: Row(
@@ -381,7 +381,7 @@ class _AddContactBottomSheetState extends State<AddContactBottomSheet> {
onTap: () => Navigator.of(context).pop(),
child: Container(
decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(50),
+ shape: BoxShape.circle,
color: colorScheme.backgroundElevated,
),
padding: const EdgeInsets.all(8),
@@ -461,6 +461,7 @@ class _AddContactBottomSheetState extends State<AddContactBottomSheet> {
context,
title: context.strings.invalidEmailAddress,
message: context.strings.enterValidEmail,
+ assetPath: "assets/warning-blue.png",
);
return;
}
diff --git a/mobile/packages/legacy/lib/services/emergency_service.dart b/mobile/packages/legacy/lib/services/emergency_service.dart
index 4fffedfe7d..209ee53bfb 100644
--- a/mobile/packages/legacy/lib/services/emergency_service.dart
+++ b/mobile/packages/legacy/lib/services/emergency_service.dart
@@ -47,8 +47,9 @@ class EmergencyContactService {
if (!isValidEmail(email)) {
await showErrorBottomSheet(
context,
- title: context.strings.invalidEmailAddress,
+ title: context.strings.letsTryThatAgain,
message: context.strings.enterValidEmail,
+ assetPath: "assets/warning-blue.png",
);
return false;
} else if (email.trim() == _config.getEmail()) {
@@ -56,6 +57,7 @@ class EmergencyContactService {
context,
title: context.strings.oops,
message: context.strings.youCannotShareWithYourself,
+ assetPath: "assets/warning-blue.png",
);
return false;
}