Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3329203
D9437.id31825.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D9437.id31825.diff
View Options
diff --git a/native/account/siwe-panel.react.js b/native/account/siwe-panel.react.js
--- a/native/account/siwe-panel.react.js
+++ b/native/account/siwe-panel.react.js
@@ -18,6 +18,7 @@
type BindServerCallsParams,
} from 'lib/utils/action-utils.js';
+import { useKeyboardHeight } from '../keyboard/keyboard-hooks.js';
import { useSelector } from '../redux/redux-utils.js';
import Alert from '../utils/alert.js';
import { getContentSigningKey } from '../utils/crypto-utils.js';
@@ -88,21 +89,24 @@
const [walletConnectModalHeight, setWalletConnectModalHeight] =
React.useState(0);
const insets = useSafeAreaInsets();
+ const keyboardHeight = useKeyboardHeight();
const bottomInset = insets.bottom;
const snapPoints = React.useMemo(() => {
if (isLoading) {
return [1];
} else if (walletConnectModalHeight) {
- const baseHeight = bottomInset + walletConnectModalHeight;
+ const baseHeight =
+ bottomInset + walletConnectModalHeight + keyboardHeight;
if (baseHeight < 400) {
- return [baseHeight + 3];
+ return [baseHeight - 10];
} else {
- return [baseHeight - 17];
+ return [baseHeight + 5];
}
} else {
- return [bottomInset + 435, bottomInset + 600];
+ const baseHeight = bottomInset + keyboardHeight;
+ return [baseHeight + 435, baseHeight + 600];
}
- }, [isLoading, walletConnectModalHeight, bottomInset]);
+ }, [isLoading, walletConnectModalHeight, bottomInset, keyboardHeight]);
const bottomSheetRef = React.useRef();
const snapToIndex = bottomSheetRef.current?.snapToIndex;
diff --git a/native/keyboard/keyboard-hooks.js b/native/keyboard/keyboard-hooks.js
new file mode 100644
--- /dev/null
+++ b/native/keyboard/keyboard-hooks.js
@@ -0,0 +1,43 @@
+// @flow
+
+import * as React from 'react';
+
+import {
+ addKeyboardShowListener,
+ addKeyboardDismissListener,
+ removeKeyboardListener,
+} from './keyboard.js';
+import type { KeyboardEvent } from '../types/react-native.js';
+
+function useKeyboardHeight(): number {
+ const [keyboardHeight, setKeyboardHeight] = React.useState<number>(0);
+
+ const onKeyboardShow = React.useCallback((event: KeyboardEvent) => {
+ console.log(`onKeyboardShow: ${JSON.stringify(event)}`);
+ const height = event?.endCoordinates?.height ?? 0;
+ setKeyboardHeight(height);
+ }, []);
+ React.useEffect(() => {
+ const keyboardShowListener = addKeyboardShowListener(onKeyboardShow);
+ return () => {
+ removeKeyboardListener(keyboardShowListener);
+ };
+ }, [onKeyboardShow]);
+
+ const onKeyboardDismiss = React.useCallback((event: ?KeyboardEvent) => {
+ console.log(`onKeyboardDismiss: ${JSON.stringify(event)}`);
+ setKeyboardHeight(0);
+ }, []);
+
+ React.useEffect(() => {
+ const keyboardDismissListener =
+ addKeyboardDismissListener(onKeyboardDismiss);
+ return () => {
+ removeKeyboardListener(keyboardDismissListener);
+ };
+ }, [onKeyboardDismiss]);
+
+ return keyboardHeight;
+}
+
+export { useKeyboardHeight };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 21, 4:39 PM (2 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2556681
Default Alt Text
D9437.id31825.diff (2 KB)
Attached To
Mode
D9437: [native] Update height calculations for SIWEPanel
Attached
Detach File
Event Timeline
Log In to Comment