Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Remove stale settings widgets (#10518)

Aman Raj69de4dac2691
diff --git a/mobile/apps/photos/lib/ui/components/expandable_menu_item_widget.dart b/mobile/apps/photos/lib/ui/components/expandable_menu_item_widget.dart
deleted file mode 100644
index bedce82e4a..0000000000
--- a/mobile/apps/photos/lib/ui/components/expandable_menu_item_widget.dart
+++ /dev/null
@@ -1,113 +0,0 @@
-import 'package:expandable/expandable.dart';
-import 'package:flutter/material.dart';
-import 'package:photos/ente_theme_data.dart';
-import 'package:photos/ui/components/captioned_text_widget.dart';
-import 'package:photos/ui/components/menu_item_widget/menu_item_widget.dart';
-import 'package:photos/ui/settings/common_settings.dart';
-import 'package:photos/ui/settings/inherited_settings_state.dart';
-
-class ExpandableMenuItemWidget extends StatefulWidget {
- final String title;
- final Widget selectionOptionsWidget;
- final IconData leadingIcon;
- // Expand callback that takes bool as argument
- final void Function(bool)? onExpand;
-
- const ExpandableMenuItemWidget({
- required this.title,
- required this.selectionOptionsWidget,
- required this.leadingIcon,
- this.onExpand,
- super.key,
- });
-
- @override
- State<ExpandableMenuItemWidget> createState() =>
- _ExpandableMenuItemWidgetState();
-}
-
-class _ExpandableMenuItemWidgetState extends State<ExpandableMenuItemWidget> {
- final expandableController = ExpandableController(initialExpanded: false);
- @override
- void initState() {
- expandableController.addListener(_expandableControllerListener);
- super.initState();
- }
-
- @override
- void dispose() {
- expandableController.removeListener(_expandableControllerListener);
- super.dispose();
- }
-
- @override
- Widget build(BuildContext context) {
- final isAnySectionExpanded =
- InheritedSettingsState.maybeOf(context)?.isAnySectionExpanded ?? false;
- final isCurrentSectionExpanded = expandableController.expanded;
- final isSuppressed = isAnySectionExpanded && !isCurrentSectionExpanded;
-
- final enteColorScheme = Theme.of(context).colorScheme.enteTheme.colorScheme;
- final backgroundColor = Theme.of(context).brightness == Brightness.light
- ? enteColorScheme.backgroundElevated2
- : enteColorScheme.backgroundElevated;
- return Padding(
- padding: EdgeInsets.only(bottom: expandableController.value ? 8 : 0),
- child: AnimatedContainer(
- curve: Curves.ease,
- duration: const Duration(milliseconds: 200),
- decoration: BoxDecoration(
- color: expandableController.value ? backgroundColor : null,
- borderRadius: BorderRadius.circular(4),
- ),
- child: ExpandableNotifier(
- controller: expandableController,
- child: ScrollOnExpand(
- child: ExpandablePanel(
- header: MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: widget.title,
- makeTextBold: true,
- textColor: isSuppressed
- ? enteColorScheme.textMuted
- : enteColorScheme.textBase,
- ),
- isExpandable: true,
- leadingIcon: widget.leadingIcon,
- leadingIconColor: isSuppressed
- ? enteColorScheme.strokeMuted
- : enteColorScheme.strokeBase,
- trailingIcon: Icons.expand_more,
- trailingIconColor: isSuppressed
- ? enteColorScheme.strokeMuted
- : enteColorScheme.strokeBase,
- menuItemColor: enteColorScheme.fillFaint,
- expandableController: expandableController,
- ),
- collapsed: const SizedBox.shrink(),
- expanded: Padding(
- padding: const EdgeInsets.only(bottom: 4),
- child: widget.selectionOptionsWidget,
- ),
- theme: getExpandableTheme(),
- controller: expandableController,
- ),
- ),
- ),
- ),
- );
- }
-
- void _expandableControllerListener() {
- setState(() {
- if (expandableController.expanded) {
- InheritedSettingsState.maybeOf(context)?.increment();
- } else {
- InheritedSettingsState.maybeOf(context)?.decrement();
- }
- });
- if (widget.onExpand != null) {
- widget.onExpand!(expandableController.expanded);
- }
- }
-}
diff --git a/mobile/apps/photos/lib/ui/components/settings/settings_menu_item.dart b/mobile/apps/photos/lib/ui/components/settings/settings_menu_item.dart
deleted file mode 100644
index d3f608b5c5..0000000000
--- a/mobile/apps/photos/lib/ui/components/settings/settings_menu_item.dart
+++ /dev/null
@@ -1,64 +0,0 @@
-import "package:flutter/material.dart";
-import "package:hugeicons/hugeicons.dart";
-import "package:photos/models/typedefs.dart";
-import "package:photos/theme/ente_theme.dart";
-import "package:photos/ui/components/menu_item_widget/menu_item_widget_new.dart";
-
-/// A settings menu item with a 40x40 icon container.
-/// Used in the redesigned settings page.
-class SettingsMenuItem extends StatelessWidget {
- final String title;
- final List<List<dynamic>> icon;
- final Color? iconColor;
- final FutureVoidCallback? onTap;
- final Widget? trailingWidget;
- final bool showChevron;
- final Color? titleColor;
-
- const SettingsMenuItem({
- required this.title,
- required this.icon,
- this.iconColor,
- this.onTap,
- this.trailingWidget,
- this.showChevron = true,
- this.titleColor,
- super.key,
- });
-
- @override
- Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- final isDarkMode = Theme.of(context).brightness == Brightness.dark;
-
- // Icon container background: Light #F5F5F5, Dark #2C2C2C
- final iconContainerColor =
- isDarkMode ? const Color(0xFF2C2C2C) : const Color(0xFFF5F5F5);
-
- return MenuItemWidgetNew(
- title: title,
- leadingIconWidget: Container(
- width: 40,
- height: 40,
- decoration: BoxDecoration(
- color: iconContainerColor,
- borderRadius: BorderRadius.circular(12),
- ),
- child: Center(
- child: HugeIcon(
- icon: icon,
- color: iconColor ?? colorScheme.menuItemIconStroke,
- size: 20,
- ),
- ),
- ),
- leadingIconSize: 40,
- trailingWidget: trailingWidget,
- trailingIcon: showChevron && trailingWidget == null
- ? Icons.chevron_right_outlined
- : null,
- trailingIconIsMuted: true,
- onTap: onTap,
- );
- }
-}
diff --git a/mobile/apps/photos/lib/ui/settings/about_section_widget.dart b/mobile/apps/photos/lib/ui/settings/about_section_widget.dart
deleted file mode 100644
index 6ad590ea3f..0000000000
--- a/mobile/apps/photos/lib/ui/settings/about_section_widget.dart
+++ /dev/null
@@ -1,133 +0,0 @@
-import 'package:flutter/material.dart';
-import "package:photos/generated/l10n.dart";
-import "package:photos/service_locator.dart";
-import "package:photos/theme/ente_theme.dart";
-import "package:photos/ui/common/web_page.dart";
-import 'package:photos/ui/components/captioned_text_widget.dart';
-import 'package:photos/ui/components/expandable_menu_item_widget.dart';
-import 'package:photos/ui/components/menu_item_widget/menu_item_widget.dart';
-import 'package:photos/ui/notification/toast.dart';
-import 'package:photos/ui/settings/app_update_dialog.dart';
-import 'package:photos/ui/settings/common_settings.dart';
-import 'package:photos/utils/dialog_util.dart';
-import 'package:url_launcher/url_launcher.dart';
-
-class AboutSectionWidget extends StatelessWidget {
- const AboutSectionWidget({super.key});
-
- @override
- Widget build(BuildContext context) {
- return ExpandableMenuItemWidget(
- title: AppLocalizations.of(context).about,
- selectionOptionsWidget: _getSectionOptions(context),
- leadingIcon: Icons.info_outline,
- );
- }
-
- Widget _getSectionOptions(BuildContext context) {
- return Column(
- children: [
- sectionOptionSpacing,
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).weAreOpenSource,
- ),
- pressedColor: getEnteColorScheme(context).fillFaint,
- trailingIcon: Icons.chevron_right_outlined,
- trailingIconIsMuted: true,
- onTap: () async {
- // ignore: unawaited_futures
- launchUrl(Uri.parse("https://github.com/ente-io/ente"));
- },
- ),
- sectionOptionSpacing,
- AboutMenuItemWidget(
- title: AppLocalizations.of(context).privacy,
- url: "https://ente.com/privacy",
- ),
- sectionOptionSpacing,
- AboutMenuItemWidget(
- title: AppLocalizations.of(context).termsOfServicesTitle,
- url: "https://ente.com/terms",
- ),
- sectionOptionSpacing,
- updateService.isIndependent()
- ? Column(
- children: [
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).checkForUpdates,
- ),
- pressedColor: getEnteColorScheme(context).fillFaint,
- trailingIcon: Icons.chevron_right_outlined,
- trailingIconIsMuted: true,
- onTap: () async {
- final dialog = createProgressDialog(
- context,
- AppLocalizations.of(context).checking,
- );
- await dialog.show();
- final shouldUpdate = await updateService.shouldUpdate();
- await dialog.hide();
- if (shouldUpdate) {
- // ignore: unawaited_futures
- showDialog(
- useRootNavigator: false,
- context: context,
- builder: (BuildContext context) {
- return AppUpdateDialog(
- updateService.getLatestVersionInfo(),
- );
- },
- barrierColor: Colors.black.withValues(alpha: 0.85),
- );
- } else {
- showShortToast(
- context,
- AppLocalizations.of(context).youAreOnTheLatestVersion,
- );
- }
- },
- ),
- sectionOptionSpacing,
- ],
- )
- : const SizedBox.shrink(),
- ],
- );
- }
-}
-
-class AboutMenuItemWidget extends StatelessWidget {
- final String title;
- final String url;
- final String? webPageTitle;
- const AboutMenuItemWidget({
- required this.title,
- required this.url,
- this.webPageTitle,
- super.key,
- });
-
- @override
- Widget build(BuildContext context) {
- return MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: title,
- ),
- pressedColor: getEnteColorScheme(context).fillFaint,
- trailingIcon: Icons.chevron_right_outlined,
- trailingIconIsMuted: true,
- onTap: () async {
- // ignore: unawaited_futures
- Navigator.of(context).push(
- MaterialPageRoute(
- builder: (BuildContext context) {
- return WebPage(webPageTitle ?? title, url);
- },
- ),
- );
- },
- );
- }
-}
diff --git a/mobile/apps/photos/lib/ui/settings/common_settings.dart b/mobile/apps/photos/lib/ui/settings/common_settings.dart
deleted file mode 100644
index 4299c1cca3..0000000000
--- a/mobile/apps/photos/lib/ui/settings/common_settings.dart
+++ /dev/null
@@ -1,15 +0,0 @@
-import 'package:expandable/expandable.dart';
-import 'package:flutter/cupertino.dart';
-import 'package:flutter/material.dart';
-
-Widget sectionOptionSpacing = const SizedBox(height: 6);
-
-ExpandableThemeData getExpandableTheme() {
- return const ExpandableThemeData(
- hasIcon: false,
- useInkWell: false,
- tapBodyToCollapse: true,
- tapBodyToExpand: true,
- animationDuration: Duration(milliseconds: 400),
- );
-}
diff --git a/mobile/apps/photos/lib/ui/settings/debug/memories_debug_section.dart b/mobile/apps/photos/lib/ui/settings/debug/memories_debug_section.dart
deleted file mode 100644
index d9c641155a..0000000000
--- a/mobile/apps/photos/lib/ui/settings/debug/memories_debug_section.dart
+++ /dev/null
@@ -1,275 +0,0 @@
-import "dart:async";
-import "dart:math";
-
-import "package:ente_pure_utils/ente_pure_utils.dart";
-import "package:figma_squircle/figma_squircle.dart";
-import "package:flutter/material.dart";
-import "package:photos/models/search/generic_search_result.dart";
-import "package:photos/models/search/recent_searches.dart";
-import "package:photos/theme/ente_theme.dart";
-import "package:photos/ui/viewer/file/no_thumbnail_widget.dart";
-import "package:photos/ui/viewer/file/thumbnail_widget.dart";
-import "package:photos/ui/viewer/search/result/search_result_page.dart";
-
-class MemoriesDebugSection extends StatefulWidget {
- final List<GenericSearchResult> momentsSearchResults;
- final VoidCallback onTapCallback;
- const MemoriesDebugSection(
- this.momentsSearchResults,
- this.onTapCallback, {
- super.key,
- });
-
- @override
- State<MemoriesDebugSection> createState() => _MemoriesDebugSectionState();
-}
-
-class _MemoriesDebugSectionState extends State<MemoriesDebugSection> {
- late List<GenericSearchResult> _momentsSearchResults;
- final streamSubscriptions = <StreamSubscription>[];
-
- @override
- void initState() {
- super.initState();
- _momentsSearchResults = widget.momentsSearchResults;
- }
-
- @override
- void dispose() {
- for (var subscriptions in streamSubscriptions) {
- subscriptions.cancel();
- }
- super.dispose();
- }
-
- @override
- void didUpdateWidget(covariant MemoriesDebugSection oldWidget) {
- super.didUpdateWidget(oldWidget);
- _momentsSearchResults = widget.momentsSearchResults;
- }
-
- @override
- Widget build(BuildContext context) {
- if (_momentsSearchResults.isEmpty) {
- final textTheme = getEnteTextTheme(context);
- return Padding(
- padding: const EdgeInsets.only(left: 12, right: 8),
- child: Row(
- children: [
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- "Smart memories debug (I)",
- style: textTheme.largeBold,
- ),
- const SizedBox(height: 24),
- Padding(
- padding: const EdgeInsets.only(left: 4),
- child: Text(
- "Test memories",
- style: textTheme.smallMuted,
- ),
- ),
- ],
- ),
- ),
- const SizedBox(width: 8),
- ],
- ),
- );
- } else {
- return Padding(
- padding: const EdgeInsets.symmetric(vertical: 8),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- _SectionHeader(widget.onTapCallback),
- const SizedBox(height: 2),
- SizedBox(
- child: SingleChildScrollView(
- clipBehavior: Clip.none,
- padding: const EdgeInsets.symmetric(horizontal: 4.5),
- physics: const BouncingScrollPhysics(),
- scrollDirection: Axis.horizontal,
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: _momentsSearchResults
- .map(
- (momentSearchResult) =>
- MomentRecommendation(momentSearchResult),
- )
- .toList(),
- ),
- ),
- ),
- ],
- ),
- );
- }
- }
-}
-
-class _SectionHeader extends StatelessWidget {
- final VoidCallback onTapCallback;
- const _SectionHeader(this.onTapCallback);
-
- @override
- Widget build(BuildContext context) {
- return GestureDetector(
- onTap: onTapCallback,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Padding(
- padding: const EdgeInsets.all(12),
- child: Text(
- "Smart memories debug (I)",
- style: getEnteTextTheme(context).largeBold,
- ),
- ),
- Container(
- color: Colors.transparent,
- child: Padding(
- padding: const EdgeInsets.fromLTRB(24, 12, 12, 12),
- child: Icon(
- Icons.chevron_right_outlined,
- color: getEnteColorScheme(context).blurStrokePressed,
- ),
- ),
- ),
- ],
- ),
- );
- }
-}
-
-class MomentRecommendation extends StatelessWidget {
- static const _width = 100.0;
- static const _height = 145.0;
- static const _borderWidth = 1.0;
- static const _cornerRadius = 5.0;
- static const _cornerSmoothing = 1.0;
- final GenericSearchResult momentSearchResult;
- const MomentRecommendation(this.momentSearchResult, {super.key});
-
- @override
- Widget build(BuildContext context) {
- final heroTag = momentSearchResult.heroTag() +
- (momentSearchResult.previewThumbnail()?.tag ?? "");
- final enteTextTheme = getEnteTextTheme(context);
- return Padding(
- padding: EdgeInsets.symmetric(horizontal: max(2.5 - _borderWidth, 0)),
- child: GestureDetector(
- onTap: () {
- RecentSearches().add(momentSearchResult.name());
- if (momentSearchResult.onResultTap != null) {
- momentSearchResult.onResultTap!(context);
- } else {
- routeToPage(
- context,
- SearchResultPage(momentSearchResult),
- );
- }
- },
- child: SizedBox(
- width: _width + _borderWidth * 2,
- height: _height + _borderWidth * 2,
- child: Stack(
- clipBehavior: Clip.none,
- alignment: Alignment.center,
- children: [
- ClipSmoothRect(
- radius: SmoothBorderRadius(
- cornerRadius: _cornerRadius + _borderWidth,
- cornerSmoothing: _cornerSmoothing,
- ),
- child: Container(
- color: Colors.white.withValues(alpha: 0.16),
- width: _width + _borderWidth * 2,
- height: _height + _borderWidth * 2,
- ),
- ),
- Container(
- decoration: BoxDecoration(
- boxShadow: [
- BoxShadow(
- color: Colors.black.withValues(alpha: 0.1),
- blurRadius: 6.25,
- offset: const Offset(-1.25, 2.5),
- ),
- ],
- ),
- child: ClipSmoothRect(
- radius: SmoothBorderRadius(
- cornerRadius: _cornerRadius,
- cornerSmoothing: _cornerSmoothing,
- ),
- child: Stack(
- alignment: Alignment.bottomCenter,
- clipBehavior: Clip.none,
- children: [
- SizedBox(
- width: _width,
- height: _height,
- child: momentSearchResult.previewThumbnail() != null
- ? Hero(
- tag: heroTag,
- child: ThumbnailWidget(
- momentSearchResult.previewThumbnail()!,
- shouldShowArchiveStatus: false,
- shouldShowSyncStatus: false,
- ),
- )
- : const NoThumbnailWidget(),
- ),
- Container(
- height: 145,
- width: 100,
- decoration: BoxDecoration(
- gradient: LinearGradient(
- begin: Alignment.topCenter,
- end: Alignment.bottomCenter,
- colors: [
- Colors.black.withValues(alpha: 0),
- Colors.black.withValues(alpha: 0),
- Colors.black.withValues(alpha: 0.5),
- ],
- stops: const [
- 0,
- 0.1,
- 1,
- ],
- ),
- ),
- ),
- ConstrainedBox(
- constraints: const BoxConstraints(
- maxWidth: 76,
- ),
- child: Padding(
- padding: const EdgeInsets.only(
- bottom: 8,
- ),
- child: Text(
- momentSearchResult.name(),
- style: enteTextTheme.small.copyWith(
- color: Colors.white,
- ),
- maxLines: 3,
- overflow: TextOverflow.fade,
- ),
- ),
- ),
- ],
- ),
- ),
- ),
- ],
- ),
- ),
- ),
- );
- }
-}
diff --git a/mobile/apps/photos/lib/ui/settings/security_section_widget.dart b/mobile/apps/photos/lib/ui/settings/security_section_widget.dart
deleted file mode 100644
index 654e1272d1..0000000000
--- a/mobile/apps/photos/lib/ui/settings/security_section_widget.dart
+++ /dev/null
@@ -1,312 +0,0 @@
-import 'dart:async';
-import "dart:typed_data";
-
-import 'package:ente_crypto/ente_crypto.dart';
-import 'package:ente_pure_utils/ente_pure_utils.dart';
-import 'package:flutter/material.dart';
-import "package:local_auth/local_auth.dart";
-import "package:logging/logging.dart";
-import 'package:photos/core/configuration.dart';
-import 'package:photos/core/event_bus.dart';
-import 'package:photos/ente_theme_data.dart';
-import 'package:photos/events/user_details_changed_event.dart';
-import "package:photos/generated/l10n.dart";
-import "package:photos/l10n/l10n.dart";
-import "package:photos/models/user_details.dart";
-import "package:photos/service_locator.dart";
-import "package:photos/services/account/passkey_service.dart";
-import 'package:photos/services/account/user_service.dart';
-import 'package:photos/services/local_authentication_service.dart';
-import 'package:photos/theme/ente_theme.dart';
-import "package:photos/ui/account/request_pwd_verification_page.dart";
-import 'package:photos/ui/account/sessions_page.dart';
-import 'package:photos/ui/components/captioned_text_widget.dart';
-import 'package:photos/ui/components/expandable_menu_item_widget.dart';
-import 'package:photos/ui/components/menu_item_widget/menu_item_widget.dart';
-import 'package:photos/ui/components/toggle_switch_widget.dart';
-import "package:photos/ui/notification/toast.dart";
-import 'package:photos/ui/settings/common_settings.dart';
-import "package:photos/ui/settings/lock_screen/lock_screen_options.dart";
-import "package:photos/utils/auth_util.dart";
-import "package:photos/utils/dialog_util.dart";
-
-class SecuritySectionWidget extends StatefulWidget {
- const SecuritySectionWidget({super.key});
-
- @override
- State<SecuritySectionWidget> createState() => _SecuritySectionWidgetState();
-}
-
-class _SecuritySectionWidgetState extends State<SecuritySectionWidget> {
- final _config = Configuration.instance;
- late StreamSubscription<UserDetailsChangedEvent> _userDetailsChangedEvent;
- final Logger _logger = Logger('SecuritySectionWidget');
- @override
- void initState() {
- super.initState();
- _userDetailsChangedEvent =
- Bus.instance.on<UserDetailsChangedEvent>().listen((event) async {
- if (mounted) {
- setState(() {});
- }
- });
- _refreshSecurityDetails().ignore();
- }
-
- @override
- void dispose() {
- _userDetailsChangedEvent.cancel();
- super.dispose();
- }
-
- @override
- Widget build(BuildContext context) {
- return ExpandableMenuItemWidget(
- title: AppLocalizations.of(context).security,
- selectionOptionsWidget: _getSectionOptions(context),
- leadingIcon: Icons.local_police_outlined,
- );
- }
-
- Widget _getSectionOptions(BuildContext context) {
- final Completer completer = Completer();
- final List<Widget> children = [];
- if (_config.hasConfiguredAccount()) {
- children.addAll([
- sectionOptionSpacing,
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).twofactor,
- ),
- trailingWidget: ToggleSwitchWidget(
- value: () => UserService.instance.hasEnabledTwoFactor(),
- onChanged: () async {
- final hasAuthenticated = await LocalAuthenticationService.instance
- .requestLocalAuthentication(
- context,
- AppLocalizations.of(
- context,
- ).authToConfigureTwofactorAuthentication,
- );
- final isTwoFactorEnabled =
- UserService.instance.hasEnabledTwoFactor();
- if (hasAuthenticated) {
- if (isTwoFactorEnabled) {
- await _disableTwoFactor();
- completer.isCompleted ? null : completer.complete();
- } else {
- await UserService.instance.setupTwoFactor(context, completer);
- }
- return completer.future;
- }
- },
- ),
- ),
- sectionOptionSpacing,
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).emailVerificationToggle,
- ),
- trailingWidget: ToggleSwitchWidget(
- value: () => UserService.instance.hasEmailMFAEnabled(),
- onChanged: () async {
- final hasAuthenticated = await LocalAuthenticationService.instance
- .requestLocalAuthentication(
- context,
- AppLocalizations.of(
- context,
- ).authToChangeEmailVerificationSetting,
- );
- final isEmailMFAEnabled =
- UserService.instance.hasEmailMFAEnabled();
- if (hasAuthenticated) {
- await updateEmailMFA(!isEmailMFAEnabled);
- }
- },
- ),
- ),
- sectionOptionSpacing,
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(title: context.l10n.passkey),
- pressedColor: getEnteColorScheme(context).fillFaint,
- trailingIcon: Icons.chevron_right_outlined,
- trailingIconIsMuted: true,
- onTap: () async {
- final hasAuthenticated = await LocalAuthenticationService.instance
- .requestLocalAuthentication(
- context,
- AppLocalizations.of(context).authToViewPasskey,
- );
- if (hasAuthenticated) {
- await onPasskeyClick(context);
- }
- },
- ),
- sectionOptionSpacing,
- ]);
- }
- children.addAll([
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).appLock,
- ),
- trailingIcon: Icons.chevron_right_outlined,
- trailingIconIsMuted: true,
- onTap: () async {
- if (await LocalAuthentication().isDeviceSupported()) {
- final bool result = await requestAuthentication(
- context,
- AppLocalizations.of(context).authToChangeLockscreenSetting,
- );
- if (result) {
- await Navigator.of(context).push(
- MaterialPageRoute(
- builder: (BuildContext context) {
- return const LockScreenOptions();
- },
- ),
- );
- }
- } else {
- await showErrorDialog(
- context,
- AppLocalizations.of(context).noSystemLockFound,
- AppLocalizations.of(
- context,
- ).toEnableAppLockPleaseSetupDevicePasscodeOrScreen,
- );
- }
- },
- ),
- sectionOptionSpacing,
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).viewActiveSessions,
- ),
- pressedColor: getEnteColorScheme(context).fillFaint,
- trailingIcon: Icons.chevron_right_outlined,
- trailingIconIsMuted: true,
- showOnlyLoadingState: true,
- onTap: () async {
- final hasAuthenticated = await LocalAuthenticationService.instance
- .requestLocalAuthentication(
- context,
- AppLocalizations.of(context).authToViewYourActiveSessions,
- );
- if (hasAuthenticated) {
- unawaited(
- Navigator.of(context).push(
- MaterialPageRoute(
- builder: (BuildContext context) {
- return const SessionsPage();
- },
- ),
- ),
- );
- }
- },
- ),
- sectionOptionSpacing,
- ]);
- return Column(children: children);
- }
-
- Future<void> _refreshSecurityDetails() async {
- if (!_config.hasConfiguredAccount() || isLocalGalleryMode) {
- return;
- }
- try {
- await UserService.instance.getUserDetailsV2(memoryCount: false);
- if (mounted) {
- setState(() {});
- }
- } catch (e, s) {
- _logger.warning("failed to refresh security details", e, s);
- }
- }
-
- Future<void> _disableTwoFactor() async {
- final AlertDialog alert = AlertDialog(
- title: Text(AppLocalizations.of(context).disableTwofactor),
- content: Text(AppLocalizations.of(context).confirm2FADisable),
- actions: [
- TextButton(
- child: Text(
- AppLocalizations.of(context).no,
- style: TextStyle(
- color: Theme.of(context).colorScheme.greenAlternative,
- ),
- ),
- onPressed: () {
- Navigator.of(context).pop('dialog');
- },
- ),
- TextButton(
- child: Text(
- AppLocalizations.of(context).yes,
- style: const TextStyle(color: Colors.red),
- ),
- onPressed: () async {
- await UserService.instance.disableTwoFactor(context);
- Navigator.of(context).pop('dialog');
- },
- ),
- ],
- );
-
- await showDialog(
- useRootNavigator: false,
- context: context,
- builder: (BuildContext context) {
- return alert;
- },
- );
- }
-
- Future<void> onPasskeyClick(BuildContext buildContext) async {
- try {
- final isPassKeyResetEnabled =
- await PasskeyService.instance.isPasskeyRecoveryEnabled();
- if (!isPassKeyResetEnabled) {
- final Uint8List recoveryKey =
- await UserService.instance.getOrCreateRecoveryKey(context);
- final resetKey = CryptoUtil.generateKey();
- final resetKeyBase64 = CryptoUtil.bin2base64(resetKey);
- final encryptionResult = CryptoUtil.encryptSync(resetKey, recoveryKey);
- await PasskeyService.instance.configurePasskeyRecovery(
- resetKeyBase64,
- CryptoUtil.bin2base64(encryptionResult.encryptedData!),
- CryptoUtil.bin2base64(encryptionResult.nonce!),
- );
- }
- PasskeyService.instance.openPasskeyPage(buildContext).ignore();
- } catch (e, s) {
- _logger.severe("failed to open passkey page", e, s);
- await showGenericErrorDialog(context: context, error: e);
- }
- }
-
- Future<void> updateEmailMFA(bool isEnabled) async {
- try {
- final UserDetails details = await UserService.instance.getUserDetailsV2(
- memoryCount: false,
- );
- if ((details.profileData?.canDisableEmailMFA ?? false) == false) {
- await routeToPage(
- context,
- RequestPasswordVerificationPage(
- onPasswordVerified: (Uint8List keyEncryptionKey) async {
- final Uint8List loginKey = await CryptoUtil.deriveLoginKey(
- keyEncryptionKey,
- );
- await UserService.instance.registerOrUpdateSrp(loginKey);
- },
- ),
- );
- }
- await UserService.instance.updateEmailMFA(isEnabled);
- } catch (e) {
- showToast(context, AppLocalizations.of(context).somethingWentWrong);
- }
- }
-}
diff --git a/mobile/apps/photos/lib/ui/settings/settings_title_bar_widget.dart b/mobile/apps/photos/lib/ui/settings/settings_title_bar_widget.dart
deleted file mode 100644
index 91ab47bb12..0000000000
--- a/mobile/apps/photos/lib/ui/settings/settings_title_bar_widget.dart
+++ /dev/null
@@ -1,50 +0,0 @@
-import 'package:flutter/material.dart';
-import "package:intl/intl.dart";
-import "package:photos/generated/l10n.dart";
-import 'package:photos/models/user_details.dart';
-import 'package:photos/states/user_details_state.dart';
-import 'package:photos/theme/ente_theme.dart';
-import 'package:photos/ui/common/loading_widget.dart';
-
-class SettingsTitleBarWidget extends StatelessWidget {
- const SettingsTitleBarWidget({super.key});
-
- @override
- Widget build(BuildContext context) {
- final inheritedDetails = InheritedUserDetails.of(context);
- final userDetails = inheritedDetails?.userDetails;
- bool isCached = false;
- if (inheritedDetails != null) {
- isCached = inheritedDetails.isCached;
- }
- return Container(
- padding: const EdgeInsets.symmetric(vertical: 4),
- child: Padding(
- padding: const EdgeInsets.fromLTRB(8, 0, 20, 0),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- IconButton(
- visualDensity: const VisualDensity(horizontal: -2, vertical: -2),
- onPressed: () {
- Navigator.pop(context);
- },
- icon: const Icon(Icons.keyboard_double_arrow_left_outlined),
- ),
- userDetails is UserDetails && !isCached
- ? Text(
- AppLocalizations.of(context).memoryCount(
- count: userDetails.fileCount,
- formattedCount:
- NumberFormat().format(userDetails.fileCount),
- ),
- // "${NumberFormat().format(userDetails.fileCount)} memories",
- style: getEnteTextTheme(context).largeBold,
- )
- : const EnteLoadingWidget(),
- ],
- ),
- ),
- );
- }
-}
diff --git a/mobile/apps/photos/lib/ui/settings/social_section_widget.dart b/mobile/apps/photos/lib/ui/settings/social_section_widget.dart
deleted file mode 100644
index ecfa6a407e..0000000000
--- a/mobile/apps/photos/lib/ui/settings/social_section_widget.dart
+++ /dev/null
@@ -1,113 +0,0 @@
-import "dart:io";
-
-import 'package:flutter/material.dart';
-import "package:photos/generated/l10n.dart";
-import "package:photos/service_locator.dart";
-import 'package:photos/theme/ente_theme.dart';
-import 'package:photos/ui/components/captioned_text_widget.dart';
-import 'package:photos/ui/components/expandable_menu_item_widget.dart';
-import 'package:photos/ui/components/menu_item_widget/menu_item_widget.dart';
-import 'package:photos/ui/settings/common_settings.dart';
-import 'package:url_launcher/url_launcher_string.dart';
-
-class SocialSectionWidget extends StatelessWidget {
- const SocialSectionWidget({super.key});
-
- @override
- Widget build(BuildContext context) {
- return ExpandableMenuItemWidget(
- title: AppLocalizations.of(context).social,
- selectionOptionsWidget: _getSectionOptions(context),
- leadingIcon: Icons.interests_outlined,
- );
- }
-
- Widget _getSectionOptions(BuildContext context) {
- final List<Widget> options = [];
- final result = updateService.getRateDetails();
- final String ratePlace = result.item1;
- final String rateUrl = result.item2;
- options.addAll(
- [
- sectionOptionSpacing,
- SocialsMenuItemWidget(
- AppLocalizations.of(context).rateUsOnStore(storeName: ratePlace),
- rateUrl,
- ),
- sectionOptionSpacing,
- ],
- );
- options.addAll(
- [
- SocialsMenuItemWidget(
- AppLocalizations.of(context).blog,
- "https://ente.com/blog",
- launchInExternalApp: !Platform.isAndroid,
- ),
- sectionOptionSpacing,
- SocialsMenuItemWidget(
- AppLocalizations.of(context).merchandise,
- "https://shop.ente.com",
- launchInExternalApp: !Platform.isAndroid,
- ),
- sectionOptionSpacing,
- SocialsMenuItemWidget(
- AppLocalizations.of(context).twitter,
- "https://twitter.com/enteio",
- ),
- sectionOptionSpacing,
- SocialsMenuItemWidget(
- AppLocalizations.of(context).mastodon,
- "https://fosstodon.org/@ente",
- ),
- sectionOptionSpacing,
- SocialsMenuItemWidget(
- AppLocalizations.of(context).discord,
- "https://ente.com/discord",
- ),
- sectionOptionSpacing,
- SocialsMenuItemWidget(
- AppLocalizations.of(context).reddit,
- "https://reddit.com/r/enteio",
- ),
- sectionOptionSpacing,
- ],
- );
-
- return Column(children: options);
- }
-}
-
-class SocialsMenuItemWidget extends StatelessWidget {
- final String text;
- final String url;
- final bool launchInExternalApp;
-
- const SocialsMenuItemWidget(
- this.text,
- this.url, {
- super.key,
- this.launchInExternalApp = true,
- });
-
- @override
- Widget build(BuildContext context) {
- return MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: text,
- ),
- pressedColor: getEnteColorScheme(context).fillFaint,
- trailingIcon: Icons.chevron_right_outlined,
- trailingIconIsMuted: true,
- onTap: () async {
- // ignore: unawaited_futures
- launchUrlString(
- url,
- mode: launchInExternalApp
- ? LaunchMode.externalApplication
- : LaunchMode.platformDefault,
- );
- },
- );
- }
-}
diff --git a/mobile/apps/photos/lib/ui/settings/support_section_widget.dart b/mobile/apps/photos/lib/ui/settings/support_section_widget.dart
deleted file mode 100644
index f6f0eec589..0000000000
--- a/mobile/apps/photos/lib/ui/settings/support_section_widget.dart
+++ /dev/null
@@ -1,85 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:photos/core/constants.dart';
-import "package:photos/generated/l10n.dart";
-import 'package:photos/theme/ente_theme.dart';
-import 'package:photos/ui/components/captioned_text_widget.dart';
-import 'package:photos/ui/components/expandable_menu_item_widget.dart';
-import 'package:photos/ui/components/menu_item_widget/menu_item_widget.dart';
-import 'package:photos/ui/settings/about_section_widget.dart';
-import 'package:photos/ui/settings/common_settings.dart';
-import 'package:photos/utils/email_util.dart';
-import "package:url_launcher/url_launcher_string.dart";
-
-class SupportSectionWidget extends StatelessWidget {
- const SupportSectionWidget({super.key});
-
- @override
- Widget build(BuildContext context) {
- return ExpandableMenuItemWidget(
- title: AppLocalizations.of(context).support,
- selectionOptionsWidget: _getSectionOptions(context),
- leadingIcon: Icons.help_outline_outlined,
- );
- }
-
- Widget _getSectionOptions(BuildContext context) {
- return Column(
- children: [
- sectionOptionSpacing,
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).contactSupport,
- ),
- pressedColor: getEnteColorScheme(context).fillFaint,
- trailingIcon: Icons.chevron_right_outlined,
- trailingIconIsMuted: true,
- onTap: () async {
- await sendEmail(context, to: supportEmail);
- },
- ),
- sectionOptionSpacing,
- AboutMenuItemWidget(
- title: AppLocalizations.of(context).help,
- url: "https://ente.com/help",
- ),
- sectionOptionSpacing,
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).suggestFeatures,
- ),
- pressedColor: getEnteColorScheme(context).fillFaint,
- trailingIcon: Icons.chevron_right_outlined,
- trailingIconIsMuted: true,
- onTap: () async {
- // ignore: unawaited_futures
- launchUrlString(
- githubDiscussionsUrl,
- mode: LaunchMode.externalApplication,
- );
- },
- ),
- sectionOptionSpacing,
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).reportABug,
- ),
- pressedColor: getEnteColorScheme(context).fillFaint,
- trailingIcon: Icons.chevron_right_outlined,
- trailingIconIsMuted: true,
- onTap: () async {
- await sendLogs(
- context,
- AppLocalizations.of(context).reportBug,
- supportEmail,
- );
- },
- onLongPress: () async {
- final zipFilePath = await getZippedLogsFile(context);
- await shareLogs(context, supportEmail, zipFilePath);
- },
- ),
- sectionOptionSpacing,
- ],
- );
- }
-}