From 8219177c1c4e2c122f0cdc37efdcf81b7110b333 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:01:52 +0530 Subject: [PATCH 1/4] [auth] Sort by natural order --- auth/lib/ui/home_page.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/auth/lib/ui/home_page.dart b/auth/lib/ui/home_page.dart index e18cfa45ae0..aaece3d26d0 100644 --- a/auth/lib/ui/home_page.dart +++ b/auth/lib/ui/home_page.dart @@ -217,10 +217,10 @@ class _HomePageState extends State { void sortFilteredCodes(List codes, CodeSortKey sortKey) { switch (sortKey) { case CodeSortKey.issuerName: - codes.sort((a, b) => a.issuer.compareTo(b.issuer)); + codes.sort((a, b) => compareNatural(a.issuer, b.issuer)); break; case CodeSortKey.accountName: - codes.sort((a, b) => a.account.compareTo(b.account)); + codes.sort((a, b) => compareNatural(a.account, b.account)); break; case CodeSortKey.mostFrequentlyUsed: codes.sort((a, b) => b.display.tapCount.compareTo(a.display.tapCount)); From b12371437f36be2b7f6730446a89f9f1d3a14220 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:02:29 +0530 Subject: [PATCH 2/4] [auth] Extract strings --- auth/lib/l10n/arb/app_en.arb | 4 ++++ auth/lib/ui/settings/theme_switch_widget.dart | 18 ++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/auth/lib/l10n/arb/app_en.arb b/auth/lib/l10n/arb/app_en.arb index 4f42e79e51e..c891ddebac8 100644 --- a/auth/lib/l10n/arb/app_en.arb +++ b/auth/lib/l10n/arb/app_en.arb @@ -258,6 +258,10 @@ "areYouSureYouWantToLogout": "Are you sure you want to logout?", "yesLogout": "Yes, logout", "exit": "Exit", + "theme": "Theme", + "lightTheme": "Light", + "darkTheme": "Dark", + "systemTheme": "System", "verifyingRecoveryKey": "Verifying recovery key...", "recoveryKeyVerified": "Recovery key verified", "recoveryKeySuccessBody": "Great! Your recovery key is valid. Thank you for verifying.\n\nPlease remember to keep your recovery key safely backed up.", diff --git a/auth/lib/ui/settings/theme_switch_widget.dart b/auth/lib/ui/settings/theme_switch_widget.dart index c0495b65b6f..6607926db22 100644 --- a/auth/lib/ui/settings/theme_switch_widget.dart +++ b/auth/lib/ui/settings/theme_switch_widget.dart @@ -1,7 +1,6 @@ - - import 'package:adaptive_theme/adaptive_theme.dart'; import 'package:ente_auth/ente_theme_data.dart'; +import 'package:ente_auth/l10n/l10n.dart'; import 'package:ente_auth/theme/ente_theme.dart'; import 'package:ente_auth/ui/components/captioned_text_widget.dart'; import 'package:ente_auth/ui/components/expandable_menu_item_widget.dart'; @@ -42,7 +41,7 @@ class _ThemeSwitchWidgetState extends State { @override Widget build(BuildContext context) { return ExpandableMenuItemWidget( - title: "Theme", + title: context.l10n.theme, selectionOptionsWidget: _getSectionOptions(context), leadingIcon: Theme.of(context).brightness == Brightness.light ? Icons.light_mode_outlined @@ -64,10 +63,21 @@ class _ThemeSwitchWidgetState extends State { ); } + String _name(BuildContext ctx, AdaptiveThemeMode mode) { + switch (mode) { + case AdaptiveThemeMode.light: + return ctx.l10n.lightTheme; + case AdaptiveThemeMode.dark: + return ctx.l10n.darkTheme; + case AdaptiveThemeMode.system: + return ctx.l10n.systemTheme; + } + } + Widget _menuItem(BuildContext context, AdaptiveThemeMode themeMode) { return MenuItemWidget( captionedTextWidget: CaptionedTextWidget( - title: toBeginningOfSentenceCase(themeMode.name)!, + title: _name(context, themeMode), textStyle: Theme.of(context).colorScheme.enteTheme.textTheme.body, ), pressedColor: getEnteColorScheme(context).fillFaint, From eec4bbde98e921a7136c3e7ef5b9086db0afe592 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:08:57 +0530 Subject: [PATCH 3/4] Lint fix --- auth/lib/ui/settings/theme_switch_widget.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/auth/lib/ui/settings/theme_switch_widget.dart b/auth/lib/ui/settings/theme_switch_widget.dart index 6607926db22..0220bf795a0 100644 --- a/auth/lib/ui/settings/theme_switch_widget.dart +++ b/auth/lib/ui/settings/theme_switch_widget.dart @@ -7,7 +7,6 @@ import 'package:ente_auth/ui/components/expandable_menu_item_widget.dart'; import 'package:ente_auth/ui/components/menu_item_widget.dart'; import 'package:ente_auth/ui/settings/common_settings.dart'; import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; class ThemeSwitchWidget extends StatefulWidget { const ThemeSwitchWidget({super.key}); From 8e6330dfdb2a22b8a0d27e6f7a533aa304f4f7a5 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:46:13 +0530 Subject: [PATCH 4/4] Fix sorting --- auth/lib/ui/home_page.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/auth/lib/ui/home_page.dart b/auth/lib/ui/home_page.dart index aaece3d26d0..1a2d0a83a76 100644 --- a/auth/lib/ui/home_page.dart +++ b/auth/lib/ui/home_page.dart @@ -217,10 +217,11 @@ class _HomePageState extends State { void sortFilteredCodes(List codes, CodeSortKey sortKey) { switch (sortKey) { case CodeSortKey.issuerName: - codes.sort((a, b) => compareNatural(a.issuer, b.issuer)); + codes.sort((a, b) => compareAsciiLowerCaseNatural(a.issuer, b.issuer)); break; case CodeSortKey.accountName: - codes.sort((a, b) => compareNatural(a.account, b.account)); + codes + .sort((a, b) => compareAsciiLowerCaseNatural(a.account, b.account)); break; case CodeSortKey.mostFrequentlyUsed: codes.sort((a, b) => b.display.tapCount.compareTo(a.display.tapCount));