feat(features): auth, accounts, home, repositories, issues, notifications
- auth: welcome/connect screens, shared connect form, connect flow, app lock - accounts: session hook, actions, switcher + add-account screens - home: dashboard (identity, shortcuts, recent repos, assigned issues, review requests, activity, unread badge) - repositories/repository: list+search, overview, files, file viewer, commits, commit detail, branches, tags, repo issues/pulls, issue/pull detail - issues/notifications: cross-repo search, query hooks, inbox with read marking and lifecycle-aware polling - settings: theme/language/biometrics/poll interval/cache/about
This commit is contained in:
1 parent
ad81db07b3
commit
0a889ebfed
36 files changed
+4186
No files matched your search
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Client-side settings (non-sensitive, persisted to AsyncStorage).
|
||||
*
|
||||
* Secrets never live here — tokens are stored via Expo SecureStore only.
|
||||
*/
|
||||
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
import { create } from 'zustand';
|
||||
import { createJSONStorage, persist } from 'zustand/middleware';
|
||||
|
||||
import type { LanguagePreference } from '@/i18n';
|
||||
|
||||
export type ThemePreference = 'system' | 'light' | 'dark';
|
||||
|
||||
export interface SettingsState {
|
||||
themePreference: ThemePreference;
|
||||
/** UI language; 'system' follows the device locale. */
|
||||
language: LanguagePreference;
|
||||
/** Require biometrics (Face ID / fingerprint) when the app becomes active again. */
|
||||
biometricsEnabled: boolean;
|
||||
/** Background polling interval for the notifications inbox, in seconds. 0 = only manual/foreground refresh. */
|
||||
notificationPollSeconds: number;
|
||||
setThemePreference: (preference: ThemePreference) => void;
|
||||
setLanguage: (language: LanguagePreference) => void;
|
||||
setBiometricsEnabled: (enabled: boolean) => void;
|
||||
setNotificationPollSeconds: (seconds: number) => void;
|
||||
}
|
||||
|
||||
export const useSettingsStore = create<SettingsState>()(
|
||||
persist(
|
||||
(set) => ({
|
||||
themePreference: 'system',
|
||||
language: 'system',
|
||||
biometricsEnabled: false,
|
||||
notificationPollSeconds: 60,
|
||||
setThemePreference: (themePreference) => set({ themePreference }),
|
||||
setLanguage: (language) => set({ language }),
|
||||
setBiometricsEnabled: (biometricsEnabled) => set({ biometricsEnabled }),
|
||||
setNotificationPollSeconds: (notificationPollSeconds) => set({ notificationPollSeconds }),
|
||||
}),
|
||||
{
|
||||
name: 'gitea-native:settings:v1',
|
||||
storage: createJSONStorage(() => AsyncStorage),
|
||||
partialize: (state) => ({
|
||||
themePreference: state.themePreference,
|
||||
language: state.language,
|
||||
biometricsEnabled: state.biometricsEnabled,
|
||||
notificationPollSeconds: state.notificationPollSeconds,
|
||||
}),
|
||||
},
|
||||
),
|
||||
);
|
||||
Reference in new issue
Block a user