react-native-boxes 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/Bar.d.ts +26 -0
- package/dist/Bar.js +159 -0
- package/dist/Bar.js.map +1 -0
- package/dist/Box.d.ts +14 -0
- package/dist/Box.js +103 -0
- package/dist/Box.js.map +1 -0
- package/dist/Button.d.ts +20 -0
- package/dist/Button.js +220 -0
- package/dist/Button.js.map +1 -0
- package/dist/Image.d.ts +21 -0
- package/dist/Image.js +79 -0
- package/dist/Image.js.map +1 -0
- package/dist/Input.d.ts +27 -0
- package/dist/Input.js +190 -0
- package/dist/Input.js.map +1 -0
- package/dist/Message.d.ts +7 -0
- package/dist/Message.js +97 -0
- package/dist/Message.js.map +1 -0
- package/dist/Modal.d.ts +22 -0
- package/dist/Modal.js +247 -0
- package/dist/Modal.js.map +1 -0
- package/dist/Styles.d.ts +113 -0
- package/dist/Styles.js +105 -0
- package/dist/Styles.js.map +1 -0
- package/dist/Text.d.ts +5 -0
- package/dist/Text.js +49 -0
- package/dist/Text.js.map +1 -0
- package/dist/ThemeContext.d.ts +93 -0
- package/dist/ThemeContext.js +26 -0
- package/dist/ThemeContext.js.map +1 -0
- package/dist/demo.d.ts +5 -0
- package/dist/demo.js +301 -0
- package/dist/demo.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +45 -0
- package/dist/utils.js.map +1 -0
- package/package.json +37 -0
- package/src/Bar.tsx +185 -0
- package/src/Box.tsx +106 -0
- package/src/Button.tsx +282 -0
- package/src/Image.tsx +107 -0
- package/src/Input.tsx +244 -0
- package/src/Message.tsx +90 -0
- package/src/Modal.tsx +306 -0
- package/src/Styles.tsx +117 -0
- package/src/Text.tsx +56 -0
- package/src/ThemeContext.ts +25 -0
- package/src/demo.tsx +383 -0
- package/src/index.tsx +8 -0
- package/src/utils.ts +49 -0
- package/tsconfig.json +25 -0
package/src/Styles.tsx
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
|
|
3
|
+
export const Dimens = {
|
|
4
|
+
space: {
|
|
5
|
+
xs: 1,
|
|
6
|
+
sm: 5,
|
|
7
|
+
md: 10,
|
|
8
|
+
lg: 20,
|
|
9
|
+
xl: 50,
|
|
10
|
+
},
|
|
11
|
+
font: {
|
|
12
|
+
sm: 12,
|
|
13
|
+
md: 14,
|
|
14
|
+
lg: 16,
|
|
15
|
+
xl: 24,
|
|
16
|
+
},
|
|
17
|
+
icon: {
|
|
18
|
+
sm: 12,
|
|
19
|
+
md: 20,
|
|
20
|
+
lg: 30,
|
|
21
|
+
xl: 50,
|
|
22
|
+
xxl: 80,
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const Fonts = {
|
|
27
|
+
Regular: 'Regular',
|
|
28
|
+
Bold: 'Bold',
|
|
29
|
+
Styled: 'Styled',
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const Colors = {
|
|
33
|
+
accent: '#1976D2',
|
|
34
|
+
accentLight: '#2196F3',
|
|
35
|
+
text: '#444444',
|
|
36
|
+
caption: '#A9A9A9',
|
|
37
|
+
heading: '#222222',
|
|
38
|
+
background: '#E6E6E6',
|
|
39
|
+
forground: '#fff',
|
|
40
|
+
transparent: 'transparent',
|
|
41
|
+
semitransparent: '#111a1a1c',
|
|
42
|
+
info: '#2196F3',
|
|
43
|
+
success: '#4CAF50',
|
|
44
|
+
warning: '#FFA726',
|
|
45
|
+
critical: '#F44336',
|
|
46
|
+
invert: {
|
|
47
|
+
text: '#fff',
|
|
48
|
+
caption: '#fff',
|
|
49
|
+
heading: '#fff',
|
|
50
|
+
background: '#1a1a1c'
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const LightColors = Colors
|
|
55
|
+
|
|
56
|
+
export const DarkColors = {
|
|
57
|
+
accent: '#1976D2',
|
|
58
|
+
accentLight: '#2196F3',
|
|
59
|
+
text: '#f2f2f2',
|
|
60
|
+
caption: '#565656',
|
|
61
|
+
heading: '#dddddd',
|
|
62
|
+
background: '#212121',
|
|
63
|
+
forground: '#191919',
|
|
64
|
+
transparent: 'transparent',
|
|
65
|
+
semitransparent: '#111a1a1c',
|
|
66
|
+
info: '#2196F3',
|
|
67
|
+
success: '#4CAF50',
|
|
68
|
+
warning: '#FFA726',
|
|
69
|
+
critical: '#F44336',
|
|
70
|
+
invert: {
|
|
71
|
+
text: '#fff',
|
|
72
|
+
caption: '#fff',
|
|
73
|
+
heading: '#fff',
|
|
74
|
+
background: '#E6E6E6'
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function extendValues(
|
|
79
|
+
dimens: typeof Dimens,
|
|
80
|
+
colors: typeof Colors,
|
|
81
|
+
fonts: typeof Fonts): {
|
|
82
|
+
dimens: typeof Dimens,
|
|
83
|
+
colors: typeof Colors,
|
|
84
|
+
fonts: typeof Fonts
|
|
85
|
+
} {
|
|
86
|
+
return {
|
|
87
|
+
dimens: Object.assign(dimens || {}, Dimens),
|
|
88
|
+
colors: Object.assign(colors || {}, Colors),
|
|
89
|
+
fonts: Object.assign(fonts || {}, Fonts),
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function createStyle(
|
|
94
|
+
dimens: typeof Dimens,
|
|
95
|
+
colors: typeof Colors,
|
|
96
|
+
fonts: typeof Fonts) {
|
|
97
|
+
|
|
98
|
+
const Styles = StyleSheet.create({
|
|
99
|
+
container: {
|
|
100
|
+
marginTop: dimens.space.xl,
|
|
101
|
+
backgroundColor: colors.background,
|
|
102
|
+
},
|
|
103
|
+
center: {
|
|
104
|
+
alignContent: 'center',
|
|
105
|
+
justifyContent: 'center'
|
|
106
|
+
},
|
|
107
|
+
textHead: {
|
|
108
|
+
color: colors.text,
|
|
109
|
+
fontSize: dimens.font.xl,
|
|
110
|
+
},
|
|
111
|
+
text: {
|
|
112
|
+
fontFamily: fonts.Regular,
|
|
113
|
+
fontSize: dimens.font.md,
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
return Styles
|
|
117
|
+
}
|
package/src/Text.tsx
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { TextProps, Text } from "react-native";
|
|
3
|
+
import { ThemeContext } from "./ThemeContext";
|
|
4
|
+
|
|
5
|
+
export function TextView(props: TextProps) {
|
|
6
|
+
const theme = useContext(ThemeContext)
|
|
7
|
+
return (
|
|
8
|
+
<Text {...props}
|
|
9
|
+
style={[{
|
|
10
|
+
flexWrap: 'wrap',
|
|
11
|
+
color: theme.colors.text,
|
|
12
|
+
padding: theme.dimens.space.sm
|
|
13
|
+
}, theme.styles.text, props.style]} />
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
export function Subtitle(props: TextProps) {
|
|
19
|
+
const theme = useContext(ThemeContext)
|
|
20
|
+
return (
|
|
21
|
+
<TextView {...props} style={[
|
|
22
|
+
{
|
|
23
|
+
fontSize: theme.dimens.font.lg,
|
|
24
|
+
color: theme.colors.text
|
|
25
|
+
},
|
|
26
|
+
props.style
|
|
27
|
+
]} />
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
export function Title(props: TextProps) {
|
|
33
|
+
const theme = useContext(ThemeContext)
|
|
34
|
+
return (
|
|
35
|
+
<TextView {...props} style={[
|
|
36
|
+
{
|
|
37
|
+
fontSize: theme.dimens.font.xl,
|
|
38
|
+
color: theme.colors.heading
|
|
39
|
+
},
|
|
40
|
+
props.style
|
|
41
|
+
]} />
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function Caption(props: TextProps) {
|
|
46
|
+
const theme = useContext(ThemeContext)
|
|
47
|
+
return (
|
|
48
|
+
<TextView {...props} style={[
|
|
49
|
+
{
|
|
50
|
+
fontSize: theme.dimens.font.sm,
|
|
51
|
+
color: theme.colors.caption
|
|
52
|
+
},
|
|
53
|
+
props.style
|
|
54
|
+
]} />
|
|
55
|
+
)
|
|
56
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createContext } from "react"
|
|
2
|
+
import { Colors, Dimens, createStyle, DarkColors, LightColors, Fonts } from "./Styles"
|
|
3
|
+
import { randomColor } from "./utils"
|
|
4
|
+
const DEFAULT_STYLE = createStyle(Dimens, Colors, Fonts)
|
|
5
|
+
export class Theme {
|
|
6
|
+
appname: string = ''
|
|
7
|
+
styles: typeof DEFAULT_STYLE
|
|
8
|
+
dimens: typeof Dimens
|
|
9
|
+
colors: typeof Colors
|
|
10
|
+
fonts: typeof Fonts
|
|
11
|
+
randomColor = randomColor
|
|
12
|
+
constructor(appname = '',
|
|
13
|
+
colors = Colors,
|
|
14
|
+
dimens = Dimens,
|
|
15
|
+
fonts = Fonts,
|
|
16
|
+
styles = DEFAULT_STYLE) {
|
|
17
|
+
this.appname = appname
|
|
18
|
+
this.fonts = fonts ?? Fonts
|
|
19
|
+
this.colors = colors ?? Colors
|
|
20
|
+
this.dimens = dimens ?? Dimens
|
|
21
|
+
this.fonts = fonts ?? Fonts
|
|
22
|
+
this.styles = styles ?? createStyle(this.dimens, this.colors, this.fonts)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export const ThemeContext = createContext(new Theme())
|
package/src/demo.tsx
ADDED
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
import { useContext, useEffect, useReducer, useState } from 'react';
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
import { LayoutAnimation, SafeAreaView } from 'react-native';
|
|
4
|
+
import { BottomNavBar, ButtonView, Caption, Center, CompositeTextInputView, Expand, HBox, LoadingButton, PressableView, RightIconButton, SimpleToolbar, Subtitle, TextInputView, TextView, Theme, ThemeContext, Title, VBox } from '.';
|
|
5
|
+
import FontAwesome from '@expo/vector-icons/FontAwesome';
|
|
6
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
7
|
+
import { AlertMessage } from './Message';
|
|
8
|
+
import { BottomSheet } from './Modal';
|
|
9
|
+
import { Avatar, Icon } from './Image';
|
|
10
|
+
import { ReactWrapper } from './utils';
|
|
11
|
+
import KeyboardAvoidingScrollView from './Box';
|
|
12
|
+
import { DarkColors, LightColors } from './Styles';
|
|
13
|
+
|
|
14
|
+
export interface DemoScreenProps {
|
|
15
|
+
navigation?: any
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function DemoScreen({ navigation }: DemoScreenProps) {
|
|
19
|
+
|
|
20
|
+
const theme: Theme = useContext(ThemeContext)
|
|
21
|
+
console.log('Rendering')
|
|
22
|
+
const btnIcon = (<FontAwesome name='google'
|
|
23
|
+
size={theme.dimens.icon.md}
|
|
24
|
+
color={theme.colors.invert.text} />)
|
|
25
|
+
const insets = useSafeAreaInsets();
|
|
26
|
+
const [loading, setLoading] = useState(false)
|
|
27
|
+
const [alert, setBs] = useState(`In this version, the icon used is always 'chevron-right' even when expanded.`)
|
|
28
|
+
const [bottomsheetVisible, setbottomsheetVisible] = useState(false)
|
|
29
|
+
function setAlert(bs: string) {
|
|
30
|
+
setBs(bs)
|
|
31
|
+
setTimeout(() => {
|
|
32
|
+
setBs(`In this version, the icon used is always 'chevron-right' even when expanded.`)
|
|
33
|
+
}, 5000)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const [selectedBottombarId, setSelectedBottomBarId] = useState('home')
|
|
37
|
+
const [mText, setMText] = useState(`@shivesh`)
|
|
38
|
+
const [bottomBarHeight, setBottombarHeight] = useState(theme.dimens.space.xl)
|
|
39
|
+
const [selectedTheme, setSelectedTheme] = useState(true)
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
theme.colors = selectedTheme ? LightColors : DarkColors
|
|
42
|
+
forceUpdate()
|
|
43
|
+
}, [selectedTheme])
|
|
44
|
+
const [, forceUpdate] = useReducer(x => x + 1, 0);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<VBox
|
|
48
|
+
style={{
|
|
49
|
+
backgroundColor: theme.colors.background,
|
|
50
|
+
padding: 0,
|
|
51
|
+
paddingBottom: bottomBarHeight,
|
|
52
|
+
margin: 0,
|
|
53
|
+
height: '100%'
|
|
54
|
+
}} >
|
|
55
|
+
<SimpleToolbar
|
|
56
|
+
title="Demo"
|
|
57
|
+
homeIcon={
|
|
58
|
+
ReactWrapper(<Icon color={theme.colors.invert.text} name="plus" />)
|
|
59
|
+
}
|
|
60
|
+
options={[
|
|
61
|
+
{
|
|
62
|
+
id: 'test',
|
|
63
|
+
icon: 'gear',
|
|
64
|
+
onClick: (id) => {
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: 'test2',
|
|
69
|
+
icon: ReactWrapper(<PressableView>
|
|
70
|
+
<Avatar
|
|
71
|
+
style={{
|
|
72
|
+
margin: 0,
|
|
73
|
+
height: theme.dimens?.icon?.md * 1.25,
|
|
74
|
+
width: theme.dimens?.icon?.md * 1.25,
|
|
75
|
+
}}
|
|
76
|
+
iconUrl="https://avatars.githubusercontent.com/u/16799797?v=4" />
|
|
77
|
+
</PressableView>),
|
|
78
|
+
onClick: (id) => {
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
]} />
|
|
82
|
+
<KeyboardAvoidingScrollView
|
|
83
|
+
automaticallyAdjustKeyboardInsets={true}
|
|
84
|
+
keyboardShouldPersistTaps={'handled'}
|
|
85
|
+
style={{
|
|
86
|
+
flexGrow: 1,
|
|
87
|
+
}}
|
|
88
|
+
nestedScrollEnabled={true}
|
|
89
|
+
showsHorizontalScrollIndicator={false}
|
|
90
|
+
showsVerticalScrollIndicator={false}
|
|
91
|
+
>
|
|
92
|
+
|
|
93
|
+
<Center style={{
|
|
94
|
+
flexDirection: 'row',
|
|
95
|
+
padding: 20
|
|
96
|
+
}}>
|
|
97
|
+
|
|
98
|
+
<Avatar
|
|
99
|
+
onPress={() => {
|
|
100
|
+
setbottomsheetVisible(true)
|
|
101
|
+
}}
|
|
102
|
+
style={{
|
|
103
|
+
borderColor: theme.colors.success,
|
|
104
|
+
}}
|
|
105
|
+
iconNameProps={{
|
|
106
|
+
name: 'user',
|
|
107
|
+
color: theme.colors.success,
|
|
108
|
+
size: theme.dimens.icon.lg
|
|
109
|
+
}}
|
|
110
|
+
/>
|
|
111
|
+
<Center>
|
|
112
|
+
<Avatar
|
|
113
|
+
style={{
|
|
114
|
+
borderWidth: theme.dimens.space.sm,
|
|
115
|
+
width: 100,
|
|
116
|
+
height: 100,
|
|
117
|
+
borderColor: theme.colors.success
|
|
118
|
+
}}
|
|
119
|
+
iconText='SN'
|
|
120
|
+
onPress={() => {
|
|
121
|
+
setbottomsheetVisible(true)
|
|
122
|
+
}}
|
|
123
|
+
iconNameProps={{
|
|
124
|
+
name: 'user',
|
|
125
|
+
color: theme.colors.success,
|
|
126
|
+
size: theme.dimens.icon.lg
|
|
127
|
+
}}
|
|
128
|
+
iconUrl='https://cdn.truelancer.com/user-picture/307510-5c1f11bad82e9.jpg' />
|
|
129
|
+
<Subtitle>{mText}</Subtitle>
|
|
130
|
+
</Center>
|
|
131
|
+
|
|
132
|
+
<Avatar
|
|
133
|
+
style={{
|
|
134
|
+
borderColor: theme.colors.success,
|
|
135
|
+
color: theme.colors.success
|
|
136
|
+
}}
|
|
137
|
+
onPress={() => {
|
|
138
|
+
setbottomsheetVisible(true)
|
|
139
|
+
}}
|
|
140
|
+
iconText='SN' />
|
|
141
|
+
</Center>
|
|
142
|
+
<Expand title='Message Alert' initialExpand={false}
|
|
143
|
+
style={{
|
|
144
|
+
backgroundColor: theme.colors.forground
|
|
145
|
+
}}
|
|
146
|
+
titleBackgroundColor={theme.colors.forground}
|
|
147
|
+
>
|
|
148
|
+
<VBox>
|
|
149
|
+
<AlertMessage text={alert} onDismiss={() => {
|
|
150
|
+
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
|
|
151
|
+
setAlert('')
|
|
152
|
+
}} />
|
|
153
|
+
<AlertMessage text='Critial Message' type='critical' />
|
|
154
|
+
<AlertMessage text='Success' type='success' />
|
|
155
|
+
<AlertMessage text='Warning Message' type='warning' />
|
|
156
|
+
</VBox>
|
|
157
|
+
|
|
158
|
+
</Expand>
|
|
159
|
+
<Expand
|
|
160
|
+
style={{
|
|
161
|
+
padding: 0,
|
|
162
|
+
borderWidth: 0.1,
|
|
163
|
+
borderColor: '#DCDCDC'
|
|
164
|
+
}}
|
|
165
|
+
duration={200}
|
|
166
|
+
title='In this version, the icon used is always chevron-right even when expanded. In this version, the icon used is always chevron-right even when expanded.'
|
|
167
|
+
initialExpand={false} iconPosition='right'>
|
|
168
|
+
<VBox>
|
|
169
|
+
<Title>Text A</Title>
|
|
170
|
+
<Subtitle>Text A Text A Text AText A Text AText A</Subtitle>
|
|
171
|
+
<TextView>Text A</TextView>
|
|
172
|
+
<Caption>Text Caption</Caption>
|
|
173
|
+
</VBox>
|
|
174
|
+
</Expand>
|
|
175
|
+
<Expand title='Inputs'>
|
|
176
|
+
|
|
177
|
+
<VBox>
|
|
178
|
+
<TextInputView
|
|
179
|
+
style={{
|
|
180
|
+
fontFamily: theme.fonts.Bold
|
|
181
|
+
}}
|
|
182
|
+
initialText={mText}
|
|
183
|
+
value={mText}
|
|
184
|
+
onChangeText={t => setMText(t)} />
|
|
185
|
+
<CompositeTextInputView
|
|
186
|
+
onChangeText={t => setMText(t)}
|
|
187
|
+
placeholder='A test'
|
|
188
|
+
initialText='Test' />
|
|
189
|
+
<CompositeTextInputView
|
|
190
|
+
inputMode='decimal'
|
|
191
|
+
icon={"close"}
|
|
192
|
+
style={{
|
|
193
|
+
}}
|
|
194
|
+
alertTextColor={theme.colors.warning}
|
|
195
|
+
placeholder='Enter your name'
|
|
196
|
+
initialText='Test'
|
|
197
|
+
value={mText}
|
|
198
|
+
onChangeText={t => setMText(t)} />
|
|
199
|
+
<CompositeTextInputView
|
|
200
|
+
style={{
|
|
201
|
+
}}
|
|
202
|
+
placeholder='Enter number'
|
|
203
|
+
alertText={mText?.indexOf("@") > -1 ? '' : 'Please enter @ or else I am gonna come down at your place and mess you up buddy !'}
|
|
204
|
+
initialText='Test'
|
|
205
|
+
value={mText}
|
|
206
|
+
onChangeText={t => setMText(t)} />
|
|
207
|
+
</VBox>
|
|
208
|
+
</Expand>
|
|
209
|
+
|
|
210
|
+
<Expand
|
|
211
|
+
iconStyle={{
|
|
212
|
+
name: 'chevron-right',
|
|
213
|
+
color: 'red'
|
|
214
|
+
}}
|
|
215
|
+
title='Buttons'
|
|
216
|
+
initialExpand={false}>
|
|
217
|
+
<VBox style={{
|
|
218
|
+
}}>
|
|
219
|
+
<VBox >
|
|
220
|
+
<ButtonView
|
|
221
|
+
icon={btnIcon}
|
|
222
|
+
style={{
|
|
223
|
+
}}>Button Icon</ButtonView>
|
|
224
|
+
|
|
225
|
+
<ButtonView style={{
|
|
226
|
+
}}>Button Text</ButtonView>
|
|
227
|
+
</VBox>
|
|
228
|
+
<RightIconButton
|
|
229
|
+
text='Click Me Icon'
|
|
230
|
+
icon={btnIcon}>
|
|
231
|
+
</RightIconButton>
|
|
232
|
+
|
|
233
|
+
<Center>
|
|
234
|
+
<LoadingButton
|
|
235
|
+
|
|
236
|
+
onPress={(e) => {
|
|
237
|
+
setLoading(!loading)
|
|
238
|
+
}}
|
|
239
|
+
loading={loading}
|
|
240
|
+
text='Click Me' />
|
|
241
|
+
|
|
242
|
+
<ButtonView
|
|
243
|
+
underlayColor={theme.colors.transparent}
|
|
244
|
+
style={{
|
|
245
|
+
color: theme.colors.accent,
|
|
246
|
+
backgroundColor: theme.colors.transparent,
|
|
247
|
+
}}>Tertiary button</ButtonView>
|
|
248
|
+
|
|
249
|
+
</Center>
|
|
250
|
+
|
|
251
|
+
<Expand title='Nested expand'>
|
|
252
|
+
<HBox style={{
|
|
253
|
+
justifyContent: 'center',
|
|
254
|
+
}}>
|
|
255
|
+
<LoadingButton
|
|
256
|
+
style={{
|
|
257
|
+
width: 'auto'
|
|
258
|
+
}}
|
|
259
|
+
onPress={(e) => {
|
|
260
|
+
setLoading(!loading)
|
|
261
|
+
}}
|
|
262
|
+
loading={loading}
|
|
263
|
+
text='Click Me left' />
|
|
264
|
+
<LoadingButton
|
|
265
|
+
loaderStyle='transparent'
|
|
266
|
+
style={{
|
|
267
|
+
width: 'auto'
|
|
268
|
+
}}
|
|
269
|
+
onPress={(e) => {
|
|
270
|
+
setLoading(!loading)
|
|
271
|
+
}}
|
|
272
|
+
loading={loading}
|
|
273
|
+
text='Click Me right' />
|
|
274
|
+
</HBox>
|
|
275
|
+
</Expand>
|
|
276
|
+
|
|
277
|
+
</VBox>
|
|
278
|
+
</Expand>
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
<ButtonView
|
|
283
|
+
underlayColor={theme.colors.transparent}
|
|
284
|
+
style={{
|
|
285
|
+
color: theme.colors.accent,
|
|
286
|
+
backgroundColor: theme.colors.transparent,
|
|
287
|
+
}}
|
|
288
|
+
onPress={() => {
|
|
289
|
+
setSelectedTheme(!selectedTheme)
|
|
290
|
+
}}>{selectedTheme ? 'Light' : 'Dark'}</ButtonView>
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
<ButtonView
|
|
294
|
+
underlayColor={theme.colors.transparent}
|
|
295
|
+
style={{
|
|
296
|
+
color: theme.colors.accent,
|
|
297
|
+
backgroundColor: theme.colors.transparent,
|
|
298
|
+
}}
|
|
299
|
+
onPress={() => {
|
|
300
|
+
setbottomsheetVisible(true)
|
|
301
|
+
}}>Show Sheet</ButtonView>
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
</KeyboardAvoidingScrollView>
|
|
305
|
+
<BottomNavBar
|
|
306
|
+
style={{
|
|
307
|
+
borderTopLeftRadius: theme.dimens.space.md,
|
|
308
|
+
borderTopRightRadius: theme.dimens.space.md,
|
|
309
|
+
}}
|
|
310
|
+
onSelect={setSelectedBottomBarId}
|
|
311
|
+
selectedId={selectedBottombarId}
|
|
312
|
+
options={[
|
|
313
|
+
{
|
|
314
|
+
id: 'home',
|
|
315
|
+
title: 'Home',
|
|
316
|
+
icon: 'home'
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
id: 'create',
|
|
320
|
+
title: 'Create',
|
|
321
|
+
icon: 'plus'
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
id: 'search',
|
|
325
|
+
title: 'Search',
|
|
326
|
+
icon: 'search'
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
id: 'profile',
|
|
330
|
+
title: 'Profile',
|
|
331
|
+
icon: ReactWrapper(<PressableView>
|
|
332
|
+
<Avatar
|
|
333
|
+
onPress={() => {
|
|
334
|
+
setSelectedBottomBarId('profile')
|
|
335
|
+
}}
|
|
336
|
+
style={{
|
|
337
|
+
borderColor: selectedBottombarId == 'profile' ?
|
|
338
|
+
theme.colors.accent : theme.colors.caption,
|
|
339
|
+
margin: 0,
|
|
340
|
+
height: theme.dimens?.icon?.md,
|
|
341
|
+
width: theme.dimens?.icon?.md,
|
|
342
|
+
}}
|
|
343
|
+
// iconName='user'
|
|
344
|
+
iconUrl="https://avatars.githubusercontent.com/u/16799797?v=4"
|
|
345
|
+
/>
|
|
346
|
+
</PressableView>)
|
|
347
|
+
}
|
|
348
|
+
]}
|
|
349
|
+
onDimens={(w, h) => {
|
|
350
|
+
setBottombarHeight(h)
|
|
351
|
+
console.log("bottomBarHeight", h)
|
|
352
|
+
}} />
|
|
353
|
+
|
|
354
|
+
<BottomSheet
|
|
355
|
+
title="About"
|
|
356
|
+
visible={bottomsheetVisible} onDismiss={() => {
|
|
357
|
+
setbottomsheetVisible(false)
|
|
358
|
+
}} >
|
|
359
|
+
<TextView>Dinosaurs are a diverse group of reptiles of the clade Dinosauria. They first appeared during the Triassic period, between 243 and 233.23 million years ago, although the exact origin and timing of the evolution of dinosaurs is a subject of active research.</TextView>
|
|
360
|
+
|
|
361
|
+
<TextView>Dinosaurs are a diverse group of reptiles of the clade Dinosauria. They first appeared during the Triassic period, between 243 and 233.23 million years ago, although the exact origin and timing of the evolution of dinosaurs is a subject of active research.</TextView>
|
|
362
|
+
<Expand title='Types' initialExpand={false}
|
|
363
|
+
style={{
|
|
364
|
+
padding: 0,
|
|
365
|
+
backgroundColor: theme.colors.forground
|
|
366
|
+
}}
|
|
367
|
+
titleBackgroundColor={theme.colors.forground}
|
|
368
|
+
>
|
|
369
|
+
<VBox>
|
|
370
|
+
<AlertMessage text={alert} onDismiss={() => {
|
|
371
|
+
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
|
|
372
|
+
setAlert('')
|
|
373
|
+
}} />
|
|
374
|
+
<AlertMessage text='Tyrannosaurus rex' type='critical' />
|
|
375
|
+
<AlertMessage text='Spinosaurus' type='success' />
|
|
376
|
+
<AlertMessage text='Ankylosaurs' type='warning' />
|
|
377
|
+
</VBox>
|
|
378
|
+
|
|
379
|
+
</Expand>
|
|
380
|
+
</BottomSheet>
|
|
381
|
+
</VBox>
|
|
382
|
+
);
|
|
383
|
+
}
|
package/src/index.tsx
ADDED
package/src/utils.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Platform } from "react-native";
|
|
2
|
+
import { Dimensions } from 'react-native';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export function ReactWrapper(component: any) {
|
|
6
|
+
return (props: any) => {
|
|
7
|
+
return component
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function randomColor() {
|
|
12
|
+
const letters = '0123456789ABCDEF';
|
|
13
|
+
let color = '#';
|
|
14
|
+
|
|
15
|
+
for (let i = 0; i < 6; i++) {
|
|
16
|
+
color += letters[Math.floor(Math.random() * 16)];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// return color;
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function isWeb() {
|
|
24
|
+
return Platform.OS == 'web'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
export function isDesktop() {
|
|
29
|
+
const windowWidth = Dimensions.get('window').width;
|
|
30
|
+
const windowHeight = Dimensions.get('window').height;
|
|
31
|
+
return windowWidth > windowHeight
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function assignFields(
|
|
35
|
+
target: any,
|
|
36
|
+
source: any,
|
|
37
|
+
fields: string[],
|
|
38
|
+
skipUndefined: boolean = true) {
|
|
39
|
+
if (!target)
|
|
40
|
+
target = {}
|
|
41
|
+
Object.keys(source || {}).forEach(k => {
|
|
42
|
+
if (fields?.indexOf(k) > -1) {
|
|
43
|
+
if (!skipUndefined && !source[k])
|
|
44
|
+
return
|
|
45
|
+
target[k] = source[k]
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
return target
|
|
49
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@tsconfig/react-native/tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"noEmit": false,
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"resolveJsonModule": true,
|
|
7
|
+
"sourceMap": true,
|
|
8
|
+
"outDir": "./dist",
|
|
9
|
+
"baseUrl": "./",
|
|
10
|
+
"paths": {
|
|
11
|
+
"@/*": [
|
|
12
|
+
"src/*"
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"include": [
|
|
17
|
+
"src/**/*.ts",
|
|
18
|
+
"src/**/*.js",
|
|
19
|
+
"src/**/*.tsx",
|
|
20
|
+
"src/**/*.jsx"
|
|
21
|
+
],
|
|
22
|
+
"exclude": [
|
|
23
|
+
"node_modules"
|
|
24
|
+
]
|
|
25
|
+
}
|