ordering-ui-react-native 0.16.66 → 0.16.67
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,4 +1,4 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
2
2
|
import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
|
|
3
3
|
import {
|
|
4
4
|
BusinessController as BusinessSingleCard,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
ToastType
|
|
12
12
|
} from 'ordering-components/native';
|
|
13
13
|
import { OIcon, OText } from '../shared';
|
|
14
|
-
import { StyleSheet, TouchableOpacity, View } from 'react-native';
|
|
14
|
+
import { StyleSheet, TouchableOpacity, View, Animated } from 'react-native';
|
|
15
15
|
import { InView } from 'react-native-intersection-observer'
|
|
16
16
|
import { BusinessControllerParams } from '../../types';
|
|
17
17
|
import { convertHoursToMinutes, shape } from '../../utils';
|
|
@@ -59,6 +59,8 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
|
|
|
59
59
|
const [, t] = useLanguage();
|
|
60
60
|
const theme = useTheme()
|
|
61
61
|
const [isIntersectionObserver, setIsIntersectionObserver] = useState(!enableIntersection)
|
|
62
|
+
const fadeAnim = useRef(new Animated.Value(0)).current;
|
|
63
|
+
|
|
62
64
|
const styles = StyleSheet.create({
|
|
63
65
|
headerStyle: {
|
|
64
66
|
borderTopLeftRadius: 7.6,
|
|
@@ -144,8 +146,25 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
|
|
|
144
146
|
}
|
|
145
147
|
}
|
|
146
148
|
|
|
149
|
+
const fadeIn = () => {
|
|
150
|
+
Animated.timing(fadeAnim, {
|
|
151
|
+
toValue: 1,
|
|
152
|
+
duration: 500,
|
|
153
|
+
useNativeDriver: true
|
|
154
|
+
}).start();
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const handleChangeInterSection = (inView: boolean) => {
|
|
158
|
+
setIsIntersectionObserver(inView)
|
|
159
|
+
fadeIn()
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
useEffect(() => {
|
|
163
|
+
if (!enableIntersection) fadeIn()
|
|
164
|
+
}, [enableIntersection])
|
|
165
|
+
|
|
147
166
|
return (
|
|
148
|
-
<InView style={{ minHeight: 200 }} triggerOnce={true} onChange={(inView: boolean) =>
|
|
167
|
+
<InView style={{ minHeight: 200 }} triggerOnce={true} onChange={(inView: boolean) => handleChangeInterSection(inView)}>
|
|
149
168
|
{isIntersectionObserver ? (
|
|
150
169
|
<Card activeOpacity={1} onPress={() => handleBusinessClick(business)} style={style}>
|
|
151
170
|
{business?.ribbon?.enabled && (
|
|
@@ -167,6 +186,13 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
|
|
|
167
186
|
</RibbonBox>
|
|
168
187
|
)}
|
|
169
188
|
<BusinessHero>
|
|
189
|
+
<Animated.View
|
|
190
|
+
style={[
|
|
191
|
+
{
|
|
192
|
+
opacity: fadeAnim
|
|
193
|
+
}
|
|
194
|
+
]}
|
|
195
|
+
>
|
|
170
196
|
<FastImage
|
|
171
197
|
style={{ height: 120 }}
|
|
172
198
|
source={{
|
|
@@ -175,6 +201,7 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
|
|
|
175
201
|
}}
|
|
176
202
|
resizeMode={FastImage.resizeMode.cover}
|
|
177
203
|
/>
|
|
204
|
+
</Animated.View>
|
|
178
205
|
{(businessFeatured ?? business?.featured) && (
|
|
179
206
|
<View style={styles.featured}>
|
|
180
207
|
<FontAwesomeIcon name="crown" size={26} color="gold" />
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
useLanguage,
|
|
4
4
|
useConfig,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
import { useTheme } from 'styled-components/native';
|
|
12
12
|
import { SingleProductCardParams } from '../../types';
|
|
13
13
|
import { CardContainer, CardInfo, SoldOut, QuantityContainer, PricesContainer, RibbonBox, LogoWrapper } from './styles';
|
|
14
|
-
import { StyleSheet, View, TouchableOpacity, Image } from 'react-native';
|
|
14
|
+
import { StyleSheet, View, TouchableOpacity, Image, Animated } from 'react-native';
|
|
15
15
|
import { InView } from 'react-native-intersection-observer'
|
|
16
16
|
import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
|
|
17
17
|
import { OButton, OText } from '../shared';
|
|
@@ -43,6 +43,8 @@ const SinguleProductCardUI = React.memo((props: SingleProductCardParams) => {
|
|
|
43
43
|
const [orderingTheme] = useOrderingTheme()
|
|
44
44
|
const hideAddButton = orderingTheme?.theme?.business_view?.components?.products?.components?.add_to_cart_button?.hidden
|
|
45
45
|
|
|
46
|
+
const fadeAnim = useRef(new Animated.Value(0)).current;
|
|
47
|
+
|
|
46
48
|
const styles = StyleSheet.create({
|
|
47
49
|
container: {
|
|
48
50
|
borderWidth: 1,
|
|
@@ -122,6 +124,14 @@ const SinguleProductCardUI = React.memo((props: SingleProductCardParams) => {
|
|
|
122
124
|
maxCartProductInventory,
|
|
123
125
|
);
|
|
124
126
|
|
|
127
|
+
const fadeIn = () => {
|
|
128
|
+
Animated.timing(fadeAnim, {
|
|
129
|
+
toValue: 1,
|
|
130
|
+
duration: 500,
|
|
131
|
+
useNativeDriver: true
|
|
132
|
+
}).start();
|
|
133
|
+
};
|
|
134
|
+
|
|
125
135
|
const handleChangeFavorite = () => {
|
|
126
136
|
if (auth) {
|
|
127
137
|
handleFavoriteProduct && handleFavoriteProduct(!product?.favorite)
|
|
@@ -130,8 +140,17 @@ const SinguleProductCardUI = React.memo((props: SingleProductCardParams) => {
|
|
|
130
140
|
}
|
|
131
141
|
}
|
|
132
142
|
|
|
143
|
+
const handleChangeIntersection = () => {
|
|
144
|
+
setIsIntersectionObserver(true);
|
|
145
|
+
fadeIn();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
useEffect(() => {
|
|
149
|
+
if (!enableIntersection) fadeIn()
|
|
150
|
+
}, [enableIntersection])
|
|
151
|
+
|
|
133
152
|
return (
|
|
134
|
-
<InView style={{ minHeight: 200 }} triggerOnce={true} onChange={(inView: boolean) =>
|
|
153
|
+
<InView style={{ minHeight: 200 }} triggerOnce={true} onChange={(inView: boolean) => handleChangeIntersection()}>
|
|
135
154
|
{isIntersectionObserver ? (
|
|
136
155
|
<CardContainer
|
|
137
156
|
showAddButton={!hideAddButton}
|
|
@@ -205,14 +224,23 @@ const SinguleProductCardUI = React.memo((props: SingleProductCardParams) => {
|
|
|
205
224
|
</RibbonBox>
|
|
206
225
|
)}
|
|
207
226
|
{product?.images && (
|
|
208
|
-
<
|
|
209
|
-
style={
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
227
|
+
<Animated.View
|
|
228
|
+
style={[
|
|
229
|
+
{
|
|
230
|
+
// Bind opacity to animated value
|
|
231
|
+
opacity: fadeAnim
|
|
232
|
+
}
|
|
233
|
+
]}
|
|
234
|
+
>
|
|
235
|
+
<FastImage
|
|
236
|
+
style={styles.productStyle}
|
|
237
|
+
source={{
|
|
238
|
+
uri: optimizeImage(product?.images, 'h_250,c_limit'),
|
|
239
|
+
priority: FastImage.priority.normal,
|
|
240
|
+
}}
|
|
241
|
+
resizeMode={FastImage.resizeMode.cover}
|
|
242
|
+
/>
|
|
243
|
+
</Animated.View>
|
|
216
244
|
)}
|
|
217
245
|
</LogoWrapper>
|
|
218
246
|
|