π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Refractor
AmanRajSinghMourya74699fea5a26
diff --git a/mobile/packages/legacy/lib/components/recovery_date_selector.dart b/mobile/packages/legacy/lib/components/recovery_date_selector.dartnew file mode 100644index 0000000000..9292101a21--- /dev/null+++ b/mobile/packages/legacy/lib/components/recovery_date_selector.dart@@ -0,0 +1,59 @@+import "package:ente_strings/ente_strings.dart";+import "package:ente_ui/theme/ente_theme.dart";+import "package:flutter/material.dart";++class RecoveryDateSelector extends StatelessWidget {+ final int selectedDays;+ final ValueChanged<int> onDaysChanged;++ const RecoveryDateSelector({+ required this.selectedDays,+ required this.onDaysChanged,+ super.key,+ });++ @override+ Widget build(BuildContext context) {+ final colorScheme = getEnteColorScheme(context);+ final textTheme = getEnteTextTheme(context);++ return Row(+ mainAxisAlignment: MainAxisAlignment.spaceBetween,+ children: [+ _buildChip(context, 7, colorScheme, textTheme),+ const SizedBox(width: 12),+ _buildChip(context, 14, colorScheme, textTheme),+ const SizedBox(width: 12),+ _buildChip(context, 30, colorScheme, textTheme),+ ],+ );+ }++ Widget _buildChip(+ BuildContext context,+ int days,+ colorScheme,+ textTheme,+ ) {+ final isSelected = selectedDays == days;+ return GestureDetector(+ onTap: () => onDaysChanged(days),+ child: Container(+ padding: const EdgeInsets.symmetric(+ horizontal: 20.0,+ vertical: 16.0,+ ),+ decoration: BoxDecoration(+ color: isSelected ? colorScheme.primary700 : colorScheme.fillFaint,+ borderRadius: BorderRadius.circular(14),+ ),+ child: Text(+ context.strings.nDays(days),+ style: textTheme.body.copyWith(+ color: isSelected ? Colors.white : colorScheme.primary700,+ ),+ ),+ ),+ );+ }+}diff --git a/mobile/packages/legacy/lib/components/trusted_contact_bottom_sheet.dart b/mobile/packages/legacy/lib/components/trusted_contact_bottom_sheet.dartindex b7436c834f..cc083376db 100644--- a/mobile/packages/legacy/lib/components/trusted_contact_bottom_sheet.dart+++ b/mobile/packages/legacy/lib/components/trusted_contact_bottom_sheet.dart@@ -1,4 +1,5 @@import "package:ente_legacy/components/gradient_button.dart";+import "package:ente_legacy/components/recovery_date_selector.dart";import "package:ente_legacy/models/emergency_models.dart";import "package:ente_strings/ente_strings.dart";import "package:ente_ui/theme/colors.dart";@@ -85,7 +86,7 @@ class _TrustedContactBottomSheetState extends State<TrustedContactBottomSheet> {const SizedBox(height: 12),_buildDescription(colorScheme, textTheme, email, isPending),const SizedBox(height: 20),- _buildRecoveryTimeSection(colorScheme, textTheme),+ _buildRecoveryTimeSection(),const SizedBox(height: 20),_buildUpdateTimeButton(colorScheme, textTheme),const SizedBox(height: 20),@@ -147,50 +148,14 @@ class _TrustedContactBottomSheetState extends State<TrustedContactBottomSheet> {);}- Widget _buildRecoveryTimeSection(- EnteColorScheme colorScheme,- EnteTextTheme textTheme,- ) {- return Row(- mainAxisAlignment: MainAxisAlignment.spaceBetween,- children: [- _buildRecoveryChip(7, colorScheme, textTheme),- const SizedBox(width: 12),- _buildRecoveryChip(14, colorScheme, textTheme),- const SizedBox(width: 12),- _buildRecoveryChip(30, colorScheme, textTheme),- ],- );- }-- Widget _buildRecoveryChip(- int days,- EnteColorScheme colorScheme,- EnteTextTheme textTheme,- ) {- final isSelected = _selectedRecoveryDays == days;- return GestureDetector(- onTap: () {+ Widget _buildRecoveryTimeSection() {+ return RecoveryDateSelector(+ selectedDays: _selectedRecoveryDays,+ onDaysChanged: (days) {setState(() {_selectedRecoveryDays = days;});},- child: Container(- padding: const EdgeInsets.symmetric(- horizontal: 20.0,- vertical: 16.0,- ),- decoration: BoxDecoration(- color: isSelected ? colorScheme.primary700 : colorScheme.fillFaint,- borderRadius: BorderRadius.circular(14),- ),- child: Text(- context.strings.nDays(days),- style: textTheme.body.copyWith(- color: isSelected ? Colors.white : colorScheme.primary700,- ),- ),- ),);}diff --git a/mobile/packages/legacy/lib/pages/select_contact_page.dart b/mobile/packages/legacy/lib/pages/select_contact_page.dartindex b0210e196c..294cec8296 100644--- a/mobile/packages/legacy/lib/pages/select_contact_page.dart+++ b/mobile/packages/legacy/lib/pages/select_contact_page.dart@@ -3,6 +3,7 @@ import "package:ente_accounts/services/user_service.dart";import "package:ente_configuration/base_configuration.dart";import "package:ente_legacy/components/alert_bottom_sheet.dart";import "package:ente_legacy/components/gradient_button.dart";+import "package:ente_legacy/components/recovery_date_selector.dart";import "package:ente_legacy/models/emergency_models.dart";import "package:ente_legacy/services/emergency_service.dart";import "package:ente_sharing/models/user.dart";@@ -105,7 +106,7 @@ class _AddContactBottomSheetState extends State<AddContactBottomSheet> {),],const SizedBox(height: 20),- _buildRecoveryTimeSection(colorScheme, textTheme),+ _buildRecoveryTimeSection(textTheme),const SizedBox(height: 20),_buildAddContactButton(textTheme),const SizedBox(height: 12),@@ -331,10 +332,7 @@ class _AddContactBottomSheetState extends State<AddContactBottomSheet> {);}- Widget _buildRecoveryTimeSection(- EnteColorScheme colorScheme,- EnteTextTheme textTheme,- ) {+ Widget _buildRecoveryTimeSection(EnteTextTheme textTheme) {return Column(crossAxisAlignment: CrossAxisAlignment.start,children: [@@ -343,51 +341,18 @@ class _AddContactBottomSheetState extends State<AddContactBottomSheet> {style: textTheme.bodyMuted,),const SizedBox(height: 12),- Row(- mainAxisAlignment: MainAxisAlignment.spaceBetween,- children: [- _buildRecoveryChip(7, colorScheme, textTheme),- const SizedBox(width: 12),- _buildRecoveryChip(14, colorScheme, textTheme),- const SizedBox(width: 12),- _buildRecoveryChip(30, colorScheme, textTheme),- ],+ RecoveryDateSelector(+ selectedDays: _selectedRecoveryDays,+ onDaysChanged: (days) {+ setState(() {+ _selectedRecoveryDays = days;+ });+ },),],);}- Widget _buildRecoveryChip(- int days,- EnteColorScheme colorScheme,- EnteTextTheme textTheme,- ) {- final isSelected = _selectedRecoveryDays == days;- return GestureDetector(- onTap: () {- setState(() {- _selectedRecoveryDays = days;- });- },- child: Container(- padding: const EdgeInsets.symmetric(- horizontal: 20.0,- vertical: 16.0,- ),- decoration: BoxDecoration(- color: isSelected ? colorScheme.primary700 : colorScheme.fillFaint,- borderRadius: BorderRadius.circular(14),- ),- child: Text(- context.strings.nDays(days),- style: textTheme.body.copyWith(- color: isSelected ? Colors.white : colorScheme.primary700,- ),- ),- ),- );- }-Widget _buildAddContactButton(EnteTextTheme textTheme) {final bool canAdd = selectedEmail.isNotEmpty || _emailIsValid;return GradientButton(