-
-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix/avoiding keyboard settings (#115)
* fix: text inputs in model screen avoid keyboard * fix: add workaround for multiline input text not avoiding the keyboard * fix: refactor stop words input -> chips
- Loading branch information
1 parent
600918b
commit b5afeca
Showing
8 changed files
with
221 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// This is a workaround for multiline input text not avoiding the keyboard.. | ||
// https://github.com/facebook/react-native/issues/16826#issuecomment-2254322144 | ||
|
||
import {useRef, useEffect} from 'react'; | ||
import {FlatList, Keyboard, KeyboardEvent, Platform} from 'react-native'; | ||
|
||
export const useMoveScroll = () => { | ||
const scrollRef = useRef<FlatList>(null); | ||
const keyboardHeight = useRef(Platform.OS === 'ios' ? 320 : 280); | ||
const visibleAreaOffset = 300; // very arbitrary number. TODO: fix this | ||
|
||
useEffect(() => { | ||
const keyboardDidShowListener = Keyboard.addListener( | ||
'keyboardDidShow', | ||
(event: KeyboardEvent) => { | ||
keyboardHeight.current = event.endCoordinates.height; | ||
}, | ||
); | ||
|
||
return () => { | ||
keyboardDidShowListener.remove(); | ||
}; | ||
}, []); | ||
|
||
const moveScrollToDown = (inputY?: number) => { | ||
if (scrollRef.current) { | ||
setTimeout(() => { | ||
const offset = inputY ?? keyboardHeight.current + visibleAreaOffset; | ||
scrollRef.current?.scrollToOffset({ | ||
offset: Math.max(0, offset), | ||
animated: true, | ||
}); | ||
}, 600); | ||
} | ||
}; | ||
|
||
return {scrollRef, moveScrollToDown}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.