@applicaster/zapp-react-native-utils 16.0.0-alpha.9530606740 → 16.0.0-alpha.9572544619
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/actionsExecutor/ActionExecutorContext.tsx +2 -2
- package/actionsExecutor/actions/index.ts +1 -1
- package/actionsExecutor/actions/showToast.ts +31 -0
- package/actionsExecutor/types.ts +1 -1
- package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +12 -6
- package/appUtils/playerManager/conts.ts +6 -0
- package/arrayUtils/__tests__/{anyThruthy.test.ts → anyTruthy.test.ts} +8 -0
- package/arrayUtils/__tests__/arrayUtils.test.ts +165 -108
- package/arrayUtils/__tests__/isEmptyArray.test.ts +11 -0
- package/arrayUtils/__tests__/isFilledArray.test.ts +12 -0
- package/arrayUtils/__tests__/isFirst.test.ts +17 -0
- package/arrayUtils/__tests__/isIndexInRange.test.ts +14 -0
- package/arrayUtils/__tests__/isLast.test.ts +31 -0
- package/arrayUtils/__tests__/makeListOf.test.ts +31 -0
- package/arrayUtils/__tests__/makeListOfIndexes.test.ts +20 -0
- package/arrayUtils/__tests__/sample.test.ts +61 -0
- package/arrayUtils/index.ts +57 -20
- package/bottomSheet/__tests__/scrollContext.test.tsx +35 -0
- package/bottomSheet/index.ts +17 -0
- package/manifestUtils/defaultManifestConfigurations/player.js +19 -19
- package/modalState/index.ts +74 -25
- package/numberUtils/__tests__/isMinusZero.test.ts +20 -0
- package/numberUtils/__tests__/isZero.test.ts +27 -0
- package/numberUtils/__tests__/requireNumber.test.ts +50 -0
- package/numberUtils/__tests__/toNumber.test.ts +27 -0
- package/numberUtils/__tests__/toNumberWithDefault.test.ts +64 -0
- package/numberUtils/__tests__/toNumberWithDefaultZero.test.ts +48 -0
- package/numberUtils/index.ts +27 -8
- package/package.json +2 -2
- package/reactHooks/feed/__tests__/useInflatedUrl.test.tsx +25 -0
- package/reactHooks/layout/index.ts +1 -1
- package/reactHooks/navigation/__mocks__/index.ts +4 -0
- package/reactHooks/navigation/__tests__/useIsScreenActive.test.ts +42 -0
- package/reactHooks/navigation/index.ts +1 -1
- package/reactHooks/navigation/useIsScreenActive.ts +29 -8
- package/reactHooks/state/useComponentScreenState.ts +1 -1
- package/stringUtils/__tests__/stringUtils.test.js +42 -0
- package/stringUtils/index.ts +2 -2
- package/zappFrameworkUtils/__tests__/localStorageHelper.test.ts +146 -0
- package/zappFrameworkUtils/localStorageHelper.ts +9 -13
- package/actionsExecutor/actions/openBottomSheet.ts +0 -177
- package/modalState/ContentViewModel.ts +0 -59
- package/modalState/ModalOrchestrator.ts +0 -204
- package/modalState/__tests__/ContentViewModel.test.ts +0 -107
- package/modalState/components/ActionItem.tsx +0 -155
- package/modalState/components/BottomSheetHeader.tsx +0 -245
- package/modalState/components/PrimaryButton.tsx +0 -54
- package/modalState/components/TrackItem.tsx +0 -241
- package/modalState/store.ts +0 -102
- package/modalState/types.ts +0 -55
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
View,
|
|
4
|
-
Text,
|
|
5
|
-
StyleSheet,
|
|
6
|
-
Pressable,
|
|
7
|
-
ActivityIndicator,
|
|
8
|
-
} from "react-native";
|
|
9
|
-
|
|
10
|
-
const styles = StyleSheet.create({
|
|
11
|
-
headerContainer: {
|
|
12
|
-
flexDirection: "row",
|
|
13
|
-
alignItems: "center",
|
|
14
|
-
justifyContent: "space-between",
|
|
15
|
-
backgroundColor: "#262626",
|
|
16
|
-
paddingVertical: 12,
|
|
17
|
-
},
|
|
18
|
-
navBarBorder: {
|
|
19
|
-
borderBottomWidth: 1,
|
|
20
|
-
borderBottomColor: "#333333",
|
|
21
|
-
},
|
|
22
|
-
headerGutter16: {
|
|
23
|
-
paddingHorizontal: 16,
|
|
24
|
-
},
|
|
25
|
-
headerGutter12: {
|
|
26
|
-
paddingHorizontal: 12,
|
|
27
|
-
},
|
|
28
|
-
headerTitle: {
|
|
29
|
-
color: "#FFFFFF",
|
|
30
|
-
fontWeight: "bold",
|
|
31
|
-
fontSize: 16,
|
|
32
|
-
textAlign: "center",
|
|
33
|
-
},
|
|
34
|
-
headerTitleCenter: {
|
|
35
|
-
fontSize: 17,
|
|
36
|
-
flex: 1,
|
|
37
|
-
textAlign: "center",
|
|
38
|
-
},
|
|
39
|
-
headerTitleSection: {
|
|
40
|
-
color: "#aaaaaa",
|
|
41
|
-
fontSize: 13,
|
|
42
|
-
fontWeight: "600",
|
|
43
|
-
textTransform: "uppercase",
|
|
44
|
-
},
|
|
45
|
-
titleWrapper: {
|
|
46
|
-
flex: 1,
|
|
47
|
-
alignItems: "center",
|
|
48
|
-
justifyContent: "center",
|
|
49
|
-
},
|
|
50
|
-
subtitle: {
|
|
51
|
-
color: "#aaaaaa",
|
|
52
|
-
fontSize: 11,
|
|
53
|
-
marginTop: 2,
|
|
54
|
-
textAlign: "center",
|
|
55
|
-
},
|
|
56
|
-
backButton: {
|
|
57
|
-
paddingVertical: 6,
|
|
58
|
-
paddingHorizontal: 12,
|
|
59
|
-
borderRadius: 6,
|
|
60
|
-
backgroundColor: "#333333",
|
|
61
|
-
width: 70,
|
|
62
|
-
alignItems: "center",
|
|
63
|
-
justifyContent: "center",
|
|
64
|
-
},
|
|
65
|
-
backButtonText: {
|
|
66
|
-
color: "#ffffff",
|
|
67
|
-
fontSize: 14,
|
|
68
|
-
fontWeight: "600",
|
|
69
|
-
},
|
|
70
|
-
closeButton: {
|
|
71
|
-
width: 44,
|
|
72
|
-
height: 44,
|
|
73
|
-
alignItems: "center",
|
|
74
|
-
justifyContent: "center",
|
|
75
|
-
},
|
|
76
|
-
closeButtonText: {
|
|
77
|
-
color: "#FFFFFF",
|
|
78
|
-
fontSize: 18,
|
|
79
|
-
},
|
|
80
|
-
headerActionButton: {
|
|
81
|
-
backgroundColor: "#3e3e3e",
|
|
82
|
-
paddingVertical: 6,
|
|
83
|
-
paddingHorizontal: 10,
|
|
84
|
-
borderRadius: 16,
|
|
85
|
-
minWidth: 70,
|
|
86
|
-
alignItems: "center",
|
|
87
|
-
justifyContent: "center",
|
|
88
|
-
},
|
|
89
|
-
headerActionText: {
|
|
90
|
-
color: "#FFFFFF",
|
|
91
|
-
fontWeight: "600",
|
|
92
|
-
fontSize: 14,
|
|
93
|
-
},
|
|
94
|
-
navSpacer: {
|
|
95
|
-
width: 70,
|
|
96
|
-
alignItems: "center",
|
|
97
|
-
justifyContent: "center",
|
|
98
|
-
},
|
|
99
|
-
pressedState: {
|
|
100
|
-
opacity: 0.7,
|
|
101
|
-
},
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
export interface BottomSheetHeaderProps {
|
|
105
|
-
variant?: "single" | "actions" | "section";
|
|
106
|
-
title: string;
|
|
107
|
-
subtitle?: string;
|
|
108
|
-
onClose?: () => void;
|
|
109
|
-
onBack?: () => void;
|
|
110
|
-
onCancel?: () => void;
|
|
111
|
-
onDone?: () => void;
|
|
112
|
-
onClear?: () => void;
|
|
113
|
-
isLoading?: boolean;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export const BottomSheetHeader: React.FC<BottomSheetHeaderProps> = ({
|
|
117
|
-
variant = "single",
|
|
118
|
-
title,
|
|
119
|
-
subtitle,
|
|
120
|
-
onClose,
|
|
121
|
-
onBack,
|
|
122
|
-
onCancel,
|
|
123
|
-
onDone,
|
|
124
|
-
onClear,
|
|
125
|
-
isLoading = false,
|
|
126
|
-
}) => {
|
|
127
|
-
if (variant === "actions") {
|
|
128
|
-
return (
|
|
129
|
-
<View
|
|
130
|
-
style={[
|
|
131
|
-
styles.headerContainer,
|
|
132
|
-
styles.headerGutter12,
|
|
133
|
-
styles.navBarBorder,
|
|
134
|
-
]}
|
|
135
|
-
>
|
|
136
|
-
<Pressable
|
|
137
|
-
style={({ pressed }) => [
|
|
138
|
-
styles.headerActionButton,
|
|
139
|
-
pressed && styles.pressedState,
|
|
140
|
-
]}
|
|
141
|
-
onPress={onCancel}
|
|
142
|
-
>
|
|
143
|
-
<Text style={styles.headerActionText}>Cancel</Text>
|
|
144
|
-
</Pressable>
|
|
145
|
-
<View style={styles.titleWrapper}>
|
|
146
|
-
<Text
|
|
147
|
-
numberOfLines={1}
|
|
148
|
-
style={[styles.headerTitle, styles.headerTitleCenter]}
|
|
149
|
-
>
|
|
150
|
-
{title}
|
|
151
|
-
</Text>
|
|
152
|
-
{subtitle ? (
|
|
153
|
-
<Text numberOfLines={1} style={styles.subtitle}>
|
|
154
|
-
{subtitle}
|
|
155
|
-
</Text>
|
|
156
|
-
) : null}
|
|
157
|
-
</View>
|
|
158
|
-
<Pressable
|
|
159
|
-
style={({ pressed }) => [
|
|
160
|
-
styles.headerActionButton,
|
|
161
|
-
pressed && styles.pressedState,
|
|
162
|
-
]}
|
|
163
|
-
onPress={onDone}
|
|
164
|
-
>
|
|
165
|
-
<Text style={styles.headerActionText}>Done</Text>
|
|
166
|
-
</Pressable>
|
|
167
|
-
</View>
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (variant === "section") {
|
|
172
|
-
return (
|
|
173
|
-
<View style={[styles.headerContainer, styles.headerGutter12]}>
|
|
174
|
-
<Text style={[styles.headerTitle, styles.headerTitleSection]}>
|
|
175
|
-
{title}
|
|
176
|
-
</Text>
|
|
177
|
-
{onClear ? (
|
|
178
|
-
<Pressable
|
|
179
|
-
style={({ pressed }) => [
|
|
180
|
-
styles.headerActionButton,
|
|
181
|
-
pressed && styles.pressedState,
|
|
182
|
-
]}
|
|
183
|
-
onPress={onClear}
|
|
184
|
-
>
|
|
185
|
-
<Text style={styles.headerActionText}>Clear</Text>
|
|
186
|
-
</Pressable>
|
|
187
|
-
) : null}
|
|
188
|
-
</View>
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// Default: Single Line with Back and Close button options
|
|
193
|
-
return (
|
|
194
|
-
<View
|
|
195
|
-
style={[
|
|
196
|
-
styles.headerContainer,
|
|
197
|
-
styles.headerGutter16,
|
|
198
|
-
styles.navBarBorder,
|
|
199
|
-
]}
|
|
200
|
-
>
|
|
201
|
-
{onBack ? (
|
|
202
|
-
<Pressable
|
|
203
|
-
onPress={onBack}
|
|
204
|
-
style={({ pressed }) => [
|
|
205
|
-
styles.backButton,
|
|
206
|
-
pressed && styles.pressedState,
|
|
207
|
-
]}
|
|
208
|
-
>
|
|
209
|
-
<Text style={styles.backButtonText}>‹ Back</Text>
|
|
210
|
-
</Pressable>
|
|
211
|
-
) : (
|
|
212
|
-
<View style={styles.navSpacer} />
|
|
213
|
-
)}
|
|
214
|
-
|
|
215
|
-
<View style={styles.titleWrapper}>
|
|
216
|
-
<Text numberOfLines={1} style={styles.headerTitle}>
|
|
217
|
-
{title}
|
|
218
|
-
</Text>
|
|
219
|
-
{subtitle ? (
|
|
220
|
-
<Text numberOfLines={1} style={styles.subtitle}>
|
|
221
|
-
{subtitle}
|
|
222
|
-
</Text>
|
|
223
|
-
) : null}
|
|
224
|
-
</View>
|
|
225
|
-
|
|
226
|
-
{isLoading ? (
|
|
227
|
-
<View style={styles.navSpacer}>
|
|
228
|
-
<ActivityIndicator size="small" color="#aaaaaa" />
|
|
229
|
-
</View>
|
|
230
|
-
) : onClose ? (
|
|
231
|
-
<Pressable
|
|
232
|
-
style={({ pressed }) => [
|
|
233
|
-
styles.closeButton,
|
|
234
|
-
pressed && styles.pressedState,
|
|
235
|
-
]}
|
|
236
|
-
onPress={onClose}
|
|
237
|
-
>
|
|
238
|
-
<Text style={styles.closeButtonText}>✕</Text>
|
|
239
|
-
</Pressable>
|
|
240
|
-
) : (
|
|
241
|
-
<View style={styles.navSpacer} />
|
|
242
|
-
)}
|
|
243
|
-
</View>
|
|
244
|
-
);
|
|
245
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Text, StyleSheet, Pressable } from "react-native";
|
|
3
|
-
|
|
4
|
-
const styles = StyleSheet.create({
|
|
5
|
-
primaryButton: {
|
|
6
|
-
flexDirection: "row",
|
|
7
|
-
backgroundColor: "#FFFFFF",
|
|
8
|
-
borderRadius: 12,
|
|
9
|
-
padding: 12,
|
|
10
|
-
marginHorizontal: 16,
|
|
11
|
-
alignItems: "center",
|
|
12
|
-
justifyContent: "center",
|
|
13
|
-
marginTop: 16,
|
|
14
|
-
marginBottom: 8,
|
|
15
|
-
},
|
|
16
|
-
primaryButtonText: {
|
|
17
|
-
color: "#000000",
|
|
18
|
-
fontSize: 15,
|
|
19
|
-
fontWeight: "bold",
|
|
20
|
-
},
|
|
21
|
-
primaryButtonIcon: {
|
|
22
|
-
color: "#000000",
|
|
23
|
-
fontSize: 18,
|
|
24
|
-
marginRight: 8,
|
|
25
|
-
},
|
|
26
|
-
pressedState: {
|
|
27
|
-
opacity: 0.8,
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
export interface PrimaryButtonProps {
|
|
32
|
-
title: string;
|
|
33
|
-
icon?: string;
|
|
34
|
-
onPress?: () => void;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export const PrimaryButton: React.FC<PrimaryButtonProps> = ({
|
|
38
|
-
title,
|
|
39
|
-
icon,
|
|
40
|
-
onPress,
|
|
41
|
-
}) => {
|
|
42
|
-
return (
|
|
43
|
-
<Pressable
|
|
44
|
-
style={({ pressed }) => [
|
|
45
|
-
styles.primaryButton,
|
|
46
|
-
pressed && styles.pressedState,
|
|
47
|
-
]}
|
|
48
|
-
onPress={onPress}
|
|
49
|
-
>
|
|
50
|
-
{icon ? <Text style={styles.primaryButtonIcon}>{icon}</Text> : null}
|
|
51
|
-
<Text style={styles.primaryButtonText}>{title}</Text>
|
|
52
|
-
</Pressable>
|
|
53
|
-
);
|
|
54
|
-
};
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import { View, Text, StyleSheet, Pressable, Image } from "react-native";
|
|
3
|
-
|
|
4
|
-
const styles = StyleSheet.create({
|
|
5
|
-
trackItem: {
|
|
6
|
-
flexDirection: "row",
|
|
7
|
-
alignItems: "center",
|
|
8
|
-
paddingVertical: 10,
|
|
9
|
-
paddingHorizontal: 12,
|
|
10
|
-
borderBottomWidth: 1,
|
|
11
|
-
borderBottomColor: "#2a2a2a",
|
|
12
|
-
backgroundColor: "#1e1e1e",
|
|
13
|
-
},
|
|
14
|
-
trackItemFocused: {
|
|
15
|
-
backgroundColor: "#2d2d2d",
|
|
16
|
-
},
|
|
17
|
-
trackImage: {
|
|
18
|
-
width: 48,
|
|
19
|
-
height: 48,
|
|
20
|
-
borderRadius: 6,
|
|
21
|
-
marginRight: 12,
|
|
22
|
-
backgroundColor: "#2a2a2a",
|
|
23
|
-
},
|
|
24
|
-
trackImagePlaceholder: {
|
|
25
|
-
width: 48,
|
|
26
|
-
height: 48,
|
|
27
|
-
borderRadius: 6,
|
|
28
|
-
borderWidth: 1,
|
|
29
|
-
borderColor: "rgba(255, 255, 255, 0.1)",
|
|
30
|
-
backgroundColor: "#333",
|
|
31
|
-
marginRight: 12,
|
|
32
|
-
alignItems: "center",
|
|
33
|
-
justifyContent: "center",
|
|
34
|
-
},
|
|
35
|
-
trackImageText: {
|
|
36
|
-
color: "#fff",
|
|
37
|
-
fontSize: 20,
|
|
38
|
-
},
|
|
39
|
-
trackTextContainer: {
|
|
40
|
-
flex: 1,
|
|
41
|
-
justifyContent: "center",
|
|
42
|
-
},
|
|
43
|
-
nowPlayingLabel: {
|
|
44
|
-
color: "#30d158",
|
|
45
|
-
fontSize: 11,
|
|
46
|
-
fontWeight: "600",
|
|
47
|
-
marginBottom: 2,
|
|
48
|
-
textTransform: "uppercase",
|
|
49
|
-
},
|
|
50
|
-
trackTitle: {
|
|
51
|
-
color: "#FFFFFF",
|
|
52
|
-
fontSize: 15,
|
|
53
|
-
fontWeight: "600",
|
|
54
|
-
},
|
|
55
|
-
trackSubtitle: {
|
|
56
|
-
color: "#999999",
|
|
57
|
-
fontSize: 13,
|
|
58
|
-
fontWeight: "500",
|
|
59
|
-
marginTop: 2,
|
|
60
|
-
},
|
|
61
|
-
trackActions: {
|
|
62
|
-
flexDirection: "row",
|
|
63
|
-
alignItems: "center",
|
|
64
|
-
},
|
|
65
|
-
queuedActionsContainer: {
|
|
66
|
-
flexDirection: "row",
|
|
67
|
-
alignItems: "center",
|
|
68
|
-
},
|
|
69
|
-
trackActionButton: {
|
|
70
|
-
padding: 10,
|
|
71
|
-
marginLeft: 4,
|
|
72
|
-
},
|
|
73
|
-
trackActionIcon: {
|
|
74
|
-
color: "#FFFFFF",
|
|
75
|
-
fontSize: 18,
|
|
76
|
-
},
|
|
77
|
-
playPauseButton: {
|
|
78
|
-
width: 36,
|
|
79
|
-
height: 36,
|
|
80
|
-
backgroundColor: "#FFFFFF",
|
|
81
|
-
borderRadius: 18,
|
|
82
|
-
alignItems: "center",
|
|
83
|
-
justifyContent: "center",
|
|
84
|
-
marginLeft: 8,
|
|
85
|
-
},
|
|
86
|
-
playPauseText: {
|
|
87
|
-
color: "#000000",
|
|
88
|
-
fontWeight: "bold",
|
|
89
|
-
fontSize: 12,
|
|
90
|
-
},
|
|
91
|
-
radioContainer: {
|
|
92
|
-
padding: 10,
|
|
93
|
-
},
|
|
94
|
-
radioUnselected: {
|
|
95
|
-
width: 24,
|
|
96
|
-
height: 24,
|
|
97
|
-
borderRadius: 12,
|
|
98
|
-
borderWidth: 1,
|
|
99
|
-
borderColor: "#999",
|
|
100
|
-
},
|
|
101
|
-
radioSelected: {
|
|
102
|
-
width: 24,
|
|
103
|
-
height: 24,
|
|
104
|
-
borderRadius: 12,
|
|
105
|
-
backgroundColor: "#FFFFFF",
|
|
106
|
-
alignItems: "center",
|
|
107
|
-
justifyContent: "center",
|
|
108
|
-
},
|
|
109
|
-
radioCheck: {
|
|
110
|
-
color: "#000000",
|
|
111
|
-
fontSize: 14,
|
|
112
|
-
fontWeight: "bold",
|
|
113
|
-
},
|
|
114
|
-
pressedState: {
|
|
115
|
-
opacity: 0.7,
|
|
116
|
-
},
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
export interface TrackItemProps {
|
|
120
|
-
variant: "nowPlaying" | "queued" | "playlist";
|
|
121
|
-
title: string;
|
|
122
|
-
subtitle?: string;
|
|
123
|
-
icon?: string;
|
|
124
|
-
isSelected?: boolean;
|
|
125
|
-
isPlaying?: boolean;
|
|
126
|
-
onPress?: () => void;
|
|
127
|
-
onSecondaryPress?: () => void;
|
|
128
|
-
onRemovePress?: () => void;
|
|
129
|
-
onPlayPausePress?: () => void;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export const TrackItem: React.FC<TrackItemProps> = ({
|
|
133
|
-
variant,
|
|
134
|
-
title,
|
|
135
|
-
subtitle,
|
|
136
|
-
icon,
|
|
137
|
-
isSelected = false,
|
|
138
|
-
isPlaying = false,
|
|
139
|
-
onPress,
|
|
140
|
-
onSecondaryPress,
|
|
141
|
-
onRemovePress,
|
|
142
|
-
onPlayPausePress,
|
|
143
|
-
}) => {
|
|
144
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
145
|
-
|
|
146
|
-
const isIconUri =
|
|
147
|
-
icon &&
|
|
148
|
-
(icon.startsWith("http") ||
|
|
149
|
-
icon.startsWith("file") ||
|
|
150
|
-
icon.includes("/") ||
|
|
151
|
-
icon.includes("."));
|
|
152
|
-
|
|
153
|
-
return (
|
|
154
|
-
<Pressable
|
|
155
|
-
style={({ pressed }) => [
|
|
156
|
-
styles.trackItem,
|
|
157
|
-
(pressed || isFocused) && styles.trackItemFocused,
|
|
158
|
-
]}
|
|
159
|
-
onPress={onPress}
|
|
160
|
-
onPressIn={() => setIsFocused(true)}
|
|
161
|
-
onPressOut={() => setIsFocused(false)}
|
|
162
|
-
>
|
|
163
|
-
{icon ? (
|
|
164
|
-
isIconUri ? (
|
|
165
|
-
<Image source={{ uri: icon }} style={styles.trackImage} />
|
|
166
|
-
) : (
|
|
167
|
-
<View style={styles.trackImagePlaceholder}>
|
|
168
|
-
<Text style={styles.trackImageText}>{icon}</Text>
|
|
169
|
-
</View>
|
|
170
|
-
)
|
|
171
|
-
) : (
|
|
172
|
-
<View style={styles.trackImagePlaceholder} />
|
|
173
|
-
)}
|
|
174
|
-
|
|
175
|
-
<View style={styles.trackTextContainer}>
|
|
176
|
-
{variant === "nowPlaying" ? (
|
|
177
|
-
<Text style={styles.nowPlayingLabel}>♪ Now Playing</Text>
|
|
178
|
-
) : null}
|
|
179
|
-
<Text numberOfLines={1} style={styles.trackTitle}>
|
|
180
|
-
{title}
|
|
181
|
-
</Text>
|
|
182
|
-
{subtitle ? (
|
|
183
|
-
<Text numberOfLines={1} style={styles.trackSubtitle}>
|
|
184
|
-
{subtitle}
|
|
185
|
-
</Text>
|
|
186
|
-
) : null}
|
|
187
|
-
</View>
|
|
188
|
-
|
|
189
|
-
<View style={styles.trackActions}>
|
|
190
|
-
{variant === "nowPlaying" ? (
|
|
191
|
-
<Pressable
|
|
192
|
-
style={({ pressed }) => [
|
|
193
|
-
styles.playPauseButton,
|
|
194
|
-
pressed && styles.pressedState,
|
|
195
|
-
]}
|
|
196
|
-
onPress={onPlayPausePress || onPress}
|
|
197
|
-
>
|
|
198
|
-
<Text style={styles.playPauseText}>{isPlaying ? "II" : "▶"}</Text>
|
|
199
|
-
</Pressable>
|
|
200
|
-
) : null}
|
|
201
|
-
|
|
202
|
-
{variant === "queued" ? (
|
|
203
|
-
<View style={styles.queuedActionsContainer}>
|
|
204
|
-
{onRemovePress ? (
|
|
205
|
-
<Pressable
|
|
206
|
-
style={({ pressed }) => [
|
|
207
|
-
styles.trackActionButton,
|
|
208
|
-
pressed && styles.pressedState,
|
|
209
|
-
]}
|
|
210
|
-
onPress={onRemovePress}
|
|
211
|
-
>
|
|
212
|
-
<Text style={styles.trackActionIcon}>⊖</Text>
|
|
213
|
-
</Pressable>
|
|
214
|
-
) : null}
|
|
215
|
-
<Pressable
|
|
216
|
-
style={({ pressed }) => [
|
|
217
|
-
styles.trackActionButton,
|
|
218
|
-
pressed && styles.pressedState,
|
|
219
|
-
]}
|
|
220
|
-
onPress={onSecondaryPress || onPress}
|
|
221
|
-
>
|
|
222
|
-
<Text style={styles.trackActionIcon}>≡</Text>
|
|
223
|
-
</Pressable>
|
|
224
|
-
</View>
|
|
225
|
-
) : null}
|
|
226
|
-
|
|
227
|
-
{variant === "playlist" ? (
|
|
228
|
-
<View style={styles.radioContainer}>
|
|
229
|
-
{isSelected ? (
|
|
230
|
-
<View style={styles.radioSelected}>
|
|
231
|
-
<Text style={styles.radioCheck}>✓</Text>
|
|
232
|
-
</View>
|
|
233
|
-
) : (
|
|
234
|
-
<View style={styles.radioUnselected} />
|
|
235
|
-
)}
|
|
236
|
-
</View>
|
|
237
|
-
) : null}
|
|
238
|
-
</View>
|
|
239
|
-
</Pressable>
|
|
240
|
-
);
|
|
241
|
-
};
|
package/modalState/store.ts
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { createStore, useStore } from "zustand";
|
|
2
|
-
|
|
3
|
-
export interface ModalState {
|
|
4
|
-
visible: boolean;
|
|
5
|
-
screen: any;
|
|
6
|
-
options: Record<string, unknown>;
|
|
7
|
-
props: Record<string, unknown>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface ModalStore {
|
|
11
|
-
modalState: ModalState;
|
|
12
|
-
setModalState: (newState: Partial<ModalState>) => void;
|
|
13
|
-
openModal: (
|
|
14
|
-
item: any,
|
|
15
|
-
options?: Record<string, unknown>,
|
|
16
|
-
props?: Record<string, unknown>
|
|
17
|
-
) => void;
|
|
18
|
-
dismissModal: () => void;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const initialModalState: ModalState = {
|
|
22
|
-
visible: false,
|
|
23
|
-
screen: null,
|
|
24
|
-
options: {},
|
|
25
|
-
props: {},
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const modalStore = createStore<ModalStore>((set, get) => ({
|
|
29
|
-
modalState: initialModalState,
|
|
30
|
-
setModalState: (newState) =>
|
|
31
|
-
set((state) => ({
|
|
32
|
-
modalState: { ...state.modalState, ...newState },
|
|
33
|
-
})),
|
|
34
|
-
openModal: ({ item, options = {}, props }: OpenModalArg) => {
|
|
35
|
-
const resetStore = () => set({ modalState: initialModalState });
|
|
36
|
-
const { onDismiss, onRequestClose, ...restOptions } = options as any;
|
|
37
|
-
|
|
38
|
-
set({
|
|
39
|
-
modalState: {
|
|
40
|
-
visible: true,
|
|
41
|
-
screen: item,
|
|
42
|
-
options: {
|
|
43
|
-
animated: true,
|
|
44
|
-
animationType: "slide",
|
|
45
|
-
onShow: () => {},
|
|
46
|
-
presentationStyle: "overFullScreen",
|
|
47
|
-
transparent: true,
|
|
48
|
-
...restOptions,
|
|
49
|
-
// Compose caller-provided callbacks with the store reset so both run
|
|
50
|
-
onDismiss: () => {
|
|
51
|
-
resetStore();
|
|
52
|
-
onDismiss?.();
|
|
53
|
-
},
|
|
54
|
-
onRequestClose: () => {
|
|
55
|
-
resetStore();
|
|
56
|
-
onRequestClose?.();
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
props,
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
},
|
|
63
|
-
dismissModal: () => {
|
|
64
|
-
const onDismiss = (get().modalState?.options as any)?.onDismiss;
|
|
65
|
-
|
|
66
|
-
if (typeof onDismiss === "function") {
|
|
67
|
-
onDismiss();
|
|
68
|
-
} else {
|
|
69
|
-
set({ modalState: initialModalState });
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
}));
|
|
73
|
-
|
|
74
|
-
export const useModalStore = <T>(selector: (state: ModalStore) => T) =>
|
|
75
|
-
useStore(modalStore, selector);
|
|
76
|
-
|
|
77
|
-
export const openModal = modalStore.getInitialState().openModal;
|
|
78
|
-
|
|
79
|
-
export const dismissModal = modalStore.getInitialState().dismissModal;
|
|
80
|
-
|
|
81
|
-
export const openBottomSheetModal = ({
|
|
82
|
-
ModalBottomSheetContent,
|
|
83
|
-
modalBottomSheetContentProps,
|
|
84
|
-
props = {},
|
|
85
|
-
options = {},
|
|
86
|
-
}: OpenModalBottomSheetArgs) => {
|
|
87
|
-
openModal({
|
|
88
|
-
item: {
|
|
89
|
-
ModalBottomSheetContent,
|
|
90
|
-
modalBottomSheetContentProps,
|
|
91
|
-
},
|
|
92
|
-
props,
|
|
93
|
-
options: {
|
|
94
|
-
animationType: "none",
|
|
95
|
-
animated: false,
|
|
96
|
-
...options,
|
|
97
|
-
},
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
export const useModalStoreState = (): ModalState =>
|
|
102
|
-
useModalStore<ModalState>((state) => state.modalState);
|
package/modalState/types.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
export interface Header {
|
|
2
|
-
title: string;
|
|
3
|
-
subtitle?: string;
|
|
4
|
-
icon?: string;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface Action {
|
|
8
|
-
type: string;
|
|
9
|
-
payload?: any;
|
|
10
|
-
options?: any;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// Represented as 3 dots icon on top menu (opens new second level menu on desktop
|
|
14
|
-
// or a new bottom sheet on mobile)
|
|
15
|
-
export interface PresentSubMenuAction extends Action {
|
|
16
|
-
menu: Menu;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface SecondaryAction {
|
|
20
|
-
action: Action | PresentSubMenuAction;
|
|
21
|
-
icon?: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface MenuItem {
|
|
25
|
-
title: string;
|
|
26
|
-
summary?: string;
|
|
27
|
-
icon?: string;
|
|
28
|
-
isSelected?: boolean;
|
|
29
|
-
// When item represents an audio item, clicking on it will start playback
|
|
30
|
-
// and secondary action will allow to add it to queue or playlist
|
|
31
|
-
action?: Action | PresentSubMenuAction;
|
|
32
|
-
secondaryAction?: SecondaryAction;
|
|
33
|
-
submenu?: MenuItem[]; // todo: not needed. Must be replaced with PresentSubMenuAction
|
|
34
|
-
trailingButton?: any;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface Content {
|
|
38
|
-
title: string;
|
|
39
|
-
stickyTitle?: boolean;
|
|
40
|
-
items: MenuItem[];
|
|
41
|
-
itemsUrl?: string;
|
|
42
|
-
action?: Action;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface Menu {
|
|
46
|
-
header?: Header;
|
|
47
|
-
content: Content;
|
|
48
|
-
closeButton?: boolean;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export function isPresentSubMenuAction(
|
|
52
|
-
action: any
|
|
53
|
-
): action is PresentSubMenuAction {
|
|
54
|
-
return !!action && typeof action === "object" && "menu" in action;
|
|
55
|
-
}
|