|
| 1 | +import {useTheme} from '@yoroi/theme' |
| 2 | +import * as React from 'react' |
| 3 | +import {StyleSheet, TouchableOpacity, View} from 'react-native' |
| 4 | +import LinearGradient from 'react-native-linear-gradient' |
| 5 | + |
| 6 | +import {Button} from '../../../components/Button/Button' |
| 7 | +import {Icon} from '../../../components/Icon' |
| 8 | +import {Text} from '../../../components/Text' |
| 9 | +import {useStrings} from './strings' |
| 10 | + |
| 11 | +type Props = { |
| 12 | + onPress(): void |
| 13 | + onClose?(): void |
| 14 | +} |
| 15 | + |
| 16 | +export const ConsiderDelegatingToYoroiBanner = ({onPress, onClose}: Props) => { |
| 17 | + const {styles, colors} = useStyles() |
| 18 | + const {title, description, cta} = useStrings() |
| 19 | + return ( |
| 20 | + <LinearGradient start={{x: 1, y: 1}} end={{x: 0, y: 0}} colors={colors.gradient} style={styles.gradient}> |
| 21 | + <View style={styles.root}> |
| 22 | + {onClose && ( |
| 23 | + <TouchableOpacity onPress={onClose} style={styles.closeButton}> |
| 24 | + <Icon.Close color={colors.icon} size={20} /> |
| 25 | + </TouchableOpacity> |
| 26 | + )} |
| 27 | + |
| 28 | + <Text style={styles.title}>{title}</Text> |
| 29 | + |
| 30 | + <Text style={styles.description}>{description}</Text> |
| 31 | + |
| 32 | + <Button style={styles.primaryButton} type="Secondary" size="S" onPress={onPress} title={cta} /> |
| 33 | + </View> |
| 34 | + </LinearGradient> |
| 35 | + ) |
| 36 | +} |
| 37 | + |
| 38 | +const useStyles = () => { |
| 39 | + const {color, atoms} = useTheme() |
| 40 | + const styles = StyleSheet.create({ |
| 41 | + closeButton: { |
| 42 | + ...atoms.absolute, |
| 43 | + right: atoms.px_lg.paddingRight, |
| 44 | + top: atoms.py_lg.paddingTop, |
| 45 | + width: 20, |
| 46 | + height: 20, |
| 47 | + zIndex: 1, |
| 48 | + }, |
| 49 | + primaryButton: { |
| 50 | + ...atoms.self_start, |
| 51 | + }, |
| 52 | + gradient: { |
| 53 | + ...atoms.relative, |
| 54 | + ...atoms.rounded_sm, |
| 55 | + }, |
| 56 | + root: { |
| 57 | + ...atoms.py_lg, |
| 58 | + ...atoms.px_lg, |
| 59 | + minHeight: 134, |
| 60 | + position: 'relative', |
| 61 | + }, |
| 62 | + title: { |
| 63 | + color: color.gray_max, |
| 64 | + ...atoms.font_semibold, |
| 65 | + ...atoms.body_1_lg_medium, |
| 66 | + }, |
| 67 | + description: { |
| 68 | + color: color.gray_max, |
| 69 | + ...atoms.font_normal, |
| 70 | + ...atoms.body_2_md_regular, |
| 71 | + ...atoms.pb_lg, |
| 72 | + maxWidth: 279, |
| 73 | + }, |
| 74 | + }) |
| 75 | + |
| 76 | + const colors = { |
| 77 | + gradient: color.bg_gradient_1, |
| 78 | + icon: color.gray_max, |
| 79 | + } |
| 80 | + |
| 81 | + return {styles, colors} |
| 82 | +} |
0 commit comments