expo-stacked-sheets 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,15 @@
1
1
  # Expo Stacked Sheets
2
2
 
3
- Edit multiple drafts in an Expo app. Minimize them to keep using the current
4
- screen, then reopen any draft from an iOS Mail-style card overview.
3
+ 3D stacked sheets for Expo and React Native. Works on iOS and Android.
4
+
5
+ ## Demo
6
+
7
+ [![Three drafts in the Notes card overview][demo-cover]][demo-video]
8
+
9
+ [Watch the 13-second Notes demo][demo-video]
10
+
11
+ [demo-cover]: https://raw.githubusercontent.com/siyo-ch/expo-stacked-sheets/main/assets/demo/notes-demo-cover.jpg
12
+ [demo-video]: https://cdn.jsdelivr.net/gh/siyo-ch/expo-stacked-sheets@main/assets/demo/notes-demo.mp4
5
13
 
6
14
  ## Install
7
15
 
@@ -11,11 +19,13 @@ Requires Expo SDK 58 and React Native 0.88.
11
19
  npx expo install expo-stacked-sheets
12
20
  ```
13
21
 
14
- If your SDK patch uses Safe Area Context 5.10.x (such as Expo 58.0.22), include
15
- `'react-native-safe-area-context@~5.10.1'` in the install command.
22
+ On Expo 58.0.22, use
23
+ `npx expo install expo-stacked-sheets 'react-native-safe-area-context@~5.10.1'`.
16
24
 
17
25
  ## Usage
18
26
 
27
+ Add this to `App.tsx` or a full-screen Expo Router route.
28
+
19
29
  ```tsx
20
30
  import { StackedSheets } from 'expo-stacked-sheets';
21
31
  import { Button } from 'react-native';
@@ -27,9 +37,13 @@ export default function App() {
27
37
  <GestureHandlerRootView style={{ flex: 1 }}>
28
38
  <SafeAreaProvider>
29
39
  <StackedSheets
40
+ initialSheets={[
41
+ { title: 'Weekend plans', body: 'Pick a place for breakfast.' },
42
+ { title: 'Reading list', body: 'Finish the last chapter.' },
43
+ ]}
30
44
  renderBackground={({ active, openSheet }) => (
31
45
  <SafeAreaView>
32
- <Button title="New draft" disabled={!active} onPress={() => openSheet()} />
46
+ <Button title="New sheet" disabled={!active} onPress={() => openSheet()} />
33
47
  </SafeAreaView>
34
48
  )}
35
49
  />
@@ -39,17 +53,16 @@ export default function App() {
39
53
  }
40
54
  ```
41
55
 
42
- Reuse the providers if your app already has them. Drafts stay in memory.
43
- Use `onSaveSheet` to save them in your app.
44
- [Component props](https://github.com/Fizzbow/expo-stacked-sheets/blob/main/packages/stacked-sheets/src/types.ts)
56
+ Tap the bar at the bottom to see both sheets. The down arrow minimizes a sheet.
57
+
58
+ Sheets stay in memory. To enable Save, pass a synchronous `onSaveSheet` callback
59
+ that returns `true` when the save succeeds.
60
+ [Component props](https://github.com/siyo-ch/expo-stacked-sheets/blob/main/packages/stacked-sheets/src/types.ts)
45
61
 
46
62
  ## Run the Notes demo
47
63
 
48
- From a [repository checkout](https://github.com/Fizzbow/expo-stacked-sheets), run
64
+ From a [repository checkout](https://github.com/siyo-ch/expo-stacked-sheets), run
49
65
  `npm ci && npm start`. Press `i` for iOS or `a` for Android.
50
- [Photo credits](https://github.com/Fizzbow/expo-stacked-sheets/blob/main/assets/notes/CREDITS.md)
51
-
52
- For an unpublished build, run `npm pack --workspace expo-stacked-sheets` and
53
- install the resulting `.tgz` in your Expo app.
66
+ [Photo credits](https://github.com/siyo-ch/expo-stacked-sheets/blob/main/assets/notes/CREDITS.md)
54
67
 
55
- [MIT](https://github.com/Fizzbow/expo-stacked-sheets/blob/main/LICENSE)
68
+ [MIT](https://github.com/siyo-ch/expo-stacked-sheets/blob/main/LICENSE)
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "expo-stacked-sheets",
3
- "version": "1.0.0",
4
- "description": "Stacked sheet editing and overview for Expo and React Native",
5
- "keywords": ["expo", "react-native", "stacked-sheets", "drafts", "reanimated"],
3
+ "version": "1.0.2",
4
+ "description": "3D stacked sheets for Expo and React Native, built with Reanimated and Gesture Handler.",
5
+ "keywords": ["expo", "react-native", "stacked-sheets", "bottom-sheet", "sheet", "3d", "reanimated", "gesture-handler", "ios", "android"],
6
6
  "license": "MIT",
7
- "homepage": "https://github.com/Fizzbow/expo-stacked-sheets",
8
- "bugs": "https://github.com/Fizzbow/expo-stacked-sheets/issues",
7
+ "homepage": "https://github.com/siyo-ch/expo-stacked-sheets",
8
+ "bugs": "https://github.com/siyo-ch/expo-stacked-sheets/issues",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "git+https://github.com/Fizzbow/expo-stacked-sheets.git",
11
+ "url": "git+https://github.com/siyo-ch/expo-stacked-sheets.git",
12
12
  "directory": "packages/stacked-sheets"
13
13
  },
14
14
  "main": "./src/index.ts",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "files": ["src"],
25
25
  "scripts": {
26
- "prepack": "node -e \"require('node:fs').copyFileSync('../../README.md', 'README.md')\""
26
+ "prepack": "node scripts/prepare-readme.cjs"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "@react-navigation/native": "^7.5.1",
@@ -0,0 +1,62 @@
1
+ import { StyleSheet, Text, View } from 'react-native';
2
+ import Animated, { type AnimatedStyle } from 'react-native-reanimated';
3
+ import { SheetControlIcon } from './StackedCard';
4
+ import type { StackedSheetsProps } from './types';
5
+
6
+ export function SheetDockContent({
7
+ title,
8
+ count,
9
+ renderIcon,
10
+ controlsStyle,
11
+ }: Pick<StackedSheetsProps, 'renderIcon'> & {
12
+ title: string;
13
+ count: number;
14
+ controlsStyle?: AnimatedStyle<{ opacity: number }>;
15
+ }) {
16
+ const hasStack = count > 1;
17
+
18
+ return (
19
+ <View pointerEvents="none" style={styles.row}>
20
+ <View style={[styles.titleInset, hasStack && styles.stackTitleInset]}>
21
+ <Text numberOfLines={1} style={styles.title}>{title}</Text>
22
+ </View>
23
+ <Animated.View style={[styles.controls, controlsStyle]}>
24
+ <SheetControlIcon name="sheet" size={20} renderIcon={renderIcon} />
25
+ {hasStack && (
26
+ <View style={styles.trailing}>
27
+ <View style={styles.pill}>
28
+ <Text numberOfLines={1} style={styles.count}>{count}</Text>
29
+ </View>
30
+ <SheetControlIcon name="expand" size={18} renderIcon={renderIcon} />
31
+ </View>
32
+ )}
33
+ </Animated.View>
34
+ </View>
35
+ );
36
+ }
37
+
38
+ const styles = StyleSheet.create({
39
+ row: { flex: 1, justifyContent: 'center' },
40
+ titleInset: { paddingHorizontal: 50 },
41
+ stackTitleInset: { paddingHorizontal: 94 },
42
+ title: { textAlign: 'center', fontSize: 16, fontWeight: '600', color: '#111' },
43
+ controls: {
44
+ ...StyleSheet.absoluteFill,
45
+ flexDirection: 'row',
46
+ alignItems: 'center',
47
+ justifyContent: 'space-between',
48
+ paddingHorizontal: 22,
49
+ },
50
+ trailing: { maxWidth: 64, flexDirection: 'row', alignItems: 'center', gap: 10 },
51
+ pill: {
52
+ height: 26,
53
+ minWidth: 26,
54
+ flexShrink: 1,
55
+ paddingHorizontal: 6,
56
+ borderRadius: 13,
57
+ alignItems: 'center',
58
+ justifyContent: 'center',
59
+ backgroundColor: '#F2F2F2',
60
+ },
61
+ count: { color: '#111', fontSize: 13, fontWeight: '500' },
62
+ });
@@ -30,6 +30,7 @@ import {
30
30
  shouldMinimize,
31
31
  } from './sheetLayout';
32
32
  import { useDraft, useMailView, useMotion, useSheetController } from './sheetMotion';
33
+ import { SheetDockContent } from './SheetDockContent';
33
34
  import { SheetControlIcon } from './StackedCard';
34
35
  import type { SheetContent, StackedSheetsProps } from './types';
35
36
 
@@ -42,12 +43,14 @@ function dismissKeyboard() {
42
43
  /** One editor shell is reused across sheets. Other sheets render lightweight previews. */
43
44
  export function SheetEditor({
44
45
  id,
46
+ draftCount,
45
47
  emptyTitle,
46
48
  renderEditor,
47
49
  onSaveSheet,
48
50
  renderIcon,
49
51
  }: {
50
52
  id: string | null;
53
+ draftCount: number;
51
54
  emptyTitle: string;
52
55
  } & Pick<StackedSheetsProps, 'renderEditor' | 'renderIcon' | 'onSaveSheet'>) {
53
56
  const sheet = useDraft(id ?? '');
@@ -127,8 +130,13 @@ export function SheetEditor({
127
130
  left: (frame.value.width - width) / 2,
128
131
  opacity: clamp((frame.value.progress - 0.22) / 0.56, 0, 1),
129
132
  }));
133
+ // Match the real dock before the editor paper disappears at the end of the spring.
130
134
  const compactStyle = useAnimatedStyle(() => ({
131
- opacity: frame.value.compact * clamp((0.28 - frame.value.progress) / 0.28, 0, 1),
135
+ opacity: clamp(frame.value.compact / 0.96, 0, 1)
136
+ * clamp((0.28 - frame.value.progress) / 0.24, 0, 1),
137
+ }));
138
+ const compactControlsStyle = useAnimatedStyle(() => ({
139
+ opacity: clamp((0.12 - frame.value.progress) / 0.1, 0, 1),
132
140
  }));
133
141
  const title = sheet?.title ?? '';
134
142
  const image = sheet?.image;
@@ -271,9 +279,12 @@ export function SheetEditor({
271
279
  accessibilityElementsHidden
272
280
  style={[styles.compact, compactStyle]}
273
281
  >
274
- <Text numberOfLines={1} style={styles.compactTitle}>
275
- {title || emptyTitle}
276
- </Text>
282
+ <SheetDockContent
283
+ title={title || emptyTitle}
284
+ count={draftCount}
285
+ renderIcon={renderIcon}
286
+ controlsStyle={compactControlsStyle}
287
+ />
277
288
  </Animated.View>
278
289
  </Animated.View>
279
290
  );
@@ -294,8 +305,7 @@ const styles = StyleSheet.create({
294
305
  },
295
306
  editorContent: { position: 'absolute', top: 0 },
296
307
  flex: { flex: 1 },
297
- compact: { ...StyleSheet.absoluteFill, alignItems: 'center', justifyContent: 'center' },
298
- compactTitle: { fontSize: 16, fontWeight: '600', color: INK, paddingHorizontal: 24 },
308
+ compact: { ...StyleSheet.absoluteFill },
299
309
  header: { paddingBottom: 4 },
300
310
  handleButton: { height: 20, alignItems: 'center', justifyContent: 'center' },
301
311
  handle: { width: 36, height: 5, borderRadius: 3, backgroundColor: '#E0E0E0' },
@@ -1,7 +1,6 @@
1
1
  import { useEffect } from 'react';
2
2
  import {
3
3
  StyleSheet,
4
- Text,
5
4
  Pressable,
6
5
  View,
7
6
  Platform,
@@ -24,9 +23,10 @@ import {
24
23
  paperTransforms,
25
24
  clamp,
26
25
  } from './sheetLayout';
26
+ import { SheetDockContent } from './SheetDockContent';
27
27
  import { SheetEditor } from './SheetEditor';
28
28
  import { useDraft, useDraftIds, useMailView, useMotion, useSheetController } from './sheetMotion';
29
- import { SheetControlIcon, StackedCard } from './StackedCard';
29
+ import { StackedCard } from './StackedCard';
30
30
  import type { StackedSheetsProps } from './types';
31
31
 
32
32
  const android = Platform.OS === 'android';
@@ -48,7 +48,8 @@ export function SheetStage({
48
48
  const { overview, scroll, editor, count, dock } = useMotion();
49
49
  const dockHeight = dock.height;
50
50
  const dockBottom = height - dock.top - dock.height;
51
- const topSheet = useDraft(ids.at(-1) ?? '');
51
+ const dockId = activeId && ids.includes(activeId) ? activeId : ids.at(-1);
52
+ const dockSheet = useDraft(dockId ?? '');
52
53
  useEffect(() => {
53
54
  count.set(withSpring(ids.length, SPRING));
54
55
  const limit = deckMetrics(height, ids.length).maxScroll;
@@ -187,25 +188,19 @@ export function SheetStage({
187
188
  else showOverview();
188
189
  }}
189
190
  onLongPress={showOverview}
190
- style={styles.dockButton}
191
+ style={styles.fill}
191
192
  >
192
- <SheetControlIcon name="sheet" size={20} renderIcon={renderIcon} />
193
- <Text numberOfLines={1} style={styles.dockTitle}>
194
- {topSheet?.title || emptyTitle}
195
- </Text>
196
- {ids.length > 1 && (
197
- <>
198
- <View style={styles.dockPill}>
199
- <Text style={styles.dockPillText}>{ids.length}</Text>
200
- </View>
201
- <SheetControlIcon name="expand" size={18} renderIcon={renderIcon} />
202
- </>
203
- )}
193
+ <SheetDockContent
194
+ title={dockSheet?.title || emptyTitle}
195
+ count={ids.length}
196
+ renderIcon={renderIcon}
197
+ />
204
198
  </Pressable>
205
199
  </Animated.View>
206
200
  )}
207
201
  <SheetEditor
208
202
  id={activeId}
203
+ draftCount={ids.length}
209
204
  emptyTitle={emptyTitle}
210
205
  renderEditor={renderEditor}
211
206
  onSaveSheet={onSaveSheet}
@@ -252,22 +247,5 @@ const styles = StyleSheet.create({
252
247
  shadowRadius: 16,
253
248
  shadowOffset: { width: 0, height: 4 },
254
249
  },
255
- dockButton: {
256
- flex: 1,
257
- flexDirection: 'row',
258
- alignItems: 'center',
259
- paddingHorizontal: 22,
260
- gap: 10,
261
- },
262
- dockTitle: { flex: 1, fontSize: 16, fontWeight: '600', color: '#111' },
263
- dockPill: {
264
- height: 26,
265
- minWidth: 26,
266
- borderRadius: 13,
267
- paddingHorizontal: 8,
268
- alignItems: 'center',
269
- justifyContent: 'center',
270
- backgroundColor: '#F2F2F2',
271
- },
272
- dockPillText: { fontSize: 13, fontWeight: '500', color: '#111' },
250
+ fill: { flex: 1 },
273
251
  });