Skip to content

Commit 0bd436f

Browse files
committed
🐛 Fix keyboard covering input in add server sheet
1 parent 2d98f97 commit 0bd436f

File tree

5 files changed

+49
-11
lines changed

5 files changed

+49
-11
lines changed

apps/expo/app/(tabs)/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default function Screen() {
3838

3939
if (defaultServer) {
4040
router.push({
41-
pathname: defaultServer.kind === 'stump' ? '/server/[id]' : '/opds/[id]',
41+
pathname: defaultServer.kind === 'stump' ? '/server/[id]/(tabs)/index' : '/opds/[id]',
4242
params: { id: defaultServer.id },
4343
})
4444
}

apps/expo/app/opds/[id]/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
OPDSPublicationGroup,
1616
} from '~/components/opds'
1717
import RefreshControl from '~/components/RefreshControl'
18-
import { Heading, icons } from '~/components/ui'
18+
import { icons } from '~/components/ui'
1919
import { useDynamicHeader } from '~/lib/hooks/useDynamicHeader'
2020

2121
const { ChevronLeft } = icons

apps/expo/components/savedServer/AddOrEditServerForm.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { cn } from '~/lib/utils'
2121
import { usePreferencesStore, useSavedServers } from '~/stores'
2222
import { SavedServerWithConfig } from '~/stores/savedServer'
2323

24-
import { Button, Heading, Input, Label, Switch, Tabs, Text } from '../ui'
24+
import { BottomSheet, Button, Heading, Label, Switch, Tabs, Text } from '../ui'
2525

2626
type Props = {
2727
editingServer?: SavedServerWithConfig | null
@@ -126,10 +126,10 @@ export default function AddOrEditServerForm({ editingServer, onSubmit, onClose }
126126
<Controller
127127
control={control}
128128
render={({ field: { onChange, onBlur, value } }) => (
129-
<Input
130-
label="Username"
129+
<BottomSheet.Input
131130
autoCorrect={false}
132131
autoCapitalize="none"
132+
label="Username"
133133
placeholder="oromei"
134134
onBlur={onBlur}
135135
onChangeText={onChange}
@@ -143,7 +143,7 @@ export default function AddOrEditServerForm({ editingServer, onSubmit, onClose }
143143
<Controller
144144
control={control}
145145
render={({ field: { onChange, onBlur, value } }) => (
146-
<Input
146+
<BottomSheet.Input
147147
label="Password"
148148
autoCorrect={false}
149149
autoCapitalize="none"
@@ -164,7 +164,7 @@ export default function AddOrEditServerForm({ editingServer, onSubmit, onClose }
164164
<Controller
165165
control={control}
166166
render={({ field: { onChange, onBlur, value } }) => (
167-
<Input
167+
<BottomSheet.Input
168168
label="Token"
169169
autoCorrect={false}
170170
autoCapitalize="none"
@@ -291,7 +291,7 @@ export default function AddOrEditServerForm({ editingServer, onSubmit, onClose }
291291
required: true,
292292
}}
293293
render={({ field: { onChange, onBlur, value } }) => (
294-
<Input
294+
<BottomSheet.Input
295295
label="Name"
296296
autoCorrect={false}
297297
autoCapitalize="none"
@@ -311,7 +311,7 @@ export default function AddOrEditServerForm({ editingServer, onSubmit, onClose }
311311
required: true,
312312
}}
313313
render={({ field: { onChange, onBlur, value } }) => (
314-
<Input
314+
<BottomSheet.Input
315315
label={kind === 'stump' ? 'URL' : 'Catalog URL'}
316316
autoCorrect={false}
317317
autoCapitalize="none"

apps/expo/components/ui/bottom-sheet/index.tsx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@ import BottomSheet, {
44
BottomSheetModal as BSModal,
55
BottomSheetModalProvider,
66
BottomSheetScrollView as BSScrollView,
7+
BottomSheetTextInput as BSTextInput,
78
BottomSheetView as BSView,
89
} from '@gorhom/bottom-sheet'
10+
import { BottomSheetTextInputProps } from '@gorhom/bottom-sheet/lib/typescript/components/bottomSheetTextInput'
911
import { cssInterop } from 'nativewind'
1012
import React, { forwardRef, Fragment } from 'react'
13+
import { View } from 'react-native'
1114

15+
import { cn } from '~/lib/utils'
16+
17+
import { Text } from '../text'
1218
import { BottomSheetProps, BSHandleProps } from './types'
1319

1420
const BottomSheetTrigger = Fragment
@@ -38,13 +44,46 @@ const BottomSheetScrollView = cssInterop(BSScrollView, {
3844

3945
const BottomSheetHandle: React.FC<BSHandleProps> = BSHandle
4046

47+
const BottomSheetTextInput = forwardRef<
48+
React.ComponentRef<typeof BSTextInput>,
49+
BottomSheetTextInputProps & { label?: string; errorMessage?: string }
50+
>(({ label, errorMessage, ...rest }, ref) => {
51+
const InputComponent = cssInterop(BSTextInput, {
52+
className: 'style',
53+
})
54+
55+
return (
56+
<View className="w-full gap-1.5">
57+
{label && <Text className="text-base font-medium text-foreground-muted">{label}</Text>}
58+
<InputComponent
59+
ref={ref}
60+
{...rest}
61+
className={cn(
62+
'native:h-12 native:text-lg native:leading-[1.25] h-10 rounded-lg border border-edge bg-background px-3 text-base text-foreground file:border-0 file:bg-transparent file:font-medium lg:text-sm',
63+
rest.editable === false && 'opacity-50',
64+
{ 'border-edge-danger': !!errorMessage },
65+
rest.className,
66+
)}
67+
placeholderClassName={cn(
68+
'text-foreground-muted',
69+
{ 'text-fill-danger': !!errorMessage },
70+
rest.placeholderClassName,
71+
)}
72+
/>
73+
{errorMessage && <Text className="text-sm text-fill-danger">{errorMessage}</Text>}
74+
</View>
75+
)
76+
})
77+
BottomSheetTextInput.displayName = 'BottomSheetTextInput'
78+
4179
type TypedBottomSheet = typeof BottomSheet & {
4280
Provider: typeof BottomSheetModalProvider
4381
Modal: typeof BottomSheetModal
4482
Handle: typeof BottomSheetHandle
4583
ScrollView: typeof BottomSheetScrollView
4684
View: typeof BottomSheetView
4785
Trigger: typeof BottomSheetTrigger
86+
Input: typeof BottomSheetTextInput
4887
}
4988

5089
const TypedBottomSheet = BottomSheet as TypedBottomSheet
@@ -54,5 +93,6 @@ TypedBottomSheet.Handle = BottomSheetHandle
5493
TypedBottomSheet.ScrollView = BottomSheetScrollView
5594
TypedBottomSheet.View = BottomSheetView
5695
TypedBottomSheet.Trigger = BottomSheetTrigger
96+
TypedBottomSheet.Input = BottomSheetTextInput
5797

5898
export { TypedBottomSheet as BottomSheet }

apps/expo/components/ui/input/input.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import * as React from 'react'
22
import { TextInput, type TextInputProps, View } from 'react-native'
33

4-
import { cn } from '~/lib/utils'
5-
64
import { Text } from '../text'
75
import { RawInput } from './raw-input'
86

0 commit comments

Comments
 (0)