Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(wallet-mobile): Add delegate to Yoroi banners #3863

Draft
wants to merge 16 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/wallet-mobile/.storybook/storybook.requires.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ type Props = {
isVisible: boolean
children: React.ReactNode
duration?: number
style?: ViewStyle
style?: Exclude<ViewStyle, 'opacity'>
}

export const DismissibleBanner = ({isVisible, children, style, duration = 300}: Props) => {
export const DismissibleView = ({isVisible, children, style, duration = 300}: Props) => {
const fadeAnim = React.useRef(new Animated.Value(0)).current
const [shouldRender, setShouldRender] = React.useState(isVisible)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {action} from '@storybook/addon-actions'
import {storiesOf} from '@storybook/react-native'
import * as React from 'react'

import {DelegateToYoroiDRepBanner} from './DelegateToYoroiDRepBanner'

storiesOf('DelegateToYoroiDRepBanner', module).add('Initial', () => (
<DelegateToYoroiDRepBanner isVisible onDismiss={action('onDismiss')} />
))
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import {useTheme} from '@yoroi/theme'
import * as React from 'react'
import {StyleSheet, TouchableOpacity, View, ViewStyle} from 'react-native'
import LinearGradient from 'react-native-linear-gradient'

import {Button} from '../../../../components/Button/Button'
import {DismissibleView} from '../../../../components/DismissableView'
import {Icon} from '../../../../components/Icon'
import {Text} from '../../../../components/Text'
import {GovernanceBackground} from '../../illustrations/GovernanceBackground'
import {useStrings} from '../strings'

type Props = {
isVisible: boolean
onDismiss: () => void
style?: ViewStyle
}

export const DelegateToYoroiDRepBanner = ({onDismiss, isVisible, style}: Props) => {
const {styles, colors} = useStyles()
const {title, description, cta} = useStrings()

const handleOnDismiss = React.useCallback(() => onDismiss(), [onDismiss])
const handleOnCta = React.useCallback(() => console.log('cta'), [])

return (
<DismissibleView isVisible={isVisible} style={style}>
<LinearGradient start={{x: 1, y: 1}} end={{x: 0, y: 0}} colors={colors.gradient} style={styles.gradient}>
<View style={styles.root}>
<GovernanceBackground style={styles.backgroundImage} />

<TouchableOpacity onPress={handleOnDismiss} style={styles.dismiss}>
<Icon.Close color={colors.icon} size={20} />
</TouchableOpacity>

<Text style={styles.title}>{title}</Text>

<Text style={styles.description}>{description}</Text>

<Button style={styles.cta} type="Secondary" size="S" onPress={handleOnCta} title={cta} />
</View>
</LinearGradient>
</DismissibleView>
)
}

const useStyles = () => {
const {color, atoms} = useTheme()
const styles = StyleSheet.create({
backgroundImage: {
...atoms.absolute,
right: 0,
bottom: 0,
},
dismiss: {
width: 20,
height: 20,
right: atoms.px_lg.paddingRight,
top: atoms.py_lg.paddingTop,
...atoms.absolute,
...atoms.z_10,
},
cta: {
...atoms.self_start,
},
gradient: {
...atoms.relative,
...atoms.rounded_sm,
},
root: {
minHeight: 134,
...atoms.py_lg,
...atoms.px_lg,
...atoms.relative,
},
title: {
color: color.gray_max,
...atoms.font_semibold,
...atoms.body_1_lg_medium,
},
description: {
color: color.gray_max,
maxWidth: 279,
...atoms.font_normal,
...atoms.body_2_md_regular,
...atoms.pb_lg,
},
})

const colors = {
gradient: color.bg_gradient_1,
icon: color.gray_max,
}

return {styles, colors} as const
}
27 changes: 27 additions & 0 deletions apps/wallet-mobile/src/features/Banners/common/strings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as React from 'react'
import {defineMessages, useIntl} from 'react-intl'

export const useStrings = () => {
const intl = useIntl()

return React.useRef({
description: intl.formatMessage(messages.description),
title: intl.formatMessage(messages.title),
cta: intl.formatMessage(messages.cta),
} as const).current
}

const messages = defineMessages({
description: {
id: 'components.considerDelegatingToYoroiBanner.description',
defaultMessage: '!!!Delegate to our DRep and help Cardano evolve in a way that benefits your wallet experience.',
},
title: {
id: 'components.considerDelegatingToYoroiBanner.title',
defaultMessage: '!!!Consider delegating to Yoroi',
},
cta: {
id: 'components.considerDelegatingToYoroiBanner.cta',
defaultMessage: '!!!Delegate Now',
},
})
5 changes: 0 additions & 5 deletions apps/wallet-mobile/src/features/Banners/common/types.ts

This file was deleted.

Loading
Loading