@rific/auto-paper 0.4.0 → 0.6.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 CHANGED
@@ -17,18 +17,21 @@ Adaptive theming for [`react-native-paper`](https://callstack.github.io/react-na
17
17
  npm install @rific/auto-paper
18
18
  ```
19
19
 
20
- Peer dependencies:
20
+ Required peer dependency:
21
21
 
22
22
  ```bash
23
- npm install react-native react-native-paper
23
+ npm install react-native-paper
24
24
  ```
25
25
 
26
- Optional — needed only if you use `BottomNavigation` on Android (syncs the system navigation bar color):
26
+ Optional peer dependencies:
27
27
 
28
28
  ```bash
29
- npm install expo-navigation-bar
29
+ npm install expo-blur # frosted-glass BlurView; without it BlurView renders its solid (non-blur) fallback
30
+ npm install expo-navigation-bar # (>= 56.0.0, SDK 54+) auto-syncs Android nav bar icon style to the theme when BottomNavigation is mounted
30
31
  ```
31
32
 
33
+ The exported Redux slice has no dependency on `@reduxjs/toolkit` — it works with RTK stores, vanilla Redux, or no Redux at all.
34
+
32
35
  ## Usage
33
36
 
34
37
  ### Provider (simplest)
@@ -194,6 +197,7 @@ export default function App() {
194
197
  | `onChange` | `(settings: ThemeSettings) => void` | Called whenever settings change via `useThemeSettings().set()` |
195
198
  | `children` | `ReactNode` | |
196
199
  | `defaults` | `PaperDefaults` | Prop defaults for wrapper components (see below) |
200
+ | `onNavBarChange` | `(color: string, dark: boolean) => void` | Overrides the built-in nav bar sync: called on Android when the theme changes while a `BottomNavigation` is mounted, instead of the automatic `expo-navigation-bar` icon-style sync |
197
201
  | `onReady` | `() => void` | Called once when the theme first resolves |
198
202
  | `statusBarProps` | `StatusBarProps` | Spread over the auto-derived `StatusBar` defaults |
199
203
  | `style` | `StyleProp<ViewStyle>` | Applied to the wrapper `View` |
@@ -249,7 +253,7 @@ import { Appbar } from '@rific/auto-paper'
249
253
 
250
254
  ### `BottomNavigation`
251
255
 
252
- A thin wrapper around `react-native-paper`'s `BottomNavigation` that automatically syncs the Android system navigation bar color and button style to the current theme surface color (requires `expo-navigation-bar`; silently no-ops when not installed).
256
+ A thin wrapper around `react-native-paper`'s `BottomNavigation` that keeps the Android system navigation bar icons readable: when the optional `expo-navigation-bar` peer is installed, the icon style automatically follows the theme's darkness (edge-to-edge safe — no background color calls). Pass `onNavBarChange` to the `Provider` to take full control instead; with neither, it silently no-ops.
253
257
 
254
258
  ```tsx
255
259
  import { BottomNavigation } from '@rific/auto-paper'
@@ -340,7 +344,7 @@ createThemeReducer({ color: '#4caf50' })
340
344
  ### Redux exports
341
345
 
342
346
  ```ts
343
- import { themeReducer, themeActions, selectThemeAppearance, selectThemeColor } from '@rific/auto-paper'
347
+ import { themeReducer, themeActions, selectThemeAppearance, selectThemeBlur, selectThemeColor, selectThemeHarmony } from '@rific/auto-paper'
344
348
  import type { ThemeState, ThemeAppearance } from '@rific/auto-paper'
345
349
  ```
346
350
 
@@ -348,7 +352,9 @@ import type { ThemeState, ThemeAppearance } from '@rific/auto-paper'
348
352
  |---|---|
349
353
  | `initialize` | `Partial<ThemeState>` |
350
354
  | `setAppearance` | `ThemeAppearance` |
355
+ | `setBlur` | `boolean` |
351
356
  | `setColor` | `string` |
357
+ | `setHarmony` | `ColorHarmony` |
352
358
 
353
359
  Selectors accept `ThemeState` directly — compose them with your root state selector:
354
360
 
package/dist/index.d.mts CHANGED
@@ -7,9 +7,6 @@ export { AppbarHeaderProps, BottomNavigationProps, BottomNavigationRoute, Button
7
7
  import * as react from 'react';
8
8
  import react__default, { ReactNode } from 'react';
9
9
  import { BlurViewProps as BlurViewProps$1 } from 'expo-blur';
10
- import * as _reduxjs_toolkit from '@reduxjs/toolkit';
11
- import { PayloadAction } from '@reduxjs/toolkit';
12
- import * as redux from 'redux';
13
10
 
14
11
  declare function useBlur(override?: boolean): boolean;
15
12
 
@@ -46,8 +43,11 @@ type BlurViewProps = BlurViewProps$1 & {
46
43
  children?: ReactNode;
47
44
  elevation?: 0 | 1 | 2 | 3 | 4 | 5;
48
45
  style?: StyleProp<ViewStyle>;
46
+ tintColor?: string;
47
+ tintOpacity?: number;
48
+ variant?: 'primary' | 'secondary' | 'tertiary' | 'error' | 'surface' | 'surfaceVariant';
49
49
  };
50
- declare const BlurView: ({ blur, children, elevation, style, ...props }: BlurViewProps) => react.JSX.Element;
50
+ declare const BlurView: ({ blur, children, elevation, style, tintColor, tintOpacity, variant, ...props }: BlurViewProps) => react.JSX.Element;
51
51
 
52
52
  declare function BottomNavigationComponent<Route extends BottomNavigationRoute>(props: BottomNavigationProps<Route>): react__default.JSX.Element;
53
53
  declare namespace BottomNavigationComponent {
@@ -137,45 +137,53 @@ type ThemeState = {
137
137
  color: string;
138
138
  harmony: ColorHarmony;
139
139
  };
140
- declare function createThemeReducer(initialState?: Partial<ThemeState>): redux.Reducer<{
141
- appearance: ThemeAppearance;
142
- blur: boolean;
143
- color: string;
144
- harmony: ColorHarmony;
145
- }>;
146
- declare const themeActions: _reduxjs_toolkit.CaseReducerActions<{
147
- initialize: (state: ThemeState, action: PayloadAction<Partial<ThemeState>>) => {
148
- appearance: ThemeAppearance;
149
- blur: boolean;
150
- color: string;
151
- harmony: ColorHarmony;
140
+ type PayloadAction<P> = {
141
+ payload: P;
142
+ type: string;
143
+ };
144
+ declare const themeActions: {
145
+ initialize: {
146
+ (payload: Partial<ThemeState>): PayloadAction<Partial<ThemeState>>;
147
+ type: string;
148
+ match(action: {
149
+ type: string;
150
+ }): action is PayloadAction<Partial<ThemeState>>;
152
151
  };
153
- setAppearance: (state: ThemeState, action: PayloadAction<ThemeAppearance>) => {
154
- appearance: ThemeAppearance;
155
- blur: boolean;
156
- color: string;
157
- harmony: ColorHarmony;
152
+ setAppearance: {
153
+ (payload: ThemeAppearance): PayloadAction<ThemeAppearance>;
154
+ type: string;
155
+ match(action: {
156
+ type: string;
157
+ }): action is PayloadAction<ThemeAppearance>;
158
158
  };
159
- setBlur: (state: ThemeState, action: PayloadAction<boolean>) => {
160
- blur: boolean;
161
- appearance: ThemeAppearance;
162
- color: string;
163
- harmony: ColorHarmony;
159
+ setBlur: {
160
+ (payload: boolean): PayloadAction<boolean>;
161
+ type: string;
162
+ match(action: {
163
+ type: string;
164
+ }): action is PayloadAction<boolean>;
164
165
  };
165
- setColor: (state: ThemeState, action: PayloadAction<string>) => {
166
- color: string;
167
- appearance: ThemeAppearance;
168
- blur: boolean;
169
- harmony: ColorHarmony;
166
+ setColor: {
167
+ (payload: string): PayloadAction<string>;
168
+ type: string;
169
+ match(action: {
170
+ type: string;
171
+ }): action is PayloadAction<string>;
170
172
  };
171
- setHarmony: (state: ThemeState, action: PayloadAction<ColorHarmony>) => {
172
- harmony: ColorHarmony;
173
- appearance: ThemeAppearance;
174
- blur: boolean;
175
- color: string;
173
+ setHarmony: {
174
+ (payload: ColorHarmony): PayloadAction<ColorHarmony>;
175
+ type: string;
176
+ match(action: {
177
+ type: string;
178
+ }): action is PayloadAction<ColorHarmony>;
176
179
  };
177
- }, "theme">;
178
- declare const themeReducer: redux.Reducer<ThemeState>;
180
+ };
181
+ declare function createThemeReducer(initialState?: Partial<ThemeState>): (state: ThemeState | undefined, action: {
182
+ type: string;
183
+ }) => ThemeState;
184
+ declare const themeReducer: (state: ThemeState | undefined, action: {
185
+ type: string;
186
+ }) => ThemeState;
179
187
  declare const selectThemeAppearance: (state: ThemeState) => ThemeAppearance;
180
188
  declare const selectThemeBlur: (state: ThemeState) => boolean;
181
189
  declare const selectThemeColor: (state: ThemeState) => string;
@@ -221,6 +229,10 @@ type RGB = {
221
229
  };
222
230
  declare const getRgb: (value: string) => RGB | null;
223
231
 
232
+ declare const getTintTextColor: (tintColor: string, backdropColor: string, tintOpacity: number) => string;
233
+
234
+ declare const getTonalColor: (color: string, lightness: number) => string;
235
+
224
236
  declare const isDarkColor: (value: string) => boolean;
225
237
 
226
- export { Appbar, AppearancePicker, BlurView, type BlurViewProps, BottomNavigation, Button, Chip, type ChipProps, type ColorHarmony, ColorPicker, Dialog, type DialogProps, FAB, HarmonyPicker, IconButton, type IconButtonProps, Menu, type MenuProps, type PaperDefaults, Provider, type ProviderProps, type RGB, type SeedColor, TextInput, type ThemeAppearance, type ThemeSettings, ThemeSettingsContext, type ThemeSettingsContextType, type ThemeState, type TriadicPalette, createThemeReducer, defaultColors, defaultThemeSettings, getBlendedColor, getHex, getRgb, getTriadicPalette, isDarkColor, selectThemeAppearance, selectThemeBlur, selectThemeColor, selectThemeHarmony, themeActions, themeReducer, useBlur, useComputedTheme, usePaperDefaults, useThemeSettings };
238
+ export { Appbar, AppearancePicker, BlurView, type BlurViewProps, BottomNavigation, Button, Chip, type ChipProps, type ColorHarmony, ColorPicker, Dialog, type DialogProps, FAB, HarmonyPicker, IconButton, type IconButtonProps, Menu, type MenuProps, type PaperDefaults, Provider, type ProviderProps, type RGB, type SeedColor, TextInput, type ThemeAppearance, type ThemeSettings, ThemeSettingsContext, type ThemeSettingsContextType, type ThemeState, type TriadicPalette, createThemeReducer, defaultColors, defaultThemeSettings, getBlendedColor, getHex, getRgb, getTintTextColor, getTonalColor, getTriadicPalette, isDarkColor, selectThemeAppearance, selectThemeBlur, selectThemeColor, selectThemeHarmony, themeActions, themeReducer, useBlur, useComputedTheme, usePaperDefaults, useThemeSettings };
package/dist/index.d.ts CHANGED
@@ -7,9 +7,6 @@ export { AppbarHeaderProps, BottomNavigationProps, BottomNavigationRoute, Button
7
7
  import * as react from 'react';
8
8
  import react__default, { ReactNode } from 'react';
9
9
  import { BlurViewProps as BlurViewProps$1 } from 'expo-blur';
10
- import * as _reduxjs_toolkit from '@reduxjs/toolkit';
11
- import { PayloadAction } from '@reduxjs/toolkit';
12
- import * as redux from 'redux';
13
10
 
14
11
  declare function useBlur(override?: boolean): boolean;
15
12
 
@@ -46,8 +43,11 @@ type BlurViewProps = BlurViewProps$1 & {
46
43
  children?: ReactNode;
47
44
  elevation?: 0 | 1 | 2 | 3 | 4 | 5;
48
45
  style?: StyleProp<ViewStyle>;
46
+ tintColor?: string;
47
+ tintOpacity?: number;
48
+ variant?: 'primary' | 'secondary' | 'tertiary' | 'error' | 'surface' | 'surfaceVariant';
49
49
  };
50
- declare const BlurView: ({ blur, children, elevation, style, ...props }: BlurViewProps) => react.JSX.Element;
50
+ declare const BlurView: ({ blur, children, elevation, style, tintColor, tintOpacity, variant, ...props }: BlurViewProps) => react.JSX.Element;
51
51
 
52
52
  declare function BottomNavigationComponent<Route extends BottomNavigationRoute>(props: BottomNavigationProps<Route>): react__default.JSX.Element;
53
53
  declare namespace BottomNavigationComponent {
@@ -137,45 +137,53 @@ type ThemeState = {
137
137
  color: string;
138
138
  harmony: ColorHarmony;
139
139
  };
140
- declare function createThemeReducer(initialState?: Partial<ThemeState>): redux.Reducer<{
141
- appearance: ThemeAppearance;
142
- blur: boolean;
143
- color: string;
144
- harmony: ColorHarmony;
145
- }>;
146
- declare const themeActions: _reduxjs_toolkit.CaseReducerActions<{
147
- initialize: (state: ThemeState, action: PayloadAction<Partial<ThemeState>>) => {
148
- appearance: ThemeAppearance;
149
- blur: boolean;
150
- color: string;
151
- harmony: ColorHarmony;
140
+ type PayloadAction<P> = {
141
+ payload: P;
142
+ type: string;
143
+ };
144
+ declare const themeActions: {
145
+ initialize: {
146
+ (payload: Partial<ThemeState>): PayloadAction<Partial<ThemeState>>;
147
+ type: string;
148
+ match(action: {
149
+ type: string;
150
+ }): action is PayloadAction<Partial<ThemeState>>;
152
151
  };
153
- setAppearance: (state: ThemeState, action: PayloadAction<ThemeAppearance>) => {
154
- appearance: ThemeAppearance;
155
- blur: boolean;
156
- color: string;
157
- harmony: ColorHarmony;
152
+ setAppearance: {
153
+ (payload: ThemeAppearance): PayloadAction<ThemeAppearance>;
154
+ type: string;
155
+ match(action: {
156
+ type: string;
157
+ }): action is PayloadAction<ThemeAppearance>;
158
158
  };
159
- setBlur: (state: ThemeState, action: PayloadAction<boolean>) => {
160
- blur: boolean;
161
- appearance: ThemeAppearance;
162
- color: string;
163
- harmony: ColorHarmony;
159
+ setBlur: {
160
+ (payload: boolean): PayloadAction<boolean>;
161
+ type: string;
162
+ match(action: {
163
+ type: string;
164
+ }): action is PayloadAction<boolean>;
164
165
  };
165
- setColor: (state: ThemeState, action: PayloadAction<string>) => {
166
- color: string;
167
- appearance: ThemeAppearance;
168
- blur: boolean;
169
- harmony: ColorHarmony;
166
+ setColor: {
167
+ (payload: string): PayloadAction<string>;
168
+ type: string;
169
+ match(action: {
170
+ type: string;
171
+ }): action is PayloadAction<string>;
170
172
  };
171
- setHarmony: (state: ThemeState, action: PayloadAction<ColorHarmony>) => {
172
- harmony: ColorHarmony;
173
- appearance: ThemeAppearance;
174
- blur: boolean;
175
- color: string;
173
+ setHarmony: {
174
+ (payload: ColorHarmony): PayloadAction<ColorHarmony>;
175
+ type: string;
176
+ match(action: {
177
+ type: string;
178
+ }): action is PayloadAction<ColorHarmony>;
176
179
  };
177
- }, "theme">;
178
- declare const themeReducer: redux.Reducer<ThemeState>;
180
+ };
181
+ declare function createThemeReducer(initialState?: Partial<ThemeState>): (state: ThemeState | undefined, action: {
182
+ type: string;
183
+ }) => ThemeState;
184
+ declare const themeReducer: (state: ThemeState | undefined, action: {
185
+ type: string;
186
+ }) => ThemeState;
179
187
  declare const selectThemeAppearance: (state: ThemeState) => ThemeAppearance;
180
188
  declare const selectThemeBlur: (state: ThemeState) => boolean;
181
189
  declare const selectThemeColor: (state: ThemeState) => string;
@@ -221,6 +229,10 @@ type RGB = {
221
229
  };
222
230
  declare const getRgb: (value: string) => RGB | null;
223
231
 
232
+ declare const getTintTextColor: (tintColor: string, backdropColor: string, tintOpacity: number) => string;
233
+
234
+ declare const getTonalColor: (color: string, lightness: number) => string;
235
+
224
236
  declare const isDarkColor: (value: string) => boolean;
225
237
 
226
- export { Appbar, AppearancePicker, BlurView, type BlurViewProps, BottomNavigation, Button, Chip, type ChipProps, type ColorHarmony, ColorPicker, Dialog, type DialogProps, FAB, HarmonyPicker, IconButton, type IconButtonProps, Menu, type MenuProps, type PaperDefaults, Provider, type ProviderProps, type RGB, type SeedColor, TextInput, type ThemeAppearance, type ThemeSettings, ThemeSettingsContext, type ThemeSettingsContextType, type ThemeState, type TriadicPalette, createThemeReducer, defaultColors, defaultThemeSettings, getBlendedColor, getHex, getRgb, getTriadicPalette, isDarkColor, selectThemeAppearance, selectThemeBlur, selectThemeColor, selectThemeHarmony, themeActions, themeReducer, useBlur, useComputedTheme, usePaperDefaults, useThemeSettings };
238
+ export { Appbar, AppearancePicker, BlurView, type BlurViewProps, BottomNavigation, Button, Chip, type ChipProps, type ColorHarmony, ColorPicker, Dialog, type DialogProps, FAB, HarmonyPicker, IconButton, type IconButtonProps, Menu, type MenuProps, type PaperDefaults, Provider, type ProviderProps, type RGB, type SeedColor, TextInput, type ThemeAppearance, type ThemeSettings, ThemeSettingsContext, type ThemeSettingsContextType, type ThemeState, type TriadicPalette, createThemeReducer, defaultColors, defaultThemeSettings, getBlendedColor, getHex, getRgb, getTintTextColor, getTonalColor, getTriadicPalette, isDarkColor, selectThemeAppearance, selectThemeBlur, selectThemeColor, selectThemeHarmony, themeActions, themeReducer, useBlur, useComputedTheme, usePaperDefaults, useThemeSettings };