ui-rn 1.0.5 → 1.0.6
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/Example/index.tsx +15 -24
- package/package.json +3 -2
- package/src/Loading/Loading.tsx +107 -0
- package/src/Loading/LoadingType.tsx +24 -0
- package/src/Loading/index.tsx +22 -0
- package/src/index.tsx +3 -1
package/Example/index.tsx
CHANGED
|
@@ -1,28 +1,19 @@
|
|
|
1
|
-
import { StyleSheet, Text, View } from 'react-native'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import {
|
|
4
|
-
export default function
|
|
5
|
-
const diameter = width
|
|
6
|
-
const radius = (diameter / 2)
|
|
7
|
-
const m = (Math.sqrt(3) / 2) * radius// Math.sin(60) * radius //-> x
|
|
8
|
-
const n = (1 / 2) * radius//Math.cos(60) * radius//-> y
|
|
9
|
-
const hexagonPoints = [
|
|
10
|
-
{ x: radius, y: 0 },
|
|
11
|
-
{ x: radius + m, y: radius - n },//60
|
|
12
|
-
{ x: radius + m, y: radius + n },
|
|
13
|
-
{ x: radius, y: diameter },//180
|
|
14
|
-
{ x: radius - m, y: radius + n },
|
|
15
|
-
{ x: radius - m, y: radius - n },
|
|
16
|
-
{ x: radius, y: 0 },
|
|
17
|
-
]
|
|
18
|
-
const points = hexagonPoints.map(point => `${point.x},${point.y}`).join(' ');
|
|
1
|
+
import { StyleSheet, Text, View } from 'react-native';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Block } from 'ui-rn';
|
|
4
|
+
export default function App() {
|
|
19
5
|
return (
|
|
20
|
-
<View style={
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
</Svg>
|
|
6
|
+
<View style={styles.container}>
|
|
7
|
+
<Text>App</Text>
|
|
8
|
+
<Block></Block>
|
|
24
9
|
</View>
|
|
25
10
|
);
|
|
26
|
-
}
|
|
11
|
+
}
|
|
27
12
|
|
|
28
|
-
const styles = StyleSheet.create({
|
|
13
|
+
const styles = StyleSheet.create({
|
|
14
|
+
container: {
|
|
15
|
+
flex: 1,
|
|
16
|
+
justifyContent: 'center',
|
|
17
|
+
alignItems: 'center',
|
|
18
|
+
},
|
|
19
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ui-rn",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"repository": "https://github.com/phamha98/ui-rn",
|
|
5
5
|
"description": "ui-rn",
|
|
6
6
|
"author": "Phamha98",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"@types/underscore": "^1.11.15",
|
|
11
11
|
"validate-color": "^2.2.4",
|
|
12
12
|
"react-native-safe-area-view": "^1.1.1",
|
|
13
|
-
"react-native-linear-gradient": "^2.8.3"
|
|
13
|
+
"react-native-linear-gradient": "^2.8.3",
|
|
14
|
+
"react-native-indicators": "^0.17.0"
|
|
14
15
|
},
|
|
15
16
|
"scripts": {
|
|
16
17
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React, { PureComponent } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
Dimensions,
|
|
4
|
+
Modal,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
View,
|
|
8
|
+
ViewProps,
|
|
9
|
+
Text
|
|
10
|
+
} from 'react-native'
|
|
11
|
+
import LoadingType, { LoadingTypeI } from './LoadingType'
|
|
12
|
+
export type Props = {
|
|
13
|
+
boxStyle?: ViewProps['style']
|
|
14
|
+
containerStyle?: ViewProps['style']
|
|
15
|
+
}
|
|
16
|
+
type State = {
|
|
17
|
+
visible: boolean,
|
|
18
|
+
touch: boolean,
|
|
19
|
+
progress: number,
|
|
20
|
+
progressShow: boolean,
|
|
21
|
+
type: LoadingTypeI
|
|
22
|
+
}
|
|
23
|
+
export default class Loading extends PureComponent<Props, State> {
|
|
24
|
+
state: State
|
|
25
|
+
constructor(props: any) {
|
|
26
|
+
super(props)
|
|
27
|
+
this.state = {
|
|
28
|
+
visible: false,
|
|
29
|
+
touch: false,
|
|
30
|
+
progress: 0,
|
|
31
|
+
progressShow: false,
|
|
32
|
+
type: 'BallIndicator'
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
show(touch = true) {
|
|
36
|
+
this.setState({ visible: true, touch })
|
|
37
|
+
}
|
|
38
|
+
hide() {
|
|
39
|
+
this.setState({ visible: false, progress: 0, progressShow: false })
|
|
40
|
+
}
|
|
41
|
+
openProgress(e: any) { this.setState(prev => ({ ...prev, ...e })) }
|
|
42
|
+
onPressOut() {
|
|
43
|
+
if (this.state.touch) {
|
|
44
|
+
this.hide()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
componentDidMount(): void {
|
|
49
|
+
}
|
|
50
|
+
componentWillUnmount(): void {
|
|
51
|
+
}
|
|
52
|
+
renderIcon() {
|
|
53
|
+
if (this.state.type) return React.createElement(LoadingType[this.state.type], { color: '#4481EB' })
|
|
54
|
+
return null
|
|
55
|
+
}
|
|
56
|
+
renderProgress() {
|
|
57
|
+
if (this.state.progressShow) {
|
|
58
|
+
return (<Text style={styles.text}>{this.state.progress}{'%'}</Text>)
|
|
59
|
+
}
|
|
60
|
+
return null
|
|
61
|
+
}
|
|
62
|
+
render() {
|
|
63
|
+
return (
|
|
64
|
+
<Modal
|
|
65
|
+
visible={this.state.visible}
|
|
66
|
+
transparent
|
|
67
|
+
style={{ zIndex: 999999 }}
|
|
68
|
+
>
|
|
69
|
+
<TouchableOpacity onPress={() => this.onPressOut()}
|
|
70
|
+
activeOpacity={1} style={[styles.container, this.props.containerStyle]}>
|
|
71
|
+
<View style={[styles.box, this.props.boxStyle]}>
|
|
72
|
+
{this.renderProgress()}
|
|
73
|
+
{this.renderIcon()}
|
|
74
|
+
</View>
|
|
75
|
+
</TouchableOpacity>
|
|
76
|
+
</Modal>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const styles = StyleSheet.create({
|
|
81
|
+
container: {
|
|
82
|
+
flex: 1,
|
|
83
|
+
justifyContent: 'center',
|
|
84
|
+
alignItems: 'center',
|
|
85
|
+
backgroundColor: '#06060660',
|
|
86
|
+
},
|
|
87
|
+
box: {
|
|
88
|
+
width: Dimensions.get('screen').width * 0.25,
|
|
89
|
+
height: Dimensions.get('screen').width * 0.25,
|
|
90
|
+
backgroundColor: '#fff',
|
|
91
|
+
justifyContent: 'center',
|
|
92
|
+
alignItems: 'center',
|
|
93
|
+
borderRadius: 16,
|
|
94
|
+
shadowColor: '#000',
|
|
95
|
+
elevation: 3,
|
|
96
|
+
shadowOffset: {
|
|
97
|
+
width: 3,
|
|
98
|
+
height: 5,
|
|
99
|
+
},
|
|
100
|
+
shadowOpacity: 0.1,
|
|
101
|
+
},
|
|
102
|
+
text: {
|
|
103
|
+
position: 'absolute',
|
|
104
|
+
fontSize: 10,
|
|
105
|
+
color: '#4481EB'
|
|
106
|
+
},
|
|
107
|
+
})
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BallIndicator,
|
|
3
|
+
BarIndicator,
|
|
4
|
+
DotIndicator,
|
|
5
|
+
MaterialIndicator,
|
|
6
|
+
PacmanIndicator,
|
|
7
|
+
PulseIndicator,
|
|
8
|
+
SkypeIndicator,
|
|
9
|
+
UIActivityIndicator,
|
|
10
|
+
WaveIndicator,
|
|
11
|
+
} from 'react-native-indicators';
|
|
12
|
+
const LoadingType = {
|
|
13
|
+
BallIndicator,
|
|
14
|
+
BarIndicator,
|
|
15
|
+
DotIndicator,
|
|
16
|
+
MaterialIndicator,
|
|
17
|
+
PacmanIndicator,
|
|
18
|
+
PulseIndicator,
|
|
19
|
+
SkypeIndicator,
|
|
20
|
+
UIActivityIndicator,
|
|
21
|
+
WaveIndicator,
|
|
22
|
+
}
|
|
23
|
+
export type LoadingTypeI = keyof typeof LoadingType
|
|
24
|
+
export default LoadingType
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { PureComponent, ReactNode } from "react"
|
|
2
|
+
import RNLoading, { Props } from "./Loading"
|
|
3
|
+
|
|
4
|
+
const loadingRef = React.createRef<RNLoading>()
|
|
5
|
+
export class Loading {
|
|
6
|
+
static show() {
|
|
7
|
+
loadingRef.current?.show()
|
|
8
|
+
}
|
|
9
|
+
static hide() {
|
|
10
|
+
loadingRef.current?.hide()
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export default class LoadingView extends PureComponent<Props> {
|
|
14
|
+
render(): ReactNode {
|
|
15
|
+
return (
|
|
16
|
+
|
|
17
|
+
<RNLoading ref={loadingRef} {...this.props} />
|
|
18
|
+
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/index.tsx
CHANGED
|
@@ -2,4 +2,6 @@ export { default as Touch } from './Touch/Touch'
|
|
|
2
2
|
export { default as Block } from './Touch/Block'
|
|
3
3
|
export { default as Text } from './Text'
|
|
4
4
|
export { default as Icon } from './Icon'
|
|
5
|
-
export { default as Layout } from './Layout'
|
|
5
|
+
export { default as Layout } from './Layout'
|
|
6
|
+
export { default as LoadingView } from './Loading'
|
|
7
|
+
export { Loading } from './Loading'
|