From b63cb9bf5d8acfe121f8fe1e48d9a653ed6f54a1 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Wed, 20 Nov 2024 11:34:35 -0600 Subject: [PATCH] Simplify the dialog --- src/components/Button.tsx | 3 + src/components/GradientFill.tsx | 7 +- src/components/dialogs/BlueskyPlus/index.tsx | 404 +++++++++---------- 3 files changed, 201 insertions(+), 213 deletions(-) diff --git a/src/components/Button.tsx b/src/components/Button.tsx index 3329dca050..19d9751e89 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -654,10 +654,12 @@ export function ButtonIcon({ icon: Comp, position, size, + style, }: { icon: React.ComponentType position?: 'left' | 'right' size?: SVGIconProps['size'] + style?: SVGIconProps['style'] }) { const {size: buttonSize, disabled} = useButtonContext() const textStyles = useSharedButtonTextStyles() @@ -742,6 +744,7 @@ export function ButtonIcon({ color: textStyles.color, pointerEvents: 'none', }, + style, ]} /> diff --git a/src/components/GradientFill.tsx b/src/components/GradientFill.tsx index c775226124..ab2f5bb059 100644 --- a/src/components/GradientFill.tsx +++ b/src/components/GradientFill.tsx @@ -1,11 +1,12 @@ import {LinearGradient} from 'expo-linear-gradient' -import {atoms as a, tokens} from '#/alf' +import {atoms as a, tokens, ViewStyleProp} from '#/alf' export function GradientFill({ gradient, rotate, -}: { + style, +}: ViewStyleProp & { gradient: | typeof tokens.gradients.primary | typeof tokens.gradients.sky @@ -39,7 +40,7 @@ export function GradientFill({ locations={gradient.values.map(c => c[0])} start={start} end={end} - style={[a.absolute, a.inset_0]} + style={[a.absolute, a.inset_0, style]} /> ) } diff --git a/src/components/dialogs/BlueskyPlus/index.tsx b/src/components/dialogs/BlueskyPlus/index.tsx index cf008f7545..00d37c2664 100644 --- a/src/components/dialogs/BlueskyPlus/index.tsx +++ b/src/components/dialogs/BlueskyPlus/index.tsx @@ -3,42 +3,48 @@ import {View} from 'react-native' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' +import { + OfferingId, + SubscriptionGroupId, +} from '#/state/purchases/subscriptions/types' +import { + usePurchaseOffering, + useSubscriptionGroup, +} from '#/state/purchases/subscriptions/useSubscriptionGroup' +import {parseOfferingId} from '#/state/purchases/subscriptions/util' import {useSession} from '#/state/session' import * as Toast from '#/view/com/util/Toast' -import {atoms as a, tokens, useBreakpoints, useTheme, web} from '#/alf' +import {atoms as a, tokens, useBreakpoints, useTheme} from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' import * as Dialog from '#/components/Dialog' import * as Toggle from '#/components/forms/Toggle' import {GradientFill} from '#/components/GradientFill' import {Full as BlueskyPlusLogo} from '#/components/icons/BlueskyPlus' -import {ChevronRight_Stroke2_Corner0_Rounded as ChevronRightIcon} from '#/components/icons/Chevron' -import {InlineLinkText} from '#/components/Link' +import {CheckThick_Stroke2_Corner0_Rounded as CheckThink} from '#/components/icons/Check' +import {PlusLarge_Stroke2_Corner0_Rounded as Plus} from '#/components/icons/Plus' import {Loader} from '#/components/Loader' import {Text} from '#/components/Typography' -import {useSubscriptionGroup, usePurchaseOffering} from '#/state/purchases/subscriptions/useSubscriptionGroup' -import {OfferingId, SubscriptionGroupId} from '#/state/purchases/subscriptions/types' -import {parseOfferingId} from '#/state/purchases/subscriptions/util' -export function BlueskyPlus({ - control, -}: { - control: Dialog.DialogControlProps -}) { +export function BlueskyPlus({control}: {control: Dialog.DialogControlProps}) { return ( + ) } function DialogInner() { + const t = useTheme() const {_} = useLingui() const {gtMobile} = useBreakpoints() const {currentAccount} = useSession() - const t = useTheme() + const copy = useCoreOfferingCopy() - const [offeringId, setOfferingId] = React.useState(OfferingId.CoreMonthly) - const {data: coreOffering, error} = useSubscriptionGroup(SubscriptionGroupId.Core) + const [offeringId, setOfferingId] = React.useState( + OfferingId.CoreAnnual, + ) + const {data: coreOffering} = useSubscriptionGroup(SubscriptionGroupId.Core) const {mutateAsync: purchaseOffering, isPending} = usePurchaseOffering() const onPressSubscribe = async () => { @@ -61,209 +67,187 @@ function DialogInner() { } return ( - - - - - - - - - - - Early bird discount! - - - Support Bluesky now and get a 25% discount for a year - - setOfferingId(parseOfferingId(values[0]))} - style={[a.w_full, a.gap_md, a.my_xl]}> - - {({selected}) => ( - - - - - - Monthly plan - - - $8/month - - - - - Billed monthly, cancel anytime. $8/month after 12 months - - - - - )} - - - {({selected}) => ( - - - - - - Annual plan - - - $80/year - - - - Billed annually, renews at $80/year - - - - )} - - - - - - Terms and Conditions - {' '} - ·{' '} - - Privacy Policy - {' '} - ·{' '} - - EULA - - - - - - - ) -} + + -function MarketingBlurb() { - return ( - <> - + + Let's build the social web. + - + - Here's the thing: we don't have any premium features yet because all - our servers are on fire. Support us now so we can put the fires out - and get working on those features! + Support Bluesky and get access to exclusive features, custom app + icons, higher video quality, and more! - - What you'll get now: - - - - {' '} - · A supporter badge on your profile - - - {' '} - · A warm fuzzy feeling knowing you helped us out - + setOfferingId(parseOfferingId(values[0]))} + style={[a.w_full, a.gap_sm, a.pt_lg]}> + {[OfferingId.CoreMonthly, OfferingId.CoreAnnual].map(id => { + return ( + + {({selected, hovered}) => ( + + {Boolean(selected || hovered) && ( + + )} + + + + {copy[id].title} + + + {copy[id].price} + + + + + {copy[id].discount && ( + + + {copy[id].discount} + + + )} + + {selected ? ( + <> + + + + ) : ( + + )} + + + + + )} + + ) + })} + + + + - - What you'll get soon: - - - - {' '} - · Custom profile colors - - - {' '} - · Longer and higher quality videos - - - {' '} - · Custom app icons - - - + + ) } + +function useCoreOfferingCopy() { + const {_} = useLingui() + return React.useMemo(() => { + return { + [OfferingId.CoreMonthly]: { + title: _(msg`1 month`), + price: _(msg`$8 / month`), + discount: undefined, + }, + [OfferingId.CoreAnnual]: { + title: _(msg`12 months`), + price: _(msg`$72 / year`), + discount: _(msg`Save 25%`), + }, + } + }, [_]) +}