expo-stacked-sheets 1.0.2 → 1.1.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/package.json +1 -1
- package/src/SheetDockContent.tsx +5 -3
- package/src/SheetEditor.tsx +37 -14
- package/src/SheetStage.tsx +23 -6
- package/src/StackedCard.tsx +23 -8
- package/src/StackedSheets.tsx +35 -32
- package/src/index.ts +2 -0
- package/src/sheetTheme.tsx +90 -0
- package/src/types.ts +5 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-stacked-sheets",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "3D stacked sheets for Expo and React Native, built with Reanimated and Gesture Handler.",
|
|
5
5
|
"keywords": ["expo", "react-native", "stacked-sheets", "bottom-sheet", "sheet", "3d", "reanimated", "gesture-handler", "ios", "android"],
|
|
6
6
|
"license": "MIT",
|
package/src/SheetDockContent.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { StyleSheet, Text, View } from 'react-native';
|
|
2
2
|
import Animated, { type AnimatedStyle } from 'react-native-reanimated';
|
|
3
|
+
import { useSheetTheme } from './sheetTheme';
|
|
3
4
|
import { SheetControlIcon } from './StackedCard';
|
|
4
5
|
import type { StackedSheetsProps } from './types';
|
|
5
6
|
|
|
@@ -13,19 +14,20 @@ export function SheetDockContent({
|
|
|
13
14
|
count: number;
|
|
14
15
|
controlsStyle?: AnimatedStyle<{ opacity: number }>;
|
|
15
16
|
}) {
|
|
17
|
+
const theme = useSheetTheme();
|
|
16
18
|
const hasStack = count > 1;
|
|
17
19
|
|
|
18
20
|
return (
|
|
19
21
|
<View pointerEvents="none" style={styles.row}>
|
|
20
22
|
<View style={[styles.titleInset, hasStack && styles.stackTitleInset]}>
|
|
21
|
-
<Text numberOfLines={1} style={styles.title}>{title}</Text>
|
|
23
|
+
<Text numberOfLines={1} style={[styles.title, { color: theme.ink }]}>{title}</Text>
|
|
22
24
|
</View>
|
|
23
25
|
<Animated.View style={[styles.controls, controlsStyle]}>
|
|
24
26
|
<SheetControlIcon name="sheet" size={20} renderIcon={renderIcon} />
|
|
25
27
|
{hasStack && (
|
|
26
28
|
<View style={styles.trailing}>
|
|
27
|
-
<View style={styles.pill}>
|
|
28
|
-
<Text numberOfLines={1} style={styles.count}>{count}</Text>
|
|
29
|
+
<View style={[styles.pill, { backgroundColor: theme.pill }]}>
|
|
30
|
+
<Text numberOfLines={1} style={[styles.count, { color: theme.ink }]}>{count}</Text>
|
|
29
31
|
</View>
|
|
30
32
|
<SheetControlIcon name="expand" size={18} renderIcon={renderIcon} />
|
|
31
33
|
</View>
|
package/src/SheetEditor.tsx
CHANGED
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
shouldMinimize,
|
|
31
31
|
} from './sheetLayout';
|
|
32
32
|
import { useDraft, useMailView, useMotion, useSheetController } from './sheetMotion';
|
|
33
|
+
import { useSheetTheme } from './sheetTheme';
|
|
33
34
|
import { SheetDockContent } from './SheetDockContent';
|
|
34
35
|
import { SheetControlIcon } from './StackedCard';
|
|
35
36
|
import type { SheetContent, StackedSheetsProps } from './types';
|
|
@@ -59,6 +60,7 @@ export function SheetEditor({
|
|
|
59
60
|
const { editor, frame, dock, full } = useMotion();
|
|
60
61
|
const { height, width } = useWindowDimensions();
|
|
61
62
|
const insets = useSafeAreaInsets();
|
|
63
|
+
const theme = useSheetTheme();
|
|
62
64
|
const top = insets.top + 4;
|
|
63
65
|
const titleRef = useRef<ComponentRef<typeof TextInput>>(null);
|
|
64
66
|
const dragStart = useSharedValue(full);
|
|
@@ -166,7 +168,11 @@ export function SheetEditor({
|
|
|
166
168
|
aria-hidden={mode !== 'compose'}
|
|
167
169
|
accessibilityElementsHidden={mode !== 'compose'}
|
|
168
170
|
importantForAccessibility={mode === 'compose' ? 'auto' : 'no-hide-descendants'}
|
|
169
|
-
style={[
|
|
171
|
+
style={[
|
|
172
|
+
styles.root,
|
|
173
|
+
{ backgroundColor: theme.surface, borderColor: theme.editorBorder },
|
|
174
|
+
style,
|
|
175
|
+
]}
|
|
170
176
|
>
|
|
171
177
|
<Animated.View
|
|
172
178
|
style={[styles.editorContent, { width, height: height - top }, contentStyle]}
|
|
@@ -178,7 +184,7 @@ export function SheetEditor({
|
|
|
178
184
|
<GestureDetector gesture={pan}>
|
|
179
185
|
<View style={styles.header}>
|
|
180
186
|
<View style={styles.handleButton}>
|
|
181
|
-
<View style={styles.handle} />
|
|
187
|
+
<View style={[styles.handle, { backgroundColor: theme.handle }]} />
|
|
182
188
|
</View>
|
|
183
189
|
<View style={styles.toolbar}>
|
|
184
190
|
<Pressable
|
|
@@ -191,7 +197,10 @@ export function SheetEditor({
|
|
|
191
197
|
(event.currentTarget as unknown as { blur?: () => void }).blur?.();
|
|
192
198
|
minimizeCompose();
|
|
193
199
|
}}
|
|
194
|
-
style={({ pressed }) => [
|
|
200
|
+
style={({ pressed }) => [
|
|
201
|
+
styles.icon,
|
|
202
|
+
pressed && { backgroundColor: theme.pressed },
|
|
203
|
+
]}
|
|
195
204
|
>
|
|
196
205
|
<SheetControlIcon name="minimize" size={22} renderIcon={renderIcon} />
|
|
197
206
|
</Pressable>
|
|
@@ -203,9 +212,19 @@ export function SheetEditor({
|
|
|
203
212
|
testID="compose-save"
|
|
204
213
|
disabled={!canSave}
|
|
205
214
|
onPress={saveSheet}
|
|
206
|
-
style={({ pressed }) => [
|
|
215
|
+
style={({ pressed }) => [
|
|
216
|
+
styles.saveButton,
|
|
217
|
+
pressed && { backgroundColor: theme.pressed },
|
|
218
|
+
]}
|
|
207
219
|
>
|
|
208
|
-
<Text
|
|
220
|
+
<Text
|
|
221
|
+
style={[
|
|
222
|
+
styles.saveLabel,
|
|
223
|
+
{ color: canSave ? theme.ink : theme.muted },
|
|
224
|
+
]}
|
|
225
|
+
>
|
|
226
|
+
Save
|
|
227
|
+
</Text>
|
|
209
228
|
</Pressable>
|
|
210
229
|
)}
|
|
211
230
|
<Pressable
|
|
@@ -214,14 +233,19 @@ export function SheetEditor({
|
|
|
214
233
|
testID="compose-close"
|
|
215
234
|
hitSlop={10}
|
|
216
235
|
onPress={requestCloseTop}
|
|
217
|
-
style={({ pressed }) => [
|
|
236
|
+
style={({ pressed }) => [
|
|
237
|
+
styles.icon,
|
|
238
|
+
pressed && { backgroundColor: theme.pressed },
|
|
239
|
+
]}
|
|
218
240
|
>
|
|
219
241
|
<SheetControlIcon name="close" size={22} renderIcon={renderIcon} />
|
|
220
242
|
</Pressable>
|
|
221
243
|
</View>
|
|
222
244
|
</View>
|
|
223
245
|
{saveErrorId && saveErrorId === id && (
|
|
224
|
-
<Text accessibilityRole="alert" style={styles.saveError
|
|
246
|
+
<Text accessibilityRole="alert" style={[styles.saveError, { color: theme.danger }]}>
|
|
247
|
+
Couldn’t save the note. Try again.
|
|
248
|
+
</Text>
|
|
225
249
|
)}
|
|
226
250
|
</View>
|
|
227
251
|
</GestureDetector>
|
|
@@ -241,10 +265,11 @@ export function SheetEditor({
|
|
|
241
265
|
ref={titleRef}
|
|
242
266
|
accessibilityLabel="Title"
|
|
243
267
|
placeholder="Title"
|
|
244
|
-
placeholderTextColor={
|
|
268
|
+
placeholderTextColor={theme.muted}
|
|
269
|
+
keyboardAppearance={theme.colorScheme}
|
|
245
270
|
value={title}
|
|
246
271
|
onChangeText={(nextTitle) => update({ title: nextTitle })}
|
|
247
|
-
style={styles.title}
|
|
272
|
+
style={[styles.title, { color: theme.ink }]}
|
|
248
273
|
multiline
|
|
249
274
|
submitBehavior="blurAndSubmit"
|
|
250
275
|
/>
|
|
@@ -262,11 +287,12 @@ export function SheetEditor({
|
|
|
262
287
|
<TextInput
|
|
263
288
|
accessibilityLabel="Body"
|
|
264
289
|
placeholder="Start writing…"
|
|
265
|
-
placeholderTextColor={
|
|
290
|
+
placeholderTextColor={theme.muted}
|
|
291
|
+
keyboardAppearance={theme.colorScheme}
|
|
266
292
|
value={sheet?.body ?? ''}
|
|
267
293
|
onChangeText={(body) => update({ body })}
|
|
268
294
|
multiline
|
|
269
|
-
style={styles.body}
|
|
295
|
+
style={[styles.body, { color: theme.body }]}
|
|
270
296
|
textAlignVertical="top"
|
|
271
297
|
/>
|
|
272
298
|
</ScrollView>
|
|
@@ -291,7 +317,6 @@ export function SheetEditor({
|
|
|
291
317
|
}
|
|
292
318
|
|
|
293
319
|
const INK = '#111';
|
|
294
|
-
const MUTED = '#B0B0B5';
|
|
295
320
|
|
|
296
321
|
const styles = StyleSheet.create({
|
|
297
322
|
root: {
|
|
@@ -318,7 +343,6 @@ const styles = StyleSheet.create({
|
|
|
318
343
|
toolbarActions: { flexDirection: 'row', alignItems: 'center', gap: 4 },
|
|
319
344
|
saveButton: { minHeight: 44, paddingHorizontal: 12, justifyContent: 'center', borderRadius: 22 },
|
|
320
345
|
saveLabel: { color: INK, fontSize: 16, fontWeight: '600' },
|
|
321
|
-
saveDisabled: { color: MUTED },
|
|
322
346
|
saveError: { color: '#A62828', paddingHorizontal: 24, paddingTop: 4 },
|
|
323
347
|
icon: {
|
|
324
348
|
width: 40,
|
|
@@ -327,7 +351,6 @@ const styles = StyleSheet.create({
|
|
|
327
351
|
alignItems: 'center',
|
|
328
352
|
justifyContent: 'center',
|
|
329
353
|
},
|
|
330
|
-
pressed: { backgroundColor: '#F2F2F2' },
|
|
331
354
|
content: { paddingHorizontal: 24, paddingTop: 12, paddingBottom: 60 },
|
|
332
355
|
title: {
|
|
333
356
|
fontSize: 28,
|
package/src/SheetStage.tsx
CHANGED
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
import { SheetDockContent } from './SheetDockContent';
|
|
27
27
|
import { SheetEditor } from './SheetEditor';
|
|
28
28
|
import { useDraft, useDraftIds, useMailView, useMotion, useSheetController } from './sheetMotion';
|
|
29
|
+
import { useSheetTheme } from './sheetTheme';
|
|
29
30
|
import { StackedCard } from './StackedCard';
|
|
30
31
|
import type { StackedSheetsProps } from './types';
|
|
31
32
|
|
|
@@ -45,6 +46,11 @@ export function SheetStage({
|
|
|
45
46
|
const { mode, activeId } = useMailView();
|
|
46
47
|
const { height } = useWindowDimensions();
|
|
47
48
|
const insets = useSafeAreaInsets();
|
|
49
|
+
const theme = useSheetTheme();
|
|
50
|
+
const dimOpacity = useSharedValue(theme.dimOpacity);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
dimOpacity.set(theme.dimOpacity);
|
|
53
|
+
}, [dimOpacity, theme.dimOpacity]);
|
|
48
54
|
const { overview, scroll, editor, count, dock } = useMotion();
|
|
49
55
|
const dockHeight = dock.height;
|
|
50
56
|
const dockBottom = height - dock.top - dock.height;
|
|
@@ -107,18 +113,22 @@ export function SheetStage({
|
|
|
107
113
|
),
|
|
108
114
|
};
|
|
109
115
|
});
|
|
110
|
-
const dimStyle = useAnimatedStyle(() => ({ opacity: editor.value *
|
|
116
|
+
const dimStyle = useAnimatedStyle(() => ({ opacity: editor.value * dimOpacity.value }));
|
|
111
117
|
const depthStyle = useAnimatedStyle(() => ({ opacity: overview.value }));
|
|
112
118
|
const dockStyle = useAnimatedStyle(() => ({
|
|
113
119
|
opacity: 1 - overviewCardOpacity(overview.value),
|
|
114
120
|
}));
|
|
115
121
|
return (
|
|
116
|
-
<View style={styles.root}>
|
|
117
|
-
{renderStatusBar?.(mode)}
|
|
122
|
+
<View style={[styles.root, { backgroundColor: theme.stage }]}>
|
|
123
|
+
{renderStatusBar?.(mode, theme.colorScheme)}
|
|
118
124
|
<GestureDetector gesture={pan}>
|
|
119
125
|
<View style={StyleSheet.absoluteFill}>
|
|
120
126
|
<Animated.View
|
|
121
|
-
style={[
|
|
127
|
+
style={[
|
|
128
|
+
styles.background,
|
|
129
|
+
{ backgroundColor: theme.background, borderColor: theme.border },
|
|
130
|
+
inboxStyle,
|
|
131
|
+
]}
|
|
122
132
|
pointerEvents={mode === 'inbox' ? 'auto' : 'none'}
|
|
123
133
|
aria-hidden={mode !== 'inbox'}
|
|
124
134
|
accessibilityElementsHidden={mode !== 'inbox'}
|
|
@@ -130,7 +140,7 @@ export function SheetStage({
|
|
|
130
140
|
<Animated.View pointerEvents="none" style={[styles.dim, dimStyle]} />
|
|
131
141
|
<Animated.View
|
|
132
142
|
pointerEvents="none"
|
|
133
|
-
style={[styles.depthShade, depthStyle]}
|
|
143
|
+
style={[styles.depthShade, { backgroundImage: theme.depthShade }, depthStyle]}
|
|
134
144
|
/>
|
|
135
145
|
</Animated.View>
|
|
136
146
|
<View
|
|
@@ -171,7 +181,14 @@ export function SheetStage({
|
|
|
171
181
|
accessibilityElementsHidden={mode !== 'inbox'}
|
|
172
182
|
style={[
|
|
173
183
|
styles.dock,
|
|
174
|
-
{
|
|
184
|
+
{
|
|
185
|
+
top: dock.top,
|
|
186
|
+
height: dock.height,
|
|
187
|
+
borderRadius: dock.radius,
|
|
188
|
+
backgroundColor: theme.surface,
|
|
189
|
+
borderColor: theme.border,
|
|
190
|
+
shadowOpacity: theme.shadowOpacity,
|
|
191
|
+
},
|
|
175
192
|
dockStyle,
|
|
176
193
|
]}
|
|
177
194
|
>
|
package/src/StackedCard.tsx
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
shouldDismissCard,
|
|
23
23
|
} from './sheetLayout';
|
|
24
24
|
import { useDraft, useMailView, useMotion, useSheetController } from './sheetMotion';
|
|
25
|
+
import { useSheetTheme, type SheetTheme } from './sheetTheme';
|
|
25
26
|
import type { Sheet, SheetIcon, StackedSheetsProps } from './types';
|
|
26
27
|
|
|
27
28
|
const android = Platform.OS === 'android';
|
|
@@ -42,9 +43,10 @@ export function SheetControlIcon({
|
|
|
42
43
|
size: number;
|
|
43
44
|
renderIcon: StackedSheetsProps['renderIcon'];
|
|
44
45
|
}) {
|
|
45
|
-
|
|
46
|
+
const theme = useSheetTheme();
|
|
47
|
+
if (renderIcon) return renderIcon(name, size, theme.ink);
|
|
46
48
|
return (
|
|
47
|
-
<Text style={[styles.icon, { fontSize: size }]}>{iconGlyphs[name]}</Text>
|
|
49
|
+
<Text style={[styles.icon, { fontSize: size, color: theme.ink }]}>{iconGlyphs[name]}</Text>
|
|
48
50
|
);
|
|
49
51
|
}
|
|
50
52
|
|
|
@@ -61,6 +63,7 @@ export const StackedCard = memo(function StackedCard({
|
|
|
61
63
|
emptyTitle: string;
|
|
62
64
|
} & Pick<StackedSheetsProps, 'renderIcon' | 'renderPreview'>) {
|
|
63
65
|
const { width, height } = useWindowDimensions();
|
|
66
|
+
const theme = useSheetTheme();
|
|
64
67
|
const { closeDraft, selectDraft } = useSheetController();
|
|
65
68
|
const sheet = useDraft(id);
|
|
66
69
|
const { overview, scroll, count: animatedCount, dock } = useMotion();
|
|
@@ -191,7 +194,11 @@ export const StackedCard = memo(function StackedCard({
|
|
|
191
194
|
projection uses the flat wrapper for touch targets. */}
|
|
192
195
|
<Animated.View
|
|
193
196
|
pointerEvents={android ? 'box-none' : 'none'}
|
|
194
|
-
style={[
|
|
197
|
+
style={[
|
|
198
|
+
styles.paper,
|
|
199
|
+
{ backgroundColor: theme.surface, borderColor: theme.border },
|
|
200
|
+
paperStyle,
|
|
201
|
+
]}
|
|
195
202
|
>
|
|
196
203
|
<Animated.View
|
|
197
204
|
pointerEvents="none"
|
|
@@ -206,11 +213,11 @@ export const StackedCard = memo(function StackedCard({
|
|
|
206
213
|
renderPreview ? (
|
|
207
214
|
<View style={styles.preview}>{renderPreview(sheet)}</View>
|
|
208
215
|
) : (
|
|
209
|
-
<SheetPreview sheet={sheet} emptyTitle={emptyTitle} />
|
|
216
|
+
<SheetPreview sheet={sheet} emptyTitle={emptyTitle} theme={theme} />
|
|
210
217
|
)
|
|
211
218
|
)}
|
|
212
219
|
</Animated.View>
|
|
213
|
-
<View pointerEvents="none" style={styles.shade} />
|
|
220
|
+
<View pointerEvents="none" style={[styles.shade, { backgroundImage: theme.depthShade }]} />
|
|
214
221
|
{android && openButton}
|
|
215
222
|
{android && closeButton}
|
|
216
223
|
</Animated.View>
|
|
@@ -220,15 +227,23 @@ export const StackedCard = memo(function StackedCard({
|
|
|
220
227
|
</GestureDetector>
|
|
221
228
|
);
|
|
222
229
|
});
|
|
223
|
-
function SheetPreview({
|
|
230
|
+
function SheetPreview({
|
|
231
|
+
sheet,
|
|
232
|
+
emptyTitle,
|
|
233
|
+
theme,
|
|
234
|
+
}: {
|
|
235
|
+
sheet: Sheet;
|
|
236
|
+
emptyTitle: string;
|
|
237
|
+
theme: SheetTheme;
|
|
238
|
+
}) {
|
|
224
239
|
const { title, body, image } = sheet;
|
|
225
240
|
return (
|
|
226
241
|
<View style={styles.content}>
|
|
227
|
-
<Text numberOfLines={1} style={styles.title}>
|
|
242
|
+
<Text numberOfLines={1} style={[styles.title, { color: theme.ink }]}>
|
|
228
243
|
{title || emptyTitle}
|
|
229
244
|
</Text>
|
|
230
245
|
<View style={styles.excerpt}>
|
|
231
|
-
<Text numberOfLines={image ? 5 : 6} style={styles.body}>
|
|
246
|
+
<Text numberOfLines={image ? 5 : 6} style={[styles.body, { color: theme.previewBody }]}>
|
|
232
247
|
{body}
|
|
233
248
|
</Text>
|
|
234
249
|
{image && <Image source={image.source} style={styles.photo} resizeMode="cover" />}
|
package/src/StackedSheets.tsx
CHANGED
|
@@ -10,6 +10,7 @@ import { StyleSheet, View } from 'react-native';
|
|
|
10
10
|
|
|
11
11
|
import { SheetStage } from './SheetStage';
|
|
12
12
|
import { createSheetController, SheetMotionProvider } from './sheetMotion';
|
|
13
|
+
import { SheetThemeProvider } from './sheetTheme';
|
|
13
14
|
import type { SheetStackParamList, StackedSheetsProps } from './types';
|
|
14
15
|
|
|
15
16
|
const Stack = createNativeStackNavigator<SheetStackParamList>();
|
|
@@ -32,40 +33,42 @@ export function StackedSheets(props: StackedSheetsProps) {
|
|
|
32
33
|
);
|
|
33
34
|
|
|
34
35
|
return (
|
|
35
|
-
<
|
|
36
|
-
<
|
|
37
|
-
<
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
<Stack.Navigator
|
|
45
|
-
initialRouteName="Inbox"
|
|
46
|
-
screenOptions={{
|
|
47
|
-
headerShown: false,
|
|
48
|
-
animation: 'none',
|
|
49
|
-
gestureEnabled: false,
|
|
50
|
-
fullScreenGestureEnabled: false,
|
|
51
|
-
freezeOnBlur: false,
|
|
52
|
-
contentStyle: styles.frame,
|
|
53
|
-
}}
|
|
36
|
+
<SheetThemeProvider colorScheme={props.colorScheme}>
|
|
37
|
+
<SheetMotionProvider controller={controller}>
|
|
38
|
+
<View style={styles.frame}>
|
|
39
|
+
<NavigationIndependentTree>
|
|
40
|
+
<NavigationContainer
|
|
41
|
+
ref={attachNavigator}
|
|
42
|
+
theme={theme}
|
|
43
|
+
initialState={controller.initialNavigationState}
|
|
44
|
+
onStateChange={controller.onNavigationStateChange}
|
|
54
45
|
>
|
|
55
|
-
<Stack.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
46
|
+
<Stack.Navigator
|
|
47
|
+
initialRouteName="Inbox"
|
|
48
|
+
screenOptions={{
|
|
49
|
+
headerShown: false,
|
|
50
|
+
animation: 'none',
|
|
51
|
+
gestureEnabled: false,
|
|
52
|
+
fullScreenGestureEnabled: false,
|
|
53
|
+
freezeOnBlur: false,
|
|
54
|
+
contentStyle: styles.frame,
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
<Stack.Screen name="Inbox" component={HistoryScreen} />
|
|
58
|
+
<Stack.Screen
|
|
59
|
+
name="Compose"
|
|
60
|
+
component={HistoryScreen}
|
|
61
|
+
getId={({ params }) => params.draftId}
|
|
62
|
+
/>
|
|
63
|
+
</Stack.Navigator>
|
|
64
|
+
</NavigationContainer>
|
|
65
|
+
</NavigationIndependentTree>
|
|
66
|
+
<View collapsable={false} style={styles.stage} pointerEvents="box-none">
|
|
67
|
+
<SheetStage {...props} />
|
|
68
|
+
</View>
|
|
66
69
|
</View>
|
|
67
|
-
</
|
|
68
|
-
</
|
|
70
|
+
</SheetMotionProvider>
|
|
71
|
+
</SheetThemeProvider>
|
|
69
72
|
);
|
|
70
73
|
}
|
|
71
74
|
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { createContext, useContext, type ReactNode } from 'react';
|
|
2
|
+
import { useColorScheme, type ColorSchemeName } from 'react-native';
|
|
3
|
+
import type { ResolvedSheetColorScheme, SheetColorScheme } from './types';
|
|
4
|
+
|
|
5
|
+
export type SheetTheme = {
|
|
6
|
+
colorScheme: ResolvedSheetColorScheme;
|
|
7
|
+
stage: string;
|
|
8
|
+
background: string;
|
|
9
|
+
surface: string;
|
|
10
|
+
border: string;
|
|
11
|
+
editorBorder: string;
|
|
12
|
+
ink: string;
|
|
13
|
+
body: string;
|
|
14
|
+
previewBody: string;
|
|
15
|
+
muted: string;
|
|
16
|
+
handle: string;
|
|
17
|
+
pressed: string;
|
|
18
|
+
pill: string;
|
|
19
|
+
danger: string;
|
|
20
|
+
dimOpacity: number;
|
|
21
|
+
shadowOpacity: number;
|
|
22
|
+
depthShade: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const LIGHT_THEME: SheetTheme = {
|
|
26
|
+
colorScheme: 'light',
|
|
27
|
+
stage: '#000',
|
|
28
|
+
background: '#FFF',
|
|
29
|
+
surface: '#FFF',
|
|
30
|
+
border: 'rgba(0,0,0,0.1)',
|
|
31
|
+
editorBorder: 'rgba(0,0,0,0.08)',
|
|
32
|
+
ink: '#111',
|
|
33
|
+
body: '#333',
|
|
34
|
+
previewBody: '#555',
|
|
35
|
+
muted: '#B0B0B5',
|
|
36
|
+
handle: '#E0E0E0',
|
|
37
|
+
pressed: '#F2F2F2',
|
|
38
|
+
pill: '#F2F2F2',
|
|
39
|
+
danger: '#A62828',
|
|
40
|
+
dimOpacity: 0.06,
|
|
41
|
+
shadowOpacity: 0.08,
|
|
42
|
+
depthShade: 'linear-gradient(to bottom, rgba(0,0,0,0) 30%, rgba(0,0,0,0.06) 100%)',
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const DARK_THEME: SheetTheme = {
|
|
46
|
+
colorScheme: 'dark',
|
|
47
|
+
stage: '#000',
|
|
48
|
+
background: '#141416',
|
|
49
|
+
surface: '#1C1C1E',
|
|
50
|
+
border: 'rgba(255,255,255,0.13)',
|
|
51
|
+
editorBorder: 'rgba(255,255,255,0.12)',
|
|
52
|
+
ink: '#F5F5F7',
|
|
53
|
+
body: '#D1D1D6',
|
|
54
|
+
previewBody: '#A1A1A6',
|
|
55
|
+
muted: '#76767A',
|
|
56
|
+
handle: 'rgba(255,255,255,0.24)',
|
|
57
|
+
pressed: '#2C2C2E',
|
|
58
|
+
pill: '#2C2C2E',
|
|
59
|
+
danger: '#FF6961',
|
|
60
|
+
dimOpacity: 0.32,
|
|
61
|
+
shadowOpacity: 0.42,
|
|
62
|
+
depthShade: 'linear-gradient(to bottom, rgba(0,0,0,0) 20%, rgba(0,0,0,0.42) 100%)',
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export function resolveSheetColorScheme(
|
|
66
|
+
preference: SheetColorScheme | undefined,
|
|
67
|
+
system: ColorSchemeName | null,
|
|
68
|
+
): ResolvedSheetColorScheme {
|
|
69
|
+
if (preference === 'light' || preference === 'dark') return preference;
|
|
70
|
+
return system === 'dark' ? 'dark' : 'light';
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const ThemeContext = createContext<SheetTheme>(LIGHT_THEME);
|
|
74
|
+
|
|
75
|
+
export function SheetThemeProvider({
|
|
76
|
+
colorScheme,
|
|
77
|
+
children,
|
|
78
|
+
}: {
|
|
79
|
+
colorScheme?: SheetColorScheme;
|
|
80
|
+
children: ReactNode;
|
|
81
|
+
}) {
|
|
82
|
+
const system = useColorScheme();
|
|
83
|
+
const resolved = resolveSheetColorScheme(colorScheme, system);
|
|
84
|
+
const theme = resolved === 'dark' ? DARK_THEME : LIGHT_THEME;
|
|
85
|
+
return <ThemeContext.Provider value={theme}>{children}</ThemeContext.Provider>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function useSheetTheme() {
|
|
89
|
+
return useContext(ThemeContext);
|
|
90
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -21,6 +21,8 @@ export type InitialSheet = SheetContent & { id?: string };
|
|
|
21
21
|
export type SheetOrigin = { x: number; y: number; width: number; height: number };
|
|
22
22
|
export type SheetMode = 'inbox' | 'compose' | 'overview';
|
|
23
23
|
export type SheetIcon = 'sheet' | 'expand' | 'minimize' | 'close';
|
|
24
|
+
export type ResolvedSheetColorScheme = 'light' | 'dark';
|
|
25
|
+
export type SheetColorScheme = ResolvedSheetColorScheme | 'system';
|
|
24
26
|
|
|
25
27
|
export type SheetBackgroundProps = {
|
|
26
28
|
active: boolean;
|
|
@@ -39,8 +41,9 @@ export type StackedSheetsProps = {
|
|
|
39
41
|
renderPreview?: (sheet: Sheet) => ReactNode;
|
|
40
42
|
renderEditor?: (props: SheetEditorProps) => ReactNode;
|
|
41
43
|
onSaveSheet?: (sheet: Sheet) => boolean;
|
|
42
|
-
renderIcon?: (name: SheetIcon, size: number) => ReactNode;
|
|
43
|
-
renderStatusBar?: (mode: SheetMode) => ReactNode;
|
|
44
|
+
renderIcon?: (name: SheetIcon, size: number, color: string) => ReactNode;
|
|
45
|
+
renderStatusBar?: (mode: SheetMode, colorScheme: ResolvedSheetColorScheme) => ReactNode;
|
|
46
|
+
colorScheme?: SheetColorScheme;
|
|
44
47
|
emptyTitle?: string;
|
|
45
48
|
};
|
|
46
49
|
|