Skip to content

Commit c828e38

Browse files
committed
feat: modal
Signed-off-by: Iuri Pereira <[email protected]>
1 parent 487e21c commit c828e38

File tree

4 files changed

+127
-1
lines changed

4 files changed

+127
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import React from 'react'
2+
import { ModalProps, View, Modal, SafeAreaView } from 'react-native'
3+
import { Button, Container, Text, TextField, BottonPanel, Spacer, ErrorBox, AppBar, ButtonIcon } from '@berty/ui-components'
4+
import FontAwesome6 from '@expo/vector-icons/FontAwesome6'
5+
import type { Meta } from '@storybook/react'
6+
7+
const meta = {
8+
title: 'Layout/Modal',
9+
component: Button,
10+
argTypes: {
11+
onPress: { action: 'pressed the button' },
12+
color: {
13+
control: {
14+
type: 'text',
15+
options: ['primary', 'secondary'],
16+
defaultValue: 'primary',
17+
},
18+
},
19+
},
20+
args: {
21+
color: 'primary',
22+
children: 'Primary Button',
23+
},
24+
decorators: [Story => <Story />],
25+
} satisfies Meta<typeof Container>
26+
27+
export default meta
28+
29+
export const NewVaultInfo = (args: any) => {
30+
const [showModal, setShowModal] = React.useState(true)
31+
32+
return (
33+
<>
34+
<ModalNewVault visible={showModal} onRequestClose={() => setShowModal(false)} />
35+
<AppBar>
36+
<ButtonIcon size={40} color='tertirary'>
37+
<FontAwesome6 name='user' size={20} color='black' />
38+
</ButtonIcon>
39+
40+
<Button color='tertirary' onPress={() => setShowModal(true)} endIcon={<FontAwesome6 name='add' size={16} color='black' />}>
41+
New Vault
42+
</Button>
43+
</AppBar>
44+
<Container>
45+
<Text.H1>Check</Text.H1>
46+
<Text.H1>Your Safe</Text.H1>
47+
<Text.H1>Keys List</Text.H1>
48+
<View style={{ flexDirection: 'row', alignItems: 'center', width: '50%', paddingTop: 24 }}>
49+
<View style={{ flexDirection: 'row', alignItems: 'baseline', paddingRight: 24 }}>
50+
<Text.H1>0</Text.H1>
51+
<Text.Body>Key</Text.Body>
52+
</View>
53+
<View style={{ flexDirection: 'row', alignItems: 'baseline' }}>
54+
<Text.H1>0</Text.H1>
55+
<Text.Body>User</Text.Body>
56+
</View>
57+
</View>
58+
</Container>
59+
<BottonPanel>
60+
<Text.H2>New User</Text.H2>
61+
<Spacer />
62+
<Text.Body style={{ textAlign: 'center' }}>
63+
As a new user, your first step is to create a new Vault in the app to securely store your data.
64+
</Text.Body>
65+
<Spacer style={{ height: 56 }} />
66+
<View style={{ flexDirection: 'row', flex: 1, width: '100%', justifyContent: 'space-between' }}>
67+
<Button color='secondary'>Import Vault</Button>
68+
<Button onPress={() => setShowModal(true)} endIcon={<FontAwesome6 name='add' size={16} color='white' />}>
69+
New Vault
70+
</Button>
71+
</View>
72+
</BottonPanel>
73+
</>
74+
)
75+
}
76+
77+
const ModalNewVault = (props: ModalProps) => {
78+
return (
79+
<Modal {...props} animationType='slide' transparent>
80+
<View
81+
style={{
82+
height: '25%',
83+
width: '100%',
84+
backgroundColor: '#25292e',
85+
borderTopRightRadius: 18,
86+
borderTopLeftRadius: 18,
87+
position: 'absolute',
88+
bottom: 0,
89+
}}
90+
>
91+
<AppBar>
92+
<View style={{ flex: 1 }} />
93+
<Button color='tertirary' onPress={props.onRequestClose} endIcon={<FontAwesome6 name='xmark' size={16} color='black' />}>
94+
Cancel
95+
</Button>
96+
</AppBar>
97+
{/*
98+
<Container>
99+
<Text.H1>Create</Text.H1>
100+
<Text.H1>New Vault</Text.H1>
101+
<View style={{ height: 16 }} />
102+
<TextField placeholder='Vault Name' />
103+
<View style={{ height: 2 }} />
104+
<TextField placeholder='Description' />
105+
<Spacer />
106+
<Button>Create</Button>
107+
<Spacer />
108+
<ErrorBox>Warning: If you forget your master keyword, you will lose access to all your vaults.</ErrorBox>
109+
</Container> */}
110+
</View>
111+
</Modal>
112+
)
113+
}

src/components/ui/ThemeProvider.tsx

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from 'react'
2+
import { DefaultTheme, ThemeProvider as RNThemeProvider } from 'styled-components'
3+
4+
type Props = {
5+
theme: DefaultTheme
6+
children?: React.ReactNode
7+
}
8+
9+
const ThemeProvider = ({ children, theme }: Props) => {
10+
return <RNThemeProvider theme={theme}>{children}</RNThemeProvider>
11+
}
12+
13+
export { DefaultTheme, ThemeProvider }

src/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { DefaultTheme, ThemeProvider } from 'styled-components'
21
import { ErrorBox } from './components/alert'
32
import { Container, BottonPanel, Spacer } from './components/layout'
43
import * as Text from './components/text'
54
import { TextField } from './components/textFields/TextField'
5+
import { ThemeProvider, DefaultTheme } from './components/ui/ThemeProvider'
66

77
export * from './components/surfaces'
88

0 commit comments

Comments
 (0)