@fluxus-ui/native 0.0.0-stage → 0.3.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/LICENSE +21 -0
- package/README.md +75 -2
- package/lib/module/AudioPlayer.js +174 -0
- package/lib/module/AudioPlayer.js.map +1 -0
- package/lib/module/Avatar.js +58 -0
- package/lib/module/Avatar.js.map +1 -0
- package/lib/module/Badge.js +72 -0
- package/lib/module/Badge.js.map +1 -0
- package/lib/module/BottomSheet.js +159 -0
- package/lib/module/BottomSheet.js.map +1 -0
- package/lib/module/Bubble.js +182 -0
- package/lib/module/Bubble.js.map +1 -0
- package/lib/module/Button.js +209 -0
- package/lib/module/Button.js.map +1 -0
- package/lib/module/Card.js +79 -0
- package/lib/module/Card.js.map +1 -0
- package/lib/module/Dialog.js +137 -0
- package/lib/module/Dialog.js.map +1 -0
- package/lib/module/Disclosure.js +153 -0
- package/lib/module/Disclosure.js.map +1 -0
- package/lib/module/EmptyState.js +71 -0
- package/lib/module/EmptyState.js.map +1 -0
- package/lib/module/Link.js +97 -0
- package/lib/module/Link.js.map +1 -0
- package/lib/module/ListItem.js +89 -0
- package/lib/module/ListItem.js.map +1 -0
- package/lib/module/Menu.js +76 -0
- package/lib/module/Menu.js.map +1 -0
- package/lib/module/Message.js +51 -0
- package/lib/module/Message.js.map +1 -0
- package/lib/module/Popover.js +153 -0
- package/lib/module/Popover.js.map +1 -0
- package/lib/module/Progress.js +54 -0
- package/lib/module/Progress.js.map +1 -0
- package/lib/module/Select.js +146 -0
- package/lib/module/Select.js.map +1 -0
- package/lib/module/Skeleton.js +40 -0
- package/lib/module/Skeleton.js.map +1 -0
- package/lib/module/Slider.js +137 -0
- package/lib/module/Slider.js.map +1 -0
- package/lib/module/Spinner.js +30 -0
- package/lib/module/Spinner.js.map +1 -0
- package/lib/module/Swap.js +87 -0
- package/lib/module/Swap.js.map +1 -0
- package/lib/module/Tabs.js +118 -0
- package/lib/module/Tabs.js.map +1 -0
- package/lib/module/Text.js +47 -0
- package/lib/module/Text.js.map +1 -0
- package/lib/module/TextField.js +190 -0
- package/lib/module/TextField.js.map +1 -0
- package/lib/module/Toast.js +157 -0
- package/lib/module/Toast.js.map +1 -0
- package/lib/module/audio.js +54 -0
- package/lib/module/audio.js.map +1 -0
- package/lib/module/blur.js +55 -0
- package/lib/module/blur.js.map +1 -0
- package/lib/module/controls.js +292 -0
- package/lib/module/controls.js.map +1 -0
- package/lib/module/feel.js +24 -0
- package/lib/module/feel.js.map +1 -0
- package/lib/module/generated/tokens.js +484 -0
- package/lib/module/generated/tokens.js.map +1 -0
- package/lib/module/haptics.js +25 -0
- package/lib/module/haptics.js.map +1 -0
- package/lib/module/icon-host.js +42 -0
- package/lib/module/icon-host.js.map +1 -0
- package/lib/module/icon-shape.js +222 -0
- package/lib/module/icon-shape.js.map +1 -0
- package/lib/module/icon.js +331 -0
- package/lib/module/icon.js.map +1 -0
- package/lib/module/index.js +39 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/layout.js +75 -0
- package/lib/module/layout.js.map +1 -0
- package/lib/module/marks.js +99 -0
- package/lib/module/marks.js.map +1 -0
- package/lib/module/motion.js +95 -0
- package/lib/module/motion.js.map +1 -0
- package/lib/module/overlay.js +99 -0
- package/lib/module/overlay.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/pending.js +181 -0
- package/lib/module/pending.js.map +1 -0
- package/lib/module/presence.js +71 -0
- package/lib/module/presence.js.map +1 -0
- package/lib/module/press.js +32 -0
- package/lib/module/press.js.map +1 -0
- package/lib/module/screen.js +50 -0
- package/lib/module/screen.js.map +1 -0
- package/lib/module/success.js +59 -0
- package/lib/module/success.js.map +1 -0
- package/lib/module/theme.js +41 -0
- package/lib/module/theme.js.map +1 -0
- package/lib/typescript/AudioPlayer.d.ts +26 -0
- package/lib/typescript/AudioPlayer.d.ts.map +1 -0
- package/lib/typescript/Avatar.d.ts +17 -0
- package/lib/typescript/Avatar.d.ts.map +1 -0
- package/lib/typescript/Badge.d.ts +21 -0
- package/lib/typescript/Badge.d.ts.map +1 -0
- package/lib/typescript/BottomSheet.d.ts +27 -0
- package/lib/typescript/BottomSheet.d.ts.map +1 -0
- package/lib/typescript/Bubble.d.ts +23 -0
- package/lib/typescript/Bubble.d.ts.map +1 -0
- package/lib/typescript/Button.d.ts +29 -0
- package/lib/typescript/Button.d.ts.map +1 -0
- package/lib/typescript/Card.d.ts +17 -0
- package/lib/typescript/Card.d.ts.map +1 -0
- package/lib/typescript/Dialog.d.ts +34 -0
- package/lib/typescript/Dialog.d.ts.map +1 -0
- package/lib/typescript/Disclosure.d.ts +39 -0
- package/lib/typescript/Disclosure.d.ts.map +1 -0
- package/lib/typescript/EmptyState.d.ts +14 -0
- package/lib/typescript/EmptyState.d.ts.map +1 -0
- package/lib/typescript/Link.d.ts +23 -0
- package/lib/typescript/Link.d.ts.map +1 -0
- package/lib/typescript/ListItem.d.ts +20 -0
- package/lib/typescript/ListItem.d.ts.map +1 -0
- package/lib/typescript/Menu.d.ts +23 -0
- package/lib/typescript/Menu.d.ts.map +1 -0
- package/lib/typescript/Message.d.ts +14 -0
- package/lib/typescript/Message.d.ts.map +1 -0
- package/lib/typescript/Popover.d.ts +71 -0
- package/lib/typescript/Popover.d.ts.map +1 -0
- package/lib/typescript/Progress.d.ts +12 -0
- package/lib/typescript/Progress.d.ts.map +1 -0
- package/lib/typescript/Select.d.ts +30 -0
- package/lib/typescript/Select.d.ts.map +1 -0
- package/lib/typescript/Skeleton.d.ts +13 -0
- package/lib/typescript/Skeleton.d.ts.map +1 -0
- package/lib/typescript/Slider.d.ts +21 -0
- package/lib/typescript/Slider.d.ts.map +1 -0
- package/lib/typescript/Spinner.d.ts +12 -0
- package/lib/typescript/Spinner.d.ts.map +1 -0
- package/lib/typescript/Swap.d.ts +25 -0
- package/lib/typescript/Swap.d.ts.map +1 -0
- package/lib/typescript/Tabs.d.ts +18 -0
- package/lib/typescript/Tabs.d.ts.map +1 -0
- package/lib/typescript/Text.d.ts +20 -0
- package/lib/typescript/Text.d.ts.map +1 -0
- package/lib/typescript/TextField.d.ts +36 -0
- package/lib/typescript/TextField.d.ts.map +1 -0
- package/lib/typescript/Toast.d.ts +25 -0
- package/lib/typescript/Toast.d.ts.map +1 -0
- package/lib/typescript/audio.d.ts +10 -0
- package/lib/typescript/audio.d.ts.map +1 -0
- package/lib/typescript/blur.d.ts +4 -0
- package/lib/typescript/blur.d.ts.map +1 -0
- package/lib/typescript/controls.d.ts +37 -0
- package/lib/typescript/controls.d.ts.map +1 -0
- package/lib/typescript/feel.d.ts +10 -0
- package/lib/typescript/feel.d.ts.map +1 -0
- package/lib/typescript/generated/tokens.d.ts +499 -0
- package/lib/typescript/generated/tokens.d.ts.map +1 -0
- package/lib/typescript/haptics.d.ts +7 -0
- package/lib/typescript/haptics.d.ts.map +1 -0
- package/lib/typescript/icon-host.d.ts +30 -0
- package/lib/typescript/icon-host.d.ts.map +1 -0
- package/lib/typescript/icon-shape.d.ts +28 -0
- package/lib/typescript/icon-shape.d.ts.map +1 -0
- package/lib/typescript/icon.d.ts +24 -0
- package/lib/typescript/icon.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +37 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/layout.d.ts +24 -0
- package/lib/typescript/layout.d.ts.map +1 -0
- package/lib/typescript/marks.d.ts +23 -0
- package/lib/typescript/marks.d.ts.map +1 -0
- package/lib/typescript/motion.d.ts +30 -0
- package/lib/typescript/motion.d.ts.map +1 -0
- package/lib/typescript/overlay.d.ts +33 -0
- package/lib/typescript/overlay.d.ts.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/pending.d.ts +26 -0
- package/lib/typescript/pending.d.ts.map +1 -0
- package/lib/typescript/presence.d.ts +37 -0
- package/lib/typescript/presence.d.ts.map +1 -0
- package/lib/typescript/press.d.ts +12 -0
- package/lib/typescript/press.d.ts.map +1 -0
- package/lib/typescript/screen.d.ts +21 -0
- package/lib/typescript/screen.d.ts.map +1 -0
- package/lib/typescript/success.d.ts +13 -0
- package/lib/typescript/success.d.ts.map +1 -0
- package/lib/typescript/theme.d.ts +32 -0
- package/lib/typescript/theme.d.ts.map +1 -0
- package/package.json +123 -3
- package/src/AudioPlayer.tsx +106 -0
- package/src/Avatar.tsx +44 -0
- package/src/Badge.tsx +45 -0
- package/src/BottomSheet.tsx +109 -0
- package/src/Bubble.tsx +112 -0
- package/src/Button.tsx +168 -0
- package/src/Card.tsx +70 -0
- package/src/Dialog.tsx +93 -0
- package/src/Disclosure.tsx +108 -0
- package/src/EmptyState.tsx +51 -0
- package/src/Link.tsx +61 -0
- package/src/ListItem.tsx +78 -0
- package/src/Menu.tsx +57 -0
- package/src/Message.tsx +43 -0
- package/src/Popover.tsx +145 -0
- package/src/Progress.tsx +33 -0
- package/src/Select.tsx +118 -0
- package/src/Skeleton.tsx +28 -0
- package/src/Slider.tsx +107 -0
- package/src/Spinner.tsx +18 -0
- package/src/Swap.tsx +74 -0
- package/src/Tabs.tsx +84 -0
- package/src/Text.tsx +44 -0
- package/src/TextField.tsx +137 -0
- package/src/Toast.tsx +122 -0
- package/src/audio.tsx +56 -0
- package/src/blur.tsx +33 -0
- package/src/controls.tsx +224 -0
- package/src/feel.ts +22 -0
- package/src/generated/tokens.ts +653 -0
- package/src/haptics.tsx +26 -0
- package/src/icon-host.tsx +46 -0
- package/src/icon-shape.ts +213 -0
- package/src/icon.tsx +276 -0
- package/src/index.ts +36 -0
- package/src/layout.tsx +40 -0
- package/src/marks.tsx +79 -0
- package/src/motion.ts +94 -0
- package/src/overlay.tsx +77 -0
- package/src/pending.tsx +135 -0
- package/src/presence.tsx +68 -0
- package/src/press.ts +23 -0
- package/src/screen.tsx +37 -0
- package/src/success.tsx +48 -0
- package/src/theme.tsx +49 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A title that shows or hides what is under it. The one piece that animates a height: what is below it has to
|
|
3
|
+
* travel with it, whatever it is. One at a time, and by a press. `Accordion` is a group of them. (SPEC §15.8)
|
|
4
|
+
*/
|
|
5
|
+
import { useEffect, useState, type ReactNode } from 'react';
|
|
6
|
+
import { Pressable, View, type StyleProp, type ViewProps, type ViewStyle } from 'react-native';
|
|
7
|
+
import Animated, { useAnimatedStyle, useSharedValue, type SharedValue } from 'react-native-reanimated';
|
|
8
|
+
import { useControlled } from './controls';
|
|
9
|
+
import { Divider, fill } from './layout';
|
|
10
|
+
import { spring } from './motion';
|
|
11
|
+
import { Text } from './Text';
|
|
12
|
+
import { useTheme } from './theme';
|
|
13
|
+
|
|
14
|
+
/** An arrow drawn with two edges, without an icon: it points down at 0 and up at 1. */
|
|
15
|
+
export function Chevron({ t, color }: { t?: SharedValue<number>; color?: string }) {
|
|
16
|
+
const theme = useTheme();
|
|
17
|
+
const side = theme.size['space.2'];
|
|
18
|
+
const turn = useAnimatedStyle(() => ({ transform: [{ rotate: `${45 + 180 * (t?.value ?? 0)}deg` }] }));
|
|
19
|
+
const edges: ViewStyle = { width: side, height: side, borderColor: color ?? theme.color['text.muted'], borderEndWidth: 2, borderBottomWidth: 2 };
|
|
20
|
+
return (
|
|
21
|
+
<View aria-hidden importantForAccessibility="no" style={{ width: theme.size['icon.md'], height: theme.size['icon.md'], alignItems: 'center', justifyContent: 'center' }}>
|
|
22
|
+
{/* One that never turns is not an animated view. */}
|
|
23
|
+
{t ? <Animated.View style={[edges, turn]} /> : <View style={[edges, { transform: [{ rotate: '45deg' }] }]} />}
|
|
24
|
+
</View>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface DisclosureProps {
|
|
29
|
+
title: string;
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
/** It holds its own state from here. Default: false. */
|
|
32
|
+
defaultOpen?: boolean;
|
|
33
|
+
/** Or the app does. */
|
|
34
|
+
open?: boolean;
|
|
35
|
+
onOpenChange?: (open: boolean) => void;
|
|
36
|
+
style?: StyleProp<ViewStyle>;
|
|
37
|
+
testID?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function Disclosure({ title, children, defaultOpen = false, open, onOpenChange, style, testID }: DisclosureProps) {
|
|
41
|
+
const theme = useTheme();
|
|
42
|
+
const [on, set] = useControlled(open, defaultOpen, onOpenChange);
|
|
43
|
+
const [height, setHeight] = useState(0);
|
|
44
|
+
const t = useSharedValue(on ? 1 : 0);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
t.value = spring(on ? 1 : 0, 'smooth');
|
|
47
|
+
}, [on, t]);
|
|
48
|
+
// Until it is measured, an open one is as tall as what it holds and a closed one has no height.
|
|
49
|
+
const body = useAnimatedStyle(() => (height ? { opacity: t.value, height: height * t.value } : { opacity: t.value }));
|
|
50
|
+
const measured = height > 0 || !on;
|
|
51
|
+
return (
|
|
52
|
+
<View style={style}>
|
|
53
|
+
<Pressable
|
|
54
|
+
role="button"
|
|
55
|
+
aria-expanded={on}
|
|
56
|
+
testID={testID}
|
|
57
|
+
onPress={() => set(!on)}
|
|
58
|
+
style={({ pressed }) => [{ minHeight: theme.size['target.min'], flexDirection: 'row', alignItems: 'center', gap: theme.size['space.3'], paddingBlock: theme.size['space.2'] }, pressed ? { backgroundColor: theme.color['surface.hover'] } : null]}
|
|
59
|
+
>
|
|
60
|
+
<Text variant="label" style={fill}>
|
|
61
|
+
{title}
|
|
62
|
+
</Text>
|
|
63
|
+
<Chevron t={t} />
|
|
64
|
+
</Pressable>
|
|
65
|
+
<Animated.View aria-hidden={!on} pointerEvents={on ? 'auto' : 'none'} style={[{ overflow: 'hidden' }, height || on ? null : { height: 0 }, body]}>
|
|
66
|
+
<View onLayout={(e) => setHeight(e.nativeEvent.layout.height)} style={[{ paddingBottom: theme.size['space.3'] }, measured ? { position: 'absolute', top: 0, start: 0, end: 0 } : null]}>
|
|
67
|
+
{children}
|
|
68
|
+
</View>
|
|
69
|
+
</Animated.View>
|
|
70
|
+
</View>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface AccordionItem {
|
|
75
|
+
key: string;
|
|
76
|
+
title: string;
|
|
77
|
+
content: ReactNode;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface AccordionProps extends Omit<ViewProps, 'children'> {
|
|
81
|
+
items: readonly AccordionItem[];
|
|
82
|
+
/** Several may be open at once. Default: opening one closes the others. */
|
|
83
|
+
multiple?: boolean;
|
|
84
|
+
/** The keys of the ones open at first. */
|
|
85
|
+
defaultOpen?: readonly string[];
|
|
86
|
+
onChange?: (open: readonly string[]) => void;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function Accordion({ items, multiple = false, defaultOpen = [], onChange, ...rest }: AccordionProps) {
|
|
90
|
+
const [open, setOpen] = useState(defaultOpen);
|
|
91
|
+
const toggle = (key: string, on: boolean): void => {
|
|
92
|
+
const next = on ? (multiple ? [...open, key] : [key]) : open.filter((k) => k !== key);
|
|
93
|
+
setOpen(next);
|
|
94
|
+
onChange?.(next);
|
|
95
|
+
};
|
|
96
|
+
return (
|
|
97
|
+
<View {...rest}>
|
|
98
|
+
{items.map((item, index) => (
|
|
99
|
+
<View key={item.key}>
|
|
100
|
+
{index > 0 && <Divider />}
|
|
101
|
+
<Disclosure title={item.title} open={open.includes(item.key)} onOpenChange={(on) => toggle(item.key, on)}>
|
|
102
|
+
{item.content}
|
|
103
|
+
</Disclosure>
|
|
104
|
+
</View>
|
|
105
|
+
))}
|
|
106
|
+
</View>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useEffect, type ReactNode } from 'react';
|
|
2
|
+
import { View, type ViewProps } from 'react-native';
|
|
3
|
+
import Animated, { useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
|
|
4
|
+
import { spring } from './motion';
|
|
5
|
+
import { Text } from './Text';
|
|
6
|
+
import { useTheme } from './theme';
|
|
7
|
+
|
|
8
|
+
export interface EmptyStateProps extends ViewProps {
|
|
9
|
+
title: string;
|
|
10
|
+
/** What to do about it. */
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
/** A button under the text. */
|
|
13
|
+
action?: ReactNode;
|
|
14
|
+
/** Above the title: an icon, an image. It comes with a little gesture, once. */
|
|
15
|
+
icon?: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** There is nothing here, and what to do about it. (SPEC §15.14) */
|
|
19
|
+
export function EmptyState({ title, children, action, icon, style, ...rest }: EmptyStateProps) {
|
|
20
|
+
const theme = useTheme();
|
|
21
|
+
return (
|
|
22
|
+
<View {...rest} style={[{ alignItems: 'center', gap: theme.size['space.2'], padding: theme.size['space.6'] }, style]}>
|
|
23
|
+
{icon !== undefined && <Arriving>{icon}</Arriving>}
|
|
24
|
+
<Text variant="title" style={{ textAlign: 'center' }}>
|
|
25
|
+
{title}
|
|
26
|
+
</Text>
|
|
27
|
+
{typeof children === 'string' ? (
|
|
28
|
+
<Text tone="muted" style={{ textAlign: 'center' }}>
|
|
29
|
+
{children}
|
|
30
|
+
</Text>
|
|
31
|
+
) : (
|
|
32
|
+
children
|
|
33
|
+
)}
|
|
34
|
+
{action !== undefined && <View style={{ marginBlockStart: theme.size['space.2'] }}>{action}</View>}
|
|
35
|
+
</View>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** It rises 6 points and grows from 85 % as it comes, on the bouncy spring, once. */
|
|
40
|
+
function Arriving({ children }: { children: ReactNode }) {
|
|
41
|
+
const t = useSharedValue(0);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
t.value = spring(1, 'bouncy');
|
|
44
|
+
}, [t]);
|
|
45
|
+
const come = useAnimatedStyle(() => ({ transform: [{ translateY: 6 * (1 - t.value) }, { scale: 0.85 + 0.15 * t.value }] }));
|
|
46
|
+
return (
|
|
47
|
+
<Animated.View testID="empty-icon" style={come}>
|
|
48
|
+
{children}
|
|
49
|
+
</Animated.View>
|
|
50
|
+
);
|
|
51
|
+
}
|
package/src/Link.tsx
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A link in text: the colour of the accent, underlined, and a link for a screen reader. Alone it is pressed
|
|
3
|
+
* with a target of 44 points; `inline`, it is part of a sentence. Pressed, it fades a little, and stays so
|
|
4
|
+
* while what its press returned is not settled: nothing moves. (SPEC §15.10, §15.11)
|
|
5
|
+
*/
|
|
6
|
+
import { useState, type ReactNode } from 'react';
|
|
7
|
+
import { Linking, Pressable, View, type StyleProp, type TextStyle, type ViewStyle } from 'react-native';
|
|
8
|
+
import { useAsyncPress } from './pending';
|
|
9
|
+
import { Text, textStyle, type TextProps, type TextVariant } from './Text';
|
|
10
|
+
import { useTheme } from './theme';
|
|
11
|
+
|
|
12
|
+
export interface LinkProps extends Omit<TextProps, 'onPress' | 'style' | 'role'> {
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
/** An address the system opens. For the browser of the app, or a screen of the app, use `onPress`. */
|
|
15
|
+
href?: string;
|
|
16
|
+
/** If it returns a promise, the link waits for it: faded, and taking no other press. */
|
|
17
|
+
onPress?: () => void | Promise<unknown>;
|
|
18
|
+
/** Inside a sentence: a nested text, with the line it is in. Default: false, an element of its own. */
|
|
19
|
+
inline?: boolean;
|
|
20
|
+
/** Default: 'body'. */
|
|
21
|
+
variant?: TextVariant;
|
|
22
|
+
/** The style of the text. */
|
|
23
|
+
style?: StyleProp<TextStyle>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** How much of it is seen while it is pressed, or waits. */
|
|
27
|
+
const FADED = 0.6;
|
|
28
|
+
|
|
29
|
+
export function Link({ children, href, onPress, inline = false, variant, style, testID, ...rest }: LinkProps) {
|
|
30
|
+
const theme = useTheme();
|
|
31
|
+
const [focused, setFocused] = useState(false);
|
|
32
|
+
// Opening an address is waited for too: two presses do not open it twice.
|
|
33
|
+
const [waiting, run] = useAsyncPress<void>(() => {
|
|
34
|
+
const result = onPress?.();
|
|
35
|
+
return href ? Promise.all([result, Linking.openURL(href)]) : result;
|
|
36
|
+
});
|
|
37
|
+
const go = (): void => {
|
|
38
|
+
if (!waiting) run();
|
|
39
|
+
};
|
|
40
|
+
const ink: TextStyle = { color: theme.color['text.accent'], textDecorationLine: 'underline' };
|
|
41
|
+
if (inline) {
|
|
42
|
+
return (
|
|
43
|
+
<Text role="link" aria-busy={waiting} disabled={waiting} suppressHighlighting variant={variant} testID={testID} {...rest} onPress={go} style={[ink, waiting ? { opacity: FADED } : null, style]}>
|
|
44
|
+
{children}
|
|
45
|
+
</Text>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
// The text may be lower than a finger: the rest of the 44 points is around it, and takes no room.
|
|
49
|
+
const slop = Math.max(0, (theme.size['target.min'] - (textStyle(theme, variant).lineHeight ?? 0)) / 2);
|
|
50
|
+
const ring: ViewStyle | null = focused ? { outlineStyle: 'solid', outlineWidth: theme.size['focus.width'], outlineOffset: theme.size['focus.offset'], outlineColor: theme.color['focus.ring'] } : null;
|
|
51
|
+
return (
|
|
52
|
+
// In a column it would be as wide as the column, and pressed where there is no text: it stays as wide as its text, in a row of its own.
|
|
53
|
+
<View style={{ flexDirection: 'row' }}>
|
|
54
|
+
<Pressable role="link" aria-busy={waiting} disabled={waiting} testID={testID} hitSlop={slop} onPress={go} onFocus={() => setFocused(true)} onBlur={() => setFocused(false)} style={({ pressed }) => [{ flexShrink: 1, borderRadius: theme.size['radius.1'], opacity: pressed || waiting ? FADED : 1 }, ring]}>
|
|
55
|
+
<Text variant={variant} {...rest} style={[ink, style]}>
|
|
56
|
+
{children}
|
|
57
|
+
</Text>
|
|
58
|
+
</Pressable>
|
|
59
|
+
</View>
|
|
60
|
+
);
|
|
61
|
+
}
|
package/src/ListItem.tsx
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ComponentRef, ReactNode, Ref } from 'react';
|
|
2
|
+
import { Pressable, View, type GestureResponderEvent, type PressableProps, type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
import { fill } from './layout';
|
|
4
|
+
import { IconHostProvider, isOn, useHostFor } from './icon-host';
|
|
5
|
+
import { useAsyncPress, usePending } from './pending';
|
|
6
|
+
import { Text } from './Text';
|
|
7
|
+
import { useTheme } from './theme';
|
|
8
|
+
|
|
9
|
+
export interface ListItemProps extends Omit<PressableProps, 'children' | 'style' | 'ref' | 'onPress'> {
|
|
10
|
+
/** If it returns a promise, the row waits for it: it fills from where it was pressed. */
|
|
11
|
+
onPress?: (event: GestureResponderEvent) => void | Promise<unknown>;
|
|
12
|
+
title: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
/** Before the text: an icon, an avatar. */
|
|
15
|
+
leading?: ReactNode;
|
|
16
|
+
/** After it: a badge, a figure, a chevron. */
|
|
17
|
+
trailing?: ReactNode;
|
|
18
|
+
style?: StyleProp<ViewStyle>;
|
|
19
|
+
ref?: Ref<ComponentRef<typeof Pressable>>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A row of a list. With `onPress` it is one button, read whole by a screen reader, that darkens when pressed.
|
|
24
|
+
* At rest it carries no animated component: a list has many rows. Only the one that waits has its fill.
|
|
25
|
+
*/
|
|
26
|
+
export function ListItem({ title, description, leading, trailing, style, onPress, onPressIn, onLayout, disabled, ...rest }: ListItemProps) {
|
|
27
|
+
const theme = useTheme();
|
|
28
|
+
const [waiting, run, failed] = useAsyncPress(onPress);
|
|
29
|
+
const pending = usePending(waiting, theme.color['text.default'], failed);
|
|
30
|
+
const icons = useHostFor(isOn(rest));
|
|
31
|
+
const row: ViewStyle = { minHeight: theme.size['target.min'], flexDirection: 'row', alignItems: 'center', gap: theme.size['space.3'], paddingInline: theme.size['space.4'], paddingBlock: theme.size['space.2'] };
|
|
32
|
+
const body = (
|
|
33
|
+
<IconHostProvider host={icons.host}>
|
|
34
|
+
{leading}
|
|
35
|
+
<View style={fill}>
|
|
36
|
+
<Text variant="label">{title}</Text>
|
|
37
|
+
{description !== undefined && (
|
|
38
|
+
<Text variant="caption" tone="muted">
|
|
39
|
+
{description}
|
|
40
|
+
</Text>
|
|
41
|
+
)}
|
|
42
|
+
</View>
|
|
43
|
+
{trailing}
|
|
44
|
+
</IconHostProvider>
|
|
45
|
+
);
|
|
46
|
+
if (!onPress) {
|
|
47
|
+
return (
|
|
48
|
+
<View testID={rest.testID} style={[row, style]}>
|
|
49
|
+
{body}
|
|
50
|
+
</View>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
return (
|
|
54
|
+
<Pressable
|
|
55
|
+
role="button"
|
|
56
|
+
aria-disabled={!!disabled}
|
|
57
|
+
aria-busy={waiting}
|
|
58
|
+
{...rest}
|
|
59
|
+
onPress={(e) => {
|
|
60
|
+
icons.push('press');
|
|
61
|
+
run(e);
|
|
62
|
+
}}
|
|
63
|
+
onPressIn={(e) => {
|
|
64
|
+
pending.onPressIn(e);
|
|
65
|
+
onPressIn?.(e);
|
|
66
|
+
}}
|
|
67
|
+
onLayout={(e) => {
|
|
68
|
+
pending.onLayout(e);
|
|
69
|
+
onLayout?.(e);
|
|
70
|
+
}}
|
|
71
|
+
disabled={!!disabled || waiting}
|
|
72
|
+
style={({ pressed }) => [row, { overflow: 'hidden' }, pressed ? { backgroundColor: theme.color['surface.hover'] } : null, disabled ? { opacity: 0.5 } : null, style]}
|
|
73
|
+
>
|
|
74
|
+
{pending.fill}
|
|
75
|
+
{body}
|
|
76
|
+
</Pressable>
|
|
77
|
+
);
|
|
78
|
+
}
|
package/src/Menu.tsx
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/** A few things to do, by what opened them. Choosing one closes the menu; if it waits, once it is done. (SPEC §15.8) */
|
|
2
|
+
import { createContext, useContext, type ReactNode } from 'react';
|
|
3
|
+
import { Divider } from './layout';
|
|
4
|
+
import { ListItem } from './ListItem';
|
|
5
|
+
import { Overlay } from './overlay';
|
|
6
|
+
import { settle } from './pending';
|
|
7
|
+
import { Floating, useAnchored, type PopoverProps } from './Popover';
|
|
8
|
+
import { useTheme } from './theme';
|
|
9
|
+
|
|
10
|
+
const Context = createContext<(() => void) | null>(null);
|
|
11
|
+
|
|
12
|
+
export interface MenuProps extends Omit<PopoverProps, 'children' | 'label'> {
|
|
13
|
+
/** `MenuItem` and `MenuSeparator`. */
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
/** Its name, for a screen reader. */
|
|
16
|
+
label?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function Menu({ trigger, children, label, placement = 'bottom-start', onOpenChange, testID }: MenuProps) {
|
|
20
|
+
const theme = useTheme();
|
|
21
|
+
const anchored = useAnchored(trigger, onOpenChange);
|
|
22
|
+
return (
|
|
23
|
+
<>
|
|
24
|
+
{anchored.trigger}
|
|
25
|
+
<Overlay open={anchored.open} onClose={anchored.close} veil={false}>
|
|
26
|
+
{(t) => (
|
|
27
|
+
<Floating t={t} rect={anchored.rect} placement={placement} role="menu" label={label} padding={theme.size['space.1']} testID={testID}>
|
|
28
|
+
<Context.Provider value={anchored.close}>{children}</Context.Provider>
|
|
29
|
+
</Floating>
|
|
30
|
+
)}
|
|
31
|
+
</Overlay>
|
|
32
|
+
</>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface MenuItemProps {
|
|
37
|
+
label: string;
|
|
38
|
+
/** Before the label. */
|
|
39
|
+
icon?: ReactNode;
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
/** When it is chosen. If it returns a promise, the row waits for it and the menu closes once it is fulfilled. */
|
|
42
|
+
onSelect?: () => void | Promise<unknown>;
|
|
43
|
+
testID?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function MenuItem({ label, icon, disabled, onSelect, testID }: MenuItemProps) {
|
|
47
|
+
const theme = useTheme();
|
|
48
|
+
const close = useContext(Context);
|
|
49
|
+
if (!close) throw new Error('@fluxus-ui/native: a <MenuItem> goes inside a <Menu>.');
|
|
50
|
+
return <ListItem role="menuitem" title={label} leading={icon} disabled={disabled} testID={testID} onPress={() => settle(onSelect?.(), close)} style={{ borderRadius: theme.size['radius.control'] }} />;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** A rule between two groups of a menu. */
|
|
54
|
+
export function MenuSeparator() {
|
|
55
|
+
const theme = useTheme();
|
|
56
|
+
return <Divider style={{ marginBlock: theme.size['space.1'] }} />;
|
|
57
|
+
}
|
package/src/Message.tsx
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useEffect, type ReactNode } from 'react';
|
|
2
|
+
import { View, type StyleProp, type ViewProps, type ViewStyle } from 'react-native';
|
|
3
|
+
import { toneColors } from './Badge';
|
|
4
|
+
import { announce } from './Toast';
|
|
5
|
+
import { Text } from './Text';
|
|
6
|
+
import { useTheme } from './theme';
|
|
7
|
+
|
|
8
|
+
export interface MessageProps extends Omit<ViewProps, 'style'> {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
/** Default: 'info'. */
|
|
11
|
+
tone?: 'info' | 'success' | 'warning' | 'danger';
|
|
12
|
+
title?: string;
|
|
13
|
+
/** It is announced when it appears: at once if it is a danger, when the reader is free otherwise. Default: true. */
|
|
14
|
+
live?: boolean;
|
|
15
|
+
style?: StyleProp<ViewStyle>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Something the person has to know: a notice, or what went wrong and what to do. */
|
|
19
|
+
export function Message({ children, tone = 'info', title, live = true, style, ...rest }: MessageProps) {
|
|
20
|
+
const theme = useTheme();
|
|
21
|
+
const { subtle, ink } = toneColors(theme, tone);
|
|
22
|
+
const urgent = tone === 'danger';
|
|
23
|
+
// Android reads a live region when it appears; iOS has to be told.
|
|
24
|
+
const said = [title, typeof children === 'string' ? children : undefined].filter(Boolean).join('. ');
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (live && said) announce(said);
|
|
27
|
+
}, [live, said]);
|
|
28
|
+
return (
|
|
29
|
+
<View
|
|
30
|
+
role={live && urgent ? 'alert' : undefined}
|
|
31
|
+
aria-live={live ? (urgent ? 'assertive' : 'polite') : 'off'}
|
|
32
|
+
{...rest}
|
|
33
|
+
style={[{ gap: theme.size['space.1'], padding: theme.size['space.3'], borderRadius: theme.size['radius.control'], backgroundColor: subtle }, style]}
|
|
34
|
+
>
|
|
35
|
+
{title !== undefined && (
|
|
36
|
+
<Text variant="label" style={{ color: ink }}>
|
|
37
|
+
{title}
|
|
38
|
+
</Text>
|
|
39
|
+
)}
|
|
40
|
+
{typeof children === 'string' ? <Text>{children}</Text> : children}
|
|
41
|
+
</View>
|
|
42
|
+
);
|
|
43
|
+
}
|
package/src/Popover.tsx
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A panel by what opened it: below if it fits, above if not, never off the screen. It grows from the corner
|
|
3
|
+
* that touches its origin. `Menu` is this with rows to choose. (SPEC §15.8)
|
|
4
|
+
*/
|
|
5
|
+
import { cloneElement, useRef, useState, type ReactElement, type ReactNode, type Ref } from 'react';
|
|
6
|
+
import { I18nManager, ScrollView, useWindowDimensions, type GestureResponderEvent } from 'react-native';
|
|
7
|
+
import Animated, { useAnimatedStyle, type SharedValue } from 'react-native-reanimated';
|
|
8
|
+
import { floating, focusOn, Overlay } from './overlay';
|
|
9
|
+
import { useTheme } from './theme';
|
|
10
|
+
|
|
11
|
+
export type Placement = 'bottom-start' | 'bottom-end' | 'top-start' | 'top-end';
|
|
12
|
+
|
|
13
|
+
export interface Rect {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Between it and its origin, and between it and the edge of the screen. */
|
|
21
|
+
const GAP = 4;
|
|
22
|
+
const MARGIN = 8;
|
|
23
|
+
const SMALL = 0.96;
|
|
24
|
+
|
|
25
|
+
const clamp = (value: number, min: number, max: number): number => Math.max(min, Math.min(value, max));
|
|
26
|
+
|
|
27
|
+
/** Where a panel of `size` goes by `anchor` in a `screen`, in the points of the window, and the corner it grows from. */
|
|
28
|
+
export function place(anchor: Rect, size: { width: number; height: number }, screen: { width: number; height: number }, placement: Placement = 'bottom-start', rtl = false): { left: number; top: number; origin: string } {
|
|
29
|
+
const below = anchor.y + anchor.height + GAP;
|
|
30
|
+
const above = anchor.y - GAP - size.height;
|
|
31
|
+
const fitsBelow = below + size.height <= screen.height - MARGIN;
|
|
32
|
+
const fitsAbove = above >= MARGIN;
|
|
33
|
+
const up = placement.startsWith('top') ? fitsAbove || !fitsBelow : !fitsBelow && fitsAbove;
|
|
34
|
+
// `end` is the right edge in a language written from the left, and the left one in the others.
|
|
35
|
+
const right = placement.endsWith('end') !== rtl;
|
|
36
|
+
return {
|
|
37
|
+
left: clamp(right ? anchor.x + anchor.width - size.width : anchor.x, MARGIN, Math.max(MARGIN, screen.width - MARGIN - size.width)),
|
|
38
|
+
top: clamp(up ? above : below, MARGIN, Math.max(MARGIN, screen.height - MARGIN - size.height)),
|
|
39
|
+
origin: `${right ? 'right' : 'left'} ${up ? 'bottom' : 'top'}`,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
type Trigger = ReactElement<{ onPress?: (event: GestureResponderEvent) => unknown; ref?: Ref<unknown>; 'aria-expanded'?: boolean }>;
|
|
44
|
+
|
|
45
|
+
/** The trigger, opening what it opens, and where it is on the screen. Its own `onPress` and `ref` still work. */
|
|
46
|
+
export function useAnchored(trigger: Trigger, onOpenChange?: (open: boolean) => void) {
|
|
47
|
+
const [open, setOpen] = useState(false);
|
|
48
|
+
const [rect, setRect] = useState<Rect | null>(null);
|
|
49
|
+
const anchor = useRef<{ measureInWindow?: (done: (x: number, y: number, width: number, height: number) => void) => void } | null>(null);
|
|
50
|
+
const set = (next: boolean): void => {
|
|
51
|
+
setOpen(next);
|
|
52
|
+
onOpenChange?.(next);
|
|
53
|
+
};
|
|
54
|
+
const own = trigger.props.ref;
|
|
55
|
+
return {
|
|
56
|
+
open,
|
|
57
|
+
rect,
|
|
58
|
+
close: (): void => {
|
|
59
|
+
set(false);
|
|
60
|
+
focusOn(anchor.current);
|
|
61
|
+
},
|
|
62
|
+
trigger: cloneElement(trigger, {
|
|
63
|
+
'aria-expanded': open,
|
|
64
|
+
ref: (node: unknown) => {
|
|
65
|
+
anchor.current = node as typeof anchor.current;
|
|
66
|
+
if (typeof own === 'function') own(node);
|
|
67
|
+
else if (own) (own as { current: unknown }).current = node;
|
|
68
|
+
},
|
|
69
|
+
onPress: (event: GestureResponderEvent) => {
|
|
70
|
+
trigger.props.onPress?.(event);
|
|
71
|
+
// Where it was the last time is not where it is now: the screen may have scrolled.
|
|
72
|
+
setRect(null);
|
|
73
|
+
anchor.current?.measureInWindow?.((x, y, width, height) => setRect({ x, y, width, height }));
|
|
74
|
+
set(true);
|
|
75
|
+
},
|
|
76
|
+
}),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface FloatingProps {
|
|
81
|
+
t: SharedValue<number>;
|
|
82
|
+
rect: Rect | null;
|
|
83
|
+
placement: Placement;
|
|
84
|
+
role: 'dialog' | 'menu';
|
|
85
|
+
label?: string;
|
|
86
|
+
/** Around what it holds. Default: none. */
|
|
87
|
+
padding?: number;
|
|
88
|
+
children: ReactNode;
|
|
89
|
+
testID?: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** The panel itself. Until it knows where its origin is and how big it is, it is not seen. */
|
|
93
|
+
export function Floating({ t, rect, placement, role, label, padding, children, testID }: FloatingProps) {
|
|
94
|
+
const theme = useTheme();
|
|
95
|
+
const screen = useWindowDimensions();
|
|
96
|
+
const [size, setSize] = useState<{ width: number; height: number } | null>(null);
|
|
97
|
+
const at = rect && size ? place(rect, size, screen, placement, I18nManager.isRTL) : null;
|
|
98
|
+
const ready = !!at;
|
|
99
|
+
const grow = useAnimatedStyle(() => ({ opacity: ready ? t.value : 0, transform: [{ scale: SMALL + (1 - SMALL) * t.value }] }));
|
|
100
|
+
return (
|
|
101
|
+
<Animated.View
|
|
102
|
+
role={role}
|
|
103
|
+
aria-label={label}
|
|
104
|
+
testID={testID}
|
|
105
|
+
onLayout={(e) => setSize({ width: e.nativeEvent.layout.width, height: e.nativeEvent.layout.height })}
|
|
106
|
+
// `left` and `top`: the points of the window, not the direction of the language.
|
|
107
|
+
style={[floating(theme), { position: 'absolute', left: at?.left ?? 0, top: at?.top ?? 0, minWidth: Math.min(rect?.width ?? 0, screen.width - 2 * MARGIN), maxWidth: screen.width - 2 * MARGIN, maxHeight: screen.height - 2 * MARGIN, overflow: 'hidden', transformOrigin: at?.origin }, grow]}
|
|
108
|
+
>
|
|
109
|
+
<ScrollView bounces={false} keyboardShouldPersistTaps="handled" contentContainerStyle={{ padding }}>
|
|
110
|
+
{children}
|
|
111
|
+
</ScrollView>
|
|
112
|
+
</Animated.View>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface PopoverProps {
|
|
117
|
+
/** What opens it: something that is pressed and takes a `ref`, as a Button. */
|
|
118
|
+
trigger: Trigger;
|
|
119
|
+
/** What it holds; as a function, it is given what closes it. */
|
|
120
|
+
children: ReactNode | ((close: () => void) => ReactNode);
|
|
121
|
+
/** Its name, for a screen reader. */
|
|
122
|
+
label: string;
|
|
123
|
+
/** Default: 'bottom-start'. It goes to the other side when it does not fit. */
|
|
124
|
+
placement?: Placement;
|
|
125
|
+
onOpenChange?: (open: boolean) => void;
|
|
126
|
+
testID?: string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** A small panel with anything in it, by what opened it. A press outside closes it. */
|
|
130
|
+
export function Popover({ trigger, children, label, placement = 'bottom-start', onOpenChange, testID }: PopoverProps) {
|
|
131
|
+
const theme = useTheme();
|
|
132
|
+
const anchored = useAnchored(trigger, onOpenChange);
|
|
133
|
+
return (
|
|
134
|
+
<>
|
|
135
|
+
{anchored.trigger}
|
|
136
|
+
<Overlay open={anchored.open} onClose={anchored.close} veil={false}>
|
|
137
|
+
{(t) => (
|
|
138
|
+
<Floating t={t} rect={anchored.rect} placement={placement} role="dialog" label={label} padding={theme.size['space.3']} testID={testID}>
|
|
139
|
+
{typeof children === 'function' ? children(anchored.close) : children}
|
|
140
|
+
</Floating>
|
|
141
|
+
)}
|
|
142
|
+
</Overlay>
|
|
143
|
+
</>
|
|
144
|
+
);
|
|
145
|
+
}
|
package/src/Progress.tsx
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { I18nManager, View, type StyleProp, type ViewProps, type ViewStyle } from 'react-native';
|
|
3
|
+
import Animated, { useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
|
|
4
|
+
import { spring } from './motion';
|
|
5
|
+
import { useTheme } from './theme';
|
|
6
|
+
|
|
7
|
+
export interface ProgressProps extends Omit<ViewProps, 'style' | 'children'> {
|
|
8
|
+
value: number;
|
|
9
|
+
/** Default: 100. */
|
|
10
|
+
max?: number;
|
|
11
|
+
/** What advances, for a screen reader. */
|
|
12
|
+
label: string;
|
|
13
|
+
style?: StyleProp<ViewStyle>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** How far something has gone. The bar travels to a new value on the smooth spring, moving only its transform. */
|
|
17
|
+
export function Progress({ value, max = 100, label, style, ...rest }: ProgressProps) {
|
|
18
|
+
const theme = useTheme();
|
|
19
|
+
const part = max > 0 ? Math.min(1, Math.max(0, value / max)) : 0;
|
|
20
|
+
const shown = useSharedValue(part);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
shown.value = spring(part, 'smooth');
|
|
23
|
+
}, [part, shown]);
|
|
24
|
+
// The whole bar is there, and slides in from the side the language starts on: no layout on each frame.
|
|
25
|
+
const from = I18nManager.isRTL ? 1 : -1;
|
|
26
|
+
const bar = useAnimatedStyle(() => ({ transform: [{ translateX: `${from * (1 - shown.value) * 100}%` }] }));
|
|
27
|
+
const height = theme.size['space.2'];
|
|
28
|
+
return (
|
|
29
|
+
<View accessible role="progressbar" aria-label={label} aria-valuemin={0} aria-valuemax={max} aria-valuenow={Math.min(max, Math.max(0, value))} {...rest} style={[{ height, borderRadius: height, backgroundColor: theme.color['surface.sunken'], overflow: 'hidden' }, style]}>
|
|
30
|
+
<Animated.View style={[{ height, borderRadius: height, backgroundColor: theme.color['accent.default'] }, bar]} />
|
|
31
|
+
</View>
|
|
32
|
+
);
|
|
33
|
+
}
|