@applicaster/zapp-react-native-ui-components 13.0.0-alpha.3332871333 → 13.0.0-alpha.3390783725
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/Components/GeneralContentScreen/GeneralContentScreen.tsx +3 -0
- package/Components/GeneralContentScreen/utils/useEventAlerts.ts +30 -0
- package/Components/ModalComponent/BottomSheetModalContent.tsx +19 -29
- package/Components/ModalComponent/Button/index.tsx +25 -29
- package/Components/ModalComponent/Header/index.tsx +9 -8
- package/package.json +5 -5
|
@@ -11,6 +11,7 @@ import { allSettled } from "promise";
|
|
|
11
11
|
import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
|
|
12
12
|
import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
|
|
13
13
|
import { ScreenTrackedViewPositionsContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenTrackedViewPositionsContext";
|
|
14
|
+
import { useEventAlerts } from "./utils/useEventAlerts";
|
|
14
15
|
|
|
15
16
|
const { log_info } = createLogger({
|
|
16
17
|
category: "ScreenContainer",
|
|
@@ -103,6 +104,8 @@ export const GeneralContentScreen = ({
|
|
|
103
104
|
[typeof cellTapAction === "function" ? cellTapAction : onCellTapAction]
|
|
104
105
|
);
|
|
105
106
|
|
|
107
|
+
useEventAlerts(screenData);
|
|
108
|
+
|
|
106
109
|
if (!isReady || isNilOrEmpty(components || uiComponents)) return null;
|
|
107
110
|
|
|
108
111
|
return (
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { showAlertDialog } from "@applicaster/zapp-react-native-utils/alertUtils";
|
|
3
|
+
import { TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT } from "@applicaster/zapp-react-native-utils/actionsExecutor/consts";
|
|
4
|
+
import { useLocalizedStrings } from "@applicaster/zapp-react-native-utils/localizationUtils";
|
|
5
|
+
import { useIsScreenActive } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
6
|
+
import { useSubscriberFor } from "@applicaster/zapp-react-native-utils/reactHooks/useSubscriberFor";
|
|
7
|
+
|
|
8
|
+
export const useEventAlerts = (screenData: ZappRiver) => {
|
|
9
|
+
const localizations = useLocalizedStrings({
|
|
10
|
+
localizations: screenData?.localizations || {},
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const isActive = useIsScreenActive();
|
|
14
|
+
|
|
15
|
+
const onMaxTagsReached = React.useCallback(() => {
|
|
16
|
+
// We can't skip subscribe hook call, so we have to check.
|
|
17
|
+
if (!isActive || !localizations?.msg_maximum_selection_reached_message) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
showAlertDialog({
|
|
22
|
+
title: "",
|
|
23
|
+
message: localizations.msg_maximum_selection_reached_message,
|
|
24
|
+
okButtonText:
|
|
25
|
+
localizations.msg_maximum_selection_reached_message_ok_button || "OK",
|
|
26
|
+
});
|
|
27
|
+
}, [localizations, isActive]);
|
|
28
|
+
|
|
29
|
+
useSubscriberFor(TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT, onMaxTagsReached);
|
|
30
|
+
};
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
|
|
3
|
-
useEffect,
|
|
4
|
-
useMemo,
|
|
5
|
-
useRef,
|
|
6
|
-
useState,
|
|
7
|
-
} from "react";
|
|
8
|
-
import { View, LayoutChangeEvent, ScrollView } from "react-native";
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useRef } from "react";
|
|
2
|
+
import { View, ScrollView, StyleSheet, Platform } from "react-native";
|
|
9
3
|
import { Button } from "./Button";
|
|
10
4
|
import { ItemIconProps } from "./Button/ItemIcon";
|
|
11
5
|
import { ItemProps } from "./Button/Item";
|
|
@@ -16,6 +10,7 @@ import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
|
16
10
|
import type { PluginConfiguration } from "./";
|
|
17
11
|
|
|
18
12
|
import { ModalHeader } from "./Header";
|
|
13
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
19
14
|
|
|
20
15
|
type ModalComponentProps = {
|
|
21
16
|
items: any[];
|
|
@@ -44,11 +39,16 @@ type ModalComponentProps = {
|
|
|
44
39
|
iconPlacement?: "left" | "right";
|
|
45
40
|
};
|
|
46
41
|
|
|
42
|
+
const styles = StyleSheet.create({
|
|
43
|
+
container: {
|
|
44
|
+
maxHeight: "100%",
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
47
48
|
export function BottomSheetModalContent(props: ModalComponentProps) {
|
|
48
49
|
const {
|
|
49
50
|
items,
|
|
50
51
|
currentRoute,
|
|
51
|
-
maxHeight,
|
|
52
52
|
current_selection = null,
|
|
53
53
|
onPress,
|
|
54
54
|
dismiss,
|
|
@@ -61,20 +61,11 @@ export function BottomSheetModalContent(props: ModalComponentProps) {
|
|
|
61
61
|
iconPlacement,
|
|
62
62
|
} = props;
|
|
63
63
|
|
|
64
|
-
const [headerHeight, setHeaderHeight] = useState(0);
|
|
65
64
|
const route = useRef(currentRoute);
|
|
66
65
|
const theme = useTheme<BaseThemePropertiesMobile>();
|
|
67
66
|
const paddingTop = Number(theme.modal_bottom_sheet_padding_top);
|
|
68
67
|
const paddingBottom = Number(theme.modal_bottom_sheet_padding_bottom);
|
|
69
68
|
|
|
70
|
-
const maxContentHeight = maxHeight
|
|
71
|
-
? maxHeight - headerHeight - paddingTop
|
|
72
|
-
: undefined;
|
|
73
|
-
|
|
74
|
-
const onHeaderLayout = useCallback((event: LayoutChangeEvent) => {
|
|
75
|
-
setHeaderHeight(event.nativeEvent.layout.height);
|
|
76
|
-
}, []);
|
|
77
|
-
|
|
78
69
|
useEffect(() => {
|
|
79
70
|
if (currentRoute !== route.current) {
|
|
80
71
|
props.dismiss();
|
|
@@ -101,33 +92,32 @@ export function BottomSheetModalContent(props: ModalComponentProps) {
|
|
|
101
92
|
[onPress, dismiss]
|
|
102
93
|
);
|
|
103
94
|
|
|
95
|
+
const bottomInset = useSafeAreaInsets().bottom;
|
|
96
|
+
|
|
104
97
|
return (
|
|
105
98
|
<View
|
|
106
|
-
style={
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
99
|
+
style={[
|
|
100
|
+
styles.container,
|
|
101
|
+
{
|
|
102
|
+
paddingTop: paddingTop,
|
|
103
|
+
},
|
|
104
|
+
]}
|
|
110
105
|
>
|
|
111
106
|
<ModalHeader
|
|
112
|
-
width={props.width}
|
|
113
107
|
dismiss={dismiss}
|
|
114
108
|
configuration={theme}
|
|
115
|
-
onLayout={onHeaderLayout}
|
|
116
109
|
summary={summary}
|
|
117
110
|
title={title}
|
|
118
111
|
/>
|
|
119
112
|
<ScrollView
|
|
120
|
-
bounces={false}
|
|
121
|
-
style={{ maxHeight: maxContentHeight }}
|
|
122
113
|
contentContainerStyle={{
|
|
123
|
-
paddingBottom
|
|
124
|
-
|
|
114
|
+
paddingBottom:
|
|
115
|
+
Platform.OS === "ios" ? paddingBottom + bottomInset : paddingBottom,
|
|
125
116
|
}}
|
|
126
117
|
>
|
|
127
118
|
{items.map((item, index) => (
|
|
128
119
|
<ButtonComponent
|
|
129
120
|
key={index}
|
|
130
|
-
width={props.width}
|
|
131
121
|
configuration={theme}
|
|
132
122
|
selectedItem={current_selection}
|
|
133
123
|
item={item}
|
|
@@ -7,7 +7,6 @@ import { defaultSelectedAsset } from "./assets";
|
|
|
7
7
|
|
|
8
8
|
type ButtonProps = {
|
|
9
9
|
configuration: any;
|
|
10
|
-
width: number;
|
|
11
10
|
selectedItem?: any;
|
|
12
11
|
item: any; // Adjust type as needed
|
|
13
12
|
onPress: (item: any) => void; // Adjust type as needed
|
|
@@ -33,7 +32,6 @@ export function Button({
|
|
|
33
32
|
item,
|
|
34
33
|
onPress,
|
|
35
34
|
configuration,
|
|
36
|
-
width,
|
|
37
35
|
iconBaseProps,
|
|
38
36
|
itemBaseProps: itemProps,
|
|
39
37
|
labelBaseProps,
|
|
@@ -65,34 +63,32 @@ export function Button({
|
|
|
65
63
|
if (disabled) return null;
|
|
66
64
|
|
|
67
65
|
return (
|
|
68
|
-
<
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
>
|
|
75
|
-
<
|
|
76
|
-
|
|
77
|
-
{iconPlacement === "left" && renderItemIcon}
|
|
66
|
+
<TouchableOpacity
|
|
67
|
+
activeOpacity={1}
|
|
68
|
+
onPress={() => onPress(item)}
|
|
69
|
+
onPressIn={() => setFocused(true)}
|
|
70
|
+
onPressOut={() => setFocused(false)}
|
|
71
|
+
>
|
|
72
|
+
<Item {...itemProps} focused={focused} selected={selected}>
|
|
73
|
+
<View style={styles.label_icon_container}>
|
|
74
|
+
{iconPlacement === "left" && renderItemIcon}
|
|
78
75
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
76
|
+
{label ? (
|
|
77
|
+
<ItemLabel
|
|
78
|
+
{...labelBaseProps}
|
|
79
|
+
label={label ?? null}
|
|
80
|
+
focused={focused}
|
|
81
|
+
selected={selected}
|
|
82
|
+
/>
|
|
83
|
+
) : null}
|
|
84
|
+
</View>
|
|
88
85
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
</View>
|
|
86
|
+
{selected ? (
|
|
87
|
+
<ItemIcon {...iconBaseProps} asset={selectedItemIconPropsAssets} />
|
|
88
|
+
) : (
|
|
89
|
+
iconPlacement === "right" && renderItemIcon
|
|
90
|
+
)}
|
|
91
|
+
</Item>
|
|
92
|
+
</TouchableOpacity>
|
|
97
93
|
);
|
|
98
94
|
}
|
|
@@ -8,13 +8,18 @@ import { PluginConfiguration } from "../index";
|
|
|
8
8
|
type Props = {
|
|
9
9
|
dismiss: () => void;
|
|
10
10
|
configuration: PluginConfiguration;
|
|
11
|
-
width: number;
|
|
12
11
|
onLayout?: (event: LayoutChangeEvent) => void;
|
|
13
12
|
summary?: string;
|
|
14
13
|
title?: string;
|
|
15
14
|
};
|
|
16
15
|
|
|
17
16
|
const styles = StyleSheet.create({
|
|
17
|
+
noFlex: {
|
|
18
|
+
flex: 0,
|
|
19
|
+
},
|
|
20
|
+
flex: {
|
|
21
|
+
flex: 1,
|
|
22
|
+
},
|
|
18
23
|
container: {
|
|
19
24
|
flexDirection: "row",
|
|
20
25
|
alignItems: "center",
|
|
@@ -22,7 +27,7 @@ const styles = StyleSheet.create({
|
|
|
22
27
|
});
|
|
23
28
|
|
|
24
29
|
export function ModalHeader(props: Props) {
|
|
25
|
-
const { configuration, dismiss,
|
|
30
|
+
const { configuration, dismiss, onLayout, summary, title } = props;
|
|
26
31
|
|
|
27
32
|
const closeButtonProps = useMemo<CloseButtonProps>(
|
|
28
33
|
() => ({
|
|
@@ -55,15 +60,11 @@ export function ModalHeader(props: Props) {
|
|
|
55
60
|
|
|
56
61
|
return (
|
|
57
62
|
<View onLayout={onLayout} style={styles.container}>
|
|
58
|
-
<View
|
|
59
|
-
style={{
|
|
60
|
-
width: width - buttonsContainerWidth,
|
|
61
|
-
}}
|
|
62
|
-
>
|
|
63
|
+
<View style={styles.flex}>
|
|
63
64
|
{title ? <Title {...titleProps} /> : null}
|
|
64
65
|
{summary ? <Title {...summaryProps} /> : null}
|
|
65
66
|
</View>
|
|
66
|
-
<View style={{ width: buttonsContainerWidth }}>
|
|
67
|
+
<View style={[styles.noFlex, { width: buttonsContainerWidth }]}>
|
|
67
68
|
<CloseButton {...closeButtonProps} />
|
|
68
69
|
</View>
|
|
69
70
|
</View>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "13.0.0-alpha.
|
|
3
|
+
"version": "13.0.0-alpha.3390783725",
|
|
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",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"redux-mock-store": "^1.5.3"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@applicaster/applicaster-types": "13.0.0-alpha.
|
|
35
|
-
"@applicaster/zapp-react-native-bridge": "13.0.0-alpha.
|
|
36
|
-
"@applicaster/zapp-react-native-redux": "13.0.0-alpha.
|
|
37
|
-
"@applicaster/zapp-react-native-utils": "13.0.0-alpha.
|
|
34
|
+
"@applicaster/applicaster-types": "13.0.0-alpha.3390783725",
|
|
35
|
+
"@applicaster/zapp-react-native-bridge": "13.0.0-alpha.3390783725",
|
|
36
|
+
"@applicaster/zapp-react-native-redux": "13.0.0-alpha.3390783725",
|
|
37
|
+
"@applicaster/zapp-react-native-utils": "13.0.0-alpha.3390783725",
|
|
38
38
|
"promise": "^8.3.0",
|
|
39
39
|
"react-router-native": "^5.1.2",
|
|
40
40
|
"url": "^0.11.0",
|