Fix Android composer padding: Director's Cut (#7412)

* fix android 15 composer padding

* while I'm here, alf some bits and pieces

* add comments
This commit is contained in:
Samuel Newman
2025-01-09 18:06:24 +00:00
committed by GitHub
parent e5c587450f
commit 3b9a51c43f
3 changed files with 21 additions and 22 deletions
+15 -7
View File
@@ -264,7 +264,14 @@ export const ComposePost = ({
() => ({
paddingTop: isAndroid ? insets.top : 0,
paddingBottom:
isAndroid || (isIOS && !isKeyboardVisible) ? insets.bottom : 0,
// iOS - when keyboard is closed, keep the bottom bar in the safe area
(isIOS && !isKeyboardVisible) ||
// Android - Android >=35 KeyboardAvoidingView adds double padding when
// keyboard is closed, so we subtract that in the offset and add it back
// here when the keyboard is open
(isAndroid && isKeyboardVisible)
? insets.bottom
: 0,
}),
[insets, isKeyboardVisible],
)
@@ -642,7 +649,7 @@ export const ComposePost = ({
ref={scrollViewRef}
layout={native(LinearTransition)}
onScroll={scrollHandler}
style={styles.scrollView}
style={a.flex_1}
keyboardShouldPersistTaps="always"
onContentSizeChange={onScrollViewContentSizeChange}
onLayout={onScrollViewLayout}>
@@ -1396,10 +1403,14 @@ function useScrollTracker({
}
function useKeyboardVerticalOffset() {
const {top} = useSafeAreaInsets()
const {top, bottom} = useSafeAreaInsets()
// Android etc
if (!isIOS) return 0
if (!isIOS) {
// if Android <35 or web, bottom is 0 anyway. if >=35, this is needed to account
// for the edge-to-edge nav bar
return bottom * -1
}
// iPhone SE
if (top === 20) return 40
@@ -1489,9 +1500,6 @@ const styles = StyleSheet.create({
inactivePost: {
opacity: 0.5,
},
scrollView: {
flex: 1,
},
textInputLayout: {
flexDirection: 'row',
paddingTop: 4,