import React from 'react'; import { StyleSheet, Text, View } from 'react-native'; import Touchable from 'react-native-platform-touchable'; import { useAppSelector } from '../lib/hooks'; import { useTheme } from '../theme'; import sharedStyles from '../views/Styles'; import { CustomIcon } from './CustomIcon'; import { BUTTON_HIT_SLOP } from './message/utils'; import AvatarContainer from './Avatar'; import StatusContainer from './Status'; import DotsLoader from './DotsLoader'; type TCallHeader = { mic: boolean; cam: boolean; setCam: Function; setMic: Function; title: string; avatar: string; uid: string; name: string; direct: boolean; }; export const CallHeader = ({ mic, cam, setCam, setMic, title, avatar, uid, name, direct }: TCallHeader): React.ReactElement => { const style = useStyle(); const { colors } = useTheme(); const calling = useAppSelector(state => state.videoConf.calling); const handleColors = (enabled: boolean) => { if (calling) { if (enabled) return { button: colors.conferenceCallCallBackButton, icon: colors.gray300 }; return { button: 'transparent', icon: colors.gray100 }; } if (enabled) return { button: colors.conferenceCallEnabledIconBackground, icon: colors.conferenceCallEnabledIcon }; return { button: 'transparent', icon: colors.conferenceCallDisabledIcon }; }; return ( {title} {calling && direct ? : null} setCam(!cam)} style={[style.iconCallContainerRight, { backgroundColor: handleColors(cam).button }]} hitSlop={BUTTON_HIT_SLOP} disabled={calling} > setMic(!mic)} style={[style.iconCallContainer, { backgroundColor: handleColors(mic).button }]} hitSlop={BUTTON_HIT_SLOP} disabled={calling} > {direct ? : null} {name} ); }; function useStyle() { const { colors } = useTheme(); const style = StyleSheet.create({ actionSheetHeader: { flexDirection: 'row', alignItems: 'center' }, actionSheetHeaderTitle: { fontSize: 14, ...sharedStyles.textBold, color: colors.n900 }, actionSheetHeaderButtons: { flex: 1, alignItems: 'center', flexDirection: 'row', justifyContent: 'flex-end' }, iconCallContainer: { padding: 6, borderRadius: 4 }, iconCallContainerRight: { padding: 6, borderRadius: 4, marginRight: 6 }, actionSheetUsernameContainer: { flexDirection: 'row', paddingTop: 8, alignItems: 'center' }, actionSheetUsername: { fontSize: 16, ...sharedStyles.textBold, color: colors.passcodePrimary, flexShrink: 1 }, rowContainer: { flexDirection: 'row' }, statusContainerMargin: { marginLeft: 8, marginRight: 6 } }); return style; }