1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
import React from 'react'
import {ScrollView, View} from 'react-native'
import {deleteAsync} from 'expo-file-system'
import {saveToLibraryAsync} from 'expo-media-library'
import {useSetThemePrefs} from '#/state/shell'
import {useVideoLibraryPermission} from 'lib/hooks/usePermissions'
import {isIOS, isWeb} from 'platform/detection'
import {CenteredView} from '#/view/com/util/Views'
import * as Toast from 'view/com/util/Toast'
import {ListContained} from 'view/screens/Storybook/ListContained'
import {atoms as a, ThemeProvider, useTheme} from '#/alf'
import {Button, ButtonText} from '#/components/Button'
import {HLSDownloadView} from '../../../../modules/expo-bluesky-swiss-army'
import {Breakpoints} from './Breakpoints'
import {Buttons} from './Buttons'
import {Dialogs} from './Dialogs'
import {Forms} from './Forms'
import {Icons} from './Icons'
import {Links} from './Links'
import {Menus} from './Menus'
import {Shadows} from './Shadows'
import {Spacing} from './Spacing'
import {Theming} from './Theming'
import {Typography} from './Typography'
export function Storybook() {
if (isWeb) return <StorybookInner />
return (
<ScrollView>
<StorybookInner />
</ScrollView>
)
}
function StorybookInner() {
const t = useTheme()
const {setColorMode, setDarkTheme} = useSetThemePrefs()
const [showContainedList, setShowContainedList] = React.useState(false)
const hlsDownloadRef = React.useRef<HLSDownloadView>(null)
const {requestVideoAccessIfNeeded} = useVideoLibraryPermission()
return (
<CenteredView style={[t.atoms.bg]}>
<View style={[a.p_xl, a.gap_5xl, {paddingBottom: 100}]}>
<HLSDownloadView
ref={hlsDownloadRef}
downloaderUrl={
isIOS
? 'http://localhost:19006/video-download'
: 'http://10.0.2.2:19006/video-download'
}
onSuccess={async e => {
const uri = e.nativeEvent.uri
const permsRes = await requestVideoAccessIfNeeded()
if (!permsRes) return
await saveToLibraryAsync(uri)
try {
deleteAsync(uri)
} catch (err) {
console.error('Failed to delete file', err)
}
Toast.show('Video saved to library')
}}
onStart={() => console.log('Download is starting')}
onError={e => console.log(e.nativeEvent.message)}
onProgress={e => console.log(e.nativeEvent.progress)}
/>
<Button
variant="solid"
color="primary"
size="small"
onPress={async () => {
hlsDownloadRef.current?.startDownloadAsync(
'https://lumi.jazco.dev/watch/did:plc:q6gjnaw2blty4crticxkmujt/Qmc8w93UpTa2adJHg4ZhnDPrBs1EsbzrekzPcqF5SwusuZ/playlist.m3u8?download=true',
)
}}
label="Video download test">
<ButtonText>Video download test</ButtonText>
</Button>
{!showContainedList ? (
<>
<View style={[a.flex_row, a.align_start, a.gap_md]}>
<Button
variant="outline"
color="primary"
size="small"
label='Set theme to "system"'
onPress={() => setColorMode('system')}>
<ButtonText>System</ButtonText>
</Button>
<Button
variant="solid"
color="secondary"
size="small"
label='Set theme to "light"'
onPress={() => setColorMode('light')}>
<ButtonText>Light</ButtonText>
</Button>
<Button
variant="solid"
color="secondary"
size="small"
label='Set theme to "dim"'
onPress={() => {
setColorMode('dark')
setDarkTheme('dim')
}}>
<ButtonText>Dim</ButtonText>
</Button>
<Button
variant="solid"
color="secondary"
size="small"
label='Set theme to "dark"'
onPress={() => {
setColorMode('dark')
setDarkTheme('dark')
}}>
<ButtonText>Dark</ButtonText>
</Button>
</View>
<Dialogs />
<ThemeProvider theme="light">
<Theming />
</ThemeProvider>
<ThemeProvider theme="dim">
<Theming />
</ThemeProvider>
<ThemeProvider theme="dark">
<Theming />
</ThemeProvider>
<Typography />
<Spacing />
<Shadows />
<Buttons />
<Icons />
<Links />
<Forms />
<Dialogs />
<Menus />
<Breakpoints />
<Button
variant="solid"
color="primary"
size="large"
label="Switch to Contained List"
onPress={() => setShowContainedList(true)}>
<ButtonText>Switch to Contained List</ButtonText>
</Button>
</>
) : (
<>
<Button
variant="solid"
color="primary"
size="large"
label="Switch to Storybook"
onPress={() => setShowContainedList(false)}>
<ButtonText>Switch to Storybook</ButtonText>
</Button>
<ListContained />
</>
)}
</View>
</CenteredView>
)
}
|