ordering-ui-react-native 0.16.85 → 0.16.86

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.16.85",
3
+ "version": "0.16.86",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -34,9 +34,9 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
34
34
  return (
35
35
  <ProductsContainer>
36
36
  {category.id && (
37
- categoryState.products?.sort((a: any, b: any) => a.rank - b.rank).map((product: any) => (
37
+ categoryState.products?.sort((a: any, b: any) => a.rank - b.rank).map((product: any, index: number) => (
38
38
  <SingleProductCard
39
- key={product.id}
39
+ key={`category${category.id}-${product.id}-${index}`}
40
40
  isSoldOut={(product.inventoried && !product.quantity)}
41
41
  product={product}
42
42
  businessId={businessId}
@@ -51,9 +51,9 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
51
51
  <>
52
52
  <OText size={18} weight='bold' mBottom={10}>{t('FEATURED', 'Featured')}</OText>
53
53
  <>
54
- {categoryState.products?.sort((a: any, b: any) => a.rank - b.rank).map((product: any) => product.featured && (
54
+ {categoryState.products?.sort((a: any, b: any) => a.rank - b.rank).map((product: any, index: number) => product.featured && (
55
55
  <SingleProductCard
56
- key={product.id}
56
+ key={`featured${product.id}-${index}`}
57
57
  isSoldOut={(product.inventoried && !product.quantity)}
58
58
  product={product}
59
59
  businessId={businessId}
@@ -70,16 +70,16 @@ const BusinessProductsListUI = (props: BusinessProductsListParams) => {
70
70
  !category.id && categories && categories.filter(category => category.id !== null).map((category, i, _categories) => {
71
71
  const products = categoryState.products?.filter((product: any) => category?.children?.some((cat: any) => cat?.category_id === product?.category_id)) || []
72
72
  return (
73
- <View key={category.id} style={{ alignItems: 'flex-start', flex: 1 }}>
73
+ <View key={`category${category.id}`} style={{ alignItems: 'flex-start', flex: 1 }}>
74
74
  {
75
75
  products.length > 0 && (
76
76
  <>
77
77
  <OText size={18} weight='bold' mBottom={10}>{category.name}</OText>
78
78
  <>
79
79
  {
80
- products?.sort((a: any, b: any) => a.rank - b.rank).map((product: any) => (
80
+ products?.sort((a: any, b: any) => a.rank - b.rank).map((product: any, index: number) => (
81
81
  <SingleProductCard
82
- key={product.id}
82
+ key={`all${product.id}-${index}`}
83
83
  isSoldOut={product.inventoried && !product.quantity}
84
84
  businessId={businessId}
85
85
  product={product}
@@ -1,13 +1,12 @@
1
1
  import React, { useEffect, useState } from 'react'
2
- import { LanguageSelector as LanguageSelectorController, useOrder } from 'ordering-components/native'
2
+ import { Platform, StyleSheet, NativeModules } from 'react-native'
3
3
  import { useTheme } from 'styled-components/native';
4
- import { I18nManager, Platform, StyleSheet, View } from 'react-native'
4
+ import RNRestart from 'react-native-restart'
5
+ import { LanguageSelector as LanguageSelectorController, useOrder, useLanguage } from 'ordering-components/native'
5
6
 
6
7
  import RNPickerSelect from 'react-native-picker-select'
7
8
  import { Container, DummyContainer } from './styles'
8
9
  import { LanguageSelectorParams } from '../../types'
9
- import { OIcon } from '../shared'
10
- import RNRestart from 'react-native-restart'
11
10
 
12
11
  const LanguageSelectorUI = (props: LanguageSelectorParams) => {
13
12
 
@@ -19,6 +18,7 @@ const LanguageSelectorUI = (props: LanguageSelectorParams) => {
19
18
  } = props
20
19
 
21
20
  const [orderState] = useOrder()
21
+ const [langugageState] = useLanguage()
22
22
  const theme = useTheme();
23
23
 
24
24
  const [language, setLanguage] = useState(currentLanguage)
@@ -70,16 +70,18 @@ const LanguageSelectorUI = (props: LanguageSelectorParams) => {
70
70
  )
71
71
 
72
72
  const changeDirection = async (language: any) => {
73
- if (language !== 'ar') {
74
- if (I18nManager.isRTL) {
75
- await I18nManager.forceRTL(false)
76
- RNRestart.Restart();
77
- }
78
- } else {
79
- if (!I18nManager.isRTL) {
80
- await I18nManager.forceRTL(true)
81
- RNRestart.Restart();
82
- }
73
+ if (language === langugageState?.language?.code) return
74
+ const isArabicLang = language === 'ar'
75
+ const isRTLOn = NativeModules.I18nManager.isRTL
76
+
77
+ if (isArabicLang && !isRTLOn) {
78
+ NativeModules.I18nManager.forceRTL(!isRTLOn)
79
+ RNRestart.Restart();
80
+ }
81
+
82
+ if (!isArabicLang && isRTLOn) {
83
+ NativeModules.I18nManager.forceRTL(!isRTLOn)
84
+ RNRestart.Restart();
83
85
  }
84
86
  }
85
87
 
@@ -87,11 +89,11 @@ const LanguageSelectorUI = (props: LanguageSelectorParams) => {
87
89
  changeDirection(Platform.OS === 'ios' ? language : langCode)
88
90
  handleChangeLanguage(Platform.OS === 'ios' ? language : langCode)
89
91
  }
90
-
92
+
91
93
  useEffect(() => {
92
94
  changeDirection(currentLanguage)
93
95
  }, [])
94
-
96
+
95
97
  return (
96
98
  <Container>
97
99
  {languagesState?.languages ? (
@@ -113,8 +115,11 @@ const LanguageSelectorUI = (props: LanguageSelectorParams) => {
113
115
  }
114
116
 
115
117
  export const LanguageSelector = (props: LanguageSelectorParams) => {
118
+ const [langugageState] = useLanguage()
119
+
116
120
  const LanguageProps = {
117
121
  ...props,
122
+ currentLanguage: langugageState?.language?.code ?? NativeModules.I18nManager.localeIdentifier?.split('_')?.[0] ?? 'en',
118
123
  UIComponent: LanguageSelectorUI
119
124
  }
120
125
 
@@ -42,8 +42,8 @@ const ORDER_STATUS: any = {
42
42
 
43
43
  const imgOptions = {
44
44
  mediaType: 'photo',
45
- maxHeight: 300,
46
- maxWidth: 300,
45
+ maxHeight: 2048,
46
+ maxWidth: 2048,
47
47
  includeBase64: true,
48
48
  selectionLimit: 0
49
49
  }