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.buttonBackgroundSecondaryDisabled, icon: colors.strokeExtraDark }; return { button: 'transparent', icon: colors.strokeLight }; } if (enabled) return { button: colors.strokeHighlight, icon: colors.surfaceLight }; return { button: 'transparent', icon: colors.strokeExtraDark }; }; 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.fontDefault }, 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.fontDefault, flexShrink: 1 }, rowContainer: { flexDirection: 'row' }, statusContainerMargin: { marginLeft: 8, marginRight: 6 } }); return style; }