Skip to content

armgit / ente

Public Imported from GitHub
0

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

Update settings section UI

AmanRajSinghMouryadbad2ae6303a
diff --git a/mobile/apps/locker/lib/ui/drawer/about_section_widget.dart b/mobile/apps/locker/lib/ui/drawer/about_section_widget.dart
index 3cb9b69b39..299aeaa24a 100644
--- a/mobile/apps/locker/lib/ui/drawer/about_section_widget.dart
+++ b/mobile/apps/locker/lib/ui/drawer/about_section_widget.dart
@@ -1,10 +1,8 @@
-import "package:ente_ui/components/captioned_text_widget.dart";
-import "package:ente_ui/components/menu_item_widget.dart";
import "package:ente_utils/platform_util.dart";
import "package:flutter/material.dart";
+import "package:hugeicons/hugeicons.dart";
import "package:locker/l10n/l10n.dart";
import "package:locker/ui/components/expandable_menu_item_widget.dart";
-import "package:locker/ui/drawer/common_settings.dart";
import "package:url_launcher/url_launcher.dart";
class AboutSectionWidget extends StatelessWidget {
@@ -15,65 +13,44 @@ class AboutSectionWidget extends StatelessWidget {
return ExpandableMenuItemWidget(
title: context.l10n.about,
selectionOptionsWidget: _getSectionOptions(context),
- leadingIcon: Icons.info_outline,
+ leadingIcon: HugeIcons.strokeRoundedInformationCircle,
);
}
Widget _getSectionOptions(BuildContext context) {
return Column(
children: [
- sectionOptionSpacing,
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: context.l10n.weAreOpenSource,
- ),
- trailingIcon: Icons.chevron_right_outlined,
+ ExpandableChildItem(
+ title: context.l10n.weAreOpenSource,
+ trailingIcon: Icons.chevron_right,
onTap: () async {
// ignore: unawaited_futures
launchUrl(Uri.parse("https://github.com/ente-io/ente"));
},
),
- sectionOptionSpacing,
- AboutMenuItemWidget(
+ ExpandableChildItem(
title: context.l10n.privacy,
- url: "https://ente.io/privacy",
+ trailingIcon: Icons.chevron_right,
+ onTap: () async {
+ await PlatformUtil.openWebView(
+ context,
+ context.l10n.privacy,
+ "https://ente.io/privacy",
+ );
+ },
),
- sectionOptionSpacing,
- AboutMenuItemWidget(
+ ExpandableChildItem(
title: context.l10n.termsOfServicesTitle,
- url: "https://ente.io/terms",
+ trailingIcon: Icons.chevron_right,
+ onTap: () async {
+ await PlatformUtil.openWebView(
+ context,
+ context.l10n.termsOfServicesTitle,
+ "https://ente.io/terms",
+ );
+ },
),
- sectionOptionSpacing,
],
);
}
}
-
-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,
- ),
- trailingIcon: Icons.chevron_right_outlined,
- onTap: () async {
- await PlatformUtil.openWebView(
- context,
- webPageTitle ?? title,
- url,
- );
- },
- );
- }
-}
diff --git a/mobile/apps/locker/lib/ui/drawer/account_section_widget.dart b/mobile/apps/locker/lib/ui/drawer/account_section_widget.dart
index 63a7223be6..15c57cc0bc 100644
--- a/mobile/apps/locker/lib/ui/drawer/account_section_widget.dart
+++ b/mobile/apps/locker/lib/ui/drawer/account_section_widget.dart
@@ -2,17 +2,16 @@ import "package:ente_accounts/pages/delete_account_page.dart";
import "package:ente_accounts/services/user_service.dart";
import "package:ente_crypto_dart/ente_crypto_dart.dart";
import "package:ente_lock_screen/local_authentication_service.dart";
-import "package:ente_ui/components/captioned_text_widget.dart";
-import "package:ente_ui/components/menu_item_widget.dart";
+import "package:ente_ui/theme/ente_theme.dart";
import "package:ente_ui/utils/dialog_util.dart";
import "package:ente_utils/navigation_util.dart";
import "package:flutter/material.dart";
+import "package:hugeicons/hugeicons.dart";
import "package:locker/l10n/l10n.dart";
import "package:locker/services/configuration.dart";
import "package:locker/ui/components/change_email_dialog_locker.dart";
import "package:locker/ui/components/expandable_menu_item_widget.dart";
import "package:locker/ui/components/recovery_key_dialog_locker.dart";
-import "package:locker/ui/drawer/common_settings.dart";
class AccountSectionWidget extends StatelessWidget {
const AccountSectionWidget({super.key});
@@ -23,127 +22,87 @@ class AccountSectionWidget extends StatelessWidget {
return ExpandableMenuItemWidget(
title: l10n.account,
selectionOptionsWidget: _getSectionOptions(context),
- leadingIcon: Icons.account_circle_outlined,
+ leadingIcon: HugeIcons.strokeRoundedUser,
);
}
Column _getSectionOptions(BuildContext context) {
final l10n = context.l10n;
- final List<Widget> children = [];
- children.addAll([
- sectionOptionSpacing,
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: l10n.recoveryKey,
- ),
- trailingIcon: Icons.chevron_right_outlined,
- onTap: () async {
- final hasAuthenticated = await LocalAuthenticationService.instance
- .requestLocalAuthentication(
- context,
- l10n.authToViewYourRecoveryKey,
- );
- if (hasAuthenticated) {
- String recoveryKey;
- try {
- recoveryKey =
- CryptoUtil.bin2hex(Configuration.instance.getRecoveryKey());
- } catch (e) {
+ final colorScheme = getEnteColorScheme(context);
+
+ return Column(
+ children: [
+ ExpandableChildItem(
+ title: l10n.changeEmail,
+ trailingIcon: Icons.chevron_right,
+ onTap: () async {
+ final hasAuthenticated = await LocalAuthenticationService.instance
+ .requestLocalAuthentication(
+ context,
+ l10n.authToChangeYourEmail,
+ );
+ if (hasAuthenticated) {
// ignore: unawaited_futures
- showGenericErrorDialog(
+ showDialog(
context: context,
- error: e,
+ builder: (BuildContext context) {
+ return const ChangeEmailDialogLocker();
+ },
+ barrierColor: Colors.black.withValues(alpha: 0.85),
+ barrierDismissible: false,
);
- return;
}
- await showRecoveryKeyDialogLocker(
+ },
+ ),
+ ExpandableChildItem(
+ title: l10n.recoveryKey,
+ trailingIcon: Icons.chevron_right,
+ onTap: () async {
+ final hasAuthenticated = await LocalAuthenticationService.instance
+ .requestLocalAuthentication(
context,
- recoveryKey: recoveryKey,
- onDone: () {},
+ l10n.authToViewYourRecoveryKey,
);
- }
- },
- ),
- sectionOptionSpacing,
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: l10n.changeEmail,
+ if (hasAuthenticated) {
+ String recoveryKey;
+ try {
+ recoveryKey =
+ CryptoUtil.bin2hex(Configuration.instance.getRecoveryKey());
+ } catch (e) {
+ // ignore: unawaited_futures
+ showGenericErrorDialog(
+ context: context,
+ error: e,
+ );
+ return;
+ }
+ await showRecoveryKeyDialogLocker(
+ context,
+ recoveryKey: recoveryKey,
+ onDone: () {},
+ );
+ }
+ },
),
- trailingIcon: Icons.chevron_right_outlined,
- onTap: () async {
- final hasAuthenticated = await LocalAuthenticationService.instance
- .requestLocalAuthentication(
- context,
- l10n.authToChangeYourEmail,
- );
- if (hasAuthenticated) {
+ ExpandableChildItem(
+ title: l10n.deleteAccount,
+ textColor: colorScheme.warning500,
+ trailingIcon: Icons.chevron_right,
+ trailingIconColor: colorScheme.warning500,
+ onTap: () async {
+ final config = Configuration.instance;
// ignore: unawaited_futures
- showDialog(
- context: context,
- builder: (BuildContext context) {
- return const ChangeEmailDialogLocker();
- },
- barrierColor: Colors.black.withValues(alpha: 0.85),
- barrierDismissible: false,
- );
- }
- },
- ),
- // TODO(aman): Re-introduce later
- // sectionOptionSpacing,
- // MenuItemWidget(
- // captionedTextWidget: CaptionedTextWidget(
- // title: l10n.changePassword,
- // ),
- // trailingIcon: Icons.chevron_right_outlined,
- // onTap: () async {
- // final hasAuthenticated = await LocalAuthenticationService.instance
- // .requestLocalAuthentication(
- // context,
- // l10n.authToChangeYourPassword,
- // );
- // if (hasAuthenticated) {
- // // ignore: unawaited_futures
- // Navigator.of(context).push(
- // MaterialPageRoute(
- // builder: (BuildContext context) {
- // return PasswordEntryPage(
- // Configuration.instance,
- // PasswordEntryMode.update,
- // const HomePage(),
- // );
- // },
- // ),
- // );
- // }
- // },
- // ),
- sectionOptionSpacing,
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: context.l10n.logout,
+ routeToPage(context, DeleteAccountPage(config));
+ },
),
- trailingIcon: Icons.chevron_right_outlined,
- onTap: () async {
- _onLogoutTapped(context);
- },
- ),
- sectionOptionSpacing,
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: context.l10n.deleteAccount,
+ ExpandableChildItem(
+ title: l10n.logout,
+ trailingIcon: Icons.chevron_right,
+ onTap: () async {
+ _onLogoutTapped(context);
+ },
),
- trailingIcon: Icons.chevron_right_outlined,
- onTap: () async {
- final config = Configuration.instance;
- // ignore: unawaited_futures
- routeToPage(context, DeleteAccountPage(config));
- },
- ),
- sectionOptionSpacing,
- ]);
- return Column(
- children: children,
+ ],
);
}
diff --git a/mobile/apps/locker/lib/ui/drawer/security_section_widget.dart b/mobile/apps/locker/lib/ui/drawer/security_section_widget.dart
index fe016384e0..c0f1c82386 100644
--- a/mobile/apps/locker/lib/ui/drawer/security_section_widget.dart
+++ b/mobile/apps/locker/lib/ui/drawer/security_section_widget.dart
@@ -10,17 +10,14 @@ import "package:ente_lock_screen/auth_util.dart";
import "package:ente_lock_screen/local_authentication_service.dart";
import "package:ente_lock_screen/lock_screen_settings.dart";
import "package:ente_lock_screen/ui/lock_screen_options.dart";
-import "package:ente_ui/components/captioned_text_widget.dart";
-import "package:ente_ui/components/menu_item_widget.dart";
import "package:ente_ui/utils/dialog_util.dart";
import "package:ente_ui/utils/toast_util.dart";
import "package:ente_utils/navigation_util.dart";
-import "package:flutter/foundation.dart";
import "package:flutter/material.dart";
+import "package:hugeicons/hugeicons.dart";
import "package:locker/l10n/l10n.dart";
import "package:locker/services/configuration.dart";
import "package:locker/ui/components/expandable_menu_item_widget.dart";
-import "package:locker/ui/drawer/common_settings.dart";
import "package:logging/logging.dart";
class SecuritySectionWidget extends StatefulWidget {
@@ -31,20 +28,7 @@ class SecuritySectionWidget extends StatefulWidget {
}
class _SecuritySectionWidgetState extends State<SecuritySectionWidget> {
- final _config = Configuration.instance;
- late bool _hasLoggedIn;
- final Logger _logger = Logger('SecuritySectionWidget');
-
- @override
- void initState() {
- _hasLoggedIn = _config.hasConfiguredAccount();
- super.initState();
- }
-
- @override
- void dispose() {
- super.dispose();
- }
+ final Logger _logger = Logger("SecuritySectionWidget");
@override
Widget build(BuildContext context) {
@@ -52,100 +36,77 @@ class _SecuritySectionWidgetState extends State<SecuritySectionWidget> {
return ExpandableMenuItemWidget(
title: l10n.security,
selectionOptionsWidget: _getSectionOptions(context),
- leadingIcon: Icons.local_police_outlined,
+ leadingIcon: HugeIcons.strokeRoundedSecurityCheck,
);
}
Widget _getSectionOptions(BuildContext context) {
final l10n = context.l10n;
- final List<Widget> children = [];
- // if (_hasLoggedIn) {
- // children.addAll(
- // [
- // sectionOptionSpacing,
- // MenuItemWidget(
- // captionedTextWidget: CaptionedTextWidget(
- // title: l10n.emailVerificationToggle,
- // makeTextBold: true,
- // ),
- // trailingWidget: ToggleSwitchWidget(
- // value: () => UserService.instance.hasEmailMFAEnabled(),
- // onChanged: () async {
- // final hasAuthenticated = await LocalAuthenticationService
- // .instance
- // .requestLocalAuthentication(
- // context,
- // l10n.authToChangeEmailVerificationSetting,
- // );
- // final isEmailMFAEnabled =
- // UserService.instance.hasEmailMFAEnabled();
- // if (hasAuthenticated) {
- // await updateEmailMFA(!isEmailMFAEnabled);
- // }
- // },
- // ),
- // ),
- // sectionOptionSpacing,
- // MenuItemWidget(
- // captionedTextWidget: CaptionedTextWidget(
- // title: context.l10n.passkey,
- // makeTextBold: true,
- // ),
- // trailingIcon: Icons.chevron_right_outlined,
- // onTap: () async {
- // final hasAuthenticated = await LocalAuthenticationService.instance
- // .requestLocalAuthentication(
- // context,
- // l10n.authToViewPasskey,
- // );
- // if (hasAuthenticated) {
- // await onPasskeyClick(context);
- // }
- // },
- // ),
- // sectionOptionSpacing,
- // ],
- // );
- // } else {
- // children.add(sectionOptionSpacing);
- // }
- children.addAll([
- sectionOptionSpacing,
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: context.l10n.appLock,
- ),
- surfaceExecutionStates: false,
- trailingIcon: Icons.chevron_right_outlined,
- onTap: () async {
- if (await LockScreenSettings.instance.isDeviceSupported()) {
- final bool result = await requestAuthentication(
- context,
- context.l10n.authToChangeLockscreenSetting,
- );
- if (result) {
- await Navigator.of(context).push(
- MaterialPageRoute(
- builder: (BuildContext context) {
- return const LockScreenOptions();
- },
- ),
+ return Column(
+ children: [
+ // TODO: Enable when ready
+ // ExpandableChildItem(
+ // title: l10n.emailVerificationToggle,
+ // trailingWidget: ToggleSwitchWidget(
+ // value: () => UserService.instance.hasEmailMFAEnabled(),
+ // onChanged: () async {
+ // final hasAuthenticated = await LocalAuthenticationService
+ // .instance
+ // .requestLocalAuthentication(
+ // context,
+ // l10n.authToChangeEmailVerificationSetting,
+ // );
+ // final isEmailMFAEnabled =
+ // UserService.instance.hasEmailMFAEnabled();
+ // if (hasAuthenticated) {
+ // await updateEmailMFA(!isEmailMFAEnabled);
+ // }
+ // },
+ // ),
+ // ),
+ // TODO: Enable when ready
+ // ExpandableChildItem(
+ // title: l10n.passkey,
+ // trailingIcon: Icons.chevron_right,
+ // onTap: () async {
+ // final hasAuthenticated = await LocalAuthenticationService.instance
+ // .requestLocalAuthentication(
+ // context,
+ // l10n.authToViewPasskey,
+ // );
+ // if (hasAuthenticated) {
+ // await onPasskeyClick(context);
+ // }
+ // },
+ // ),
+ ExpandableChildItem(
+ title: l10n.appLock,
+ trailingIcon: Icons.chevron_right,
+ onTap: () async {
+ if (await LockScreenSettings.instance.isDeviceSupported()) {
+ final bool result = await requestAuthentication(
+ context,
+ context.l10n.authToChangeLockscreenSetting,
+ );
+ if (result) {
+ await Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return const LockScreenOptions();
+ },
+ ),
+ );
+ }
+ } else {
+ await showErrorDialog(
+ context,
+ context.l10n.noSystemLockFound,
+ context.l10n.toEnableAppLockPleaseSetupDevicePasscodeOrScreen,
);
}
- } else {
- await showErrorDialog(
- context,
- context.l10n.noSystemLockFound,
- context.l10n.toEnableAppLockPleaseSetupDevicePasscodeOrScreen,
- );
- }
- },
- ),
- sectionOptionSpacing,
- ]);
-
- return Column(
- children: children,
+ },
+ ),
+ ],
);
}
diff --git a/mobile/apps/locker/lib/ui/drawer/social_section_widget.dart b/mobile/apps/locker/lib/ui/drawer/social_section_widget.dart
index 4db2664d6c..95e63a11f0 100644
--- a/mobile/apps/locker/lib/ui/drawer/social_section_widget.dart
+++ b/mobile/apps/locker/lib/ui/drawer/social_section_widget.dart
@@ -1,12 +1,10 @@
-import 'dart:io';
+import "dart:io";
-import "package:ente_ui/components/captioned_text_widget.dart";
-import "package:ente_ui/components/menu_item_widget.dart";
-import 'package:flutter/material.dart';
+import "package:flutter/material.dart";
+import "package:hugeicons/hugeicons.dart";
import "package:locker/l10n/l10n.dart";
import "package:locker/ui/components/expandable_menu_item_widget.dart";
-import "package:locker/ui/drawer/common_settings.dart";
-import 'package:url_launcher/url_launcher_string.dart';
+import "package:url_launcher/url_launcher_string.dart";
class SocialSectionWidget extends StatelessWidget {
const SocialSectionWidget({super.key});
@@ -17,7 +15,7 @@ class SocialSectionWidget extends StatelessWidget {
return ExpandableMenuItemWidget(
title: l10n.social,
selectionOptionsWidget: _getSectionOptions(context),
- leadingIcon: Icons.interests_outlined,
+ leadingIcon: HugeIcons.strokeRoundedGlobe,
);
}
@@ -25,62 +23,53 @@ class SocialSectionWidget extends StatelessWidget {
final l10n = context.l10n;
final List<Widget> options = [
- sectionOptionSpacing,
- SocialsMenuItemWidget(
+ _SocialsChildItem(
l10n.blog,
"https://ente.io/blog",
launchInExternalApp: !Platform.isAndroid,
),
- sectionOptionSpacing,
- SocialsMenuItemWidget(
+ _SocialsChildItem(
l10n.merchandise,
"https://shop.ente.io",
launchInExternalApp: !Platform.isAndroid,
),
- const SocialsMenuItemWidget(
+ const _SocialsChildItem(
"Twitter",
"https://twitter.com/enteio",
),
- sectionOptionSpacing,
- const SocialsMenuItemWidget(
+ const _SocialsChildItem(
"Mastodon",
"https://fosstodon.org/@ente",
),
- sectionOptionSpacing,
- const SocialsMenuItemWidget(
+ const _SocialsChildItem(
"Discord",
"https://ente.io/discord",
),
- sectionOptionSpacing,
- const SocialsMenuItemWidget(
+ const _SocialsChildItem(
"Reddit",
"https://reddit.com/r/enteio",
),
- sectionOptionSpacing,
];
return Column(children: options);
}
}
-class SocialsMenuItemWidget extends StatelessWidget {
+class _SocialsChildItem extends StatelessWidget {
final String text;
final String url;
final bool launchInExternalApp;
- const SocialsMenuItemWidget(
+ const _SocialsChildItem(
this.text,
this.url, {
- super.key,
this.launchInExternalApp = true,
});
@override
Widget build(BuildContext context) {
- return MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: text,
- ),
- trailingIcon: Icons.chevron_right_outlined,
+ return ExpandableChildItem(
+ title: text,
+ trailingIcon: Icons.chevron_right,
onTap: () async {
// ignore: unawaited_futures
launchUrlString(
diff --git a/mobile/apps/locker/lib/ui/drawer/support_section_widget.dart b/mobile/apps/locker/lib/ui/drawer/support_section_widget.dart
index 5d0e32bdab..22687ebac4 100644
--- a/mobile/apps/locker/lib/ui/drawer/support_section_widget.dart
+++ b/mobile/apps/locker/lib/ui/drawer/support_section_widget.dart
@@ -1,14 +1,12 @@
-import 'dart:io';
+import "dart:io";
-import "package:ente_ui/components/captioned_text_widget.dart";
-import "package:ente_ui/components/menu_item_widget.dart";
import "package:ente_utils/email_util.dart";
-import 'package:flutter/material.dart';
+import "package:ente_utils/platform_util.dart";
+import "package:flutter/material.dart";
+import "package:hugeicons/hugeicons.dart";
import "package:locker/core/constants.dart";
import "package:locker/l10n/l10n.dart";
import "package:locker/ui/components/expandable_menu_item_widget.dart";
-import "package:locker/ui/drawer/about_section_widget.dart";
-import "package:locker/ui/drawer/common_settings.dart";
import "package:url_launcher/url_launcher_string.dart";
class SupportSectionWidget extends StatelessWidget {
@@ -19,7 +17,7 @@ class SupportSectionWidget extends StatelessWidget {
return ExpandableMenuItemWidget(
title: context.l10n.support,
selectionOptionsWidget: _getSectionOptions(context),
- leadingIcon: Icons.help_outline_outlined,
+ leadingIcon: HugeIcons.strokeRoundedHelpCircle,
);
}
@@ -28,27 +26,27 @@ class SupportSectionWidget extends StatelessWidget {
Platform.isAndroid ? "[email protected]" : "[email protected]";
return Column(
children: [
- sectionOptionSpacing,
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: context.l10n.contactSupport,
- ),
- trailingIcon: Icons.chevron_right_outlined,
+ ExpandableChildItem(
+ title: context.l10n.contactSupport,
+ trailingIcon: Icons.chevron_right,
onTap: () async {
await sendEmail(context, to: supportEmail);
},
),
- sectionOptionSpacing,
- AboutMenuItemWidget(
+ ExpandableChildItem(
title: context.l10n.help,
- url: "https://ente.io/help",
+ trailingIcon: Icons.chevron_right,
+ onTap: () async {
+ await PlatformUtil.openWebView(
+ context,
+ context.l10n.help,
+ "https://ente.io/help",
+ );
+ },
),
- sectionOptionSpacing,
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: context.l10n.suggestFeatures,
- ),
- trailingIcon: Icons.chevron_right_outlined,
+ ExpandableChildItem(
+ title: context.l10n.suggestFeatures,
+ trailingIcon: Icons.chevron_right,
onTap: () async {
// ignore: unawaited_futures
launchUrlString(
@@ -57,12 +55,9 @@ class SupportSectionWidget extends StatelessWidget {
);
},
),
- sectionOptionSpacing,
- MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: context.l10n.reportABug,
- ),
- trailingIcon: Icons.chevron_right_outlined,
+ ExpandableChildItem(
+ title: context.l10n.reportABug,
+ trailingIcon: Icons.chevron_right,
onTap: () async {
await sendLogs(
context,
@@ -75,7 +70,6 @@ class SupportSectionWidget extends StatelessWidget {
await shareLogs(context, bugsEmail, zipFilePath);
},
),
- sectionOptionSpacing,
],
);
}
diff --git a/mobile/apps/locker/lib/ui/drawer/theme_switch_widget.dart b/mobile/apps/locker/lib/ui/drawer/theme_switch_widget.dart
index a996dbc555..5737a94ce3 100644
--- a/mobile/apps/locker/lib/ui/drawer/theme_switch_widget.dart
+++ b/mobile/apps/locker/lib/ui/drawer/theme_switch_widget.dart
@@ -1,11 +1,9 @@
import "package:adaptive_theme/adaptive_theme.dart";
-import "package:ente_ui/components/captioned_text_widget.dart";
-import "package:ente_ui/components/menu_item_widget.dart";
-import "package:ente_ui/theme/ente_theme_data.dart";
+import "package:ente_ui/theme/ente_theme.dart";
import "package:flutter/material.dart";
+import "package:hugeicons/hugeicons.dart";
import "package:locker/l10n/l10n.dart";
import "package:locker/ui/components/expandable_menu_item_widget.dart";
-import "package:locker/ui/drawer/common_settings.dart";
class ThemeSwitchWidget extends StatefulWidget {
const ThemeSwitchWidget({super.key});
@@ -23,7 +21,7 @@ class _ThemeSwitchWidgetState extends State<ThemeSwitchWidget> {
AdaptiveTheme.getThemeMode().then(
(value) {
currentThemeMode = value ?? AdaptiveThemeMode.system;
- debugPrint('theme value $value');
+ debugPrint("theme value $value");
if (mounted) {
setState(() => {});
}
@@ -41,22 +39,16 @@ class _ThemeSwitchWidgetState extends State<ThemeSwitchWidget> {
return ExpandableMenuItemWidget(
title: context.l10n.theme,
selectionOptionsWidget: _getSectionOptions(context),
- leadingIcon: Theme.of(context).brightness == Brightness.light
- ? Icons.light_mode_outlined
- : Icons.dark_mode_outlined,
+ leadingIcon: HugeIcons.strokeRoundedSun01,
);
}
Widget _getSectionOptions(BuildContext context) {
return Column(
children: [
- sectionOptionSpacing,
- _menuItem(context, AdaptiveThemeMode.light),
- sectionOptionSpacing,
- _menuItem(context, AdaptiveThemeMode.dark),
- sectionOptionSpacing,
_menuItem(context, AdaptiveThemeMode.system),
- sectionOptionSpacing,
+ _menuItem(context, AdaptiveThemeMode.dark),
+ _menuItem(context, AdaptiveThemeMode.light),
],
);
}
@@ -73,14 +65,11 @@ class _ThemeSwitchWidgetState extends State<ThemeSwitchWidget> {
}
Widget _menuItem(BuildContext context, AdaptiveThemeMode themeMode) {
- return MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: _name(context, themeMode),
- textStyle: Theme.of(context).colorScheme.enteTheme.textTheme.body,
- ),
- isExpandable: false,
+ final colorScheme = getEnteColorScheme(context);
+ return ExpandableChildItem(
+ title: _name(context, themeMode),
trailingIcon: currentThemeMode == themeMode ? Icons.check : null,
- trailingExtraMargin: 4,
+ trailingIconColor: colorScheme.primary500,
onTap: () async {
AdaptiveTheme.of(context).setThemeMode(themeMode);
currentThemeMode = themeMode;