Dialog text input
This commit is contained in:
@@ -3,12 +3,14 @@ import {View, Dimensions} from 'react-native'
|
|||||||
import BottomSheet, {
|
import BottomSheet, {
|
||||||
BottomSheetBackdrop,
|
BottomSheetBackdrop,
|
||||||
BottomSheetScrollView,
|
BottomSheetScrollView,
|
||||||
|
BottomSheetTextInput,
|
||||||
BottomSheetView,
|
BottomSheetView,
|
||||||
} from '@gorhom/bottom-sheet'
|
} from '@gorhom/bottom-sheet'
|
||||||
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
||||||
|
|
||||||
import {useTheme, atoms as a} from '#/alf'
|
import {useTheme, atoms as a} from '#/alf'
|
||||||
import {Portal} from '#/components/Portal'
|
import {Portal} from '#/components/Portal'
|
||||||
|
import {createTextInput} from '#/components/forms/InputText'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
DialogOuterProps,
|
DialogOuterProps,
|
||||||
@@ -19,6 +21,8 @@ import {Context} from '#/components/Dialog/context'
|
|||||||
|
|
||||||
export {useDialogControl, useDialogContext} from '#/components/Dialog/context'
|
export {useDialogControl, useDialogContext} from '#/components/Dialog/context'
|
||||||
export * from '#/components/Dialog/types'
|
export * from '#/components/Dialog/types'
|
||||||
|
// @ts-ignore
|
||||||
|
export const InputText = createTextInput(BottomSheetTextInput)
|
||||||
|
|
||||||
export function Outer({
|
export function Outer({
|
||||||
children,
|
children,
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {Context, useDialogContext} from '#/components/Dialog/context'
|
|||||||
|
|
||||||
export {useDialogControl, useDialogContext} from '#/components/Dialog/context'
|
export {useDialogControl, useDialogContext} from '#/components/Dialog/context'
|
||||||
export * from '#/components/Dialog/types'
|
export * from '#/components/Dialog/types'
|
||||||
|
export {InputText} from '#/components/forms/InputText'
|
||||||
|
|
||||||
const stopPropagation = (e: any) => e.stopPropagation()
|
const stopPropagation = (e: any) => e.stopPropagation()
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ type Props = BaseProps &
|
|||||||
suffix?: React.FunctionComponent<any>
|
suffix?: React.FunctionComponent<any>
|
||||||
}
|
}
|
||||||
|
|
||||||
export function InputText({
|
export function createTextInput(Input: typeof TextInput) {
|
||||||
|
return function InputText({
|
||||||
value: initialValue,
|
value: initialValue,
|
||||||
onChange,
|
onChange,
|
||||||
testID,
|
testID,
|
||||||
@@ -75,7 +76,9 @@ export function InputText({
|
|||||||
if (hasError) {
|
if (hasError) {
|
||||||
base.push({
|
base.push({
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
t.name === 'light' ? t.palette.negative_25 : t.palette.negative_900,
|
t.name === 'light'
|
||||||
|
? t.palette.negative_25
|
||||||
|
: t.palette.negative_900,
|
||||||
borderColor:
|
borderColor:
|
||||||
t.name === 'light'
|
t.name === 'light'
|
||||||
? t.palette.negative_300
|
? t.palette.negative_300
|
||||||
@@ -86,7 +89,9 @@ export function InputText({
|
|||||||
})
|
})
|
||||||
focus.push({
|
focus.push({
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
t.name === 'light' ? t.palette.negative_25 : t.palette.negative_900,
|
t.name === 'light'
|
||||||
|
? t.palette.negative_25
|
||||||
|
: t.palette.negative_900,
|
||||||
borderColor: tokens.color.red_500,
|
borderColor: tokens.color.red_500,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -155,7 +160,7 @@ export function InputText({
|
|||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<TextInput
|
<Input
|
||||||
{...props}
|
{...props}
|
||||||
value={value}
|
value={value}
|
||||||
testID={testID}
|
testID={testID}
|
||||||
@@ -238,3 +243,6 @@ export function InputText({
|
|||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const InputText = createTextInput(TextInput)
|
||||||
|
|||||||
@@ -56,6 +56,14 @@ export function Dialogs() {
|
|||||||
<View style={[a.relative, a.gap_md, a.w_full]}>
|
<View style={[a.relative, a.gap_md, a.w_full]}>
|
||||||
<H3 nativeID="dialog-title">Dialog</H3>
|
<H3 nativeID="dialog-title">Dialog</H3>
|
||||||
<P nativeID="dialog-description">Description</P>
|
<P nativeID="dialog-description">Description</P>
|
||||||
|
<Dialog.InputText
|
||||||
|
testID=""
|
||||||
|
value=""
|
||||||
|
onChange={() => {}}
|
||||||
|
placeholder="Type here"
|
||||||
|
accessibilityLabel="Type"
|
||||||
|
accessibilityHint="Type"
|
||||||
|
/>
|
||||||
<View style={{height: 1000}} />
|
<View style={{height: 1000}} />
|
||||||
<View style={[a.flex_row, a.justify_end]}>
|
<View style={[a.flex_row, a.justify_end]}>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
Reference in New Issue
Block a user