import * as React from 'react';
import { Flex, Text, Button, Box, } from '../../themes/components';
import SelfPreview from '../../components/SelfPreview';
import { TextInput } from 'react-native';
import { ThemeContext } from 'styled-components';
import { SDK_BUILD } from '../../env';
import borderRadius from '../../themes/foundations/borderRadius';
import { setUserDisplayName, } from '../../store/participantSlice';
import { useDispatch, useSelector } from 'react-redux';
export default function ShowSetupScreen({ width, height, isLandscape, meetingCode, roomName, onChangeMeetingCode, joinMeeting, }) {
    const dispatch = useDispatch();
    const [inputError, setInputError] = React.useState({
        displayName: false,
        meetingCode: false,
    });
    const { colors } = React.useContext(ThemeContext);
    const displayName = useSelector((state) => state.participant.displayName);
    const onJoinMeetingClicked = () => {
        const inputFieldsErrors = {
            displayName: false,
            meetingCode: false,
        };
        if (!meetingCode || !displayName) {
            if (!displayName) {
                inputFieldsErrors.displayName = true;
            }
            if (!meetingCode) {
                inputFieldsErrors.meetingCode = true;
            }
        }
        else {
            joinMeeting();
        }
        setInputError(inputFieldsErrors);
    };
    return (<Flex height={height} width={width} justify={isLandscape ? 'space-evenly' : 'center'} align="center" backgroundColor="secondary.1000" top={0} direction={isLandscape ? 'row' : 'column'} bottom={0}>
			<SelfPreview />

			<Flex width={width / (isLandscape ? 3 : 1) - 40} justify="center">
				<Text color="textPrimary.300" mt={20}>Name: </Text>
				<TextInput style={{
        paddingLeft: 15,
        height: 48,
        marginVertical: 10,
        borderRadius: borderRadius.medium,
        color: colors.textPrimary[300],
        backgroundColor: colors.secondary[800],
        width: width / (isLandscape ? 3 : 1) - 40,
    }} onChangeText={(e) => dispatch(setUserDisplayName(e))} editable={!SDK_BUILD} showSoftInputOnFocus={!SDK_BUILD} value={displayName}/>
				{inputError.displayName && <Text color="danger.300" mb={10}> Please enter your display name</Text>}
				{!roomName && !SDK_BUILD && (<Box>
						<Text color="textPrimary.300">Meeting Code:</Text>
						<TextInput style={{
        paddingLeft: 15,
        paddingBottom: 7,
        paddingTop: 7,
        marginVertical: 10,
        borderRadius: borderRadius.medium,
        color: colors.textPrimary[300],
        backgroundColor: colors.secondary[800],
        width: width / (isLandscape ? 3 : 1) - 40,
    }} onChangeText={onChangeMeetingCode} value={meetingCode}/>
						{inputError.meetingCode && <Text color="danger.300" mb={10}> Please enter meeting room code</Text>}
					</Box>)}
				<Button onClick={onJoinMeetingClicked}>
					<Box bg="primary.500" py={12} mt={10} borderRadius={borderRadius.medium} align="center">
						<Text>Join</Text>
					</Box>
				</Button>
			</Flex>
		</Flex>);
}
//# sourceMappingURL=showSetupScreen.js.map