Skip to content

Commit cc42a30

Browse files
Use BillingBanner's built-in rightIcon for dismiss; constrain icon width in BillingBanner
Co-authored-by: Shubham Agrawal <shubham1206agra@users.noreply.github.com>
1 parent 58e8e62 commit cc42a30

2 files changed

Lines changed: 24 additions & 48 deletions

File tree

src/components/AgentPromotionalBanner.tsx

Lines changed: 22 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@ import {View} from 'react-native';
44
import {useMemoizedLazyExpensifyIcons, useMemoizedLazyIllustrations} from '@hooks/useLazyAsset';
55
import useLocalize from '@hooks/useLocalize';
66
import useResponsiveLayout from '@hooks/useResponsiveLayout';
7-
import useTheme from '@hooks/useTheme';
87
import useThemeStyles from '@hooks/useThemeStyles';
98
import BillingBanner from '@pages/settings/Subscription/CardSection/BillingBanner/BillingBanner';
10-
import CONST from '@src/CONST';
119
import Badge from './Badge';
1210
import Button from './Button';
13-
import Icon from './Icon';
14-
import {PressableWithoutFeedback} from './Pressable';
1511
import Text from './Text';
1612

1713
type AgentPromotionalBannerProps = {
@@ -42,7 +38,6 @@ type AgentPromotionalBannerProps = {
4238

4339
function AgentPromotionalBanner({title, subtitle, onDismiss, dismissSentryLabel, ctaText, onCtaPress, ctaSentryLabel, style}: AgentPromotionalBannerProps) {
4440
const styles = useThemeStyles();
45-
const theme = useTheme();
4641
const {translate} = useLocalize();
4742
const {shouldUseNarrowLayout, isInLandscapeMode} = useResponsiveLayout();
4843
const illustrations = useMemoizedLazyIllustrations(['AiBot']);
@@ -68,57 +63,33 @@ function AgentPromotionalBanner({title, subtitle, onDismiss, dismissSentryLabel,
6863
[title, styles, translate],
6964
);
7065

71-
const dismissIcon = useMemo(
72-
() => (
73-
<PressableWithoutFeedback
74-
onPress={onDismiss}
75-
style={[styles.touchableButtonImage]}
76-
role={CONST.ROLE.BUTTON}
77-
accessibilityLabel={translate('common.dismiss')}
78-
sentryLabel={dismissSentryLabel}
79-
>
80-
<Icon
81-
src={expensifyIcons.Close}
82-
fill={theme.icon}
83-
/>
84-
</PressableWithoutFeedback>
85-
),
86-
[onDismiss, styles.touchableButtonImage, translate, dismissSentryLabel, expensifyIcons.Close, theme.icon],
87-
);
88-
8966
const rightComponent = useMemo(() => {
9067
if (!hasCta) {
91-
return dismissIcon;
68+
return null;
9269
}
9370
if (shouldUseNarrowLayout && !isInLandscapeMode) {
9471
return (
95-
<>
96-
{dismissIcon}
97-
<View style={[styles.flex0, styles.flexBasis100, styles.maxWidth100Percentage, styles.justifyContentCenter]}>
98-
<Button
99-
success
100-
medium
101-
text={ctaText}
102-
onPress={onCtaPress}
103-
sentryLabel={ctaSentryLabel}
104-
/>
105-
</View>
106-
</>
72+
<View style={[styles.flex0, styles.flexBasis100, styles.maxWidth100Percentage, styles.justifyContentCenter]}>
73+
<Button
74+
success
75+
medium
76+
text={ctaText}
77+
onPress={onCtaPress}
78+
sentryLabel={ctaSentryLabel}
79+
/>
80+
</View>
10781
);
10882
}
10983
return (
110-
<View style={[styles.flexRow, styles.gap4, styles.alignItemsCenter]}>
111-
<Button
112-
success
113-
medium
114-
text={ctaText}
115-
onPress={onCtaPress}
116-
sentryLabel={ctaSentryLabel}
117-
/>
118-
{dismissIcon}
119-
</View>
84+
<Button
85+
success
86+
medium
87+
text={ctaText}
88+
onPress={onCtaPress}
89+
sentryLabel={ctaSentryLabel}
90+
/>
12091
);
121-
}, [hasCta, shouldUseNarrowLayout, isInLandscapeMode, ctaText, onCtaPress, ctaSentryLabel, styles, dismissIcon]);
92+
}, [hasCta, shouldUseNarrowLayout, isInLandscapeMode, ctaText, onCtaPress, ctaSentryLabel, styles]);
12293

12394
return (
12495
<View style={style}>
@@ -128,6 +99,10 @@ function AgentPromotionalBanner({title, subtitle, onDismiss, dismissSentryLabel,
12899
subtitle={subtitle}
129100
subtitleStyle={[styles.mt1, styles.textLabel]}
130101
style={[styles.borderRadiusComponentLarge]}
102+
rightIcon={expensifyIcons.Close}
103+
onRightIconPress={onDismiss}
104+
rightIconAccessibilityLabel={translate('common.dismiss')}
105+
rightIconSentryLabel={dismissSentryLabel}
131106
rightComponent={rightComponent}
132107
/>
133108
</View>

src/pages/settings/Subscription/CardSection/BillingBanner/BillingBanner.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function BillingBanner({
7575
return onRightIconPress && rightIconAccessibilityLabel ? (
7676
<PressableWithoutFeedback
7777
onPress={onRightIconPress}
78-
style={[styles.touchableButtonImage]}
78+
style={[styles.touchableButtonImage, styles.threeDotsMenuIconWidth]}
7979
role={CONST.ROLE.BUTTON}
8080
accessibilityLabel={rightIconAccessibilityLabel}
8181
sentryLabel={rightIconSentryLabel ?? CONST.SENTRY_LABEL.BILLING_BANNER.RIGHT_ICON}
@@ -108,6 +108,7 @@ function BillingBanner({
108108
rightIconAccessibilityLabel,
109109
rightIconSentryLabel,
110110
styles.touchableButtonImage,
111+
styles.threeDotsMenuIconWidth,
111112
theme.danger,
112113
theme.icon,
113114
theme.success,

0 commit comments

Comments
 (0)