From ba7463cadf15bd5420e1a8cc46952bde2c81cad9 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Mon, 12 Feb 2024 13:36:20 -0800 Subject: Improved server selector during account creation and signin (#2840) * Replace the ServerInput modal with a new dialog based on alf that remembers your server address history and doesnt put staging and localdev in the options * Update the server selector during account creation * dont apply capitalization, use url keyboard * Apply insets to dialog top * Improve padding of dialogs on native * Fix race condition in dialog close; also fix fire of the onClose event in dialogs --------- Co-authored-by: Hailey --- src/components/Dialog/index.tsx | 54 +++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 21 deletions(-) (limited to 'src/components/Dialog/index.tsx') diff --git a/src/components/Dialog/index.tsx b/src/components/Dialog/index.tsx index 44e4dc8a7..9132e68de 100644 --- a/src/components/Dialog/index.tsx +++ b/src/components/Dialog/index.tsx @@ -34,6 +34,7 @@ export function Outer({ const sheet = React.useRef(null) const sheetOptions = nativeOptions?.sheet || {} const hasSnapPoints = !!sheetOptions.snapPoints + const insets = useSafeAreaInsets() const open = React.useCallback((i = 0) => { sheet.current?.snapToIndex(i) @@ -41,8 +42,7 @@ export function Outer({ const close = React.useCallback(() => { sheet.current?.close() - onClose?.() - }, [onClose]) + }, []) useImperativeHandle( control.ref, @@ -53,6 +53,15 @@ export function Outer({ [open, close], ) + const onChange = React.useCallback( + (index: number) => { + if (index === -1) { + onClose?.() + } + }, + [onClose], + ) + const context = React.useMemo(() => ({close}), [close]) return ( @@ -63,6 +72,7 @@ export function Outer({ keyboardBehavior="interactive" android_keyboardInputMode="adjustResize" keyboardBlurBehavior="restore" + topInset={insets.top} {...sheetOptions} ref={sheet} index={-1} @@ -77,7 +87,7 @@ export function Outer({ )} handleIndicatorStyle={{backgroundColor: t.palette.primary_500}} handleStyle={{display: 'none'}} - onClose={onClose}> + onChange={onChange}> + + + ) } -- cgit 1.4.1