@applicaster/zapp-react-native-ui-components 16.0.0-alpha.3255644194 → 16.0.0-alpha.3439504142
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useMemo, useRef } from "react";
|
|
2
|
-
import
|
|
2
|
+
import Sortable from "react-native-sortables";
|
|
3
|
+
import { StyleSheet, View, Text } from "react-native";
|
|
3
4
|
import { Button } from "./Button";
|
|
4
5
|
import { ItemIconProps } from "./Button/ItemIcon";
|
|
5
6
|
import { ItemProps } from "./Button/Item";
|
|
@@ -12,6 +13,33 @@ import type { PluginConfiguration } from "./";
|
|
|
12
13
|
import { ModalHeader as DefaultModalHeader } from "./Header";
|
|
13
14
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
14
15
|
|
|
16
|
+
const styles = StyleSheet.create({
|
|
17
|
+
alphaItem: {
|
|
18
|
+
backgroundColor: "#aaaaff",
|
|
19
|
+
borderRadius: 8,
|
|
20
|
+
height: 80,
|
|
21
|
+
flexDirection: "row",
|
|
22
|
+
alignItems: "center",
|
|
23
|
+
justifyContent: "space-between",
|
|
24
|
+
paddingHorizontal: 16,
|
|
25
|
+
},
|
|
26
|
+
alphaText: {
|
|
27
|
+
fontSize: 28,
|
|
28
|
+
},
|
|
29
|
+
handle: {
|
|
30
|
+
backgroundColor: "rgba(0,0,0,0.2)",
|
|
31
|
+
borderRadius: 5,
|
|
32
|
+
padding: 10,
|
|
33
|
+
},
|
|
34
|
+
handleText: {
|
|
35
|
+
color: "white",
|
|
36
|
+
fontWeight: "bold",
|
|
37
|
+
},
|
|
38
|
+
sortableGrid: {
|
|
39
|
+
padding: 8,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
15
43
|
type ModalComponentProps = {
|
|
16
44
|
items: any[];
|
|
17
45
|
current_selection?: any;
|
|
@@ -38,6 +66,7 @@ type ModalComponentProps = {
|
|
|
38
66
|
theme: PluginConfiguration
|
|
39
67
|
) => ItemIconProps["asset"] | null;
|
|
40
68
|
iconPlacement?: "left" | "right";
|
|
69
|
+
sortable?: boolean;
|
|
41
70
|
};
|
|
42
71
|
|
|
43
72
|
export function BottomSheetModalContent(props: ModalComponentProps) {
|
|
@@ -51,6 +80,7 @@ export function BottomSheetModalContent(props: ModalComponentProps) {
|
|
|
51
80
|
title,
|
|
52
81
|
headerComponent: ModalHeader = DefaultModalHeader,
|
|
53
82
|
buttonComponent: ButtonComponent = Button,
|
|
83
|
+
sortable = true,
|
|
54
84
|
getSelectedItemIcon = ({
|
|
55
85
|
modal_bottom_sheet_item_selected_icon,
|
|
56
86
|
}: BaseThemePropertiesMobile) => modal_bottom_sheet_item_selected_icon,
|
|
@@ -91,6 +121,12 @@ export function BottomSheetModalContent(props: ModalComponentProps) {
|
|
|
91
121
|
|
|
92
122
|
const bottomInset = useSafeAreaInsets().bottom;
|
|
93
123
|
|
|
124
|
+
const [sortableItems, setSortableItems] = React.useState(
|
|
125
|
+
new Array(items.length)
|
|
126
|
+
.fill(null)
|
|
127
|
+
.map((_, index) => items[index]?.name ?? "unknown")
|
|
128
|
+
);
|
|
129
|
+
|
|
94
130
|
return (
|
|
95
131
|
<View
|
|
96
132
|
style={{
|
|
@@ -104,30 +140,50 @@ export function BottomSheetModalContent(props: ModalComponentProps) {
|
|
|
104
140
|
summary={summary}
|
|
105
141
|
title={title}
|
|
106
142
|
/>
|
|
107
|
-
|
|
108
|
-
|
|
143
|
+
|
|
144
|
+
<View
|
|
145
|
+
style={{
|
|
109
146
|
paddingBottom: paddingBottom + bottomInset,
|
|
110
147
|
}}
|
|
111
148
|
>
|
|
112
|
-
{
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
149
|
+
{sortable ? (
|
|
150
|
+
<Sortable.Grid
|
|
151
|
+
customHandle
|
|
152
|
+
columns={1}
|
|
153
|
+
rowGap={8}
|
|
154
|
+
columnGap={8}
|
|
155
|
+
data={sortableItems}
|
|
156
|
+
keyExtractor={(item) => item}
|
|
157
|
+
onDragEnd={({ data }) => {
|
|
158
|
+
console.log("Sortable new order", { data });
|
|
159
|
+
setSortableItems(data);
|
|
160
|
+
}}
|
|
161
|
+
renderItem={({ item, index }) => (
|
|
162
|
+
<View style={styles.alphaItem}>
|
|
163
|
+
<ButtonComponent
|
|
164
|
+
key={index}
|
|
165
|
+
configuration={theme}
|
|
166
|
+
selectedItem={current_selection}
|
|
167
|
+
item={items[index]}
|
|
168
|
+
onPress={handlePress}
|
|
169
|
+
label={theme[item?.label] ?? item?.label}
|
|
170
|
+
iconBaseProps={iconBaseProps}
|
|
171
|
+
itemBaseProps={itemBaseProps}
|
|
172
|
+
labelBaseProps={labelBaseProps}
|
|
173
|
+
selectedItemIcon={getSelectedItemIcon(theme)}
|
|
174
|
+
defaultItemIcon={getDefaultItemIcon(theme)}
|
|
175
|
+
iconPlacement={iconPlacement}
|
|
176
|
+
/>
|
|
177
|
+
<Sortable.Handle>
|
|
178
|
+
<View pointerEvents="none" style={styles.handle}>
|
|
179
|
+
<Text style={styles.handleText}>⋮{index}:</Text>
|
|
180
|
+
</View>
|
|
181
|
+
</Sortable.Handle>
|
|
182
|
+
</View>
|
|
183
|
+
)}
|
|
184
|
+
/>
|
|
185
|
+
) : null}
|
|
186
|
+
</View>
|
|
131
187
|
</View>
|
|
132
188
|
);
|
|
133
189
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "16.0.0-alpha.
|
|
3
|
+
"version": "16.0.0-alpha.3439504142",
|
|
4
4
|
"description": "Applicaster Zapp React Native ui components for the Quick Brick App",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "16.0.0-alpha.
|
|
32
|
-
"@applicaster/zapp-react-native-bridge": "16.0.0-alpha.
|
|
33
|
-
"@applicaster/zapp-react-native-redux": "16.0.0-alpha.
|
|
34
|
-
"@applicaster/zapp-react-native-utils": "16.0.0-alpha.
|
|
31
|
+
"@applicaster/applicaster-types": "16.0.0-alpha.3439504142",
|
|
32
|
+
"@applicaster/zapp-react-native-bridge": "16.0.0-alpha.3439504142",
|
|
33
|
+
"@applicaster/zapp-react-native-redux": "16.0.0-alpha.3439504142",
|
|
34
|
+
"@applicaster/zapp-react-native-utils": "16.0.0-alpha.3439504142",
|
|
35
35
|
"fast-json-stable-stringify": "^2.1.0",
|
|
36
36
|
"promise": "^8.3.0",
|
|
37
37
|
"url": "^0.11.0",
|