Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Android composer padding: Director's Cut #7412

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/view/com/composer/Composer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,9 @@ export const ComposePost = ({
() => ({
paddingTop: isAndroid ? insets.top : 0,
paddingBottom:
isAndroid || (isIOS && !isKeyboardVisible) ? insets.bottom : 0,
(isIOS && !isKeyboardVisible) || (isAndroid && isKeyboardVisible)
mozzius marked this conversation as resolved.
Show resolved Hide resolved
? insets.bottom
: 0,
}),
[insets, isKeyboardVisible],
)
Expand Down Expand Up @@ -642,7 +644,7 @@ export const ComposePost = ({
ref={scrollViewRef}
layout={native(LinearTransition)}
onScroll={scrollHandler}
style={styles.scrollView}
style={a.flex_1}
keyboardShouldPersistTaps="always"
onContentSizeChange={onScrollViewContentSizeChange}
onLayout={onScrollViewLayout}>
Expand Down Expand Up @@ -1396,10 +1398,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
Expand Down Expand Up @@ -1489,9 +1495,6 @@ const styles = StyleSheet.create({
inactivePost: {
opacity: 0.5,
},
scrollView: {
flex: 1,
},
textInputLayout: {
flexDirection: 'row',
paddingTop: 4,
Expand Down
19 changes: 5 additions & 14 deletions src/view/shell/Composer.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {useEffect} from 'react'
import {Animated, Easing, StyleSheet, View} from 'react-native'
import {Animated, Easing} from 'react-native'

import {useAnimatedValue} from '#/lib/hooks/useAnimatedValue'
import {usePalette} from '#/lib/hooks/usePalette'
import {useComposerState} from '#/state/shell/composer'
import {atoms as a, useTheme} from '#/alf'
import {ComposePost} from '../com/composer/Composer'

export function Composer({winHeight}: {winHeight: number}) {
const state = useComposerState()
const pal = usePalette('default')
const t = useTheme()
const initInterp = useAnimatedValue(0)

useEffect(() => {
Expand Down Expand Up @@ -38,12 +38,12 @@ export function Composer({winHeight}: {winHeight: number}) {
// =

if (!state) {
return <View />
return null
}

return (
<Animated.View
style={[styles.wrapper, pal.view, wrapperAnimStyle]}
style={[a.absolute, a.inset_0, t.atoms.bg, wrapperAnimStyle]}
aria-modal
accessibilityViewIsModal>
<ComposePost
Expand All @@ -58,12 +58,3 @@ export function Composer({winHeight}: {winHeight: number}) {
</Animated.View>
)
}

const styles = StyleSheet.create({
wrapper: {
position: 'absolute',
top: 0,
bottom: 0,
width: '100%',
},
})
2 changes: 1 addition & 1 deletion src/view/shell/Composer.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function Composer({}: {winHeight: number}) {
// =

if (!isActive) {
return <View />
return null
}

return (
Expand Down
Loading