expo-stacked-sheets 1.0.0 → 1.0.1

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
@@ -3,6 +3,15 @@
3
3
  Edit multiple drafts in an Expo app. Minimize them to keep using the current
4
4
  screen, then reopen any draft from an iOS Mail-style card overview.
5
5
 
6
+ ## Demo
7
+
8
+ [![Three drafts in the Notes card overview][demo-cover]][demo-video]
9
+
10
+ [Watch the 13-second Notes demo][demo-video]
11
+
12
+ [demo-cover]: https://raw.githubusercontent.com/siyo-ch/expo-stacked-sheets/main/assets/demo/notes-demo-cover.jpg
13
+ [demo-video]: https://cdn.jsdelivr.net/gh/siyo-ch/expo-stacked-sheets@main/assets/demo/notes-demo.mp4
14
+
6
15
  ## Install
7
16
 
8
17
  Requires Expo SDK 58 and React Native 0.88.
@@ -41,15 +50,15 @@ export default function App() {
41
50
 
42
51
  Reuse the providers if your app already has them. Drafts stay in memory.
43
52
  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)
53
+ [Component props](https://github.com/siyo-ch/expo-stacked-sheets/blob/main/packages/stacked-sheets/src/types.ts)
45
54
 
46
55
  ## Run the Notes demo
47
56
 
48
- From a [repository checkout](https://github.com/Fizzbow/expo-stacked-sheets), run
57
+ From a [repository checkout](https://github.com/siyo-ch/expo-stacked-sheets), run
49
58
  `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)
59
+ [Photo credits](https://github.com/siyo-ch/expo-stacked-sheets/blob/main/assets/notes/CREDITS.md)
51
60
 
52
61
  For an unpublished build, run `npm pack --workspace expo-stacked-sheets` and
53
62
  install the resulting `.tgz` in your Expo app.
54
63
 
55
- [MIT](https://github.com/Fizzbow/expo-stacked-sheets/blob/main/LICENSE)
64
+ [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",
3
+ "version": "1.0.1",
4
4
  "description": "Stacked sheet editing and overview for Expo and React Native",
5
5
  "keywords": ["expo", "react-native", "stacked-sheets", "drafts", "reanimated"],
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",
@@ -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
  });