feat: simplify code for pair device

This commit is contained in:
RadoslavDimchev 2023-12-21 11:23:39 +02:00
parent ba56e05438
commit 3db25407db
1 changed files with 33 additions and 40 deletions

View File

@ -27,11 +27,7 @@ const PairDevice = () => {
setIsConnectingViaIp(state => !state) setIsConnectingViaIp(state => !state)
} }
const continueHandler = () => { const continueHandler = () => {}
if (isConnectingViaIp) {
} else {
}
}
return ( return (
<PageWrapperShadow rightImageSrc="./background-images/day-night-bg.png" rightImageLogo={true}> <PageWrapperShadow rightImageSrc="./background-images/day-night-bg.png" rightImageLogo={true}>
@ -43,23 +39,42 @@ const PairDevice = () => {
/> />
{isConnectingViaIp ? ( {isConnectingViaIp ? (
<ConnectViaIP /> <ConnectViaIP />
) : isPaired ? (
<PairedSuccessfully />
) : ( ) : (
<> <>
{isPaired ? ( <GenerateId isAwaitingPairing={isAwaitingPairing} />
<PairedSuccessfully /> <SyncStatus
) : ( isPairing={isPairing}
<GenerateId isAwaitingPairing={isAwaitingPairing} /> isAwaitingPairing={isAwaitingPairing}
)} changeSetIsAwaitingPairing={changeSetIsAwaitingPairing}
{isPaired === false && ( />
<SyncStatus
isPairing={isPairing}
isAwaitingPairing={isAwaitingPairing}
changeSetIsAwaitingPairing={changeSetIsAwaitingPairing}
/>
)}
</> </>
)} )}
{isPaired === false && ( {isPaired ? (
<>
<YStack space={'$3'}>
<Separator alignSelf="stretch" borderColor={'#F0F2F5'} marginTop={3} />
<Text size={19} weight="semibold">
General Settings
</Text>
<XStack space={'$4'} alignItems={'center'}>
<Checkbox
id="auto-connect"
selected={isAutoConnectChecked}
onCheckedChange={e => setIsAutoConnectChecked(e)}
variant="outline"
/>
<Label htmlFor="auto-connect">
<Text size={15} weight="regular">
Auto Connect Paired Device
</Text>
</Label>
</XStack>
</YStack>
<CreateAvatar />
</>
) : (
<YStack space={'$3'}> <YStack space={'$3'}>
<Separator borderColor={'#e3e3e3'} /> <Separator borderColor={'#e3e3e3'} />
<YStack space={'$1'}> <YStack space={'$1'}>
@ -80,28 +95,6 @@ const PairDevice = () => {
</YStack> </YStack>
</YStack> </YStack>
)} )}
{isPaired && (
<YStack space={'$3'}>
<Separator alignSelf="stretch" borderColor={'#F0F2F5'} marginTop={3} />
<Text size={19} weight="semibold">
General Settings
</Text>
<XStack space={'$4'} alignItems={'center'}>
<Checkbox
id="auto-connect"
selected={isAutoConnectChecked}
onCheckedChange={e => setIsAutoConnectChecked(e)}
variant="outline"
/>
<Label htmlFor="auto-connect">
<Text size={15} weight="regular">
Auto Connect Paired Device
</Text>
</Label>
</XStack>
</YStack>
)}
{isPaired && <CreateAvatar />}
<Separator borderColor={'#e3e3e3'} /> <Separator borderColor={'#e3e3e3'} />
<div> <div>
<Button icon={<NodeIcon size={20} />} disabled={!isPaired} onPress={continueHandler}> <Button icon={<NodeIcon size={20} />} disabled={!isPaired} onPress={continueHandler}>