Browse Source

add use cutLongText helper

pull/14/head
YaroslavBerkuta 9 months ago
parent
commit
017ccd24c4
  1. 16
      src/modules/root/smart-components/select-country-phone.smart-component.tsx
  2. 12
      src/shared/helpers/text.helpers.ts

16
src/modules/root/smart-components/select-country-phone.smart-component.tsx

@ -16,8 +16,7 @@ import { @@ -16,8 +16,7 @@ import {
FlatList,
} from 'react-native'
import countries, { Countries, Country } from 'world-countries'
import { $size } from '@/shared/helpers'
import * as _ from 'lodash'
import { $size, cutLongText } from '@/shared/helpers'
import CountryFlag from 'react-native-country-flag'
import RBSheet from 'react-native-raw-bottom-sheet'
@ -84,19 +83,14 @@ export const SelectCountryPhone = () => { @@ -84,19 +83,14 @@ export const SelectCountryPhone = () => {
style={{ marginRight: 10 }}
/>
<Text style={styles.code}>
{_.truncate(
`${item?.idd?.root || ''}${
item?.idd?.suffixes[0] || ''
}`,
{ length: 5, separator: null },
{cutLongText(
`${item?.idd?.root}${item?.idd?.suffixes[0] || ''}`,
5,
)}
</Text>
</View>
<Text style={styles.label}>
{_.truncate(item.name.common, {
length: 25,
separator: null,
})}
{cutLongText(item.name.common, 20)}
</Text>
<CheckBox
isChecked={item.cca2 === currentIso}

12
src/shared/helpers/text.helpers.ts

@ -1,12 +1,12 @@ @@ -1,12 +1,12 @@
export const cutLongText = (txt: string, length: number): string => {
if (txt.length > length) {
const cuttingTxt = txt.slice(0, length)
if (txt.length > length) {
const cuttingTxt = txt.slice(0, length)
return `${cuttingTxt}...`
}
return `${cuttingTxt}...`
}
return txt
return txt
}
export const getLinksFromTxt = (txt: string) =>
txt?.match(/\bhttp(s)?:(:)?\/\/\S+/gi)
txt?.match(/\bhttp(s)?:(:)?\/\/\S+/gi)

Loading…
Cancel
Save