@reown/appkit-react-native 0.0.0-chore-qr-borders-20251104183806 → 0.0.0-chore-use-theme-hook-20251105184714

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.
@@ -65,6 +65,7 @@ function useAccount() {
65
65
  networks
66
66
  } = (0, _valtio.useSnapshot)(_appkitCoreReactNative.ConnectionsController.state);
67
67
  const allAccounts = (0, _react.useMemo)(() => {
68
+ if (!address) return [];
68
69
  return Array.from(connections.values()).flatMap(_connection => _connection.accounts.map(account => {
69
70
  const [namespace, chainId, plainAddress] = account.split(':');
70
71
  if (!plainAddress || !namespace || !chainId) {
@@ -80,7 +81,7 @@ function useAccount() {
80
81
  type: _connection.type
81
82
  };
82
83
  }).filter(account => account !== undefined));
83
- }, [connections]);
84
+ }, [connections, address]);
84
85
  const activeChain = (0, _react.useMemo)(() => connection?.caipNetwork ? networks.find(network => network.caipNetworkId === connection?.caipNetwork) : undefined, [connection?.caipNetwork, networks]);
85
86
  return {
86
87
  allAccounts,
@@ -1 +1 @@
1
- {"version":3,"names":["_appkitCoreReactNative","require","_react","_valtio","_useAppKit","useAccount","useAppKit","activeAddress","address","activeNamespace","connection","connections","networks","useSnapshot","ConnectionsController","state","allAccounts","useMemo","Array","from","values","flatMap","_connection","accounts","map","account","namespace","chainId","plainAddress","split","LogController","sendError","undefined","type","filter","activeChain","caipNetwork","find","network","caipNetworkId","CoreHelperUtil","getPlainAddress","isConnected","id","String","chain"],"sourceRoot":"../../../src","sources":["hooks/useAccount.ts"],"mappings":";;;;;;AACA,IAAAA,sBAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AARA;;AAWA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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AACtB,UAAU,EAAE0B,WAAW,EAAExB,QAAQ,CACpC,CAAC;EAED,OAAO;IACLI,WAAW;IACXR,OAAO,EAAEgC,qCAAc,CAACC,eAAe,CAACjC,OAAO,CAAC;IAChDkC,WAAW,EAAE,CAAC,CAAClC,OAAO;IACtBmB,OAAO,EAAEQ,WAAW,EAAEQ,EAAE,KAAKX,SAAS,GAAGY,MAAM,CAACT,WAAW,CAACQ,EAAE,CAAC,GAAGX,SAAS;IAC3Ea,KAAK,EAAEV,WAAwC;IAC/CT,SAAS,EAAEjB;EACb,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["_appkitCoreReactNative","require","_react","_valtio","_useAppKit","useAccount","useAppKit","activeAddress","address","activeNamespace","connection","connections","networks","useSnapshot","ConnectionsController","state","allAccounts","useMemo","Array","from","values","flatMap","_connection","accounts","map","account","namespace","chainId","plainAddress","split","LogController","sendError","undefined","type","filter","activeChain","caipNetwork","find","network","caipNetworkId","CoreHelperUtil","getPlainAddress","isConnected","id","String","chain"],"sourceRoot":"../../../src","sources":["hooks/useAccount.ts"],"mappings":";;;;;;AACA,IAAAA,sBAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AARA;;AAWA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,UAAUA,CAAA,EAAG;EAC3B,IAAAC,oBAAS,EAAC,CAAC,CAAC,CAAC;;EAEb,MAAM;IACJC,aAAa,EAAEC,OAAO;IACtBC,eAAe;IACfC,UAAU;IACVC,WAAW;IACXC;EACF,CAAC,GAAG,IAAAC,mBAAW,EAACC,4CAAqB,CA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AGY,MAAM,CAACT,WAAW,CAACQ,EAAE,CAAC,GAAGX,SAAS;IAC3Ea,KAAK,EAAEV,WAAwC;IAC/CT,SAAS,EAAEjB;EACb,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useAppKitTheme = useAppKitTheme;
7
+ var _react = require("react");
8
+ var _valtio = require("valtio");
9
+ var _appkitCoreReactNative = require("@reown/appkit-core-react-native");
10
+ var _useAppKit = require("./useAppKit");
11
+ /**
12
+ * Interface representing the result of the useAppKitTheme hook
13
+ */
14
+
15
+ /**
16
+ * Hook to control the visual appearance of the AppKit modal
17
+ *
18
+ * @remarks
19
+ * This hook provides access to the theme mode and theme variables, allowing you to
20
+ * customize the modal's appearance. Use this hook when you need to implement dark/light
21
+ * mode or match the modal's appearance with your application's theme.
22
+ *
23
+ * Currently, the only supported theme variable is `accent`, which controls the primary
24
+ * accent color used throughout the modal interface.
25
+ *
26
+ * @returns {UseAppKitThemeReturn} An object containing:
27
+ * - `themeMode`: The current theme mode ('dark' or 'light')
28
+ * - `themeVariables`: The current theme variables (only 'accent' is supported)
29
+ * - `setThemeMode`: Function to change the theme mode
30
+ * - `setThemeVariables`: Function to update theme variables
31
+ *
32
+ * @throws {Error} If used outside of an AppKitProvider
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * import { useAppKitTheme } from '@reown/appkit-react-native';
37
+ *
38
+ * function MyComponent() {
39
+ * const { themeMode, themeVariables, setThemeMode, setThemeVariables } = useAppKitTheme();
40
+ *
41
+ * // Set theme to dark mode
42
+ * setThemeMode('dark');
43
+ *
44
+ * // Customize the accent color
45
+ * setThemeVariables({
46
+ * accent: '#00BB7F'
47
+ * });
48
+ *
49
+ * return (
50
+ * <View>
51
+ * <Text>Current theme: {themeMode}</Text>
52
+ * <Text>Accent color: {themeVariables?.accent}</Text>
53
+ * </View>
54
+ * );
55
+ * }
56
+ * ```
57
+ */
58
+ function useAppKitTheme() {
59
+ (0, _useAppKit.useAppKit)(); // Use the hook for checks
60
+ const {
61
+ themeMode,
62
+ themeVariables
63
+ } = (0, _valtio.useSnapshot)(_appkitCoreReactNative.ThemeController.state);
64
+ const stableFunctions = (0, _react.useMemo)(() => ({
65
+ setThemeMode: _appkitCoreReactNative.ThemeController.setThemeMode.bind(_appkitCoreReactNative.ThemeController),
66
+ setThemeVariables: _appkitCoreReactNative.ThemeController.setThemeVariables.bind(_appkitCoreReactNative.ThemeController)
67
+ }), []);
68
+ return {
69
+ themeMode,
70
+ themeVariables,
71
+ ...stableFunctions
72
+ };
73
+ }
74
+ //# sourceMappingURL=useAppKitTheme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_valtio","_appkitCoreReactNative","_useAppKit","useAppKitTheme","useAppKit","themeMode","themeVariables","useSnapshot","ThemeController","state","stableFunctions","useMemo","setThemeMode","bind","setThemeVariables"],"sourceRoot":"../../../src","sources":["hooks/useAppKitTheme.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,sBAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAEA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,cAAcA,CAAA,EAAyB;EACrD,IAAAC,oBAAS,EAAC,CAAC,CAAC,CAAC;EACb,MAAM;IAAEC,SAAS;IAAEC;EAAe,CAAC,GAAG,IAAAC,mBAAW,EAACC,sCAAe,CAACC,KAAK,CAAC;EAExE,MAAMC,eAAe,GAAG,IAAAC,cAAO,EAC7B,OAAO;IACLC,YAAY,EAAEJ,sCAAe,CAACI,YAAY,CAACC,IAAI,CAACL,sCAAe,CAAC;IAChEM,iBAAiB,EAAEN,sCAAe,CAACM,iBAAiB,CAACD,IAAI,CAACL,sCAAe;EAC3E,CAAC,CAAC,EACF,EACF,CAAC;EAED,OAAO;IACLH,SAAS;IACTC,cAAc;IACd,GAAGI;EACL,CAAC;AACH","ignoreList":[]}
@@ -61,6 +61,7 @@ export function useAccount() {
61
61
  networks
62
62
  } = useSnapshot(ConnectionsController.state);
63
63
  const allAccounts = useMemo(() => {
64
+ if (!address) return [];
64
65
  return Array.from(connections.values()).flatMap(_connection => _connection.accounts.map(account => {
65
66
  const [namespace, chainId, plainAddress] = account.split(':');
66
67
  if (!plainAddress || !namespace || !chainId) {
@@ -76,7 +77,7 @@ export function useAccount() {
76
77
  type: _connection.type
77
78
  };
78
79
  }).filter(account => account !== undefined));
79
- }, [connections]);
80
+ }, [connections, address]);
80
81
  const activeChain = useMemo(() => connection?.caipNetwork ? networks.find(network => network.caipNetworkId === connection?.caipNetwork) : undefined, [connection?.caipNetwork, networks]);
81
82
  return {
82
83
  allAccounts,
@@ -1 +1 @@
1
- {"version":3,"names":["ConnectionsController","CoreHelperUtil","LogController","useMemo","useSnapshot","useAppKit","useAccount","activeAddress","address","activeNamespace","connection","connections","networks","state","allAccounts","Array","from","values","flatMap","_connection","accounts","map","account","namespace","chainId","plainAddress","split","sendError","undefined","type","filter","activeChain","caipNetwork","find","network","caipNetworkId","getPlainAddress","isConnected","id","String","chain"],"sourceRoot":"../../../src","sources":["hooks/useAccount.ts"],"mappings":";;AAAA;AACA,SACEA,qBAAqB,EACrBC,cAAc,EACdC,aAAa,QACR,iCAAiC;AACxC,SAASC,OAAO,QAAQ,OAAO;AAC/B,SAASC,WAAW,QAAQ,QAAQ;AACpC,SAASC,SAAS,QAAQ,aAAa;;AAGvC;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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C3EJ,SAAS,EACf,CAAClB,UAAU,EAAEsB,WAAW,EAAEpB,QAAQ,CACpC,CAAC;EAED,OAAO;IACLE,WAAW;IACXN,OAAO,EAAEP,cAAc,CAACmC,eAAe,CAAC5B,OAAO,CAAC;IAChD6B,WAAW,EAAE,CAAC,CAAC7B,OAAO;IACtBgB,OAAO,EAAEO,WAAW,EAAEO,EAAE,KAAKV,SAAS,GAAGW,MAAM,CAACR,WAAW,CAACO,EAAE,CAAC,GAAGV,SAAS;IAC3EY,KAAK,EAAET,WAAwC;IAC/CR,SAAS,EAAEd;EACb,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["ConnectionsController","CoreHelperUtil","LogController","useMemo","useSnapshot","useAppKit","useAccount","activeAddress","address","activeNamespace","connection","connections","networks","state","allAccounts","Array","from","values","flatMap","_connection","accounts","map","account","namespace","chainId","plainAddress","split","sendError","undefined","type","filter","activeChain","caipNetwork","find","network","caipNetworkId","getPlainAddress","isConnected","id","String","chain"],"sourceRoot":"../../../src","sources":["hooks/useAccount.ts"],"mappings":";;AAAA;AACA,SACEA,qBAAqB,EACrBC,cAAc,EACdC,aAAa,QACR,iCAAiC;AACxC,SAASC,OAAO,QAAQ,OAAO;AAC/B,SAASC,WAAW,QAAQ,QAAQ;AACpC,SAASC,SAAS,QAAQ,aAAa;;AAGvC;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAAA,EAAG;EAC3BD,SAAS,CAAC,CAAC,CAAC,CAAC;;EAEb,MAAM;IACJE,aAAa,EAAEC,OAAO;IACtBC,eAAe;IACfC,UAAU;IACVC,WAAW;IACXC;EACF,CAAC,GAAGR,WAAW,CAACJ,qBAAqB,CAACa,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R,WAAW,CAACO,EAAE,CAAC,GAAGV,SAAS;IAC3EY,KAAK,EAAET,WAAwC;IAC/CR,SAAS,EAAEd;EACb,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ import { useMemo } from 'react';
4
+ import { useSnapshot } from 'valtio';
5
+ import { ThemeController } from '@reown/appkit-core-react-native';
6
+ import { useAppKit } from './useAppKit';
7
+
8
+ /**
9
+ * Interface representing the result of the useAppKitTheme hook
10
+ */
11
+
12
+ /**
13
+ * Hook to control the visual appearance of the AppKit modal
14
+ *
15
+ * @remarks
16
+ * This hook provides access to the theme mode and theme variables, allowing you to
17
+ * customize the modal's appearance. Use this hook when you need to implement dark/light
18
+ * mode or match the modal's appearance with your application's theme.
19
+ *
20
+ * Currently, the only supported theme variable is `accent`, which controls the primary
21
+ * accent color used throughout the modal interface.
22
+ *
23
+ * @returns {UseAppKitThemeReturn} An object containing:
24
+ * - `themeMode`: The current theme mode ('dark' or 'light')
25
+ * - `themeVariables`: The current theme variables (only 'accent' is supported)
26
+ * - `setThemeMode`: Function to change the theme mode
27
+ * - `setThemeVariables`: Function to update theme variables
28
+ *
29
+ * @throws {Error} If used outside of an AppKitProvider
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * import { useAppKitTheme } from '@reown/appkit-react-native';
34
+ *
35
+ * function MyComponent() {
36
+ * const { themeMode, themeVariables, setThemeMode, setThemeVariables } = useAppKitTheme();
37
+ *
38
+ * // Set theme to dark mode
39
+ * setThemeMode('dark');
40
+ *
41
+ * // Customize the accent color
42
+ * setThemeVariables({
43
+ * accent: '#00BB7F'
44
+ * });
45
+ *
46
+ * return (
47
+ * <View>
48
+ * <Text>Current theme: {themeMode}</Text>
49
+ * <Text>Accent color: {themeVariables?.accent}</Text>
50
+ * </View>
51
+ * );
52
+ * }
53
+ * ```
54
+ */
55
+ export function useAppKitTheme() {
56
+ useAppKit(); // Use the hook for checks
57
+ const {
58
+ themeMode,
59
+ themeVariables
60
+ } = useSnapshot(ThemeController.state);
61
+ const stableFunctions = useMemo(() => ({
62
+ setThemeMode: ThemeController.setThemeMode.bind(ThemeController),
63
+ setThemeVariables: ThemeController.setThemeVariables.bind(ThemeController)
64
+ }), []);
65
+ return {
66
+ themeMode,
67
+ themeVariables,
68
+ ...stableFunctions
69
+ };
70
+ }
71
+ //# sourceMappingURL=useAppKitTheme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useMemo","useSnapshot","ThemeController","useAppKit","useAppKitTheme","themeMode","themeVariables","state","stableFunctions","setThemeMode","bind","setThemeVariables"],"sourceRoot":"../../../src","sources":["hooks/useAppKitTheme.ts"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,WAAW,QAAQ,QAAQ;AAEpC,SAASC,eAAe,QAAQ,iCAAiC;AACjE,SAASC,SAAS,QAAQ,aAAa;;AAEvC;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAAA,EAAyB;EACrDD,SAAS,CAAC,CAAC,CAAC,CAAC;EACb,MAAM;IAAEE,SAAS;IAAEC;EAAe,CAAC,GAAGL,WAAW,CAACC,eAAe,CAACK,KAAK,CAAC;EAExE,MAAMC,eAAe,GAAGR,OAAO,CAC7B,OAAO;IACLS,YAAY,EAAEP,eAAe,CAACO,YAAY,CAACC,IAAI,CAACR,eAAe,CAAC;IAChES,iBAAiB,EAAET,eAAe,CAACS,iBAAiB,CAACD,IAAI,CAACR,eAAe;EAC3E,CAAC,CAAC,EACF,EACF,CAAC;EAED,OAAO;IACLG,SAAS;IACTC,cAAc;IACd,GAAGE;EACL,CAAC;AACH","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"useAccount.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAccount.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAEpF;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,kFAAkF;IAClF,SAAS,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,UAAU;;;;;;;EAoDzB"}
1
+ {"version":3,"file":"useAccount.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAccount.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAEpF;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,kFAAkF;IAClF,SAAS,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,UAAU;;;;;;;EAsDzB"}
@@ -0,0 +1,60 @@
1
+ import type { ThemeMode, ThemeVariables } from '@reown/appkit-common-react-native';
2
+ /**
3
+ * Interface representing the result of the useAppKitTheme hook
4
+ */
5
+ interface UseAppKitThemeReturn {
6
+ /** The current theme mode ('dark' or 'light'), or undefined if using system default */
7
+ themeMode: ThemeMode | undefined;
8
+ /** The current theme variables, currently only supports 'accent' color */
9
+ themeVariables: ThemeVariables | undefined;
10
+ /** Function to set the theme mode */
11
+ setThemeMode: (themeMode: ThemeMode | undefined) => void;
12
+ /** Function to set theme variables */
13
+ setThemeVariables: (themeVariables: ThemeVariables | undefined) => void;
14
+ }
15
+ /**
16
+ * Hook to control the visual appearance of the AppKit modal
17
+ *
18
+ * @remarks
19
+ * This hook provides access to the theme mode and theme variables, allowing you to
20
+ * customize the modal's appearance. Use this hook when you need to implement dark/light
21
+ * mode or match the modal's appearance with your application's theme.
22
+ *
23
+ * Currently, the only supported theme variable is `accent`, which controls the primary
24
+ * accent color used throughout the modal interface.
25
+ *
26
+ * @returns {UseAppKitThemeReturn} An object containing:
27
+ * - `themeMode`: The current theme mode ('dark' or 'light')
28
+ * - `themeVariables`: The current theme variables (only 'accent' is supported)
29
+ * - `setThemeMode`: Function to change the theme mode
30
+ * - `setThemeVariables`: Function to update theme variables
31
+ *
32
+ * @throws {Error} If used outside of an AppKitProvider
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * import { useAppKitTheme } from '@reown/appkit-react-native';
37
+ *
38
+ * function MyComponent() {
39
+ * const { themeMode, themeVariables, setThemeMode, setThemeVariables } = useAppKitTheme();
40
+ *
41
+ * // Set theme to dark mode
42
+ * setThemeMode('dark');
43
+ *
44
+ * // Customize the accent color
45
+ * setThemeVariables({
46
+ * accent: '#00BB7F'
47
+ * });
48
+ *
49
+ * return (
50
+ * <View>
51
+ * <Text>Current theme: {themeMode}</Text>
52
+ * <Text>Accent color: {themeVariables?.accent}</Text>
53
+ * </View>
54
+ * );
55
+ * }
56
+ * ```
57
+ */
58
+ export declare function useAppKitTheme(): UseAppKitThemeReturn;
59
+ export {};
60
+ //# sourceMappingURL=useAppKitTheme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAppKitTheme.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAppKitTheme.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAInF;;GAEG;AACH,UAAU,oBAAoB;IAC5B,uFAAuF;IACvF,SAAS,EAAE,SAAS,GAAG,SAAS,CAAC;IACjC,0EAA0E;IAC1E,cAAc,EAAE,cAAc,GAAG,SAAS,CAAC;IAC3C,qCAAqC;IACrC,YAAY,EAAE,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,KAAK,IAAI,CAAC;IACzD,sCAAsC;IACtC,iBAAiB,EAAE,CAAC,cAAc,EAAE,cAAc,GAAG,SAAS,KAAK,IAAI,CAAC;CACzE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,cAAc,IAAI,oBAAoB,CAiBrD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reown/appkit-react-native",
3
- "version": "0.0.0-chore-qr-borders-20251104183806",
3
+ "version": "0.0.0-chore-use-theme-hook-20251105184714",
4
4
  "main": "lib/commonjs/index.js",
5
5
  "types": "lib/typescript/index.d.ts",
6
6
  "module": "lib/module/index.js",
@@ -39,9 +39,9 @@
39
39
  "provenance": true
40
40
  },
41
41
  "dependencies": {
42
- "@reown/appkit-common-react-native": "0.0.0-chore-qr-borders-20251104183806",
43
- "@reown/appkit-core-react-native": "0.0.0-chore-qr-borders-20251104183806",
44
- "@reown/appkit-ui-react-native": "0.0.0-chore-qr-borders-20251104183806",
42
+ "@reown/appkit-common-react-native": "0.0.0-chore-use-theme-hook-20251105184714",
43
+ "@reown/appkit-core-react-native": "0.0.0-chore-use-theme-hook-20251105184714",
44
+ "@reown/appkit-ui-react-native": "0.0.0-chore-use-theme-hook-20251105184714",
45
45
  "@walletconnect/universal-provider": "2.21.10",
46
46
  "valtio": "2.1.8"
47
47
  },
@@ -75,6 +75,8 @@ export function useAccount() {
75
75
  } = useSnapshot(ConnectionsController.state);
76
76
 
77
77
  const allAccounts: Account[] = useMemo(() => {
78
+ if (!address) return [];
79
+
78
80
  return Array.from(connections.values()).flatMap(
79
81
  _connection =>
80
82
  _connection.accounts
@@ -97,7 +99,7 @@ export function useAccount() {
97
99
  })
98
100
  .filter(account => account !== undefined) as Account[]
99
101
  );
100
- }, [connections]);
102
+ }, [connections, address]);
101
103
 
102
104
  const activeChain = useMemo(
103
105
  () =>
@@ -0,0 +1,81 @@
1
+ import { useMemo } from 'react';
2
+ import { useSnapshot } from 'valtio';
3
+ import type { ThemeMode, ThemeVariables } from '@reown/appkit-common-react-native';
4
+ import { ThemeController } from '@reown/appkit-core-react-native';
5
+ import { useAppKit } from './useAppKit';
6
+
7
+ /**
8
+ * Interface representing the result of the useAppKitTheme hook
9
+ */
10
+ interface UseAppKitThemeReturn {
11
+ /** The current theme mode ('dark' or 'light'), or undefined if using system default */
12
+ themeMode: ThemeMode | undefined;
13
+ /** The current theme variables, currently only supports 'accent' color */
14
+ themeVariables: ThemeVariables | undefined;
15
+ /** Function to set the theme mode */
16
+ setThemeMode: (themeMode: ThemeMode | undefined) => void;
17
+ /** Function to set theme variables */
18
+ setThemeVariables: (themeVariables: ThemeVariables | undefined) => void;
19
+ }
20
+
21
+ /**
22
+ * Hook to control the visual appearance of the AppKit modal
23
+ *
24
+ * @remarks
25
+ * This hook provides access to the theme mode and theme variables, allowing you to
26
+ * customize the modal's appearance. Use this hook when you need to implement dark/light
27
+ * mode or match the modal's appearance with your application's theme.
28
+ *
29
+ * Currently, the only supported theme variable is `accent`, which controls the primary
30
+ * accent color used throughout the modal interface.
31
+ *
32
+ * @returns {UseAppKitThemeReturn} An object containing:
33
+ * - `themeMode`: The current theme mode ('dark' or 'light')
34
+ * - `themeVariables`: The current theme variables (only 'accent' is supported)
35
+ * - `setThemeMode`: Function to change the theme mode
36
+ * - `setThemeVariables`: Function to update theme variables
37
+ *
38
+ * @throws {Error} If used outside of an AppKitProvider
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * import { useAppKitTheme } from '@reown/appkit-react-native';
43
+ *
44
+ * function MyComponent() {
45
+ * const { themeMode, themeVariables, setThemeMode, setThemeVariables } = useAppKitTheme();
46
+ *
47
+ * // Set theme to dark mode
48
+ * setThemeMode('dark');
49
+ *
50
+ * // Customize the accent color
51
+ * setThemeVariables({
52
+ * accent: '#00BB7F'
53
+ * });
54
+ *
55
+ * return (
56
+ * <View>
57
+ * <Text>Current theme: {themeMode}</Text>
58
+ * <Text>Accent color: {themeVariables?.accent}</Text>
59
+ * </View>
60
+ * );
61
+ * }
62
+ * ```
63
+ */
64
+ export function useAppKitTheme(): UseAppKitThemeReturn {
65
+ useAppKit(); // Use the hook for checks
66
+ const { themeMode, themeVariables } = useSnapshot(ThemeController.state);
67
+
68
+ const stableFunctions = useMemo(
69
+ () => ({
70
+ setThemeMode: ThemeController.setThemeMode.bind(ThemeController),
71
+ setThemeVariables: ThemeController.setThemeVariables.bind(ThemeController)
72
+ }),
73
+ []
74
+ );
75
+
76
+ return {
77
+ themeMode,
78
+ themeVariables,
79
+ ...stableFunctions
80
+ };
81
+ }