create-ern-boilerplate 0.0.33 → 0.0.34

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ern-boilerplate",
3
- "version": "0.0.33",
3
+ "version": "0.0.34",
4
4
  "description": "Expo React Native boilerplate generator",
5
5
  "bin": {
6
6
  "create-ern-boilerplate": "./create.js",
@@ -1,12 +1,23 @@
1
- import { useState, useEffect, useContext, createContext } from "react";
2
- import { AuthContext } from '@contexts/AuthContext';
1
+ import { useAuthStore } from '@/store/authStore';
3
2
 
3
+ /**
4
+ * Hook for accessing authentication state and actions
5
+ * Uses Zustand store for global state management
6
+ */
4
7
  export function useAuth() {
5
- const context = useContext(AuthContext);
6
-
7
- if (!context) {
8
- throw new Error('useAuth must be used within an AuthProvider');
9
- }
10
-
11
- return context;
8
+ const user = useAuthStore((state) => state.user);
9
+ const isAuthenticated = useAuthStore((state) => state.isAuthenticated);
10
+ const isLoading = useAuthStore((state) => state.isLoading);
11
+ const login = useAuthStore((state) => state.login);
12
+ const logout = useAuthStore((state) => state.logout);
13
+ const checkAuth = useAuthStore((state) => state.checkAuth);
14
+
15
+ return {
16
+ user,
17
+ isAuthenticated,
18
+ isLoading,
19
+ login,
20
+ logout,
21
+ checkAuth,
22
+ };
12
23
  }
@@ -1,12 +1,18 @@
1
- import { useContext } from 'react';
2
- import { ThemeContext } from '@contexts/ThemeContext';
1
+ import { useThemeStore } from '@/store/themeStore';
3
2
 
3
+ /**
4
+ * Hook for accessing theme state and actions
5
+ * Uses Zustand store for global state management
6
+ */
4
7
  export function useTheme() {
5
- const context = useContext(ThemeContext);
6
-
7
- if (!context) {
8
- throw new Error('useTheme must be used within a ThemeProvider');
9
- }
10
-
11
- return context;
8
+ const colorScheme = useThemeStore((state) => state.colorScheme);
9
+ const setColorScheme = useThemeStore((state) => state.setColorScheme);
10
+ const toggleColorScheme = useThemeStore((state) => state.toggleColorScheme);
11
+
12
+ return {
13
+ colorScheme,
14
+ setColorScheme,
15
+ toggleColorScheme,
16
+ isDark: colorScheme === 'dark',
17
+ };
12
18
  }
@@ -8,13 +8,19 @@ interface ThemeState {
8
8
  colorScheme: ColorSchemeName;
9
9
  setThemeMode: (mode: ThemeMode) => void;
10
10
  setColorScheme: (scheme: ColorSchemeName) => void;
11
+ toggleColorScheme: () => void;
11
12
  }
12
13
 
13
- export const useThemeStore = create<ThemeState>((set) => ({
14
+ export const useThemeStore = create<ThemeState>((set, get) => ({
14
15
  mode: 'auto',
15
16
  colorScheme: 'light',
16
17
 
17
18
  setThemeMode: (mode) => set({ mode }),
18
19
 
19
20
  setColorScheme: (scheme) => set({ colorScheme: scheme }),
21
+
22
+ toggleColorScheme: () => {
23
+ const currentScheme = get().colorScheme;
24
+ set({ colorScheme: currentScheme === 'dark' ? 'light' : 'dark' });
25
+ },
20
26
  }));