Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit bcbf374

Browse files
committed
temp save
1 parent 470a9ca commit bcbf374

File tree

6 files changed

+93
-2
lines changed

6 files changed

+93
-2
lines changed

entry/src/main/ets/common/settings.ets

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export type UserPreferences = Map<string, ValueType>;
44

55
export type AppLanguage = 'default' | 'zh-Hans' | 'en-Latn-US';
66
export type DarkMode = 'default' | 'light' | 'dark';
7+
export type ViewMode = 'compact' | 'normal' | 'large';
78
export type DigitGroup = '2' | '3' | '4' | 'even' | 'none';
89
export type ShowAccountName = 'always' | 'smart' | 'off';
910
export type AuthTypePriority = 'face' | 'touch' | 'pin';
@@ -19,6 +20,7 @@ export const DefaultUserPreferences: UserPreferences = new Map<string, ValueType
1920
// outlook
2021
['AppLanguage', 'default' as AppLanguage],
2122
['DarkMode', 'default' as DarkMode],
23+
['ViewMode', 'compact' as ViewMode],
2224
['DigitGroup', '3' as DigitGroup],
2325
['ShowAccountName', 'always' as ShowAccountName],
2426
['ItemSortOrder', 'custom' as ItemSortOrder],

entry/src/main/ets/pages/Index.ets

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ import { unifiedDataChannel } from '@kit.ArkData';
3535
import { pasteboard } from '@kit.BasicServicesKit';
3636
import { AuthTypePriority, DigitGroup, ItemSortOrder,
3737
PasswordReminderPeriod,
38-
ShowAccountName } from '../common/settings';
38+
ShowAccountName,
39+
ViewMode} from '../common/settings';
3940
import { IconManager } from '../common/icons';
4041
import { IssuerIcon } from '../components/icons';
4142
import { decodeOtpauthMigrationLink } from '../crypto/googleAuth';
@@ -48,6 +49,28 @@ import { DummyOTPItemInfo } from '../common/dummies';
4849
const REFRESH_INTERVAL = 100;//ms
4950
const storage = LocalStorage.getShared();
5051

52+
interface OTPItemUISpec {
53+
itemHeight: number,
54+
iconSize: number,
55+
}
56+
const CompactItemUISpec: OTPItemUISpec = {
57+
itemHeight: 64,
58+
iconSize: 48,
59+
};
60+
const NormalItemUISpec: OTPItemUISpec = {
61+
itemHeight: 96,
62+
iconSize: 64,
63+
};
64+
const LargeItemUISpec: OTPItemUISpec = {
65+
itemHeight: 128,
66+
iconSize: 64,
67+
};
68+
const OTPItemUIOptions: Map<ViewMode, OTPItemUISpec> = new Map([
69+
['compact', CompactItemUISpec],
70+
['normal', NormalItemUISpec],
71+
['large', LargeItemUISpec],
72+
]);
73+
5174
class EditState {
5275
public editPageShow: boolean = false;
5376
public editKeyAlias: string = '';
@@ -713,6 +736,7 @@ struct OTPItem {
713736
@StorageProp('settingsPreviewNextToken') PreviewNextToken: boolean = false;
714737
@StorageProp('settingsItemSortOrder') ItemSortOrder: ItemSortOrder = 'custom';
715738
@StorageProp('settingsEnableDoubleClickCopy') EnableDoubleClickCopy: boolean = false;
739+
@StorageProp('settingsViewMode') ViewMode: ViewMode = 'compact';
716740
@StorageProp('settingsDigitGroup') DigitGroup: DigitGroup = '3';
717741
@StorageProp('settingsShowAccountName') ShowAccountName: ShowAccountName = 'always';
718742
@StorageProp('settingsShowIssuerIcons') ShowIssuerIcons: boolean = true;

entry/src/main/ets/pages/SettingsPage.ets

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import { SettingListItemInfo, SettingListItem, SettingListItemToggle,
66
SettingListIconItem} from "../components/settings";
77
import { AppLanguage, AuthTypePriority, DarkMode, DigitGroup,
88
PasswordReminderPeriod,
9-
ShowAccountName, ValueType } from "../common/settings";
9+
ShowAccountName, ValueType,
10+
ViewMode } from "../common/settings";
1011
import {
1112
ChangePasswordInputDialog,
1213
CustomSelectDialog, NewPasswordInputDialog, PasswordInputDialog } from "../components/dialog";
@@ -38,6 +39,12 @@ const DarkModeSelections: Map<ResourceStr, DarkMode> = new Map([
3839
[$r('app.string.setting_dark_mode_always_light'), 'light'],
3940
]);
4041

42+
const ViewModeSelections: Map<ResourceStr, ViewMode> = new Map([
43+
[$r('app.string.setting_view_mode_compact'), 'compact'],
44+
[$r('app.string.setting_view_mode_normal'), 'normal'],
45+
[$r('app.string.setting_view_mode_large'), 'large'],
46+
]);
47+
4148
const AppLanguageSelections: Map<ResourceStr, AppLanguage> = new Map<ResourceStr, AppLanguage>([
4249
[$r('app.string.setting_language_system_default'), 'default'],
4350
['简体中文 ', 'zh-Hans'],
@@ -104,6 +111,8 @@ export struct SettingsPage {
104111
@Watch('onItChanged') AppLanguage: AppLanguage = 'default';
105112
@StorageProp('settingsDarkMode')
106113
@Watch('onItChanged') DarkMode: DarkMode = 'default';
114+
@StorageProp('settingsViewMode')
115+
@Watch('onItChanged') ViewMode: ViewMode = 'compact';
107116
@StorageProp('settingsDigitGroup')
108117
@Watch('onItChanged') DigitGroup: DigitGroup = '3';
109118
@StorageProp('settingsShowAccountName')
@@ -245,6 +254,11 @@ export struct SettingsPage {
245254
selected: this.DarkMode,
246255
entries: DarkModeSelections
247256
})
257+
SettingListItemSelect({
258+
title: $r('app.string.setting_view_mode_title'),
259+
selected: this.ViewMode,
260+
entries: ViewModeSelections,
261+
})
248262
SettingListItemSelect({
249263
title: $r('app.string.setting_digit_group_title'),
250264
selected: this.DigitGroup,
@@ -453,6 +467,9 @@ export struct SettingsPage {
453467
case 'DarkMode':
454468
value = this.DarkMode;
455469
break;
470+
case 'ViewMode':
471+
value = this.ViewMode;
472+
break;
456473
case 'DigitGroup':
457474
value = this.DigitGroup;
458475
break;

entry/src/main/resources/base/element/settings.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,22 @@
6262
"name": "setting_dark_mode_always_light",
6363
"value": "Always Light Mode"
6464
},
65+
{
66+
"name": "setting_view_mode_title",
67+
"value": "View Mode"
68+
},
69+
{
70+
"name": "setting_view_mode_compact",
71+
"value": "Compact"
72+
},
73+
{
74+
"name": "setting_view_mode_normal",
75+
"value": "Normal"
76+
},
77+
{
78+
"name": "setting_view_mode_large",
79+
"value": "Large"
80+
},
6581
{
6682
"name": "setting_language",
6783
"value": "Language"

entry/src/main/resources/en_US/element/settings.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,22 @@
6262
"name": "setting_dark_mode_always_light",
6363
"value": "Always Light "
6464
},
65+
{
66+
"name": "setting_view_mode_title",
67+
"value": "View Mode"
68+
},
69+
{
70+
"name": "setting_view_mode_compact",
71+
"value": "Compact "
72+
},
73+
{
74+
"name": "setting_view_mode_normal",
75+
"value": "Normal "
76+
},
77+
{
78+
"name": "setting_view_mode_large",
79+
"value": "Large "
80+
},
6581
{
6682
"name": "setting_language",
6783
"value": "Language"

entry/src/main/resources/zh_CN/element/settings.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,22 @@
6262
"name": "setting_dark_mode_always_light",
6363
"value": "始终浅色模式 "
6464
},
65+
{
66+
"name": "setting_view_mode_title",
67+
"value": "视图模式"
68+
},
69+
{
70+
"name": "setting_view_mode_compact",
71+
"value": "紧凑模式 "
72+
},
73+
{
74+
"name": "setting_view_mode_normal",
75+
"value": "标准模式 "
76+
},
77+
{
78+
"name": "setting_view_mode_large",
79+
"value": "宽松模式 "
80+
},
6581
{
6682
"name": "setting_language",
6783
"value": "语言"

0 commit comments

Comments
 (0)