@rific/auto-paper 0.10.3 → 0.12.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/README.md +35 -0
- package/dist/index.d.mts +69 -36
- package/dist/index.d.ts +69 -36
- package/dist/index.js +78 -97
- package/dist/index.mjs +53 -73
- package/package.json +6 -4
- package/src/ThemeProvider.tsx +33 -31
- package/src/ThemeSettingsContext.ts +10 -9
- package/src/components/PalettePicker.tsx +1 -1
- package/src/index.ts +2 -0
- package/src/redux/themeSlice.ts +19 -40
- package/src/useThemeBridgeProps.ts +48 -0
- package/src/useThemeSettings.ts +2 -4
package/README.md
CHANGED
|
@@ -201,6 +201,26 @@ dispatch(themeActions.setColor('#e91e63'))
|
|
|
201
201
|
dispatch(themeActions.setAppearance('dark'))
|
|
202
202
|
```
|
|
203
203
|
|
|
204
|
+
The `App.tsx` example above hand-builds the `initialValue`/`onReady` prop pair inline. Once you also need `onChange` wired back to `dispatch`, reach for `useThemeBridgeProps` instead of re-deriving that same three-field object by hand: it takes your already-resolved `settings`/`onChange`/`onReady` and reshapes them into the exact, memoized prop bag `Provider` expects.
|
|
205
|
+
|
|
206
|
+
```tsx
|
|
207
|
+
// Theme.tsx
|
|
208
|
+
import { Provider as AutoPaperProvider, useThemeBridgeProps } from '@rific/auto-paper'
|
|
209
|
+
import { useCallback } from 'react'
|
|
210
|
+
import { shallowEqual, useDispatch, useSelector } from 'react-redux'
|
|
211
|
+
|
|
212
|
+
export function Theme({ children }: { children: React.ReactNode }) {
|
|
213
|
+
const settings = useSelector((state: RootState) => state.theme, shallowEqual)
|
|
214
|
+
const dispatch = useDispatch()
|
|
215
|
+
const onChange = useCallback((next: ThemeSettings) => dispatch(themeActions.initialize(next)), [dispatch])
|
|
216
|
+
const bridgeProps = useThemeBridgeProps({ initialValue: settings, onChange, onReady: SplashScreen.hideAsync })
|
|
217
|
+
|
|
218
|
+
return <AutoPaperProvider {...bridgeProps}>{children}</AutoPaperProvider>
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Keep the scope honest: this only replaces the final `<Provider initialValue={...} onChange={...} onReady={...}>` prop list with `<Provider {...bridgeProps}>`. It doesn't do the `useSelector`/`useDispatch` wiring above it — that's still yours to write, since `RootState`'s shape is app-local and this package has no opinion on it (or on state management being Redux at all; `useThemeBridgeProps` takes plain values and callbacks, not a `dispatch` function).
|
|
223
|
+
|
|
204
224
|
### With `useComputedTheme`
|
|
205
225
|
|
|
206
226
|
Use the hook directly when you need to extend the theme before passing it to `PaperProvider`, for example to merge in a navigation theme or add custom color keys:
|
|
@@ -262,6 +282,21 @@ export default function App() {
|
|
|
262
282
|
| `blur` | `boolean` | `true` |
|
|
263
283
|
| `blurTint` | `number` | `0.2` |
|
|
264
284
|
|
|
285
|
+
### `useThemeBridgeProps({ initialValue, onChange, onReady })`
|
|
286
|
+
|
|
287
|
+
Reshapes already-resolved values into the exact `Pick<ProviderProps, 'initialValue' | 'onChange' | 'onReady'>` shape `Provider` expects, memoized on those three fields so the returned object is referentially stable across re-renders until an input actually changes. Meant for a consuming app's own Redux-backed "Theme" component — see "With Redux" above — but takes plain values and callbacks rather than a `dispatch` function or anything Redux-specific, so it works with any state management, or none.
|
|
288
|
+
|
|
289
|
+
It only replaces the final prop list handed to `Provider`; it does not do any `useSelector`/`dispatch` wiring itself, and `onReady` is threaded through unchanged.
|
|
290
|
+
|
|
291
|
+
```ts
|
|
292
|
+
import { useThemeBridgeProps } from '@rific/auto-paper'
|
|
293
|
+
|
|
294
|
+
const bridgeProps = useThemeBridgeProps({ initialValue: settings, onChange, onReady })
|
|
295
|
+
// → { initialValue, onChange, onReady }
|
|
296
|
+
|
|
297
|
+
<Provider {...bridgeProps}>{children}</Provider>
|
|
298
|
+
```
|
|
299
|
+
|
|
265
300
|
### `useThemeSettings()`
|
|
266
301
|
|
|
267
302
|
Returns `{ settings: ThemeSettings, set: (patch: Partial<ThemeSettings>) => void }`. Use this hook from any component inside `Provider` to read or update the current theme settings.
|
package/dist/index.d.mts
CHANGED
|
@@ -6,6 +6,8 @@ import { AppbarHeaderProps, MD3Theme, BottomNavigationRoute, BottomNavigationPro
|
|
|
6
6
|
export { AppbarHeaderProps, BottomNavigationProps, BottomNavigationRoute, ButtonProps, FABProps, ChipProps as PaperChipProps, DialogProps as PaperDialogProps, IconButtonProps as PaperIconButtonProps, MenuProps as PaperMenuProps, TextInputProps } from 'react-native-paper';
|
|
7
7
|
import * as react from 'react';
|
|
8
8
|
import react__default, { RefObject, ReactNode, ComponentType } from 'react';
|
|
9
|
+
import * as _rific_core from '@rific/core';
|
|
10
|
+
import { SettingsContextValue } from '@rific/core';
|
|
9
11
|
|
|
10
12
|
declare function useBlur(override?: boolean): boolean;
|
|
11
13
|
|
|
@@ -227,53 +229,46 @@ type ThemeState = {
|
|
|
227
229
|
color: string | TriadicPalette;
|
|
228
230
|
harmony: ColorHarmony;
|
|
229
231
|
};
|
|
230
|
-
type PayloadAction<P> = {
|
|
231
|
-
payload: P;
|
|
232
|
-
type: string;
|
|
233
|
-
};
|
|
234
232
|
declare const themeActions: {
|
|
235
233
|
initialize: {
|
|
236
|
-
(payload: Partial<ThemeState>):
|
|
234
|
+
(payload: Partial<ThemeState>): _rific_core.SettingsAction<Partial<ThemeState>>;
|
|
237
235
|
type: string;
|
|
238
|
-
match(action: {
|
|
236
|
+
match: (action: {
|
|
239
237
|
type: string;
|
|
240
|
-
})
|
|
238
|
+
}) => action is _rific_core.SettingsAction<Partial<ThemeState>>;
|
|
241
239
|
};
|
|
242
|
-
|
|
243
|
-
|
|
240
|
+
} & {
|
|
241
|
+
setColor: {
|
|
242
|
+
(payload: string | TriadicPalette): _rific_core.SettingsAction<string | TriadicPalette>;
|
|
244
243
|
type: string;
|
|
245
|
-
match(action: {
|
|
244
|
+
match: (action: {
|
|
246
245
|
type: string;
|
|
247
|
-
})
|
|
246
|
+
}) => action is _rific_core.SettingsAction<string | TriadicPalette>;
|
|
248
247
|
};
|
|
249
|
-
|
|
250
|
-
(payload:
|
|
248
|
+
setAppearance: {
|
|
249
|
+
(payload: ThemeAppearance): _rific_core.SettingsAction<ThemeAppearance>;
|
|
251
250
|
type: string;
|
|
252
|
-
match(action: {
|
|
251
|
+
match: (action: {
|
|
253
252
|
type: string;
|
|
254
|
-
})
|
|
253
|
+
}) => action is _rific_core.SettingsAction<ThemeAppearance>;
|
|
255
254
|
};
|
|
256
|
-
|
|
257
|
-
(payload:
|
|
255
|
+
setBlur: {
|
|
256
|
+
(payload: boolean): _rific_core.SettingsAction<boolean>;
|
|
258
257
|
type: string;
|
|
259
|
-
match(action: {
|
|
258
|
+
match: (action: {
|
|
260
259
|
type: string;
|
|
261
|
-
})
|
|
260
|
+
}) => action is _rific_core.SettingsAction<boolean>;
|
|
262
261
|
};
|
|
263
262
|
setHarmony: {
|
|
264
|
-
(payload: ColorHarmony):
|
|
263
|
+
(payload: ColorHarmony): _rific_core.SettingsAction<ColorHarmony>;
|
|
265
264
|
type: string;
|
|
266
|
-
match(action: {
|
|
265
|
+
match: (action: {
|
|
267
266
|
type: string;
|
|
268
|
-
})
|
|
267
|
+
}) => action is _rific_core.SettingsAction<ColorHarmony>;
|
|
269
268
|
};
|
|
270
269
|
};
|
|
271
|
-
declare
|
|
272
|
-
|
|
273
|
-
}) => ThemeState;
|
|
274
|
-
declare const themeReducer: (state: ThemeState | undefined, action: {
|
|
275
|
-
type: string;
|
|
276
|
-
}) => ThemeState;
|
|
270
|
+
declare const themeReducer: _rific_core.SettingsReducer<ThemeState>;
|
|
271
|
+
declare const createThemeReducer: (overrideInitialState?: Partial<ThemeState> | undefined) => _rific_core.SettingsReducer<ThemeState>;
|
|
277
272
|
declare const selectThemeAppearance: (state: ThemeState) => ThemeAppearance;
|
|
278
273
|
declare const selectThemeBlur: (state: ThemeState) => boolean;
|
|
279
274
|
declare const selectThemeColor: (state: ThemeState) => string | TriadicPalette;
|
|
@@ -287,11 +282,8 @@ type ThemeSettings = {
|
|
|
287
282
|
harmony: ColorHarmony;
|
|
288
283
|
};
|
|
289
284
|
declare const defaultThemeSettings: ThemeSettings;
|
|
290
|
-
type ThemeSettingsContextType =
|
|
291
|
-
|
|
292
|
-
set: (patch: Partial<ThemeSettings>) => void;
|
|
293
|
-
};
|
|
294
|
-
declare const ThemeSettingsContext: react.Context<ThemeSettingsContextType>;
|
|
285
|
+
type ThemeSettingsContextType = SettingsContextValue<ThemeSettings>;
|
|
286
|
+
declare const ThemeSettingsContext: react.Context<SettingsContextValue<ThemeSettings>>;
|
|
295
287
|
|
|
296
288
|
type NavBarContextType = {
|
|
297
289
|
navigationBar?: ExpoNavigationBarModule;
|
|
@@ -322,11 +314,52 @@ type ProviderProps = {
|
|
|
322
314
|
statusBarProps?: StatusBarProps;
|
|
323
315
|
style?: StyleProp<ViewStyle>;
|
|
324
316
|
};
|
|
325
|
-
declare function Provider({ children, defaults, expoBlur, fontFamily, initialValue, navigationBar, onChange, onNavBarChange, onReady, reanimated, statusBarProps, style }: ProviderProps): react.JSX.Element
|
|
317
|
+
declare function Provider({ children, defaults, expoBlur, fontFamily, initialValue, navigationBar, onChange, onNavBarChange, onReady, reanimated, statusBarProps, style }: ProviderProps): react.JSX.Element;
|
|
326
318
|
|
|
327
319
|
declare const useAutoPaperTheme: () => AutoPaperTheme;
|
|
328
320
|
|
|
329
|
-
|
|
321
|
+
/**
|
|
322
|
+
* The subset of ProviderProps a consuming app's own Redux-backed "Theme" component is responsible
|
|
323
|
+
* for supplying. Every field here has an identically-named counterpart on ProviderProps itself
|
|
324
|
+
* (see ThemeProvider.tsx) - deliberately not renamed, so wiring this up needs no new vocabulary
|
|
325
|
+
* beyond the provider's own.
|
|
326
|
+
*/
|
|
327
|
+
type ThemeBridgeProps = Pick<ProviderProps, 'initialValue' | 'onChange' | 'onReady'>;
|
|
328
|
+
/**
|
|
329
|
+
* Reshapes an app's own Redux-sourced theme state and callbacks into the exact prop object
|
|
330
|
+
* `<Provider>` expects, so a consuming app's own "Theme" component - every game in the fleet
|
|
331
|
+
* defines one, reading `state.theme` from its own store via `useSelector(..., shallowEqual)` and
|
|
332
|
+
* dispatching `themeActions.initialize` on change - can hand its own `useSelector`/`dispatch`
|
|
333
|
+
* results straight to this hook instead of re-deriving the same three-prop shape by hand in every
|
|
334
|
+
* app:
|
|
335
|
+
*
|
|
336
|
+
* ```tsx
|
|
337
|
+
* export function Theme({ children }: Props) {
|
|
338
|
+
* const settings = useSelector((state: RootState) => state.theme, shallowEqual)
|
|
339
|
+
* const dispatch = useDispatch()
|
|
340
|
+
* const onChange = useCallback((next: ThemeSettings) => dispatch(themeActions.initialize(next)), [dispatch])
|
|
341
|
+
* const onReady = useCallback(() => markSplashReady('theme'), [])
|
|
342
|
+
* const bridgeProps = useThemeBridgeProps({ initialValue: settings, onChange, onReady })
|
|
343
|
+
* return <Provider {...bridgeProps}>{children}</Provider>
|
|
344
|
+
* }
|
|
345
|
+
* ```
|
|
346
|
+
*
|
|
347
|
+
* Deliberately takes plain values and callbacks rather than a `dispatch` function or any
|
|
348
|
+
* Redux-specific type: this package has no opinion on any app's own RootState shape, or even that
|
|
349
|
+
* state management is Redux at all - the app does its own `useSelector`/`dispatch` wiring and
|
|
350
|
+
* passes just the results in.
|
|
351
|
+
*
|
|
352
|
+
* `onReady` is threaded through completely unchanged, never recomputed or wrapped here - it fires
|
|
353
|
+
* exactly once, the first time `<Provider>` itself reports its computed theme is ready, which is
|
|
354
|
+
* the timing a consuming app's own splash-gate mark depends on. A wrong `onReady` callback (e.g.
|
|
355
|
+
* one that marks the gate ready before `<Provider>` actually is) is a bug in the app's own
|
|
356
|
+
* callback, not something this hook can catch or fix - see BoxHockey's and LightCycles' own history
|
|
357
|
+
* of hand-fixing exactly that "marked ready before Provider was actually ready" bug in their own
|
|
358
|
+
* Theme.tsx before this hook existed.
|
|
359
|
+
*/
|
|
360
|
+
declare function useThemeBridgeProps(props: ThemeBridgeProps): ThemeBridgeProps;
|
|
361
|
+
|
|
362
|
+
declare const useThemeSettings: () => _rific_core.SettingsContextValue<ThemeSettings>;
|
|
330
363
|
|
|
331
364
|
declare const getBlendedColor: (foreground: string, background: string, alpha: number) => string;
|
|
332
365
|
|
|
@@ -360,4 +393,4 @@ declare const isDarkColor: (value: string) => boolean;
|
|
|
360
393
|
|
|
361
394
|
declare const resolveSeedColor: (color: string | TriadicPalette) => string;
|
|
362
395
|
|
|
363
|
-
export { Appbar, type AppearanceIcons, AppearancePicker, AutoAppearancePicker, AutoPalettePicker, type AutoPaperTheme, BlurView, type BlurViewProps, BottomNavigation, Button, Chip, type ChipProps, type ColorHarmony, ColorPicker, type ColorRoles, Dialog, type DialogProps, type ExpoBlurModule, type ExpoNavigationBarModule, FAB, HarmonyPicker, IconButton, type IconButtonProps, Menu, type MenuProps, PalettePicker, type PaletteWeights, type PaperDefaults, Provider, type ProviderProps, type RGB, type ReanimatedModule, SEMANTIC_BASE_COLORS, type SeedColor, type SemanticColorRoles, TextInput, type ThemeAppearance, type ThemeSettings, ThemeSettingsContext, type ThemeSettingsContextType, type ThemeState, type TriadicPalette, createThemeReducer, defaultColors, defaultThemeSettings, getBlendedColor, getColorRoles, getContrastColor, getHex, getRgb, getThirdColor, getTintTextColor, getTonalColor, getTriadicPalette, isDarkColor, resolveSeedColor, selectThemeAppearance, selectThemeBlur, selectThemeColor, selectThemeHarmony, themeActions, themeReducer, useAutoPaperTheme, useBlur, useBlurModule, useComputedTheme, useNavBarContext, usePaperDefaults, useReanimatedModule, useThemeSettings };
|
|
396
|
+
export { Appbar, type AppearanceIcons, AppearancePicker, AutoAppearancePicker, AutoPalettePicker, type AutoPaperTheme, BlurView, type BlurViewProps, BottomNavigation, Button, Chip, type ChipProps, type ColorHarmony, ColorPicker, type ColorRoles, Dialog, type DialogProps, type ExpoBlurModule, type ExpoNavigationBarModule, FAB, HarmonyPicker, IconButton, type IconButtonProps, Menu, type MenuProps, PalettePicker, type PaletteWeights, type PaperDefaults, Provider, type ProviderProps, type RGB, type ReanimatedModule, SEMANTIC_BASE_COLORS, type SeedColor, type SemanticColorRoles, TextInput, type ThemeAppearance, type ThemeBridgeProps, type ThemeSettings, ThemeSettingsContext, type ThemeSettingsContextType, type ThemeState, type TriadicPalette, createThemeReducer, defaultColors, defaultThemeSettings, getBlendedColor, getColorRoles, getContrastColor, getHex, getRgb, getThirdColor, getTintTextColor, getTonalColor, getTriadicPalette, isDarkColor, resolveSeedColor, selectThemeAppearance, selectThemeBlur, selectThemeColor, selectThemeHarmony, themeActions, themeReducer, useAutoPaperTheme, useBlur, useBlurModule, useComputedTheme, useNavBarContext, usePaperDefaults, useReanimatedModule, useThemeBridgeProps, useThemeSettings };
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ import { AppbarHeaderProps, MD3Theme, BottomNavigationRoute, BottomNavigationPro
|
|
|
6
6
|
export { AppbarHeaderProps, BottomNavigationProps, BottomNavigationRoute, ButtonProps, FABProps, ChipProps as PaperChipProps, DialogProps as PaperDialogProps, IconButtonProps as PaperIconButtonProps, MenuProps as PaperMenuProps, TextInputProps } from 'react-native-paper';
|
|
7
7
|
import * as react from 'react';
|
|
8
8
|
import react__default, { RefObject, ReactNode, ComponentType } from 'react';
|
|
9
|
+
import * as _rific_core from '@rific/core';
|
|
10
|
+
import { SettingsContextValue } from '@rific/core';
|
|
9
11
|
|
|
10
12
|
declare function useBlur(override?: boolean): boolean;
|
|
11
13
|
|
|
@@ -227,53 +229,46 @@ type ThemeState = {
|
|
|
227
229
|
color: string | TriadicPalette;
|
|
228
230
|
harmony: ColorHarmony;
|
|
229
231
|
};
|
|
230
|
-
type PayloadAction<P> = {
|
|
231
|
-
payload: P;
|
|
232
|
-
type: string;
|
|
233
|
-
};
|
|
234
232
|
declare const themeActions: {
|
|
235
233
|
initialize: {
|
|
236
|
-
(payload: Partial<ThemeState>):
|
|
234
|
+
(payload: Partial<ThemeState>): _rific_core.SettingsAction<Partial<ThemeState>>;
|
|
237
235
|
type: string;
|
|
238
|
-
match(action: {
|
|
236
|
+
match: (action: {
|
|
239
237
|
type: string;
|
|
240
|
-
})
|
|
238
|
+
}) => action is _rific_core.SettingsAction<Partial<ThemeState>>;
|
|
241
239
|
};
|
|
242
|
-
|
|
243
|
-
|
|
240
|
+
} & {
|
|
241
|
+
setColor: {
|
|
242
|
+
(payload: string | TriadicPalette): _rific_core.SettingsAction<string | TriadicPalette>;
|
|
244
243
|
type: string;
|
|
245
|
-
match(action: {
|
|
244
|
+
match: (action: {
|
|
246
245
|
type: string;
|
|
247
|
-
})
|
|
246
|
+
}) => action is _rific_core.SettingsAction<string | TriadicPalette>;
|
|
248
247
|
};
|
|
249
|
-
|
|
250
|
-
(payload:
|
|
248
|
+
setAppearance: {
|
|
249
|
+
(payload: ThemeAppearance): _rific_core.SettingsAction<ThemeAppearance>;
|
|
251
250
|
type: string;
|
|
252
|
-
match(action: {
|
|
251
|
+
match: (action: {
|
|
253
252
|
type: string;
|
|
254
|
-
})
|
|
253
|
+
}) => action is _rific_core.SettingsAction<ThemeAppearance>;
|
|
255
254
|
};
|
|
256
|
-
|
|
257
|
-
(payload:
|
|
255
|
+
setBlur: {
|
|
256
|
+
(payload: boolean): _rific_core.SettingsAction<boolean>;
|
|
258
257
|
type: string;
|
|
259
|
-
match(action: {
|
|
258
|
+
match: (action: {
|
|
260
259
|
type: string;
|
|
261
|
-
})
|
|
260
|
+
}) => action is _rific_core.SettingsAction<boolean>;
|
|
262
261
|
};
|
|
263
262
|
setHarmony: {
|
|
264
|
-
(payload: ColorHarmony):
|
|
263
|
+
(payload: ColorHarmony): _rific_core.SettingsAction<ColorHarmony>;
|
|
265
264
|
type: string;
|
|
266
|
-
match(action: {
|
|
265
|
+
match: (action: {
|
|
267
266
|
type: string;
|
|
268
|
-
})
|
|
267
|
+
}) => action is _rific_core.SettingsAction<ColorHarmony>;
|
|
269
268
|
};
|
|
270
269
|
};
|
|
271
|
-
declare
|
|
272
|
-
|
|
273
|
-
}) => ThemeState;
|
|
274
|
-
declare const themeReducer: (state: ThemeState | undefined, action: {
|
|
275
|
-
type: string;
|
|
276
|
-
}) => ThemeState;
|
|
270
|
+
declare const themeReducer: _rific_core.SettingsReducer<ThemeState>;
|
|
271
|
+
declare const createThemeReducer: (overrideInitialState?: Partial<ThemeState> | undefined) => _rific_core.SettingsReducer<ThemeState>;
|
|
277
272
|
declare const selectThemeAppearance: (state: ThemeState) => ThemeAppearance;
|
|
278
273
|
declare const selectThemeBlur: (state: ThemeState) => boolean;
|
|
279
274
|
declare const selectThemeColor: (state: ThemeState) => string | TriadicPalette;
|
|
@@ -287,11 +282,8 @@ type ThemeSettings = {
|
|
|
287
282
|
harmony: ColorHarmony;
|
|
288
283
|
};
|
|
289
284
|
declare const defaultThemeSettings: ThemeSettings;
|
|
290
|
-
type ThemeSettingsContextType =
|
|
291
|
-
|
|
292
|
-
set: (patch: Partial<ThemeSettings>) => void;
|
|
293
|
-
};
|
|
294
|
-
declare const ThemeSettingsContext: react.Context<ThemeSettingsContextType>;
|
|
285
|
+
type ThemeSettingsContextType = SettingsContextValue<ThemeSettings>;
|
|
286
|
+
declare const ThemeSettingsContext: react.Context<SettingsContextValue<ThemeSettings>>;
|
|
295
287
|
|
|
296
288
|
type NavBarContextType = {
|
|
297
289
|
navigationBar?: ExpoNavigationBarModule;
|
|
@@ -322,11 +314,52 @@ type ProviderProps = {
|
|
|
322
314
|
statusBarProps?: StatusBarProps;
|
|
323
315
|
style?: StyleProp<ViewStyle>;
|
|
324
316
|
};
|
|
325
|
-
declare function Provider({ children, defaults, expoBlur, fontFamily, initialValue, navigationBar, onChange, onNavBarChange, onReady, reanimated, statusBarProps, style }: ProviderProps): react.JSX.Element
|
|
317
|
+
declare function Provider({ children, defaults, expoBlur, fontFamily, initialValue, navigationBar, onChange, onNavBarChange, onReady, reanimated, statusBarProps, style }: ProviderProps): react.JSX.Element;
|
|
326
318
|
|
|
327
319
|
declare const useAutoPaperTheme: () => AutoPaperTheme;
|
|
328
320
|
|
|
329
|
-
|
|
321
|
+
/**
|
|
322
|
+
* The subset of ProviderProps a consuming app's own Redux-backed "Theme" component is responsible
|
|
323
|
+
* for supplying. Every field here has an identically-named counterpart on ProviderProps itself
|
|
324
|
+
* (see ThemeProvider.tsx) - deliberately not renamed, so wiring this up needs no new vocabulary
|
|
325
|
+
* beyond the provider's own.
|
|
326
|
+
*/
|
|
327
|
+
type ThemeBridgeProps = Pick<ProviderProps, 'initialValue' | 'onChange' | 'onReady'>;
|
|
328
|
+
/**
|
|
329
|
+
* Reshapes an app's own Redux-sourced theme state and callbacks into the exact prop object
|
|
330
|
+
* `<Provider>` expects, so a consuming app's own "Theme" component - every game in the fleet
|
|
331
|
+
* defines one, reading `state.theme` from its own store via `useSelector(..., shallowEqual)` and
|
|
332
|
+
* dispatching `themeActions.initialize` on change - can hand its own `useSelector`/`dispatch`
|
|
333
|
+
* results straight to this hook instead of re-deriving the same three-prop shape by hand in every
|
|
334
|
+
* app:
|
|
335
|
+
*
|
|
336
|
+
* ```tsx
|
|
337
|
+
* export function Theme({ children }: Props) {
|
|
338
|
+
* const settings = useSelector((state: RootState) => state.theme, shallowEqual)
|
|
339
|
+
* const dispatch = useDispatch()
|
|
340
|
+
* const onChange = useCallback((next: ThemeSettings) => dispatch(themeActions.initialize(next)), [dispatch])
|
|
341
|
+
* const onReady = useCallback(() => markSplashReady('theme'), [])
|
|
342
|
+
* const bridgeProps = useThemeBridgeProps({ initialValue: settings, onChange, onReady })
|
|
343
|
+
* return <Provider {...bridgeProps}>{children}</Provider>
|
|
344
|
+
* }
|
|
345
|
+
* ```
|
|
346
|
+
*
|
|
347
|
+
* Deliberately takes plain values and callbacks rather than a `dispatch` function or any
|
|
348
|
+
* Redux-specific type: this package has no opinion on any app's own RootState shape, or even that
|
|
349
|
+
* state management is Redux at all - the app does its own `useSelector`/`dispatch` wiring and
|
|
350
|
+
* passes just the results in.
|
|
351
|
+
*
|
|
352
|
+
* `onReady` is threaded through completely unchanged, never recomputed or wrapped here - it fires
|
|
353
|
+
* exactly once, the first time `<Provider>` itself reports its computed theme is ready, which is
|
|
354
|
+
* the timing a consuming app's own splash-gate mark depends on. A wrong `onReady` callback (e.g.
|
|
355
|
+
* one that marks the gate ready before `<Provider>` actually is) is a bug in the app's own
|
|
356
|
+
* callback, not something this hook can catch or fix - see BoxHockey's and LightCycles' own history
|
|
357
|
+
* of hand-fixing exactly that "marked ready before Provider was actually ready" bug in their own
|
|
358
|
+
* Theme.tsx before this hook existed.
|
|
359
|
+
*/
|
|
360
|
+
declare function useThemeBridgeProps(props: ThemeBridgeProps): ThemeBridgeProps;
|
|
361
|
+
|
|
362
|
+
declare const useThemeSettings: () => _rific_core.SettingsContextValue<ThemeSettings>;
|
|
330
363
|
|
|
331
364
|
declare const getBlendedColor: (foreground: string, background: string, alpha: number) => string;
|
|
332
365
|
|
|
@@ -360,4 +393,4 @@ declare const isDarkColor: (value: string) => boolean;
|
|
|
360
393
|
|
|
361
394
|
declare const resolveSeedColor: (color: string | TriadicPalette) => string;
|
|
362
395
|
|
|
363
|
-
export { Appbar, type AppearanceIcons, AppearancePicker, AutoAppearancePicker, AutoPalettePicker, type AutoPaperTheme, BlurView, type BlurViewProps, BottomNavigation, Button, Chip, type ChipProps, type ColorHarmony, ColorPicker, type ColorRoles, Dialog, type DialogProps, type ExpoBlurModule, type ExpoNavigationBarModule, FAB, HarmonyPicker, IconButton, type IconButtonProps, Menu, type MenuProps, PalettePicker, type PaletteWeights, type PaperDefaults, Provider, type ProviderProps, type RGB, type ReanimatedModule, SEMANTIC_BASE_COLORS, type SeedColor, type SemanticColorRoles, TextInput, type ThemeAppearance, type ThemeSettings, ThemeSettingsContext, type ThemeSettingsContextType, type ThemeState, type TriadicPalette, createThemeReducer, defaultColors, defaultThemeSettings, getBlendedColor, getColorRoles, getContrastColor, getHex, getRgb, getThirdColor, getTintTextColor, getTonalColor, getTriadicPalette, isDarkColor, resolveSeedColor, selectThemeAppearance, selectThemeBlur, selectThemeColor, selectThemeHarmony, themeActions, themeReducer, useAutoPaperTheme, useBlur, useBlurModule, useComputedTheme, useNavBarContext, usePaperDefaults, useReanimatedModule, useThemeSettings };
|
|
396
|
+
export { Appbar, type AppearanceIcons, AppearancePicker, AutoAppearancePicker, AutoPalettePicker, type AutoPaperTheme, BlurView, type BlurViewProps, BottomNavigation, Button, Chip, type ChipProps, type ColorHarmony, ColorPicker, type ColorRoles, Dialog, type DialogProps, type ExpoBlurModule, type ExpoNavigationBarModule, FAB, HarmonyPicker, IconButton, type IconButtonProps, Menu, type MenuProps, PalettePicker, type PaletteWeights, type PaperDefaults, Provider, type ProviderProps, type RGB, type ReanimatedModule, SEMANTIC_BASE_COLORS, type SeedColor, type SemanticColorRoles, TextInput, type ThemeAppearance, type ThemeBridgeProps, type ThemeSettings, ThemeSettingsContext, type ThemeSettingsContextType, type ThemeState, type TriadicPalette, createThemeReducer, defaultColors, defaultThemeSettings, getBlendedColor, getColorRoles, getContrastColor, getHex, getRgb, getThirdColor, getTintTextColor, getTonalColor, getTriadicPalette, isDarkColor, resolveSeedColor, selectThemeAppearance, selectThemeBlur, selectThemeColor, selectThemeHarmony, themeActions, themeReducer, useAutoPaperTheme, useBlur, useBlurModule, useComputedTheme, useNavBarContext, usePaperDefaults, useReanimatedModule, useThemeBridgeProps, useThemeSettings };
|