ordering-ui-react-native 0.17.63 → 0.17.65

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": "ordering-ui-react-native",
3
- "version": "0.17.63",
3
+ "version": "0.17.65",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -48,7 +48,7 @@ import { OrderTypeSelector } from '../../../OrderTypeSelector';
48
48
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
49
49
  import { BusinessFeaturedController } from '../../../BusinessFeaturedController';
50
50
  import { HighestRatedBusinesses } from '../../../HighestRatedBusinesses';
51
- import { getTypesText, convertToRadian } from '../../../../utils';
51
+ import { getTypesText } from '../../../../utils';
52
52
  import { OrderProgress } from '../../../OrderProgress';
53
53
  import { useFocusEffect, useIsFocused } from '@react-navigation/native';
54
54
  import FastImage from 'react-native-fast-image';
@@ -189,6 +189,10 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
189
189
  }
190
190
  };
191
191
 
192
+ const convertToRadian = (value: number) => {
193
+ return value * Math.PI / 180
194
+ }
195
+
192
196
  const getDistance = (lat1: any, lon1: any, lat2: any, lon2: any) => {
193
197
  const R = 6371 // km
194
198
  const dLat = convertToRadian(lat2 - lat1)
@@ -1,13 +1,13 @@
1
- import React from 'react'
1
+ import React, { useRef } from 'react'
2
2
  import { useUtils, PageBanner as PageBannerController } from 'ordering-components/native'
3
3
 
4
- import { View, StyleSheet } from 'react-native'
4
+ import { View, StyleSheet, Dimensions, TouchableOpacity } from 'react-native'
5
5
  import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
6
- import Swiper from 'react-native-swiper'
6
+ import Carousel from 'react-native-snap-carousel'
7
7
  import FastImage from 'react-native-fast-image';
8
8
  import IconAntDesign from 'react-native-vector-icons/AntDesign';
9
9
  import { useTheme } from 'styled-components/native';
10
- import { PageBannerWrapper } from './styles'
10
+ import { PageBannerWrapper, ArrowButtonsContainer } from './styles'
11
11
 
12
12
  const PageBannerUI = (props: any) => {
13
13
  const {
@@ -16,6 +16,9 @@ const PageBannerUI = (props: any) => {
16
16
 
17
17
  const theme = useTheme();
18
18
  const [{ optimizeImage }] = useUtils();
19
+ const carouselRef = useRef(null)
20
+
21
+ const windowWidth = Dimensions.get('window').width;
19
22
 
20
23
  const styles = StyleSheet.create({
21
24
  mainSwiper: {
@@ -36,6 +39,18 @@ const PageBannerUI = (props: any) => {
36
39
  }
37
40
  })
38
41
 
42
+ const renderItem = ({ item, index }) => {
43
+ return (
44
+ <View style={styles.sliderWrapper}>
45
+ <FastImage
46
+ style={{ height: '100%', width: '100%' }}
47
+ resizeMode='cover'
48
+ source={{ uri: optimizeImage(item.url, 'h_300,c_limit') }}
49
+ />
50
+ </View>
51
+ )
52
+ }
53
+
39
54
  return (
40
55
  <>
41
56
  {pageBannerState.loading ? (
@@ -53,40 +68,40 @@ const PageBannerUI = (props: any) => {
53
68
  <>
54
69
  {pageBannerState.banner?.items && pageBannerState.banner?.items.length > 0 && (
55
70
  <PageBannerWrapper>
56
- <Swiper
71
+ <ArrowButtonsContainer>
72
+ <TouchableOpacity
73
+ style={styles.swiperButton}
74
+ onPress={() => carouselRef.current.snapToPrev()}
75
+ >
76
+ <IconAntDesign
77
+ name="caretleft"
78
+ color={theme.colors.white}
79
+ size={13}
80
+ />
81
+ </TouchableOpacity>
82
+ <TouchableOpacity
83
+ style={styles.swiperButton}
84
+ onPress={() => carouselRef.current.snapToNext()}
85
+ >
86
+ <IconAntDesign
87
+ name="caretright"
88
+ color={theme.colors.white}
89
+ size={13}
90
+ />
91
+ </TouchableOpacity>
92
+ </ArrowButtonsContainer>
93
+ <Carousel
94
+ ref={carouselRef}
57
95
  loop={pageBannerState.banner?.items.length > 1}
58
- showsButtons={true}
59
- style={styles.mainSwiper}
60
- showsPagination={false}
61
- prevButton={
62
- <View style={styles.swiperButton}>
63
- <IconAntDesign
64
- name="caretleft"
65
- color={theme.colors.white}
66
- size={13}
67
- />
68
- </View>
69
- }
70
- nextButton={
71
- <View style={styles.swiperButton}>
72
- <IconAntDesign
73
- name="caretright"
74
- color={theme.colors.white}
75
- size={13}
76
- />
77
- </View>
78
- }
79
- >
80
- {pageBannerState.banner?.items.map((img, i) => (
81
- <View key={i} style={styles.sliderWrapper}>
82
- <FastImage
83
- style={{ height: '100%', width: '100%' }}
84
- resizeMode='cover'
85
- source={{ uri: optimizeImage(img.url, 'h_300,c_limit') }}
86
- />
87
- </View>
88
- ))}
89
- </Swiper>
96
+ data={pageBannerState.banner?.items}
97
+ renderItem={renderItem}
98
+ sliderWidth={windowWidth - 80}
99
+ itemWidth={windowWidth - 80}
100
+ inactiveSlideScale={1}
101
+ pagingEnabled
102
+ removeClippedSubviews={false}
103
+ inactiveSlideOpacity={1}
104
+ />
90
105
  </PageBannerWrapper>
91
106
  )}
92
107
  </>
@@ -1,8 +1,18 @@
1
- import styled, { css } from 'styled-components/native'
1
+ import styled from 'styled-components/native'
2
2
 
3
3
  export const PageBannerWrapper = styled.View`
4
4
  margin-horizontal: 40px;
5
5
  border-radius: 8px;
6
6
  overflow: hidden;
7
7
  margin-vertical: 30px;
8
+ position: relative;
9
+ flex-direction: row;
10
+ align-items: center;
11
+ `
12
+ export const ArrowButtonsContainer = styled.View`
13
+ position: absolute;
14
+ z-index: 100;
15
+ flex-direction: row;
16
+ justify-content: space-between;
17
+ width: 100%;
8
18
  `