Fix thread_overview style on android

This commit is contained in:
Elias Nahum 2022-03-22 23:36:44 -03:00
parent 71d442b693
commit 2463e17e52
No known key found for this signature in database
GPG key ID: E038DB71E0B61702
4 changed files with 13 additions and 6 deletions

View file

@ -235,6 +235,7 @@ const PostList = ({
<ThreadOverview
rootId={rootId!}
testID={`${testID}.thread_overview`}
style={styles.scale}
/>
);
}

View file

@ -16,6 +16,7 @@ exports[`ThreadOverview should match snapshot when post is not saved and 0 repli
Object {
"borderBottomWidth": 0,
},
Object {},
]
}
testID="thread-overview"
@ -120,6 +121,7 @@ exports[`ThreadOverview should match snapshot when post is saved and has replies
"paddingHorizontal": 20,
"paddingVertical": 10,
},
Object {},
]
}
testID="thread-overview"

View file

@ -16,6 +16,7 @@ describe('ThreadOverview', () => {
repliesCount: 0,
rootPost: {} as PostModel,
testID: 'thread-overview',
style: {},
};
const wrapper = renderWithIntl(<ThreadOverview {...props}/>);
@ -28,6 +29,7 @@ describe('ThreadOverview', () => {
repliesCount: 2,
rootPost: {} as PostModel,
testID: 'thread-overview',
style: {},
};
const wrapper = renderWithIntl(<ThreadOverview {...props}/>);

View file

@ -3,7 +3,7 @@
import React, {useCallback, useMemo} from 'react';
import {useIntl} from 'react-intl';
import {Keyboard, Platform, View} from 'react-native';
import {Keyboard, Platform, StyleProp, View, ViewStyle} from 'react-native';
import {TouchableOpacity} from 'react-native-gesture-handler';
import {deleteSavedPost, savePostPreference} from '@actions/remote/preference';
@ -25,6 +25,7 @@ type Props = {
repliesCount: number;
rootPost?: PostModel;
testID: string;
style: StyleProp<ViewStyle>;
};
const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => {
@ -55,7 +56,7 @@ const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => {
};
});
const ThreadOverview = ({isSaved, repliesCount, rootPost, testID}: Props) => {
const ThreadOverview = ({isSaved, repliesCount, rootPost, style, testID}: Props) => {
const theme = useTheme();
const styles = getStyleSheet(theme);
@ -85,14 +86,15 @@ const ThreadOverview = ({isSaved, repliesCount, rootPost, testID}: Props) => {
}), [rootPost]);
const containerStyle = useMemo(() => {
const style = [styles.container];
const container = [styles.container];
if (repliesCount === 0) {
style.push({
container.push({
borderBottomWidth: 0,
});
}
return style;
}, [repliesCount]);
container.push(style);
return container;
}, [repliesCount, style]);
return (
<View