ordering-ui-react-native 0.17.77 → 0.17.78

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.77",
3
+ "version": "0.17.78",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -1,6 +1,6 @@
1
- import React, { useState } from 'react'
1
+ import React, { useState, useCallback } from 'react'
2
2
 
3
- import { Platform, StyleSheet, View } from 'react-native';
3
+ import { Platform, StyleSheet, View, TouchableOpacity } from 'react-native';
4
4
 
5
5
  import { OButton, OText, OLink, OModal } from '../shared'
6
6
  import {
@@ -44,6 +44,9 @@ export const OrderContentComponent = (props: OrderContent) => {
44
44
  const [{ configs }] = useConfig();
45
45
  const [openReviewModal, setOpenReviewModal] = useState(false)
46
46
 
47
+ const [isReadMore, setIsReadMore] = useState(false)
48
+ const [lengthMore, setLengthMore] = useState(false)
49
+
47
50
  const pastOrderStatuses = [1, 2, 5, 6, 10, 11, 12, 16, 17]
48
51
 
49
52
  const walletName: any = {
@@ -95,6 +98,10 @@ export const OrderContentComponent = (props: OrderContent) => {
95
98
  return /^\d+$/.test(str);
96
99
  }
97
100
 
101
+ const onTextLayout = useCallback((e: any) => {
102
+ setLengthMore(e.nativeEvent.lines.length >= 3); //to check the text is more than 2 lines or not
103
+ },[]);
104
+
98
105
  return (
99
106
  <OrderContent isOrderGroup={isOrderGroup} lastOrder={lastOrder}>
100
107
  {isOrderGroup && (
@@ -298,18 +305,26 @@ export const OrderContentComponent = (props: OrderContent) => {
298
305
  )}
299
306
 
300
307
  {!!order?.customer?.address && (
301
- <View style={styles.linkWithIcons}>
302
- <OLink
303
- PressStyle={styles.linkWithIcons}
304
- url={Platform.select({
305
- ios: `maps:0,0?q=${order?.customer?.address}`,
306
- android: `geo:0,0?q=${order?.customer?.address}`,
307
- })}
308
- numberOfLines={2}
309
- shorcut={order?.customer?.address}
310
- TextStyle={styles.textLink}
311
- />
312
- </View>
308
+ <>
309
+ <View style={styles.linkWithIcons}>
310
+ <OLink
311
+ PressStyle={{ ...styles.linkWithIcons, marginBottom: 0 }}
312
+ url={Platform.select({
313
+ ios: `maps:0,0?q=${order?.customer?.address}`,
314
+ android: `geo:0,0?q=${order?.customer?.address}`,
315
+ })}
316
+ onTextLayout={onTextLayout}
317
+ numberOfLines={isReadMore ? 20 : 2}
318
+ shorcut={order?.customer?.address}
319
+ TextStyle={styles.textLink}
320
+ />
321
+ </View>
322
+ {lengthMore && (
323
+ <TouchableOpacity onPress={() => setIsReadMore(!isReadMore)}>
324
+ <OText size={12} color={theme.colors.statusOrderBlue}>{isReadMore ? t('SHOW_LESS', 'Show less') : t('READ_MORE', 'Read more')}</OText>
325
+ </TouchableOpacity>
326
+ )}
327
+ </>
313
328
  )}
314
329
 
315
330
  {!!order?.customer?.internal_number && (
@@ -13,10 +13,11 @@ interface Props {
13
13
  type?: string;
14
14
  hasButton?: boolean;
15
15
  numberOfLines?: number;
16
+ onTextLayout?: (e : any) => void;
16
17
  }
17
18
 
18
19
  const OLink = (props: Props): React.ReactElement => {
19
- const { url, shorcut, color, PressStyle, TextStyle, type, hasButton, numberOfLines } = props;
20
+ const { url, shorcut, color, PressStyle, TextStyle, type, hasButton, numberOfLines, onTextLayout } = props;
20
21
  const [, t] = useLanguage();
21
22
 
22
23
  const handleAlert = () =>
@@ -78,7 +79,9 @@ const OLink = (props: Props): React.ReactElement => {
78
79
  style={TextStyle}
79
80
  numberOfLines={numberOfLines ?? 1}
80
81
  ellipsizeMode="tail"
81
- color={color}>
82
+ color={color}
83
+ onTextLayout={onTextLayout}
84
+ >
82
85
  {shorcut}
83
86
  </OText>
84
87
  )}
@@ -86,4 +89,8 @@ const OLink = (props: Props): React.ReactElement => {
86
89
  );
87
90
  };
88
91
 
92
+ OLink.defaultProps = {
93
+ onTextLayout: (e: any) => {}
94
+ };
95
+
89
96
  export default OLink;
@@ -42,15 +42,20 @@ interface Props {
42
42
  adjustsFontSizeToFit?: boolean;
43
43
  textDecorationLine?: string;
44
44
  lineHeight?: number;
45
+ onTextLayout?: (e : any) => void;
45
46
  }
46
47
 
47
48
  const OText = (props: Props): React.ReactElement => {
48
49
  return (
49
- <SText {...props} style={[props.style, { lineHeight: props.lineHeight }]}>
50
+ <SText {...props} style={[props.style, { lineHeight: props.lineHeight }]} onTextLayout={props.onTextLayout}>
50
51
  {props.children}
51
52
  {props.space && ' '}
52
53
  </SText>
53
54
  );
54
55
  };
55
56
 
57
+ OText.defaultProps = {
58
+ onTextLayout: (e: any) => {}
59
+ };
60
+
56
61
  export default OText;