rnnovaui 0.10.2 → 0.10.4
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rnnovaui",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"react-native": "src/index.js",
|
|
@@ -38,11 +38,12 @@
|
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"react": "19.2.3",
|
|
40
40
|
"react-native": "0.86.2",
|
|
41
|
-
"react-native-reanimated": "^4.5.3"
|
|
41
|
+
"react-native-reanimated": "^4.5.3",
|
|
42
|
+
"react-native-safe-area-context": ">=4.0.0"
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
|
44
45
|
"react": ">=19.0.0",
|
|
45
46
|
"react-native": ">=0.76.0",
|
|
46
|
-
"react-native-safe-area-context": "
|
|
47
|
+
"react-native-safe-area-context": ">=4.0.0"
|
|
47
48
|
}
|
|
48
49
|
}
|
|
@@ -1,256 +1,98 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
KeyboardAvoidingView,
|
|
5
|
-
Platform,
|
|
6
|
-
StyleSheet,
|
|
7
|
-
View,
|
|
8
|
-
} from "react-native";
|
|
9
|
-
import {
|
|
10
|
-
SafeAreaView,
|
|
11
|
-
useSafeAreaInsets,
|
|
12
|
-
} from "react-native-safe-area-context";
|
|
13
|
-
|
|
14
|
-
import { useUITheme } from "../../../theme";
|
|
15
|
-
import { useRNNovaAnimation } from "../../../animations";
|
|
16
|
-
import {
|
|
17
|
-
flattenStyle,
|
|
18
|
-
mergeTransforms,
|
|
19
|
-
separateTransform,
|
|
20
|
-
} from "../../../utils";
|
|
21
|
-
|
|
22
|
-
const ALL_EDGES = ["top", "right", "bottom", "left"];
|
|
23
|
-
|
|
24
|
-
const normalizeEdges = (edges) => {
|
|
25
|
-
if (!edges) return ALL_EDGES;
|
|
26
|
-
|
|
27
|
-
if (edges === "all") return ALL_EDGES;
|
|
28
|
-
if (edges === "vertical") return ["top", "bottom"];
|
|
29
|
-
if (edges === "horizontal") return ["left", "right"];
|
|
30
|
-
|
|
31
|
-
if (typeof edges === "string") return [edges];
|
|
32
|
-
|
|
33
|
-
if (Array.isArray(edges)) return edges;
|
|
34
|
-
|
|
35
|
-
return ALL_EDGES;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const getColor = (value, theme) => {
|
|
39
|
-
if (!value) return undefined;
|
|
40
|
-
|
|
41
|
-
if (typeof value !== "string") return value;
|
|
42
|
-
|
|
43
|
-
/*
|
|
44
|
-
* Direct colors are always respected.
|
|
45
|
-
*
|
|
46
|
-
* Examples:
|
|
47
|
-
* "red"
|
|
48
|
-
* "#FF0000"
|
|
49
|
-
* "rgb(255,0,0)"
|
|
50
|
-
*/
|
|
51
|
-
if (
|
|
52
|
-
value.startsWith("#") ||
|
|
53
|
-
value.startsWith("rgb") ||
|
|
54
|
-
value.startsWith("rgba") ||
|
|
55
|
-
value.startsWith("hsl") ||
|
|
56
|
-
value.startsWith("hsla")
|
|
57
|
-
) {
|
|
58
|
-
return value;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/*
|
|
62
|
-
* Theme color support.
|
|
63
|
-
*
|
|
64
|
-
* Examples:
|
|
65
|
-
* "background"
|
|
66
|
-
* "surface"
|
|
67
|
-
* "primary"
|
|
68
|
-
* "card"
|
|
69
|
-
*/
|
|
70
|
-
const colors = theme?.colors || {};
|
|
71
|
-
|
|
72
|
-
return colors[value] || value;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const resolveBarStyle = (style, fallback = "dark") => {
|
|
76
|
-
if (style === "light") return "light-content";
|
|
77
|
-
if (style === "dark") return "dark-content";
|
|
78
|
-
|
|
79
|
-
return fallback === "light" ? "light-content" : "dark-content";
|
|
80
|
-
};
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, StyleSheet, useColorScheme } from "react-native";
|
|
3
|
+
import { SafeAreaView } from "react-native-safe-area-context";
|
|
81
4
|
|
|
82
5
|
const UILayout = ({
|
|
83
6
|
children,
|
|
84
7
|
|
|
85
|
-
|
|
86
|
-
edges = "all",
|
|
87
|
-
|
|
88
|
-
/* Theme/background */
|
|
89
|
-
background,
|
|
8
|
+
// Colors
|
|
90
9
|
backgroundColor,
|
|
10
|
+
lightBackgroundColor,
|
|
11
|
+
darkBackgroundColor,
|
|
91
12
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
statusBarStyle = "dark",
|
|
95
|
-
|
|
96
|
-
navigationBarColor,
|
|
97
|
-
navigationBarStyle = "dark",
|
|
13
|
+
// Safe area
|
|
14
|
+
edges = ["top", "bottom", "left", "right"],
|
|
98
15
|
|
|
99
|
-
|
|
16
|
+
// Layout
|
|
100
17
|
flex = 1,
|
|
101
|
-
centered = false,
|
|
102
|
-
responsive = true,
|
|
103
18
|
|
|
104
|
-
|
|
105
|
-
keyboardAvoidingView = false,
|
|
106
|
-
keyboardVerticalOffset = 0,
|
|
107
|
-
keyboardBehavior,
|
|
108
|
-
|
|
109
|
-
/* Styles */
|
|
19
|
+
// Styles
|
|
110
20
|
style,
|
|
111
21
|
containerStyle,
|
|
112
22
|
contentStyle,
|
|
113
23
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
animationDuration,
|
|
117
|
-
animationDelay,
|
|
118
|
-
animationDistance,
|
|
119
|
-
animationEnabled = true,
|
|
120
|
-
|
|
121
|
-
/* Native props */
|
|
122
|
-
pointerEvents,
|
|
123
|
-
testID,
|
|
124
|
-
accessible,
|
|
125
|
-
accessibilityLabel,
|
|
24
|
+
// Content
|
|
25
|
+
centered = false,
|
|
126
26
|
|
|
127
|
-
|
|
27
|
+
// Future-compatible prop
|
|
28
|
+
keyboardAvoiding = false,
|
|
128
29
|
}) => {
|
|
129
|
-
const
|
|
130
|
-
const insets = useSafeAreaInsets();
|
|
30
|
+
const colorScheme = useColorScheme();
|
|
131
31
|
|
|
132
|
-
|
|
32
|
+
let resolvedBackgroundColor = backgroundColor;
|
|
133
33
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
theme,
|
|
142
|
-
);
|
|
143
|
-
|
|
144
|
-
const resolvedNavigationBarColor = getColor(
|
|
145
|
-
navigationBarColor || resolvedBackgroundColor,
|
|
146
|
-
theme,
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
const { progress, animatedStyle, animationTransform } = useRNNovaAnimation({
|
|
150
|
-
animationStyle,
|
|
151
|
-
duration: animationDuration,
|
|
152
|
-
delay: animationDelay,
|
|
153
|
-
distance: animationDistance,
|
|
154
|
-
enabled: animationEnabled,
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
const baseContentStyle = {
|
|
158
|
-
flex,
|
|
159
|
-
...(centered && {
|
|
160
|
-
alignItems: "center",
|
|
161
|
-
justifyContent: "center",
|
|
162
|
-
}),
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
const responsiveStyle = responsive
|
|
166
|
-
? {
|
|
167
|
-
width: "100%",
|
|
168
|
-
minHeight: 0,
|
|
169
|
-
}
|
|
170
|
-
: {};
|
|
171
|
-
|
|
172
|
-
const safeAreaStyle = [
|
|
173
|
-
styles.safeArea,
|
|
174
|
-
{
|
|
175
|
-
flex,
|
|
176
|
-
backgroundColor: resolvedBackgroundColor,
|
|
177
|
-
},
|
|
178
|
-
responsiveStyle,
|
|
179
|
-
style,
|
|
180
|
-
containerStyle,
|
|
181
|
-
];
|
|
182
|
-
|
|
183
|
-
const contentBaseStyle = [styles.content, baseContentStyle, contentStyle];
|
|
184
|
-
|
|
185
|
-
const separated = separateTransform(flattenStyle(contentBaseStyle));
|
|
186
|
-
|
|
187
|
-
const finalContentStyle = [
|
|
188
|
-
separated.style,
|
|
189
|
-
animatedStyle,
|
|
190
|
-
{
|
|
191
|
-
transform: mergeTransforms(separated.transform, animationTransform),
|
|
192
|
-
},
|
|
193
|
-
];
|
|
194
|
-
|
|
195
|
-
const renderContent = (
|
|
196
|
-
<Animated.View
|
|
197
|
-
pointerEvents={pointerEvents}
|
|
198
|
-
testID={testID}
|
|
199
|
-
accessible={accessible}
|
|
200
|
-
accessibilityLabel={accessibilityLabel}
|
|
201
|
-
style={finalContentStyle}
|
|
202
|
-
>
|
|
203
|
-
{children}
|
|
204
|
-
</Animated.View>
|
|
205
|
-
);
|
|
206
|
-
|
|
207
|
-
const wrappedContent = keyboardAvoidingView ? (
|
|
208
|
-
<KeyboardAvoidingView
|
|
209
|
-
style={styles.keyboard}
|
|
210
|
-
behavior={
|
|
211
|
-
keyboardBehavior || (Platform.OS === "ios" ? "padding" : "height")
|
|
212
|
-
}
|
|
213
|
-
keyboardVerticalOffset={keyboardVerticalOffset}
|
|
214
|
-
>
|
|
215
|
-
{renderContent}
|
|
216
|
-
</KeyboardAvoidingView>
|
|
217
|
-
) : (
|
|
218
|
-
renderContent
|
|
219
|
-
);
|
|
34
|
+
if (!resolvedBackgroundColor) {
|
|
35
|
+
if (colorScheme === "dark") {
|
|
36
|
+
resolvedBackgroundColor = darkBackgroundColor || "#000000";
|
|
37
|
+
} else {
|
|
38
|
+
resolvedBackgroundColor = lightBackgroundColor || "#FFFFFF";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
220
41
|
|
|
221
42
|
return (
|
|
222
43
|
<View
|
|
223
44
|
style={[
|
|
224
|
-
styles.
|
|
45
|
+
styles.container,
|
|
225
46
|
{
|
|
226
47
|
flex,
|
|
227
|
-
backgroundColor:
|
|
48
|
+
backgroundColor: resolvedBackgroundColor,
|
|
228
49
|
},
|
|
50
|
+
containerStyle,
|
|
229
51
|
]}
|
|
230
|
-
{...rest}
|
|
231
52
|
>
|
|
232
|
-
<SafeAreaView
|
|
233
|
-
{
|
|
53
|
+
<SafeAreaView
|
|
54
|
+
edges={edges}
|
|
55
|
+
style={[
|
|
56
|
+
styles.safeArea,
|
|
57
|
+
{
|
|
58
|
+
backgroundColor: resolvedBackgroundColor,
|
|
59
|
+
},
|
|
60
|
+
style,
|
|
61
|
+
]}
|
|
62
|
+
>
|
|
63
|
+
<View
|
|
64
|
+
style={[
|
|
65
|
+
styles.content,
|
|
66
|
+
{
|
|
67
|
+
flex,
|
|
68
|
+
},
|
|
69
|
+
centered && styles.centered,
|
|
70
|
+
contentStyle,
|
|
71
|
+
]}
|
|
72
|
+
>
|
|
73
|
+
{children}
|
|
74
|
+
</View>
|
|
234
75
|
</SafeAreaView>
|
|
235
76
|
</View>
|
|
236
77
|
);
|
|
237
78
|
};
|
|
238
79
|
|
|
239
80
|
const styles = StyleSheet.create({
|
|
240
|
-
|
|
241
|
-
|
|
81
|
+
container: {
|
|
82
|
+
flex: 1,
|
|
242
83
|
},
|
|
243
84
|
|
|
244
85
|
safeArea: {
|
|
245
|
-
|
|
86
|
+
flex: 1,
|
|
246
87
|
},
|
|
247
88
|
|
|
248
|
-
|
|
89
|
+
content: {
|
|
249
90
|
flex: 1,
|
|
250
91
|
},
|
|
251
92
|
|
|
252
|
-
|
|
253
|
-
|
|
93
|
+
centered: {
|
|
94
|
+
alignItems: "center",
|
|
95
|
+
justifyContent: "center",
|
|
254
96
|
},
|
|
255
97
|
});
|
|
256
98
|
|