@croacroa/react-native-template 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +187 -184
- package/.github/workflows/eas-build.yml +55 -55
- package/.github/workflows/eas-update.yml +50 -50
- package/CHANGELOG.md +106 -106
- package/CONTRIBUTING.md +377 -377
- package/README.md +399 -399
- package/__tests__/components/snapshots.test.tsx +131 -0
- package/__tests__/integration/auth-api.test.tsx +227 -0
- package/__tests__/performance/VirtualizedList.perf.test.tsx +362 -0
- package/app/(public)/onboarding.tsx +5 -5
- package/app.config.ts +45 -2
- package/assets/images/.gitkeep +7 -7
- package/components/onboarding/OnboardingScreen.tsx +370 -370
- package/components/onboarding/index.ts +2 -2
- package/components/providers/SuspenseBoundary.tsx +357 -0
- package/components/providers/index.ts +13 -0
- package/components/ui/Avatar.tsx +316 -316
- package/components/ui/Badge.tsx +416 -416
- package/components/ui/BottomSheet.tsx +307 -307
- package/components/ui/Checkbox.tsx +261 -261
- package/components/ui/OptimizedImage.tsx +369 -369
- package/components/ui/Select.tsx +240 -240
- package/components/ui/VirtualizedList.tsx +285 -0
- package/components/ui/index.ts +23 -18
- package/constants/config.ts +97 -54
- package/docs/adr/001-state-management.md +79 -79
- package/docs/adr/002-styling-approach.md +130 -130
- package/docs/adr/003-data-fetching.md +155 -155
- package/docs/adr/004-auth-adapter-pattern.md +144 -144
- package/docs/adr/README.md +78 -78
- package/hooks/index.ts +27 -25
- package/hooks/useApi.ts +102 -5
- package/hooks/useAuth.tsx +82 -0
- package/hooks/useBiometrics.ts +295 -295
- package/hooks/useDeepLinking.ts +256 -256
- package/hooks/useMFA.ts +499 -0
- package/hooks/useNotifications.ts +39 -0
- package/hooks/useOffline.ts +32 -2
- package/hooks/usePerformance.ts +434 -434
- package/hooks/useTheme.tsx +76 -0
- package/hooks/useUpdates.ts +358 -358
- package/i18n/index.ts +194 -77
- package/i18n/locales/ar.json +101 -0
- package/i18n/locales/de.json +101 -0
- package/i18n/locales/en.json +101 -101
- package/i18n/locales/es.json +101 -0
- package/i18n/locales/fr.json +101 -101
- package/jest.config.js +4 -4
- package/maestro/README.md +113 -113
- package/maestro/config.yaml +35 -35
- package/maestro/flows/login.yaml +62 -62
- package/maestro/flows/mfa-login.yaml +92 -0
- package/maestro/flows/mfa-setup.yaml +86 -0
- package/maestro/flows/navigation.yaml +68 -68
- package/maestro/flows/offline-conflict.yaml +101 -0
- package/maestro/flows/offline-sync.yaml +128 -0
- package/maestro/flows/offline.yaml +60 -60
- package/maestro/flows/register.yaml +94 -94
- package/package.json +175 -170
- package/services/analytics.ts +428 -428
- package/services/api.ts +340 -340
- package/services/authAdapter.ts +333 -333
- package/services/backgroundSync.ts +626 -0
- package/services/index.ts +54 -22
- package/services/security.ts +229 -0
- package/tailwind.config.js +47 -47
- package/utils/accessibility.ts +446 -446
- package/utils/index.ts +52 -43
- package/utils/withAccessibility.tsx +272 -0
package/hooks/useTheme.tsx
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Theme management with light/dark mode support
|
|
3
|
+
* Provides context and hooks for managing app theme with system preference detection.
|
|
4
|
+
* @module hooks/useTheme
|
|
5
|
+
*/
|
|
6
|
+
|
|
1
7
|
import {
|
|
2
8
|
createContext,
|
|
3
9
|
useContext,
|
|
@@ -8,13 +14,27 @@ import {
|
|
|
8
14
|
import { useColorScheme } from "react-native";
|
|
9
15
|
import AsyncStorage from "@react-native-async-storage/async-storage";
|
|
10
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Theme mode options
|
|
19
|
+
* - 'light': Force light theme
|
|
20
|
+
* - 'dark': Force dark theme
|
|
21
|
+
* - 'system': Follow device system preference
|
|
22
|
+
*/
|
|
11
23
|
type ThemeMode = "light" | "dark" | "system";
|
|
12
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Theme context type definition
|
|
27
|
+
*/
|
|
13
28
|
interface ThemeContextType {
|
|
29
|
+
/** Current theme mode setting ('light', 'dark', or 'system') */
|
|
14
30
|
mode: ThemeMode;
|
|
31
|
+
/** Whether the current effective theme is dark */
|
|
15
32
|
isDark: boolean;
|
|
33
|
+
/** Whether the theme has been loaded from storage */
|
|
16
34
|
isLoaded: boolean;
|
|
35
|
+
/** Set the theme mode and persist to storage */
|
|
17
36
|
setMode: (mode: ThemeMode) => void;
|
|
37
|
+
/** Toggle between light and dark mode */
|
|
18
38
|
toggleTheme: () => void;
|
|
19
39
|
}
|
|
20
40
|
|
|
@@ -22,6 +42,29 @@ const ThemeContext = createContext<ThemeContextType | undefined>(undefined);
|
|
|
22
42
|
|
|
23
43
|
const THEME_KEY = "theme_mode";
|
|
24
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Theme Provider component.
|
|
47
|
+
* Wraps your app to provide theme context with persistent preferences.
|
|
48
|
+
*
|
|
49
|
+
* Features:
|
|
50
|
+
* - System theme detection
|
|
51
|
+
* - Persistent theme preference
|
|
52
|
+
* - Real-time system theme updates
|
|
53
|
+
*
|
|
54
|
+
* @param children - Child components to wrap
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```tsx
|
|
58
|
+
* // In your app root
|
|
59
|
+
* export default function RootLayout() {
|
|
60
|
+
* return (
|
|
61
|
+
* <ThemeProvider>
|
|
62
|
+
* <App />
|
|
63
|
+
* </ThemeProvider>
|
|
64
|
+
* );
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
25
68
|
export function ThemeProvider({ children }: { children: ReactNode }) {
|
|
26
69
|
const systemColorScheme = useColorScheme();
|
|
27
70
|
const [mode, setModeState] = useState<ThemeMode>("system");
|
|
@@ -76,6 +119,39 @@ export function ThemeProvider({ children }: { children: ReactNode }) {
|
|
|
76
119
|
);
|
|
77
120
|
}
|
|
78
121
|
|
|
122
|
+
/**
|
|
123
|
+
* Hook to access theme state and controls.
|
|
124
|
+
* Must be used within a ThemeProvider.
|
|
125
|
+
*
|
|
126
|
+
* @returns Theme context with mode, isDark flag, and control functions
|
|
127
|
+
* @throws Error if used outside of ThemeProvider
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```tsx
|
|
131
|
+
* function SettingsScreen() {
|
|
132
|
+
* const { mode, isDark, setMode, toggleTheme } = useTheme();
|
|
133
|
+
*
|
|
134
|
+
* return (
|
|
135
|
+
* <View>
|
|
136
|
+
* <Text>Current mode: {mode}</Text>
|
|
137
|
+
* <Text>Is dark: {isDark ? 'Yes' : 'No'}</Text>
|
|
138
|
+
*
|
|
139
|
+
* <Button onPress={toggleTheme}>Toggle Theme</Button>
|
|
140
|
+
*
|
|
141
|
+
* <Select
|
|
142
|
+
* value={mode}
|
|
143
|
+
* onValueChange={setMode}
|
|
144
|
+
* options={[
|
|
145
|
+
* { label: 'Light', value: 'light' },
|
|
146
|
+
* { label: 'Dark', value: 'dark' },
|
|
147
|
+
* { label: 'System', value: 'system' },
|
|
148
|
+
* ]}
|
|
149
|
+
* />
|
|
150
|
+
* </View>
|
|
151
|
+
* );
|
|
152
|
+
* }
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
79
155
|
export function useTheme() {
|
|
80
156
|
const context = useContext(ThemeContext);
|
|
81
157
|
if (context === undefined) {
|