Skip to content

Commit 817f24b

Browse files
committed
fixup! Integrate new kav buttons to
Quote: I don't know if is an awesome name. I would call it or something like that.\nURL: #5837 (comment)
1 parent 8e66c8f commit 817f24b

File tree

5 files changed

+28
-46
lines changed

5 files changed

+28
-46
lines changed

src/components/common/SceneWrapper.tsx

Lines changed: 20 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,11 @@ interface SceneWrapperProps {
126126
// True to make the scene scrolling (if avoidKeyboard is false):
127127
scroll?: boolean
128128

129-
// Optional KeyboardAccessoryView rendered as a sibling to the SceneWrapper content:
130-
kavProps?: {
129+
// Optional "dock" view rendered at the bottom of the scene, attached to the
130+
// keyboard, tabs, footer, etc, whatever is highest:
131+
dockProps?: {
131132
children: React.ReactNode
132-
alwaysVisible?: boolean
133+
keyboardVisibleOnly?: boolean
133134
contentContainerStyle?: ViewStyle
134135
}
135136
}
@@ -162,7 +163,7 @@ function SceneWrapperComponent(props: SceneWrapperProps): React.ReactElement {
162163
padding = 0,
163164
renderFooter,
164165
scroll = false,
165-
kavProps
166+
dockProps: kavProps
166167
} = props
167168

168169
const notificationHeight = useSelector(state => state.ui.notificationHeight)
@@ -179,42 +180,23 @@ function SceneWrapperComponent(props: SceneWrapperProps): React.ReactElement {
179180
}
180181
})
181182

182-
// Local keyboard visible state for KAV parity (iOS willShow vs Android didShow):
183+
// Local keyboard visibility and opening/closing state for dock parity:
183184
const [isKeyboardVisibleFull, setKeyboardVisibleKav] = useState(false)
184-
useEffect(() => {
185-
const keyboardDidShowListener = Keyboard.addListener(
186-
isIos ? 'keyboardWillShow' : 'keyboardDidShow',
187-
() => {
188-
setKeyboardVisibleKav(true)
189-
}
190-
)
191-
const keyboardDidHideListener = Keyboard.addListener(
192-
isIos ? 'keyboardWillHide' : 'keyboardDidHide',
193-
() => {
194-
setKeyboardVisibleKav(false)
195-
}
196-
)
197-
return () => {
198-
keyboardDidShowListener.remove()
199-
keyboardDidHideListener.remove()
200-
}
201-
}, [isIos])
202-
203185
// Track closing/opening state explicitly for animation direction:
204186
const isClosingSv = useSharedValue(false)
205187
useEffect(() => {
206-
const showListener = Keyboard.addListener(
207-
isIos ? 'keyboardWillShow' : 'keyboardDidShow',
208-
() => {
209-
isClosingSv.value = false
210-
}
211-
)
212-
const hideListener = Keyboard.addListener(
213-
isIos ? 'keyboardWillHide' : 'keyboardDidHide',
214-
() => {
215-
isClosingSv.value = true
216-
}
217-
)
188+
const showEvent = isIos ? 'keyboardWillShow' : 'keyboardDidShow'
189+
const hideEvent = isIos ? 'keyboardWillHide' : 'keyboardDidHide'
190+
const onShow = (): void => {
191+
setKeyboardVisibleKav(true)
192+
isClosingSv.value = false
193+
}
194+
const onHide = (): void => {
195+
setKeyboardVisibleKav(false)
196+
isClosingSv.value = true
197+
}
198+
const showListener = Keyboard.addListener(showEvent, onShow)
199+
const hideListener = Keyboard.addListener(hideEvent, onHide)
218200
return () => {
219201
showListener.remove()
220202
hideListener.remove()
@@ -342,7 +324,7 @@ function SceneWrapperComponent(props: SceneWrapperProps): React.ReactElement {
342324
}, [children, sceneWrapperInfo])
343325

344326
// Build Keyboard Accessory View element
345-
const alwaysVisibleKav = kavProps?.alwaysVisible === true
327+
const keyboardVisibleOnlyKav = kavProps?.keyboardVisibleOnly ?? true
346328
const kavBaseStyle = useMemo(
347329
() => ({
348330
position: 'absolute' as const,
@@ -380,7 +362,7 @@ function SceneWrapperComponent(props: SceneWrapperProps): React.ReactElement {
380362
return { bottom }
381363
})
382364
const shouldShowKav =
383-
kavProps != null && (alwaysVisibleKav || isKeyboardVisibleFull)
365+
kavProps != null && (!keyboardVisibleOnlyKav || isKeyboardVisibleFull)
384366
const kavElement = !shouldShowKav ? null : (
385367
<Reanimated.View
386368
style={[kavBaseStyle, kavAnimatedStyle, kavProps?.contentContainerStyle]}

src/components/scenes/RampCreateScene.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -776,8 +776,8 @@ export const RampCreateScene: React.FC<Props> = (props: Props) => {
776776
<SceneWrapper
777777
scroll
778778
hasTabs
779-
kavProps={{
780-
alwaysVisible: true,
779+
dockProps={{
780+
keyboardVisibleOnly: false,
781781
children: (
782782
<KavButtons
783783
primary={{

src/components/scenes/RampKycFormScene.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ export const RampKycFormScene = React.memo((props: Props) => {
193193
scroll
194194
hasTabs
195195
avoidKeyboard
196-
kavProps={{
197-
alwaysVisible: true,
196+
dockProps={{
197+
keyboardVisibleOnly: false,
198198
children: (
199199
<KavButtons
200200
primary={{

src/components/scenes/SwapCreateScene.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,8 +517,8 @@ export const SwapCreateScene: React.FC<Props> = props => {
517517
hasNotifications
518518
scroll
519519
keyboardShouldPersistTaps="handled"
520-
kavProps={{
521-
alwaysVisible: false,
520+
dockProps={{
521+
keyboardVisibleOnly: true,
522522
children: (
523523
<KavButtons
524524
primary={{

src/plugins/gui/scenes/FiatPluginEnterAmountScene.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ export const FiatPluginEnterAmountScene = React.memo((props: Props) => {
241241
keyboardShouldPersistTaps="handled"
242242
hasNotifications
243243
hasTabs
244-
kavProps={{
245-
alwaysVisible: true,
244+
dockProps={{
245+
keyboardVisibleOnly: false,
246246
children: (
247247
<KavButtons
248248
primary={{

0 commit comments

Comments
 (0)