Browse Source
Reviewed-on: #12 Co-authored-by: YaroslavBerkuta <yaroslavberkuta@gmail.com> Co-committed-by: YaroslavBerkuta <yaroslavberkuta@gmail.com>pull/16/head
20 changed files with 227 additions and 73 deletions
Binary file not shown.
Binary file not shown.
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
export enum ContactFieldKeyEnum { |
||||
firstName = "Ім'я", |
||||
lastName = 'Фамілія', |
||||
fullName = "Повне ім'я", |
||||
position = 'Посада', |
||||
factoryName = 'Місце роботи', |
||||
avatarUrl = 'Фото профілю', |
||||
dateOfBirthday = 'День народження', |
||||
workPhoneNumber = 'Робочий номер телефону', |
||||
personalPhoneNumber = 'Персональний номер', |
||||
innerPhoneNumber = 'Внутрішній номер телефону', |
||||
email = 'Електрона пошта', |
||||
} |
@ -1 +1,2 @@
@@ -1 +1,2 @@
|
||||
export * from './contact-detail.enums' |
||||
export * from './contact-detail.enums' |
||||
export * from './contact-field-key.enum' |
||||
|
@ -1,2 +1,3 @@
@@ -1,2 +1,3 @@
|
||||
export * from './use-fetch-contacts.hook' |
||||
export * from './use-contact-detail.hook' |
||||
export * from './use-contact-copy.hook' |
||||
|
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
import { IContacForCopy, appEvents } from '@/shared' |
||||
import { CopyToBuffer } from '@/shared/helpers' |
||||
import * as _ from 'lodash' |
||||
import { ContactFieldKeyEnum } from '../enums' |
||||
|
||||
export const useContactCopy = (contact: IContacForCopy) => { |
||||
const formatContactForCopy = (contacData: IContacForCopy): string => { |
||||
const formatData = _.omit(contacData, [ |
||||
'userId', |
||||
'isSoonBirthday', |
||||
'chatId', |
||||
'status', |
||||
]) |
||||
|
||||
let resultString = '' |
||||
|
||||
for (const key in formatData) { |
||||
resultString += `${ContactFieldKeyEnum[key]}: ${formatData[key]}\n` |
||||
} |
||||
|
||||
return resultString |
||||
} |
||||
|
||||
const actionCopy = () => { |
||||
appEvents.emit('openActionSheet', { |
||||
items: [ |
||||
{ |
||||
name: "Скопіювати І'мя та Прізвище", |
||||
onPress: () => CopyToBuffer(`${contact.fullName}`), |
||||
}, |
||||
{ |
||||
name: 'Скопіювати Посаду', |
||||
onPress: () => |
||||
CopyToBuffer( |
||||
`${contact.factoryName}, ${contact.position}`, |
||||
), |
||||
}, |
||||
{ |
||||
name: 'Скопіювати всі данні користувача', |
||||
onPress: () => CopyToBuffer(formatContactForCopy(contact)), |
||||
}, |
||||
], |
||||
}) |
||||
} |
||||
|
||||
return { |
||||
actionCopy, |
||||
} |
||||
} |
@ -1,45 +1,38 @@
@@ -1,45 +1,38 @@
|
||||
import React from 'react'; |
||||
import { createIconSetFromFontello } from 'react-native-vector-icons'; |
||||
import { fontelloConfig } from '@/config/fontello.config'; |
||||
import { StyleSheet, TouchableOpacity, ViewStyle } from 'react-native'; |
||||
const Icon = createIconSetFromFontello(fontelloConfig); |
||||
import React from 'react' |
||||
import { createIconSetFromFontello } from 'react-native-vector-icons' |
||||
import { fontelloConfig } from '@/config/fontello.config' |
||||
import { TouchableOpacity, ViewStyle } from 'react-native' |
||||
const Icon = createIconSetFromFontello(fontelloConfig) |
||||
|
||||
interface IProps { |
||||
name: string |
||||
size: number |
||||
color?: string |
||||
style?: any |
||||
onPress?: () => void |
||||
btnStyle?: ViewStyle |
||||
name: string |
||||
size: number |
||||
color?: string |
||||
style?: any |
||||
onPress?: () => void |
||||
btnStyle?: ViewStyle |
||||
} |
||||
|
||||
export const IconComponent = ({ |
||||
onPress, |
||||
...props |
||||
}: IProps) => { |
||||
|
||||
if (onPress) { |
||||
return ( |
||||
<TouchableOpacity onPress={onPress} style={[ props.btnStyle]}> |
||||
<Icon |
||||
name={props.name} |
||||
size={props.size} |
||||
color={props.color} |
||||
style={props.style}
|
||||
/> |
||||
</TouchableOpacity> |
||||
) |
||||
} else { |
||||
return ( |
||||
<Icon |
||||
name={props.name} |
||||
size={props.size} |
||||
color={props.color} |
||||
style={props.style}
|
||||
/> |
||||
) |
||||
} |
||||
export const IconComponent = ({ onPress, ...props }: IProps) => { |
||||
if (onPress) { |
||||
return ( |
||||
<TouchableOpacity onPress={onPress} style={[props.btnStyle]}> |
||||
<Icon |
||||
name={props.name} |
||||
size={props.size} |
||||
color={props.color} |
||||
style={props.style} |
||||
/> |
||||
</TouchableOpacity> |
||||
) |
||||
} else { |
||||
return ( |
||||
<Icon |
||||
name={props.name} |
||||
size={props.size} |
||||
color={props.color} |
||||
style={props.style} |
||||
/> |
||||
) |
||||
} |
||||
} |
||||
|
||||
const styles = StyleSheet.create({ |
||||
}) |
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
import Clipboard from '@react-native-community/clipboard' |
||||
import { appEvents } from '../events' |
||||
|
||||
export const CopyToBuffer = (value: string) => { |
||||
Clipboard.setString(value) |
||||
appEvents.emit('openInfoModal', { |
||||
title: '', |
||||
message: 'Данні скопійовано в буфер обміну', |
||||
pressButtonText: 'Продовжити', |
||||
}) |
||||
} |
Loading…
Reference in new issue