From aaa9ee9af7b9419a27925882dac6132d4b4644f3 Mon Sep 17 00:00:00 2001 From: Mattermost Build Date: Mon, 30 Sep 2024 18:48:27 +0200 Subject: [PATCH] MM-60534 -fix rate my app broken styles (#8232) (#8239) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * MM-60534 -fix rate my app broken styles * use a simpler and more general approach (cherry picked from commit 0cbbe7266d6a99ce334ca8e79cc15f5b428a9432) Co-authored-by: Pablo VĂ©lez --- app/components/button/index.tsx | 19 +++++++++++-------- app/screens/review_app/index.tsx | 20 ++++++++++---------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/app/components/button/index.tsx b/app/components/button/index.tsx index 0d9aa5f6836..41ba1410bc8 100644 --- a/app/components/button/index.tsx +++ b/app/components/button/index.tsx @@ -14,6 +14,7 @@ type ConditionalProps = | {iconName: string; iconSize: number} | {iconName?: nev type Props = ConditionalProps & { theme: Theme; backgroundStyle?: StyleProp; + buttonContainerStyle?: StyleProp; textStyle?: StyleProp; size?: ButtonSize; emphasis?: ButtonEmphasis; @@ -25,7 +26,7 @@ type Props = ConditionalProps & { iconComponent?: ReactNode; disabled?: boolean; hitSlop?: Insets; -} +}; const styles = StyleSheet.create({ container: {flexDirection: 'row'}, @@ -35,6 +36,7 @@ const styles = StyleSheet.create({ const Button = ({ theme, backgroundStyle, + buttonContainerStyle, textStyle, size, emphasis, @@ -59,7 +61,7 @@ const Button = ({ textStyle, ], [theme, textStyle, size, emphasis, buttonType]); - const containerStyle = useMemo( + const textContainerStyle = useMemo( () => (iconSize ? [ styles.container, @@ -68,11 +70,11 @@ const Button = ({ [iconSize], ); - let buttonContainerStyle = StyleSheet.flatten(bgStyle); + let buttonStyle = StyleSheet.flatten(bgStyle); if (disabled) { - buttonContainerStyle = { - ...buttonContainerStyle, - backgroundColor: changeOpacity(buttonContainerStyle.backgroundColor! as string, 0.4), + buttonStyle = { + ...buttonStyle, + backgroundColor: changeOpacity(buttonStyle.backgroundColor! as string, 0.4), }; } @@ -93,13 +95,14 @@ const Button = ({ return ( - + {icon} ({ flexDirection: 'row', width: '100%', }, + leftButton: { + flex: 1, + marginRight: 5, + }, + rightButton: { + flex: 1, + marginLeft: 5, + }, close: { justifyContent: 'center', height: 44, @@ -83,14 +91,6 @@ const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => ({ marginBottom: 24, textAlign: 'center', }, - leftButton: { - flex: 1, - marginRight: 5, - }, - rightButton: { - flex: 1, - marginLeft: 5, - }, dontAsk: { ...typography('Body', 75, 'SemiBold'), color: theme.buttonBg, @@ -204,14 +204,14 @@ const ReviewApp = ({ emphasis={'tertiary'} onPress={onPressNeedsWork} text={intl.formatMessage({id: 'rate.button.needs_work', defaultMessage: 'Needs work'})} - backgroundStyle={styles.leftButton} + buttonContainerStyle={styles.leftButton} />