Skip to content

Commit 12155ca

Browse files
Exo1itonynagyyim-saifHelanaNady
authored
fix: add useHeaderHeight to fix reply section on android - [CU-869b98b3n] (#140)
Co-authored-by: tonynagyy <nagytony2@gmail.com> Co-authored-by: Saif <78622218+im-saif@users.noreply.github.com> Co-authored-by: Helana Nady <Helana.saif04@eng-st.cu.edu.eg> Co-authored-by: helana <helananady7@gmail.com>
1 parent baf0fc4 commit 12155ca

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/__tests__/screens/tweets/TweetDetailScreen.test.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ jest.mock('@/stores/userStore', () => ({
2020
})),
2121
}));
2222

23+
jest.mock('@react-navigation/elements', () => ({
24+
useHeaderHeight: () => 0,
25+
}));
26+
2327
const mockPush = jest.fn();
2428
const mockNavigate = jest.fn();
2529

src/screens/tweets/TweetDetailScreen.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
View,
1111
} from 'react-native';
1212

13+
import { useHeaderHeight } from '@react-navigation/elements';
1314
import { RouteProp, useNavigation, useRoute } from '@react-navigation/native';
1415
import { StackNavigationProp } from '@react-navigation/stack';
1516
import { FlashList, ListRenderItem } from '@shopify/flash-list';
@@ -51,6 +52,8 @@ export default function TweetDetailScreen() {
5152
const [error, setError] = useState<string | null>(null);
5253
const [replyError, setReplyError] = useState<string | null>(null);
5354

55+
const headerHeight = useHeaderHeight();
56+
5457
const styles = useMemo(
5558
() => getTweetDetailScreenStyles(theme, replyInputFocused),
5659
[theme, replyInputFocused]
@@ -244,12 +247,11 @@ export default function TweetDetailScreen() {
244247
/>
245248
</View>
246249
);
247-
248250
return (
249251
<KeyboardAvoidingView
250-
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
252+
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
251253
style={styles.keyboardAvoid}
252-
keyboardVerticalOffset={Platform.OS === 'ios' ? 90 : 0}
254+
keyboardVerticalOffset={headerHeight}
253255
>
254256
<SafeAreaView edges={['right', 'left', 'bottom']} style={styles.container}>
255257
{error && mainTweet && (

src/screens/tweets/styles.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export const getTweetDetailScreenStyles = (theme: 'dark' | 'light', isFocused: b
77
container: {
88
flex: 1,
99
backgroundColor: colors[theme].background,
10-
marginBottom: -10,
1110
},
1211
keyboardAvoid: {
1312
flex: 1,

0 commit comments

Comments
 (0)