Skip to content

Commit

Permalink
chore: make error scrollable
Browse files Browse the repository at this point in the history
  • Loading branch information
janrtvld committed Dec 4, 2024
1 parent 7c8c971 commit 06b15ec
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
6 changes: 3 additions & 3 deletions apps/easypid/src/features/menu/FunkeSettingsScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FlexPage, Heading, ScrollView, Stack, Switch, YStack } from '@package/ui'
import { FlexPage, Heading, HeroIcons, ScrollView, Stack, Switch, YStack } from '@package/ui'
import React from 'react'

import { TextBackButton } from 'packages/app/src'
Expand Down Expand Up @@ -28,15 +28,15 @@ export function FunkeSettingsScreen() {
>
<YStack fg={1} px="$4" jc="space-between">
<YStack gap="$4" py="$2">
<LocalAiContainer />
<Switch
id="development-mode"
label="Development Mode"
icon={<HeroIcons.CommandLineFilled />}
value={isDevelopmentModeEnabled ?? false}
onChange={setIsDevelopmentModeEnabled}
/>
<LocalAiContainer />
</YStack>

<YStack btw="$0.5" borderColor="$grey-200" pt="$4" mx="$-4" px="$4" bg="$background">
<TextBackButton />
</YStack>
Expand Down
23 changes: 14 additions & 9 deletions apps/easypid/src/features/receive/slides/CredentialErrorSlide.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { Button, Heading, HeroIcons, Paragraph, Stack, XStack, YStack } from '@package/ui'
import { Button, Heading, HeroIcons, Paragraph, ScrollView, Stack, XStack, YStack } from '@package/ui'
import { useState } from 'react'

interface CredentialErrorSlideProps {
reason?: string
onCancel: () => void
}

export const CredentialErrorSlide = ({ reason, onCancel }: CredentialErrorSlideProps) => {
const [scrollViewHeight, setScrollViewHeight] = useState(0)

return (
<YStack fg={1} jc="space-between">
<YStack gap="$6">
<YStack gap="$2">
<YStack gap="$6" fg={1} onLayout={(event) => setScrollViewHeight(event.nativeEvent.layout.height)}>
<ScrollView gap="$2" fg={1} maxHeight={scrollViewHeight}>
<YStack gap="$4">
<Heading>Something went wrong</Heading>
<Stack alignSelf="flex-start">
Expand All @@ -22,13 +25,15 @@ export const CredentialErrorSlide = ({ reason, onCancel }: CredentialErrorSlideP
again later.
</Paragraph>
</YStack>
{reason && (
<Paragraph variant="sub">
<Paragraph variant="caption">Reason: </Paragraph>
{reason}
</Paragraph>
{reason && scrollViewHeight !== 0 && (
<YStack>
<Paragraph variant="sub">
<Paragraph variant="caption">Reason: </Paragraph>
{reason}
</Paragraph>
</YStack>
)}
</YStack>
</ScrollView>
</YStack>
<Stack borderTopWidth="$0.5" borderColor="$grey-200" py="$4" mx="$-4" px="$4">
<Button.Solid scaleOnPress onPress={onCancel}>
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/content/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import {
CircleStackIcon as CircleStackFilledIcon,
ClockIcon as ClockFilledIcon,
Cog8ToothIcon as Cog8ToothFilledIcon,
CommandLineIcon,
CpuChipIcon as CpuChipFilledIcon,
CreditCardIcon as CreditCardFilledIcon,
ExclamationCircleIcon as ExclamationCircleFilledIcon,
Expand Down Expand Up @@ -177,6 +178,7 @@ export const HeroIcons = {
Link: wrapHeroIcon(LinkIcon),
Cloud: wrapHeroIcon(CloudIcon),
CpuChipFilled: wrapHeroIcon(CpuChipFilledIcon),
CommandLineFilled: wrapHeroIcon(CommandLineIcon),
} as const

export const CustomIcons = {
Expand Down

0 comments on commit 06b15ec

Please sign in to comment.