@rific/auto-paper 0.9.2 → 0.9.4
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 +53 -4
- package/dist/index.d.mts +54 -34
- package/dist/index.d.ts +54 -34
- package/dist/index.js +350 -329
- package/dist/index.mjs +326 -308
- package/package.json +1 -1
- package/src/components/AutoAppearancePicker.tsx +17 -0
- package/src/components/AutoPalettePicker.tsx +21 -0
- package/src/components/HarmonyPicker.tsx +44 -34
- package/src/components/PalettePicker.tsx +14 -1
- package/src/index.ts +3 -0
- package/src/utils/resolveSeedColor.ts +8 -0
package/dist/index.mjs
CHANGED
|
@@ -68,20 +68,35 @@ var AppearancePicker = ({ value, onChange, showLabels = true, icons }) => {
|
|
|
68
68
|
return /* @__PURE__ */ jsx2(SegmentedButtons, { value, onValueChange: (v) => onChange(v), buttons: APPEARANCES.map((a) => ({ value: a.value, label: showLabels ? a.label : void 0, icon: resolvedIcons[a.value], accessibilityLabel: a.label })) });
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
-
// src/
|
|
72
|
-
import { useContext as
|
|
73
|
-
|
|
74
|
-
import { useTheme as useTheme2 } from "react-native-paper";
|
|
71
|
+
// src/useThemeSettings.ts
|
|
72
|
+
import { useContext as useContext3 } from "react";
|
|
73
|
+
var useThemeSettings = () => useContext3(ThemeSettingsContext);
|
|
75
74
|
|
|
76
|
-
// src/
|
|
77
|
-
import {
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
// src/components/AutoAppearancePicker.tsx
|
|
76
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
77
|
+
var AutoAppearancePicker = (props) => {
|
|
78
|
+
const { settings, set } = useThemeSettings();
|
|
79
|
+
return /* @__PURE__ */ jsx3(AppearancePicker, { ...props, value: settings.appearance, onChange: (appearance) => set({ appearance }) });
|
|
80
|
+
};
|
|
80
81
|
|
|
81
|
-
// src/
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
// src/utils/resolveSeedColor.ts
|
|
83
|
+
var resolveSeedColor = (color) => typeof color === "string" ? color : color.primary;
|
|
84
|
+
|
|
85
|
+
// src/components/PalettePicker.tsx
|
|
86
|
+
import { useState as useState6 } from "react";
|
|
87
|
+
import { StyleSheet as StyleSheet5, TouchableOpacity as TouchableOpacity2, View as View5 } from "react-native";
|
|
88
|
+
import { Icon as Icon2, TouchableRipple as TouchableRipple2, useTheme as useTheme5 } from "react-native-paper";
|
|
89
|
+
|
|
90
|
+
// src/useSwatchGrid.ts
|
|
91
|
+
import { useState } from "react";
|
|
92
|
+
var SWATCH_GRID_COLUMNS = 5;
|
|
93
|
+
var SWATCH_GRID_GAP = 12;
|
|
94
|
+
function useSwatchSize(fallback) {
|
|
95
|
+
const [width, setWidth] = useState(0);
|
|
96
|
+
const onLayout = ({ nativeEvent }) => setWidth(nativeEvent.layout.width);
|
|
97
|
+
const size = width > 0 ? (width - SWATCH_GRID_GAP * (SWATCH_GRID_COLUMNS - 1)) / SWATCH_GRID_COLUMNS : fallback;
|
|
98
|
+
return { onLayout, size };
|
|
99
|
+
}
|
|
85
100
|
|
|
86
101
|
// src/utils/colorNames.ts
|
|
87
102
|
var colorNames = {
|
|
@@ -281,6 +296,25 @@ var getRgb = (value) => {
|
|
|
281
296
|
return null;
|
|
282
297
|
};
|
|
283
298
|
|
|
299
|
+
// src/utils/isDarkColor.ts
|
|
300
|
+
var isDarkColor = (value) => {
|
|
301
|
+
const rgb = getRgb(value);
|
|
302
|
+
if (!rgb) return false;
|
|
303
|
+
const [r, g, b] = [rgb.r / 255, rgb.g / 255, rgb.b / 255];
|
|
304
|
+
const [rs, gs, bs] = [r, g, b].map((c) => c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4));
|
|
305
|
+
const luminance = 0.2126 * rs + 0.7152 * gs + 0.0722 * bs;
|
|
306
|
+
return luminance < 0.5;
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
// src/utils/getSwatchContrast.ts
|
|
310
|
+
var RING_WIDTH = 1;
|
|
311
|
+
var SELECTED_RING_WIDTH = 3;
|
|
312
|
+
var getContrastColor = (color) => isDarkColor(color) ? "#ffffff" : "#000000";
|
|
313
|
+
var getSwatchRing = (color, selected, outlineColor) => ({
|
|
314
|
+
borderColor: selected ? getContrastColor(color) : outlineColor,
|
|
315
|
+
borderWidth: selected ? SELECTED_RING_WIDTH : RING_WIDTH
|
|
316
|
+
});
|
|
317
|
+
|
|
284
318
|
// src/utils/getHex.ts
|
|
285
319
|
var getHex = (value) => {
|
|
286
320
|
const rgb = getRgb(value);
|
|
@@ -296,92 +330,6 @@ var getHex = (value) => {
|
|
|
296
330
|
return hexString;
|
|
297
331
|
};
|
|
298
332
|
|
|
299
|
-
// src/utils/getBlendedColor.ts
|
|
300
|
-
var getBlendedColor = (foreground, background, alpha) => {
|
|
301
|
-
const fg = getRgb(foreground);
|
|
302
|
-
const bg = getRgb(background);
|
|
303
|
-
if (!fg || !bg) return background;
|
|
304
|
-
const safeAlpha = Math.min(1, Math.max(0, alpha));
|
|
305
|
-
const r = Math.round(fg.r * safeAlpha + bg.r * (1 - safeAlpha));
|
|
306
|
-
const g = Math.round(fg.g * safeAlpha + bg.g * (1 - safeAlpha));
|
|
307
|
-
const b = Math.round(fg.b * safeAlpha + bg.b * (1 - safeAlpha));
|
|
308
|
-
return getHex(`rgb(${r}, ${g}, ${b})`) ?? background;
|
|
309
|
-
};
|
|
310
|
-
|
|
311
|
-
// src/utils/getTonalColor.ts
|
|
312
|
-
var getTonalColor = (color, lightness) => {
|
|
313
|
-
const rgb = getRgb(color);
|
|
314
|
-
if (!rgb) return color;
|
|
315
|
-
const r = rgb.r / 255;
|
|
316
|
-
const g = rgb.g / 255;
|
|
317
|
-
const b = rgb.b / 255;
|
|
318
|
-
const max = Math.max(r, g, b);
|
|
319
|
-
const min = Math.min(r, g, b);
|
|
320
|
-
const delta = max - min;
|
|
321
|
-
let h = 0;
|
|
322
|
-
if (delta !== 0) {
|
|
323
|
-
if (max === r) h = (g - b) / delta % 6;
|
|
324
|
-
else if (max === g) h = (b - r) / delta + 2;
|
|
325
|
-
else h = (r - g) / delta + 4;
|
|
326
|
-
h = (h * 60 + 360) % 360;
|
|
327
|
-
}
|
|
328
|
-
const l = (max + min) / 2;
|
|
329
|
-
const s = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));
|
|
330
|
-
const targetL = Math.min(1, Math.max(0, lightness));
|
|
331
|
-
const c = (1 - Math.abs(2 * targetL - 1)) * s;
|
|
332
|
-
const x = c * (1 - Math.abs(h / 60 % 2 - 1));
|
|
333
|
-
const m = targetL - c / 2;
|
|
334
|
-
let r2 = 0, g2 = 0, b2 = 0;
|
|
335
|
-
if (h < 60) {
|
|
336
|
-
r2 = c;
|
|
337
|
-
g2 = x;
|
|
338
|
-
b2 = 0;
|
|
339
|
-
} else if (h < 120) {
|
|
340
|
-
r2 = x;
|
|
341
|
-
g2 = c;
|
|
342
|
-
b2 = 0;
|
|
343
|
-
} else if (h < 180) {
|
|
344
|
-
r2 = 0;
|
|
345
|
-
g2 = c;
|
|
346
|
-
b2 = x;
|
|
347
|
-
} else if (h < 240) {
|
|
348
|
-
r2 = 0;
|
|
349
|
-
g2 = x;
|
|
350
|
-
b2 = c;
|
|
351
|
-
} else if (h < 300) {
|
|
352
|
-
r2 = x;
|
|
353
|
-
g2 = 0;
|
|
354
|
-
b2 = c;
|
|
355
|
-
} else {
|
|
356
|
-
r2 = c;
|
|
357
|
-
g2 = 0;
|
|
358
|
-
b2 = x;
|
|
359
|
-
}
|
|
360
|
-
const toInt = (n) => Math.round((n + m) * 255);
|
|
361
|
-
return getHex(`rgb(${toInt(r2)}, ${toInt(g2)}, ${toInt(b2)})`) ?? color;
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
// src/utils/isDarkColor.ts
|
|
365
|
-
var isDarkColor = (value) => {
|
|
366
|
-
const rgb = getRgb(value);
|
|
367
|
-
if (!rgb) return false;
|
|
368
|
-
const [r, g, b] = [rgb.r / 255, rgb.g / 255, rgb.b / 255];
|
|
369
|
-
const [rs, gs, bs] = [r, g, b].map((c) => c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4));
|
|
370
|
-
const luminance = 0.2126 * rs + 0.7152 * gs + 0.0722 * bs;
|
|
371
|
-
return luminance < 0.5;
|
|
372
|
-
};
|
|
373
|
-
|
|
374
|
-
// src/utils/getColorRoles.ts
|
|
375
|
-
var getColorRoles = (base, surface, containerAlpha = 0.15) => {
|
|
376
|
-
const container = getBlendedColor(base, surface, containerAlpha);
|
|
377
|
-
return {
|
|
378
|
-
color: base,
|
|
379
|
-
onColor: getTonalColor(base, isDarkColor(base) ? 0.95 : 0.08),
|
|
380
|
-
container,
|
|
381
|
-
onContainer: getTonalColor(base, isDarkColor(container) ? 0.92 : 0.12)
|
|
382
|
-
};
|
|
383
|
-
};
|
|
384
|
-
|
|
385
333
|
// src/utils/getTriadicPalette.ts
|
|
386
334
|
var HARMONY_OFFSETS = {
|
|
387
335
|
analogous: [1 / 12, 2 / 12],
|
|
@@ -463,6 +411,103 @@ function hslToHex(h, s, l) {
|
|
|
463
411
|
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
|
464
412
|
}
|
|
465
413
|
|
|
414
|
+
// src/components/ColorPicker.tsx
|
|
415
|
+
import { useState as useState5 } from "react";
|
|
416
|
+
import { StyleSheet as StyleSheet4, TouchableOpacity, View as View4 } from "react-native";
|
|
417
|
+
import { Icon, TouchableRipple, useTheme as useTheme4 } from "react-native-paper";
|
|
418
|
+
|
|
419
|
+
// src/components/Dialog.tsx
|
|
420
|
+
import React, { useEffect as useEffect3, useRef as useRef2, useState as useState4 } from "react";
|
|
421
|
+
import { Animated, BackHandler, Easing, Pressable, StyleSheet as StyleSheet3, View as View3 } from "react-native";
|
|
422
|
+
import { Dialog as PaperDialog, Portal, useTheme as useTheme3 } from "react-native-paper";
|
|
423
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
424
|
+
|
|
425
|
+
// src/ThemeProvider.tsx
|
|
426
|
+
import { createContext as createContext3, useCallback as useCallback2, useContext as useContext4, useEffect as useEffect2, useRef, useState as useState3 } from "react";
|
|
427
|
+
import { StatusBar as StatusBar2, StyleSheet, View } from "react-native";
|
|
428
|
+
import { Provider as PaperProvider } from "react-native-paper";
|
|
429
|
+
|
|
430
|
+
// src/useComputedTheme.ts
|
|
431
|
+
import { useCallback, useEffect, useState as useState2 } from "react";
|
|
432
|
+
import { Appearance } from "react-native";
|
|
433
|
+
import { MD3DarkTheme, MD3LightTheme } from "react-native-paper";
|
|
434
|
+
|
|
435
|
+
// src/utils/getBlendedColor.ts
|
|
436
|
+
var getBlendedColor = (foreground, background, alpha) => {
|
|
437
|
+
const fg = getRgb(foreground);
|
|
438
|
+
const bg = getRgb(background);
|
|
439
|
+
if (!fg || !bg) return background;
|
|
440
|
+
const safeAlpha = Math.min(1, Math.max(0, alpha));
|
|
441
|
+
const r = Math.round(fg.r * safeAlpha + bg.r * (1 - safeAlpha));
|
|
442
|
+
const g = Math.round(fg.g * safeAlpha + bg.g * (1 - safeAlpha));
|
|
443
|
+
const b = Math.round(fg.b * safeAlpha + bg.b * (1 - safeAlpha));
|
|
444
|
+
return getHex(`rgb(${r}, ${g}, ${b})`) ?? background;
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
// src/utils/getTonalColor.ts
|
|
448
|
+
var getTonalColor = (color, lightness) => {
|
|
449
|
+
const rgb = getRgb(color);
|
|
450
|
+
if (!rgb) return color;
|
|
451
|
+
const r = rgb.r / 255;
|
|
452
|
+
const g = rgb.g / 255;
|
|
453
|
+
const b = rgb.b / 255;
|
|
454
|
+
const max = Math.max(r, g, b);
|
|
455
|
+
const min = Math.min(r, g, b);
|
|
456
|
+
const delta = max - min;
|
|
457
|
+
let h = 0;
|
|
458
|
+
if (delta !== 0) {
|
|
459
|
+
if (max === r) h = (g - b) / delta % 6;
|
|
460
|
+
else if (max === g) h = (b - r) / delta + 2;
|
|
461
|
+
else h = (r - g) / delta + 4;
|
|
462
|
+
h = (h * 60 + 360) % 360;
|
|
463
|
+
}
|
|
464
|
+
const l = (max + min) / 2;
|
|
465
|
+
const s = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));
|
|
466
|
+
const targetL = Math.min(1, Math.max(0, lightness));
|
|
467
|
+
const c = (1 - Math.abs(2 * targetL - 1)) * s;
|
|
468
|
+
const x = c * (1 - Math.abs(h / 60 % 2 - 1));
|
|
469
|
+
const m = targetL - c / 2;
|
|
470
|
+
let r2 = 0, g2 = 0, b2 = 0;
|
|
471
|
+
if (h < 60) {
|
|
472
|
+
r2 = c;
|
|
473
|
+
g2 = x;
|
|
474
|
+
b2 = 0;
|
|
475
|
+
} else if (h < 120) {
|
|
476
|
+
r2 = x;
|
|
477
|
+
g2 = c;
|
|
478
|
+
b2 = 0;
|
|
479
|
+
} else if (h < 180) {
|
|
480
|
+
r2 = 0;
|
|
481
|
+
g2 = c;
|
|
482
|
+
b2 = x;
|
|
483
|
+
} else if (h < 240) {
|
|
484
|
+
r2 = 0;
|
|
485
|
+
g2 = x;
|
|
486
|
+
b2 = c;
|
|
487
|
+
} else if (h < 300) {
|
|
488
|
+
r2 = x;
|
|
489
|
+
g2 = 0;
|
|
490
|
+
b2 = c;
|
|
491
|
+
} else {
|
|
492
|
+
r2 = c;
|
|
493
|
+
g2 = 0;
|
|
494
|
+
b2 = x;
|
|
495
|
+
}
|
|
496
|
+
const toInt = (n) => Math.round((n + m) * 255);
|
|
497
|
+
return getHex(`rgb(${toInt(r2)}, ${toInt(g2)}, ${toInt(b2)})`) ?? color;
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
// src/utils/getColorRoles.ts
|
|
501
|
+
var getColorRoles = (base, surface, containerAlpha = 0.15) => {
|
|
502
|
+
const container = getBlendedColor(base, surface, containerAlpha);
|
|
503
|
+
return {
|
|
504
|
+
color: base,
|
|
505
|
+
onColor: getTonalColor(base, isDarkColor(base) ? 0.95 : 0.08),
|
|
506
|
+
container,
|
|
507
|
+
onContainer: getTonalColor(base, isDarkColor(container) ? 0.92 : 0.12)
|
|
508
|
+
};
|
|
509
|
+
};
|
|
510
|
+
|
|
466
511
|
// src/useComputedTheme.ts
|
|
467
512
|
function normalizeExplicitColor(value) {
|
|
468
513
|
if (!getRgb(value)) throw new Error(`Invalid color format: ${value}`);
|
|
@@ -474,7 +519,7 @@ var SEMANTIC_BASE_COLORS = {
|
|
|
474
519
|
danger: "#B00020"
|
|
475
520
|
};
|
|
476
521
|
function useComputedTheme(appearance, color, harmony = "split-complementary") {
|
|
477
|
-
const [theme, setTheme] =
|
|
522
|
+
const [theme, setTheme] = useState2(null);
|
|
478
523
|
const primaryInput = typeof color === "string" ? color : color.primary;
|
|
479
524
|
const secondaryInput = typeof color === "string" ? null : color.secondary;
|
|
480
525
|
const tertiaryInput = typeof color === "string" ? null : color.tertiary;
|
|
@@ -551,15 +596,15 @@ function useComputedTheme(appearance, color, harmony = "split-complementary") {
|
|
|
551
596
|
}
|
|
552
597
|
|
|
553
598
|
// src/ThemeProvider.tsx
|
|
554
|
-
import { jsx as
|
|
599
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
555
600
|
var NavBarContext = createContext3({});
|
|
556
|
-
var useNavBarContext = () =>
|
|
601
|
+
var useNavBarContext = () => useContext4(NavBarContext);
|
|
557
602
|
var BlurModuleContext = createContext3(void 0);
|
|
558
|
-
var useBlurModule = () =>
|
|
603
|
+
var useBlurModule = () => useContext4(BlurModuleContext);
|
|
559
604
|
var ReanimatedModuleContext = createContext3(void 0);
|
|
560
|
-
var useReanimatedModule = () =>
|
|
605
|
+
var useReanimatedModule = () => useContext4(ReanimatedModuleContext);
|
|
561
606
|
function Provider({ children, defaults, expoBlur, initialValue, navigationBar, onChange, onNavBarChange, onReady, reanimated, statusBarProps, style }) {
|
|
562
|
-
const [settings, setSettings] =
|
|
607
|
+
const [settings, setSettings] = useState3(() => ({ ...defaultThemeSettings, ...initialValue }));
|
|
563
608
|
const set = useCallback2((patch) => {
|
|
564
609
|
setSettings((prev) => ({ ...prev, ...patch }));
|
|
565
610
|
}, []);
|
|
@@ -581,9 +626,9 @@ function Provider({ children, defaults, expoBlur, initialValue, navigationBar, o
|
|
|
581
626
|
}
|
|
582
627
|
}, [theme, onReady]);
|
|
583
628
|
if (!theme) return null;
|
|
584
|
-
return /* @__PURE__ */
|
|
585
|
-
/* @__PURE__ */
|
|
586
|
-
/* @__PURE__ */
|
|
629
|
+
return /* @__PURE__ */ jsx4(ThemeSettingsContext.Provider, { value: { settings, set }, children: /* @__PURE__ */ jsxs2(PaperProvider, { theme, children: [
|
|
630
|
+
/* @__PURE__ */ jsx4(StatusBar2, { backgroundColor: theme.colors.background, barStyle: theme.dark ? "light-content" : "dark-content", ...statusBarProps }),
|
|
631
|
+
/* @__PURE__ */ jsx4(PaperDefaultsContext.Provider, { value: defaults ?? {}, children: /* @__PURE__ */ jsx4(NavBarContext.Provider, { value: { navigationBar, onNavBarChange }, children: /* @__PURE__ */ jsx4(BlurModuleContext.Provider, { value: expoBlur, children: /* @__PURE__ */ jsx4(ReanimatedModuleContext.Provider, { value: reanimated, children: /* @__PURE__ */ jsx4(View, { style: [styles.flex, { backgroundColor: theme.colors.background }, style], children }) }) }) }) })
|
|
587
632
|
] }) });
|
|
588
633
|
}
|
|
589
634
|
var styles = StyleSheet.create({
|
|
@@ -591,21 +636,24 @@ var styles = StyleSheet.create({
|
|
|
591
636
|
});
|
|
592
637
|
|
|
593
638
|
// src/components/BlurView.tsx
|
|
594
|
-
import {
|
|
639
|
+
import { useContext as useContext5 } from "react";
|
|
640
|
+
import { StyleSheet as StyleSheet2, View as View2 } from "react-native";
|
|
641
|
+
import { useTheme as useTheme2 } from "react-native-paper";
|
|
642
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
595
643
|
var ELEVATION_OPACITY = { 0: 0, 1: 0.05, 2: 0.08, 3: 0.11, 4: 0.12, 5: 0.14 };
|
|
596
644
|
var VARIANT_TINT_OPACITY = { light: 0.12, dark: 0.18 };
|
|
597
645
|
var BlurView = ({ blur = true, children, elevation, style, tintColor, tintOpacity, variant = "surface", ...props }) => {
|
|
598
646
|
const { dark, colors } = useTheme2();
|
|
599
|
-
const { settings } =
|
|
647
|
+
const { settings } = useContext5(ThemeSettingsContext);
|
|
600
648
|
const expoBlur = useBlurModule();
|
|
601
649
|
const surfaceColor = variant === "surfaceVariant" ? colors.surfaceVariant : colors.surface;
|
|
602
650
|
const variantColor = variant === "primary" ? colors.primary : variant === "secondary" ? colors.secondary : variant === "tertiary" ? colors.tertiary : variant === "error" ? colors.error : void 0;
|
|
603
651
|
const resolvedTintColor = tintColor ?? variantColor ?? (elevation !== void 0 ? colors.primary : void 0);
|
|
604
652
|
const resolvedTintOpacity = tintOpacity ?? (tintColor ? dark ? 0.24 : 0.16 : variantColor ? dark ? VARIANT_TINT_OPACITY.dark : VARIANT_TINT_OPACITY.light : elevation !== void 0 ? ELEVATION_OPACITY[elevation] : 0);
|
|
605
|
-
const tint = resolvedTintColor && resolvedTintOpacity > 0 ? /* @__PURE__ */
|
|
653
|
+
const tint = resolvedTintColor && resolvedTintOpacity > 0 ? /* @__PURE__ */ jsx5(View2, { style: [StyleSheet2.absoluteFill, { backgroundColor: resolvedTintColor, opacity: resolvedTintOpacity }] }) : null;
|
|
606
654
|
if (blur && expoBlur)
|
|
607
655
|
return /* @__PURE__ */ jsxs3(expoBlur.BlurView, { ...props, tint: dark ? "dark" : "light", style, children: [
|
|
608
|
-
/* @__PURE__ */
|
|
656
|
+
/* @__PURE__ */ jsx5(View2, { style: [StyleSheet2.absoluteFill, { backgroundColor: surfaceColor, opacity: settings.blurTint }] }),
|
|
609
657
|
tint,
|
|
610
658
|
children
|
|
611
659
|
] });
|
|
@@ -615,103 +663,20 @@ var BlurView = ({ blur = true, children, elevation, style, tintColor, tintOpacit
|
|
|
615
663
|
] });
|
|
616
664
|
};
|
|
617
665
|
|
|
618
|
-
// src/components/BottomNavigation.tsx
|
|
619
|
-
import { useEffect as useEffect3 } from "react";
|
|
620
|
-
import { Platform } from "react-native";
|
|
621
|
-
import { BottomNavigation as PaperBottomNavigation, useTheme as useTheme3 } from "react-native-paper";
|
|
622
|
-
|
|
623
|
-
// src/navigation-bar.ts
|
|
624
|
-
var setNavigationBarStyle = (navigationBar, dark) => {
|
|
625
|
-
if (!navigationBar) return;
|
|
626
|
-
navigationBar.NavigationBar.setStyle(dark ? "light" : "dark");
|
|
627
|
-
};
|
|
628
|
-
|
|
629
|
-
// src/components/BottomNavigation.tsx
|
|
630
|
-
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
631
|
-
function useNavigationBarSync() {
|
|
632
|
-
const theme = useTheme3();
|
|
633
|
-
const { navigationBar, onNavBarChange } = useNavBarContext();
|
|
634
|
-
useEffect3(() => {
|
|
635
|
-
if (Platform.OS !== "android") return;
|
|
636
|
-
if (onNavBarChange) onNavBarChange(theme.colors.surface, theme.dark);
|
|
637
|
-
else if (navigationBar) setNavigationBarStyle(navigationBar, theme.dark);
|
|
638
|
-
}, [theme, onNavBarChange, navigationBar]);
|
|
639
|
-
}
|
|
640
|
-
function BottomNavigationComponent(props) {
|
|
641
|
-
const defaults = usePaperDefaults();
|
|
642
|
-
useNavigationBarSync();
|
|
643
|
-
return /* @__PURE__ */ jsx5(PaperBottomNavigation, { ...defaults.BottomNavigation, ...props });
|
|
644
|
-
}
|
|
645
|
-
function Bar(props) {
|
|
646
|
-
useNavigationBarSync();
|
|
647
|
-
return /* @__PURE__ */ jsx5(PaperBottomNavigation.Bar, { ...props });
|
|
648
|
-
}
|
|
649
|
-
BottomNavigationComponent.Bar = Bar;
|
|
650
|
-
BottomNavigationComponent.SceneMap = PaperBottomNavigation?.SceneMap;
|
|
651
|
-
var BottomNavigation = BottomNavigationComponent;
|
|
652
|
-
|
|
653
|
-
// src/components/Button.tsx
|
|
654
|
-
import { Button as PaperButton } from "react-native-paper";
|
|
655
|
-
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
656
|
-
function Button(props) {
|
|
657
|
-
const defaults = usePaperDefaults();
|
|
658
|
-
return /* @__PURE__ */ jsx6(PaperButton, { ...defaults.Button, ...props });
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
// src/components/Chip.tsx
|
|
662
|
-
import { Chip as PaperChip, useTheme as useTheme4 } from "react-native-paper";
|
|
663
|
-
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
664
|
-
function Chip({ variant, style, selectedColor, ...props }) {
|
|
665
|
-
const defaults = usePaperDefaults();
|
|
666
|
-
const { colors } = useTheme4();
|
|
667
|
-
const variantStyle = variant === "primary" ? { backgroundColor: colors.primaryContainer } : variant === "secondary" ? { backgroundColor: colors.secondaryContainer } : variant === "tertiary" ? { backgroundColor: colors.tertiaryContainer } : variant === "surface" ? { backgroundColor: colors.surface } : void 0;
|
|
668
|
-
const variantSelectedColor = variant === "primary" ? colors.onPrimaryContainer : variant === "secondary" ? colors.onSecondaryContainer : variant === "tertiary" ? colors.onTertiaryContainer : variant === "surface" ? colors.onSurface : void 0;
|
|
669
|
-
return /* @__PURE__ */ jsx7(PaperChip, { ...defaults.Chip, selectedColor: selectedColor ?? variantSelectedColor, ...props, style: [variantStyle, style] });
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
// src/components/ColorPicker.tsx
|
|
673
|
-
import { useState as useState5 } from "react";
|
|
674
|
-
import { StyleSheet as StyleSheet4, TouchableOpacity, View as View4 } from "react-native";
|
|
675
|
-
import { Icon, TouchableRipple, useTheme as useTheme6 } from "react-native-paper";
|
|
676
|
-
|
|
677
|
-
// src/useSwatchGrid.ts
|
|
678
|
-
import { useState as useState3 } from "react";
|
|
679
|
-
var SWATCH_GRID_COLUMNS = 5;
|
|
680
|
-
var SWATCH_GRID_GAP = 12;
|
|
681
|
-
function useSwatchSize(fallback) {
|
|
682
|
-
const [width, setWidth] = useState3(0);
|
|
683
|
-
const onLayout = ({ nativeEvent }) => setWidth(nativeEvent.layout.width);
|
|
684
|
-
const size = width > 0 ? (width - SWATCH_GRID_GAP * (SWATCH_GRID_COLUMNS - 1)) / SWATCH_GRID_COLUMNS : fallback;
|
|
685
|
-
return { onLayout, size };
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
// src/utils/getSwatchContrast.ts
|
|
689
|
-
var RING_WIDTH = 1;
|
|
690
|
-
var SELECTED_RING_WIDTH = 3;
|
|
691
|
-
var getContrastColor = (color) => isDarkColor(color) ? "#ffffff" : "#000000";
|
|
692
|
-
var getSwatchRing = (color, selected, outlineColor) => ({
|
|
693
|
-
borderColor: selected ? getContrastColor(color) : outlineColor,
|
|
694
|
-
borderWidth: selected ? SELECTED_RING_WIDTH : RING_WIDTH
|
|
695
|
-
});
|
|
696
|
-
|
|
697
666
|
// src/components/Dialog.tsx
|
|
698
|
-
import
|
|
699
|
-
import { Animated, BackHandler, Easing, Pressable, StyleSheet as StyleSheet3, View as View3 } from "react-native";
|
|
700
|
-
import { Dialog as PaperDialog, Portal, useTheme as useTheme5 } from "react-native-paper";
|
|
701
|
-
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
702
|
-
import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
667
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
703
668
|
var ANIMATION_DURATION = 220;
|
|
704
669
|
var DIALOG_MARGIN = 32;
|
|
705
670
|
function DialogComponent({ animatedStyle, blur: blurProp, dismissable = true, dismissableBackButton = dismissable, visible, onDismiss, children, style, testID = "dialog" }) {
|
|
706
671
|
const blur = useBlur(blurProp);
|
|
707
672
|
const reanimated = useReanimatedModule();
|
|
708
|
-
const theme =
|
|
673
|
+
const theme = useTheme3();
|
|
709
674
|
const { colors, isV3, roundness } = theme;
|
|
710
675
|
const { scale } = theme.animation;
|
|
711
676
|
const { bottom, left, right, top } = useSafeAreaInsets();
|
|
712
677
|
const opacity = useRef2(new Animated.Value(visible ? 1 : 0)).current;
|
|
713
678
|
const [mounted, setMounted] = useState4(visible);
|
|
714
|
-
|
|
679
|
+
useEffect3(() => {
|
|
715
680
|
if (visible) {
|
|
716
681
|
setMounted(true);
|
|
717
682
|
Animated.timing(opacity, { duration: scale * ANIMATION_DURATION, easing: Easing.out(Easing.cubic), toValue: 1, useNativeDriver: true }).start();
|
|
@@ -721,7 +686,7 @@ function DialogComponent({ animatedStyle, blur: blurProp, dismissable = true, di
|
|
|
721
686
|
});
|
|
722
687
|
}
|
|
723
688
|
}, [visible]);
|
|
724
|
-
|
|
689
|
+
useEffect3(() => {
|
|
725
690
|
if (!visible) return void 0;
|
|
726
691
|
const onHardwareBackPress = () => {
|
|
727
692
|
if (dismissable || dismissableBackButton) onDismiss?.();
|
|
@@ -731,21 +696,21 @@ function DialogComponent({ animatedStyle, blur: blurProp, dismissable = true, di
|
|
|
731
696
|
return () => subscription.remove();
|
|
732
697
|
}, [dismissable, dismissableBackButton, onDismiss, visible]);
|
|
733
698
|
if (!mounted) return null;
|
|
734
|
-
const content =
|
|
699
|
+
const content = React.Children.toArray(children).filter((child) => child != null && typeof child !== "boolean").map((child, i) => {
|
|
735
700
|
if (isV3) {
|
|
736
|
-
if (i === 0 &&
|
|
737
|
-
return
|
|
701
|
+
if (i === 0 && React.isValidElement(child)) {
|
|
702
|
+
return React.cloneElement(child, { style: [{ marginTop: 24 }, child.props.style] });
|
|
738
703
|
}
|
|
739
704
|
}
|
|
740
|
-
if (i === 0 &&
|
|
741
|
-
return
|
|
705
|
+
if (i === 0 && React.isValidElement(child) && child.type === PaperDialog.Content) {
|
|
706
|
+
return React.cloneElement(child, { style: [{ paddingTop: 24 }, child.props.style] });
|
|
742
707
|
}
|
|
743
708
|
return child;
|
|
744
709
|
});
|
|
745
710
|
const borderRadius = (isV3 ? 7 : 1) * roundness;
|
|
746
|
-
return /* @__PURE__ */
|
|
747
|
-
/* @__PURE__ */
|
|
748
|
-
/* @__PURE__ */
|
|
711
|
+
return /* @__PURE__ */ jsx6(Portal, { children: /* @__PURE__ */ jsxs4(Animated.View, { accessibilityLiveRegion: "polite", accessibilityViewIsModal: true, pointerEvents: visible ? "box-none" : "none", style: [StyleSheet3.absoluteFill, { opacity }], testID, children: [
|
|
712
|
+
/* @__PURE__ */ jsx6(Pressable, { accessibilityLabel: "Close modal", accessibilityRole: "button", disabled: !dismissable, onPress: dismissable ? onDismiss : void 0, style: [StyleSheet3.absoluteFill, { backgroundColor: colors.backdrop }], testID: `${testID}-backdrop` }),
|
|
713
|
+
/* @__PURE__ */ jsx6(View3, { pointerEvents: "box-none", style: [styles2.wrapper, { marginBottom: bottom, marginTop: top, paddingHorizontal: Math.max(left, right, DIALOG_MARGIN) }], testID: `${testID}-wrapper`, children: reanimated && animatedStyle ? /* @__PURE__ */ jsx6(reanimated.View, { style: animatedStyle, testID: `${testID}-animated-wrapper`, children: /* @__PURE__ */ jsx6(BlurView, { blur, style: [styles2.card, { borderRadius }, style], testID: `${testID}-surface`, children: content }) }) : /* @__PURE__ */ jsx6(BlurView, { blur, style: [styles2.card, { borderRadius }, style], testID: `${testID}-surface`, children: content }) })
|
|
749
714
|
] }) });
|
|
750
715
|
}
|
|
751
716
|
DialogComponent.Title = PaperDialog.Title;
|
|
@@ -760,7 +725,7 @@ var styles2 = StyleSheet3.create({
|
|
|
760
725
|
});
|
|
761
726
|
|
|
762
727
|
// src/components/ColorPicker.tsx
|
|
763
|
-
import { Fragment as Fragment2, jsx as
|
|
728
|
+
import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
764
729
|
var SIZE = 48;
|
|
765
730
|
var defaultColors = [
|
|
766
731
|
{ label: "Red", value: "#f44336" },
|
|
@@ -786,12 +751,12 @@ var defaultColors = [
|
|
|
786
751
|
];
|
|
787
752
|
var ColorPicker = ({ value, onChange, colors = defaultColors, blur: blurProp }) => {
|
|
788
753
|
const blur = useBlur(blurProp);
|
|
789
|
-
const { colors: themeColors } =
|
|
754
|
+
const { colors: themeColors } = useTheme4();
|
|
790
755
|
const [open, setOpen] = useState5(false);
|
|
791
756
|
const { onLayout, size } = useSwatchSize(SIZE);
|
|
792
757
|
return /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
793
|
-
/* @__PURE__ */
|
|
794
|
-
/* @__PURE__ */
|
|
758
|
+
/* @__PURE__ */ jsx7(TouchableRipple, { onPress: () => setOpen(true), style: [styles3.trigger, { backgroundColor: value }, getSwatchRing(value, false, themeColors.outlineVariant)], borderless: true, children: /* @__PURE__ */ jsx7(Icon, { source: "palette", size: 20, color: getContrastColor(value) }) }),
|
|
759
|
+
/* @__PURE__ */ jsx7(Dialog, { blur, visible: open, onDismiss: () => setOpen(false), children: /* @__PURE__ */ jsx7(Dialog.Content, { children: /* @__PURE__ */ jsx7(View4, { style: styles3.swatches, onLayout, children: colors.map(({ value: hex }) => /* @__PURE__ */ jsx7(
|
|
795
760
|
TouchableOpacity,
|
|
796
761
|
{
|
|
797
762
|
onPress: () => {
|
|
@@ -799,7 +764,7 @@ var ColorPicker = ({ value, onChange, colors = defaultColors, blur: blurProp })
|
|
|
799
764
|
setOpen(false);
|
|
800
765
|
},
|
|
801
766
|
style: [styles3.swatch, { backgroundColor: hex, borderRadius: size / 2, height: size, width: size }, getSwatchRing(hex, value === hex, themeColors.outlineVariant)],
|
|
802
|
-
children: value === hex && /* @__PURE__ */
|
|
767
|
+
children: value === hex && /* @__PURE__ */ jsx7(Icon, { source: "check", size: 20, color: getContrastColor(hex) })
|
|
803
768
|
},
|
|
804
769
|
hex
|
|
805
770
|
)) }) }) })
|
|
@@ -811,35 +776,9 @@ var styles3 = StyleSheet4.create({
|
|
|
811
776
|
trigger: { alignItems: "center", alignSelf: "flex-start", borderRadius: SIZE / 2, height: SIZE, justifyContent: "center", width: SIZE }
|
|
812
777
|
});
|
|
813
778
|
|
|
814
|
-
// src/components/FAB.tsx
|
|
815
|
-
import { FAB as PaperFAB } from "react-native-paper";
|
|
816
|
-
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
817
|
-
function FAB(props) {
|
|
818
|
-
const defaults = usePaperDefaults();
|
|
819
|
-
return /* @__PURE__ */ jsx10(PaperFAB, { ...defaults.FAB, ...props });
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
// src/components/HarmonyPicker.tsx
|
|
823
|
-
import { useState as useState6 } from "react";
|
|
824
|
-
import { Button as Button2 } from "react-native-paper";
|
|
825
|
-
|
|
826
|
-
// src/components/Menu.tsx
|
|
827
|
-
import { StyleSheet as StyleSheet5 } from "react-native";
|
|
828
|
-
import { Menu as PaperMenu } from "react-native-paper";
|
|
829
|
-
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
830
|
-
var MenuComponent = ({ blur: blurProp, children, ...props }) => {
|
|
831
|
-
const blur = useBlur(blurProp);
|
|
832
|
-
return /* @__PURE__ */ jsx11(PaperMenu, { ...props, contentStyle: [styles4.content, props.contentStyle], children: /* @__PURE__ */ jsx11(BlurView, { blur, children }) });
|
|
833
|
-
};
|
|
834
|
-
var Menu = Object.assign(MenuComponent, {
|
|
835
|
-
Item: PaperMenu.Item
|
|
836
|
-
});
|
|
837
|
-
var styles4 = StyleSheet5.create({
|
|
838
|
-
content: { backgroundColor: "transparent", paddingVertical: 0 }
|
|
839
|
-
});
|
|
840
|
-
|
|
841
779
|
// src/components/HarmonyPicker.tsx
|
|
842
|
-
import {
|
|
780
|
+
import { SegmentedButtons as SegmentedButtons2 } from "react-native-paper";
|
|
781
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
843
782
|
var HARMONIES = [
|
|
844
783
|
{ label: "Triadic", value: "triadic", icon: "triangle-outline" },
|
|
845
784
|
{ label: "Split", value: "split-complementary", icon: "arrow-split-vertical" },
|
|
@@ -848,49 +787,30 @@ var HARMONIES = [
|
|
|
848
787
|
{ label: "Complement", value: "complementary", icon: "circle-half-full" },
|
|
849
788
|
{ label: "Dbl Split", value: "double-split", icon: "arrow-expand-horizontal" }
|
|
850
789
|
];
|
|
851
|
-
var
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
{
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
h.value
|
|
873
|
-
))
|
|
874
|
-
}
|
|
875
|
-
);
|
|
876
|
-
};
|
|
877
|
-
|
|
878
|
-
// src/components/IconButton.tsx
|
|
879
|
-
import { IconButton as PaperIconButton, useTheme as useTheme7 } from "react-native-paper";
|
|
880
|
-
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
881
|
-
function IconButton({ variant, iconColor, containerColor, ...props }) {
|
|
882
|
-
const defaults = usePaperDefaults();
|
|
883
|
-
const { colors } = useTheme7();
|
|
884
|
-
const variantContainerColor = variant === "primary" ? colors.primaryContainer : variant === "secondary" ? colors.secondaryContainer : variant === "tertiary" ? colors.tertiaryContainer : variant === "surface" ? colors.surface : void 0;
|
|
885
|
-
const variantIconColor = variant === "primary" ? colors.onPrimaryContainer : variant === "secondary" ? colors.onSecondaryContainer : variant === "tertiary" ? colors.onTertiaryContainer : variant === "surface" ? colors.onSurface : void 0;
|
|
886
|
-
return /* @__PURE__ */ jsx13(PaperIconButton, { ...defaults.IconButton, containerColor: containerColor ?? variantContainerColor, iconColor: iconColor ?? variantIconColor, ...props });
|
|
887
|
-
}
|
|
790
|
+
var COMPACT_MIN_WIDTH = 0;
|
|
791
|
+
var HarmonyPicker = ({ value, onChange, showLabels = true, checkedColor, uncheckedColor, checkedContainerColor, uncheckedContainerColor }) => /* @__PURE__ */ jsx8(
|
|
792
|
+
SegmentedButtons2,
|
|
793
|
+
{
|
|
794
|
+
value,
|
|
795
|
+
onValueChange: (v) => onChange(v),
|
|
796
|
+
buttons: HARMONIES.map((h) => {
|
|
797
|
+
const checked = h.value === value;
|
|
798
|
+
const containerColor = checked ? checkedContainerColor : uncheckedContainerColor;
|
|
799
|
+
return {
|
|
800
|
+
value: h.value,
|
|
801
|
+
icon: h.icon,
|
|
802
|
+
label: showLabels ? h.label : void 0,
|
|
803
|
+
accessibilityLabel: h.label,
|
|
804
|
+
checkedColor,
|
|
805
|
+
uncheckedColor,
|
|
806
|
+
style: [showLabels ? void 0 : { minWidth: COMPACT_MIN_WIDTH }, containerColor ? { backgroundColor: containerColor } : void 0]
|
|
807
|
+
};
|
|
808
|
+
})
|
|
809
|
+
}
|
|
810
|
+
);
|
|
888
811
|
|
|
889
812
|
// src/components/PalettePicker.tsx
|
|
890
|
-
import {
|
|
891
|
-
import { StyleSheet as StyleSheet6, TouchableOpacity as TouchableOpacity2, View as View5 } from "react-native";
|
|
892
|
-
import { Icon as Icon2, TouchableRipple as TouchableRipple2, useTheme as useTheme8 } from "react-native-paper";
|
|
893
|
-
import { Fragment as Fragment3, jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
813
|
+
import { Fragment as Fragment3, jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
894
814
|
var SIZE2 = 48;
|
|
895
815
|
var defaultWeights = { primary: 2, secondary: 1, tertiary: 1 };
|
|
896
816
|
var buildWedges = (weights) => {
|
|
@@ -904,36 +824,40 @@ var buildWedges = (weights) => {
|
|
|
904
824
|
{ key: "secondary", rotate: primary / 2 + tertiary, share: secondary }
|
|
905
825
|
];
|
|
906
826
|
};
|
|
907
|
-
var Pie = ({ palette, weights = defaultWeights, size = SIZE2 }) => /* @__PURE__ */
|
|
908
|
-
var PalettePicker = ({ value, onChange, harmony = "split-complementary", weights, colors = defaultColors, blur: blurProp }) => {
|
|
827
|
+
var Pie = ({ palette, weights = defaultWeights, size = SIZE2 }) => /* @__PURE__ */ jsx9(View5, { style: [styles4.pie, { borderRadius: size / 2, height: size, width: size }], children: buildWedges(weights).map(({ key, rotate, share }) => /* @__PURE__ */ jsx9(View5, { style: [styles4.rotator, { transform: [{ rotate: `${rotate}deg` }] }], children: /* @__PURE__ */ jsx9(View5, { style: styles4.halfMask, children: /* @__PURE__ */ jsx9(View5, { style: [styles4.innerRotator, { transform: [{ rotate: `${share - 180}deg` }] }], children: /* @__PURE__ */ jsx9(View5, { style: [styles4.wedgeFill, { backgroundColor: palette[key] }] }) }) }) }, key)) });
|
|
828
|
+
var PalettePicker = ({ value, onChange, harmony = "split-complementary", onHarmonyChange, weights, colors = defaultColors, blur: blurProp }) => {
|
|
909
829
|
const blur = useBlur(blurProp);
|
|
910
|
-
const { colors: themeColors } =
|
|
911
|
-
const [open, setOpen] =
|
|
830
|
+
const { colors: themeColors } = useTheme5();
|
|
831
|
+
const [open, setOpen] = useState6(false);
|
|
912
832
|
const { onLayout, size } = useSwatchSize(SIZE2);
|
|
913
833
|
return /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
|
914
|
-
/* @__PURE__ */
|
|
915
|
-
/* @__PURE__ */
|
|
916
|
-
/* @__PURE__ */
|
|
834
|
+
/* @__PURE__ */ jsx9(TouchableRipple2, { onPress: () => setOpen(true), style: styles4.trigger, borderless: true, children: /* @__PURE__ */ jsxs6(View5, { style: styles4.triggerContent, children: [
|
|
835
|
+
/* @__PURE__ */ jsx9(Pie, { palette: getTriadicPalette(value, harmony), weights }),
|
|
836
|
+
/* @__PURE__ */ jsx9(View5, { pointerEvents: "none", style: [styles4.triggerIcon, { borderRadius: SIZE2 / 2 }, getSwatchRing(value, false, themeColors.outlineVariant)], children: /* @__PURE__ */ jsx9(Icon2, { source: "palette", size: 20, color: getContrastColor(value) }) })
|
|
917
837
|
] }) }),
|
|
918
|
-
/* @__PURE__ */
|
|
919
|
-
|
|
920
|
-
{
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
838
|
+
/* @__PURE__ */ jsx9(Dialog, { blur, visible: open, onDismiss: () => setOpen(false), children: /* @__PURE__ */ jsxs6(Dialog.Content, { children: [
|
|
839
|
+
onHarmonyChange && /* @__PURE__ */ jsx9(View5, { style: styles4.harmonyRow, children: /* @__PURE__ */ jsx9(HarmonyPicker, { value: harmony, onChange: onHarmonyChange, showLabels: false }) }),
|
|
840
|
+
/* @__PURE__ */ jsx9(View5, { style: styles4.swatches, onLayout, children: colors.map(({ value: hex }) => /* @__PURE__ */ jsxs6(
|
|
841
|
+
TouchableOpacity2,
|
|
842
|
+
{
|
|
843
|
+
onPress: () => {
|
|
844
|
+
onChange(hex);
|
|
845
|
+
setOpen(false);
|
|
846
|
+
},
|
|
847
|
+
style: [styles4.swatch, { height: size, width: size }],
|
|
848
|
+
children: [
|
|
849
|
+
/* @__PURE__ */ jsx9(Pie, { palette: getTriadicPalette(hex, harmony), weights, size }),
|
|
850
|
+
/* @__PURE__ */ jsx9(View5, { pointerEvents: "none", style: [styles4.ring, { borderRadius: size / 2 }, getSwatchRing(hex, value === hex, themeColors.outlineVariant)], children: value === hex && /* @__PURE__ */ jsx9(Icon2, { source: "check", size: 20, color: getContrastColor(hex) }) })
|
|
851
|
+
]
|
|
924
852
|
},
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
/* @__PURE__ */ jsx14(View5, { pointerEvents: "none", style: [styles5.ring, { borderRadius: size / 2 }, getSwatchRing(hex, value === hex, themeColors.outlineVariant)], children: value === hex && /* @__PURE__ */ jsx14(Icon2, { source: "check", size: 20, color: getContrastColor(hex) }) })
|
|
929
|
-
]
|
|
930
|
-
},
|
|
931
|
-
hex
|
|
932
|
-
)) }) }) })
|
|
853
|
+
hex
|
|
854
|
+
)) })
|
|
855
|
+
] }) })
|
|
933
856
|
] });
|
|
934
857
|
};
|
|
935
|
-
var
|
|
858
|
+
var styles4 = StyleSheet5.create({
|
|
936
859
|
halfMask: { height: "100%", left: "50%", overflow: "hidden", position: "absolute", top: 0, width: "50%" },
|
|
860
|
+
harmonyRow: { marginBottom: 4 },
|
|
937
861
|
innerRotator: { height: "100%", left: "-100%", overflow: "hidden", position: "absolute", top: 0, width: "200%" },
|
|
938
862
|
pie: { overflow: "hidden" },
|
|
939
863
|
rotator: { height: "100%", left: 0, overflow: "hidden", position: "absolute", top: 0, width: "100%" },
|
|
@@ -946,13 +870,108 @@ var styles5 = StyleSheet6.create({
|
|
|
946
870
|
wedgeFill: { height: "100%", left: "50%", position: "absolute", top: 0, width: "50%" }
|
|
947
871
|
});
|
|
948
872
|
|
|
873
|
+
// src/components/AutoPalettePicker.tsx
|
|
874
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
875
|
+
var AutoPalettePicker = (props) => {
|
|
876
|
+
const { settings, set } = useThemeSettings();
|
|
877
|
+
return /* @__PURE__ */ jsx10(PalettePicker, { ...props, value: resolveSeedColor(settings.color), onChange: (color) => set({ color }), harmony: settings.harmony, onHarmonyChange: (harmony) => set({ harmony }) });
|
|
878
|
+
};
|
|
879
|
+
|
|
880
|
+
// src/components/BottomNavigation.tsx
|
|
881
|
+
import { useEffect as useEffect4 } from "react";
|
|
882
|
+
import { Platform } from "react-native";
|
|
883
|
+
import { BottomNavigation as PaperBottomNavigation, useTheme as useTheme6 } from "react-native-paper";
|
|
884
|
+
|
|
885
|
+
// src/navigation-bar.ts
|
|
886
|
+
var setNavigationBarStyle = (navigationBar, dark) => {
|
|
887
|
+
if (!navigationBar) return;
|
|
888
|
+
navigationBar.NavigationBar.setStyle(dark ? "light" : "dark");
|
|
889
|
+
};
|
|
890
|
+
|
|
891
|
+
// src/components/BottomNavigation.tsx
|
|
892
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
893
|
+
function useNavigationBarSync() {
|
|
894
|
+
const theme = useTheme6();
|
|
895
|
+
const { navigationBar, onNavBarChange } = useNavBarContext();
|
|
896
|
+
useEffect4(() => {
|
|
897
|
+
if (Platform.OS !== "android") return;
|
|
898
|
+
if (onNavBarChange) onNavBarChange(theme.colors.surface, theme.dark);
|
|
899
|
+
else if (navigationBar) setNavigationBarStyle(navigationBar, theme.dark);
|
|
900
|
+
}, [theme, onNavBarChange, navigationBar]);
|
|
901
|
+
}
|
|
902
|
+
function BottomNavigationComponent(props) {
|
|
903
|
+
const defaults = usePaperDefaults();
|
|
904
|
+
useNavigationBarSync();
|
|
905
|
+
return /* @__PURE__ */ jsx11(PaperBottomNavigation, { ...defaults.BottomNavigation, ...props });
|
|
906
|
+
}
|
|
907
|
+
function Bar(props) {
|
|
908
|
+
useNavigationBarSync();
|
|
909
|
+
return /* @__PURE__ */ jsx11(PaperBottomNavigation.Bar, { ...props });
|
|
910
|
+
}
|
|
911
|
+
BottomNavigationComponent.Bar = Bar;
|
|
912
|
+
BottomNavigationComponent.SceneMap = PaperBottomNavigation?.SceneMap;
|
|
913
|
+
var BottomNavigation = BottomNavigationComponent;
|
|
914
|
+
|
|
915
|
+
// src/components/Button.tsx
|
|
916
|
+
import { Button as PaperButton } from "react-native-paper";
|
|
917
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
918
|
+
function Button(props) {
|
|
919
|
+
const defaults = usePaperDefaults();
|
|
920
|
+
return /* @__PURE__ */ jsx12(PaperButton, { ...defaults.Button, ...props });
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
// src/components/Chip.tsx
|
|
924
|
+
import { Chip as PaperChip, useTheme as useTheme7 } from "react-native-paper";
|
|
925
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
926
|
+
function Chip({ variant, style, selectedColor, ...props }) {
|
|
927
|
+
const defaults = usePaperDefaults();
|
|
928
|
+
const { colors } = useTheme7();
|
|
929
|
+
const variantStyle = variant === "primary" ? { backgroundColor: colors.primaryContainer } : variant === "secondary" ? { backgroundColor: colors.secondaryContainer } : variant === "tertiary" ? { backgroundColor: colors.tertiaryContainer } : variant === "surface" ? { backgroundColor: colors.surface } : void 0;
|
|
930
|
+
const variantSelectedColor = variant === "primary" ? colors.onPrimaryContainer : variant === "secondary" ? colors.onSecondaryContainer : variant === "tertiary" ? colors.onTertiaryContainer : variant === "surface" ? colors.onSurface : void 0;
|
|
931
|
+
return /* @__PURE__ */ jsx13(PaperChip, { ...defaults.Chip, selectedColor: selectedColor ?? variantSelectedColor, ...props, style: [variantStyle, style] });
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
// src/components/FAB.tsx
|
|
935
|
+
import { FAB as PaperFAB } from "react-native-paper";
|
|
936
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
937
|
+
function FAB(props) {
|
|
938
|
+
const defaults = usePaperDefaults();
|
|
939
|
+
return /* @__PURE__ */ jsx14(PaperFAB, { ...defaults.FAB, ...props });
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
// src/components/IconButton.tsx
|
|
943
|
+
import { IconButton as PaperIconButton, useTheme as useTheme8 } from "react-native-paper";
|
|
944
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
945
|
+
function IconButton({ variant, iconColor, containerColor, ...props }) {
|
|
946
|
+
const defaults = usePaperDefaults();
|
|
947
|
+
const { colors } = useTheme8();
|
|
948
|
+
const variantContainerColor = variant === "primary" ? colors.primaryContainer : variant === "secondary" ? colors.secondaryContainer : variant === "tertiary" ? colors.tertiaryContainer : variant === "surface" ? colors.surface : void 0;
|
|
949
|
+
const variantIconColor = variant === "primary" ? colors.onPrimaryContainer : variant === "secondary" ? colors.onSecondaryContainer : variant === "tertiary" ? colors.onTertiaryContainer : variant === "surface" ? colors.onSurface : void 0;
|
|
950
|
+
return /* @__PURE__ */ jsx15(PaperIconButton, { ...defaults.IconButton, containerColor: containerColor ?? variantContainerColor, iconColor: iconColor ?? variantIconColor, ...props });
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
// src/components/Menu.tsx
|
|
954
|
+
import { StyleSheet as StyleSheet6 } from "react-native";
|
|
955
|
+
import { Menu as PaperMenu } from "react-native-paper";
|
|
956
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
957
|
+
var MenuComponent = ({ blur: blurProp, children, ...props }) => {
|
|
958
|
+
const blur = useBlur(blurProp);
|
|
959
|
+
return /* @__PURE__ */ jsx16(PaperMenu, { ...props, contentStyle: [styles5.content, props.contentStyle], children: /* @__PURE__ */ jsx16(BlurView, { blur, children }) });
|
|
960
|
+
};
|
|
961
|
+
var Menu = Object.assign(MenuComponent, {
|
|
962
|
+
Item: PaperMenu.Item
|
|
963
|
+
});
|
|
964
|
+
var styles5 = StyleSheet6.create({
|
|
965
|
+
content: { backgroundColor: "transparent", paddingVertical: 0 }
|
|
966
|
+
});
|
|
967
|
+
|
|
949
968
|
// src/components/TextInput.tsx
|
|
950
969
|
import { forwardRef } from "react";
|
|
951
970
|
import { TextInput as PaperTextInput } from "react-native-paper";
|
|
952
|
-
import { jsx as
|
|
971
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
953
972
|
var TextInput = forwardRef(function TextInput2(props, ref) {
|
|
954
973
|
const defaults = usePaperDefaults();
|
|
955
|
-
return /* @__PURE__ */
|
|
974
|
+
return /* @__PURE__ */ jsx17(PaperTextInput, { ref, ...defaults.TextInput, ...props });
|
|
956
975
|
});
|
|
957
976
|
|
|
958
977
|
// src/redux/themeSlice.ts
|
|
@@ -996,10 +1015,6 @@ var selectThemeHarmony = (state) => state.harmony;
|
|
|
996
1015
|
import { useTheme as usePaperTheme } from "react-native-paper";
|
|
997
1016
|
var useAutoPaperTheme = () => usePaperTheme();
|
|
998
1017
|
|
|
999
|
-
// src/useThemeSettings.ts
|
|
1000
|
-
import { useContext as useContext5 } from "react";
|
|
1001
|
-
var useThemeSettings = () => useContext5(ThemeSettingsContext);
|
|
1002
|
-
|
|
1003
1018
|
// src/utils/getThirdColor.ts
|
|
1004
1019
|
function rgbToHsl(r, g, b) {
|
|
1005
1020
|
r /= 255;
|
|
@@ -1084,6 +1099,8 @@ var getTintTextColor = (tintColor, backdropColor, tintOpacity) => {
|
|
|
1084
1099
|
export {
|
|
1085
1100
|
Appbar,
|
|
1086
1101
|
AppearancePicker,
|
|
1102
|
+
AutoAppearancePicker,
|
|
1103
|
+
AutoPalettePicker,
|
|
1087
1104
|
BlurView,
|
|
1088
1105
|
BottomNavigation,
|
|
1089
1106
|
Button,
|
|
@@ -1112,6 +1129,7 @@ export {
|
|
|
1112
1129
|
getTonalColor,
|
|
1113
1130
|
getTriadicPalette,
|
|
1114
1131
|
isDarkColor,
|
|
1132
|
+
resolveSeedColor,
|
|
1115
1133
|
selectThemeAppearance,
|
|
1116
1134
|
selectThemeBlur,
|
|
1117
1135
|
selectThemeColor,
|