Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[auth] Sort by natural order #4423

Merged
merged 4 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions auth/lib/l10n/arb/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
5 changes: 3 additions & 2 deletions auth/lib/ui/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,11 @@ class _HomePageState extends State<HomePage> {
void sortFilteredCodes(List<Code> codes, CodeSortKey sortKey) {
switch (sortKey) {
case CodeSortKey.issuerName:
codes.sort((a, b) => a.issuer.compareTo(b.issuer));
codes.sort((a, b) => compareAsciiLowerCaseNatural(a.issuer, b.issuer));
break;
case CodeSortKey.accountName:
codes.sort((a, b) => a.account.compareTo(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));
Expand Down
19 changes: 14 additions & 5 deletions auth/lib/ui/settings/theme_switch_widget.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@


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';
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});
Expand Down Expand Up @@ -42,7 +40,7 @@ class _ThemeSwitchWidgetState extends State<ThemeSwitchWidget> {
@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
Expand All @@ -64,10 +62,21 @@ class _ThemeSwitchWidgetState extends State<ThemeSwitchWidget> {
);
}

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,
Expand Down
Loading