-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
51516ec
commit 49605fe
Showing
13 changed files
with
440 additions
and
70 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react' | ||
import Svg, {Path} from 'react-native-svg' | ||
|
||
type Props = { | ||
size?: number | ||
color?: string | ||
} | ||
|
||
export const Connection = ({size = 36, color = '#000000'}: Props) => { | ||
return ( | ||
<Svg width={size} height={size} viewBox="0 0 21 20" fill="none"> | ||
<Path | ||
d="M16.207.293a1 1 0 10-1.414 1.414L17.086 4H7.5a1 1 0 000 2h9.586l-2.293 2.293a1 1 0 001.414 1.414l4-4a1 1 0 000-1.414l-4-4zM6.207 10.293a1 1 0 010 1.414L3.914 14H13.5a1 1 0 110 2H3.914l2.293 2.293a1 1 0 11-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z" | ||
fill={color} | ||
/> | ||
</Svg> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react' | ||
import Svg, {Path, Rect, Defs, LinearGradient, Stop} from 'react-native-svg' | ||
|
||
type Props = { | ||
size?: number | ||
} | ||
|
||
export const YoroiApp = ({size = 36}: Props) => { | ||
return ( | ||
<Svg width={size} height={size} viewBox="0 0 49 48" fill="none"> | ||
<Rect x={0.5} width={48} height={48} rx={8} fill="url(#paint0_linear_16084_126466)" /> | ||
<Path | ||
d="M23.702 21.15L10 11h4.304l10.16 7.293L34.674 11H39L25.23 21.15a1.318 1.318 0 01-1.527 0zM29.06 32.771L12.298 20.762v-3.44l19.465 13.834-2.703 1.615zM29.871 25.748l5.948-4.424v-3.3l-8.246 6.039 2.298 1.685zM35.143 29.54l.676-.561v-3.23l-2.974 2.106 2.298 1.686zM12.298 28.205L23.383 36l2.77-1.545-13.855-9.832v3.582z" | ||
fill="#fff" | ||
/> | ||
<Defs> | ||
<LinearGradient | ||
id="paint0_linear_16084_126466" | ||
x1={50.6518} | ||
y1={77.0646} | ||
x2={108.781} | ||
y2={-23.2391} | ||
gradientUnits="userSpaceOnUse" | ||
> | ||
<Stop stopColor="#244ABF" /> | ||
<Stop offset={1} stopColor="#4760FF" /> | ||
</LinearGradient> | ||
</Defs> | ||
</Svg> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
apps/wallet-mobile/src/features/Discover/common/ConfirmConnectionModal.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import {storiesOf} from '@storybook/react-native' | ||
import * as React from 'react' | ||
import {ConfirmConnectionModal, useOpenConfirmConnectionModal} from './ConfirmConnectionModal' | ||
import {action} from '@storybook/addon-actions' | ||
import {Button, ModalProvider, Spacer} from '../../../components' | ||
Check failure on line 5 in apps/wallet-mobile/src/features/Discover/common/ConfirmConnectionModal.stories.tsx GitHub Actions / check
|
||
import {View} from 'react-native' | ||
|
||
storiesOf('Discover ConfirmConnectionModal', module) | ||
.addDecorator((story) => <View style={{padding: 20}}>{story()}</View>) | ||
.add('initial', () => <Initial />) | ||
.add('With Button', () => <WithButton />) | ||
|
||
const Initial = () => { | ||
return ( | ||
<ConfirmConnectionModal | ||
logo={'https://daehx1qv45z7c.cloudfront.net/cardano-spot.png'} | ||
onConfirm={action('onConfirm')} | ||
name="Example DApp" | ||
website={'example.com'} | ||
/> | ||
) | ||
} | ||
|
||
const WithButton = () => { | ||
const {openConfirmConnectionModal} = useOpenConfirmConnectionModal() | ||
|
||
const handleOnPress = () => { | ||
openConfirmConnectionModal({ | ||
onConfirm: action('onConfirm'), | ||
website: 'example.com', | ||
name: 'Example DApp', | ||
logo: 'https://daehx1qv45z7c.cloudfront.net/cardano-spot.png', | ||
onClose: action('onClose'), | ||
}) | ||
} | ||
|
||
return <Button title={'Open Modal'} shelleyTheme onPress={handleOnPress} /> | ||
} |
107 changes: 107 additions & 0 deletions
107
apps/wallet-mobile/src/features/Discover/common/ConfirmConnectionModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import * as React from 'react' | ||
import {View, Text, Image, StyleSheet} from 'react-native' | ||
import {Button, Icon, Spacer, useModal} from '../../../components' | ||
import {useTheme} from '@yoroi/theme' | ||
import {useStrings} from './useStrings' | ||
|
||
type Props = { | ||
name: string | ||
website: string | ||
logo: string | ||
onConfirm: () => void | ||
} | ||
|
||
export const confirmConnectionModalHeight = 400 | ||
|
||
export const useOpenConfirmConnectionModal = () => { | ||
const {openModal, closeModal} = useModal() | ||
const strings = useStrings() | ||
const open = React.useCallback((props: Props & {onClose: () => void}) => { | ||
openModal( | ||
strings.confirmConnectionModalTitle, | ||
<ConfirmConnectionModal | ||
name={props.name} | ||
website={props.website} | ||
logo={props.logo} | ||
onConfirm={() => { | ||
props.onConfirm() | ||
closeModal() | ||
}} | ||
/>, | ||
confirmConnectionModalHeight, | ||
props.onClose, | ||
) | ||
}, []) | ||
Check warning on line 34 in apps/wallet-mobile/src/features/Discover/common/ConfirmConnectionModal.tsx GitHub Actions / check
|
||
return {openConfirmConnectionModal: open, closeModal} | ||
} | ||
|
||
export const ConfirmConnectionModal = ({name, website, onConfirm, logo}: Props) => { | ||
const {styles, colors} = useStyles() | ||
const strings = useStrings() | ||
|
||
return ( | ||
<View> | ||
<View style={styles.imagesLine}> | ||
<Icon.YoroiApp size={48} /> | ||
<Icon.Connection size={20} color={colors.connection} /> | ||
<Image source={{uri: logo}} style={styles.image} /> | ||
</View> | ||
<Spacer height={8} /> | ||
|
||
<View style={styles.line}> | ||
<Text style={styles.text}>{strings.confirmConnectionModalConnectTo}</Text> | ||
<Text style={styles.bold}>{name}</Text> | ||
</View> | ||
<Spacer height={8} /> | ||
<View style={styles.line}> | ||
<Text style={styles.text}>{website}</Text> | ||
</View> | ||
<Spacer height={16} /> | ||
|
||
<View> | ||
<Text style={styles.text}>{strings.confirmConnectionModalAllowThisDAppTo}</Text> | ||
<Text style={styles.text}>{`\u2022 ${strings.confirmConnectionModalPermission1}`}</Text> | ||
<Text style={styles.text}>{`\u2022 ${strings.confirmConnectionModalPermission2}`}</Text> | ||
</View> | ||
<Spacer height={46} /> | ||
<Button title={strings.confirmConnectionModalConnect} shelleyTheme onPress={onConfirm} /> | ||
</View> | ||
) | ||
} | ||
|
||
const useStyles = () => { | ||
const theme = useTheme() | ||
const colors = {connection: theme.color.black_static} | ||
const styles = StyleSheet.create({ | ||
imagesLine: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
gap: 24, | ||
}, | ||
image: { | ||
width: 48, | ||
height: 48, | ||
}, | ||
line: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
gap: 4, | ||
}, | ||
text: { | ||
color: theme.color.gray_c900, | ||
fontSize: 16, | ||
lineHeight: 24, | ||
}, | ||
bold: { | ||
fontWeight: 'bold', | ||
color: theme.color.gray_c900, | ||
fontSize: 16, | ||
lineHeight: 24, | ||
}, | ||
}) | ||
return {styles, colors} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.