react-crud-mobile 1.0.671 → 1.0.673
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/dist/react-crud-mobile.cjs.development.js +1 -1
- package/dist/react-crud-mobile.cjs.development.js.map +1 -1
- package/dist/react-crud-mobile.cjs.production.min.js +1 -1
- package/dist/react-crud-mobile.cjs.production.min.js.map +1 -1
- package/dist/react-crud-mobile.esm.js +2 -2
- package/dist/react-crud-mobile.esm.js.map +1 -1
- package/package.json +73 -73
- package/src/elements/UI.tsx +67 -67
- package/src/elements/UIChildren.tsx +139 -139
- package/src/elements/UIComplete.tsx +14 -14
- package/src/elements/UIElement.tsx +625 -625
- package/src/elements/UITag.tsx +13 -13
- package/src/elements/charts/ElChart.tsx +10 -10
- package/src/elements/core/SafeView.tsx +63 -63
- package/src/elements/core/UIAutoComplete.tsx +17 -17
- package/src/elements/core/UIButton.tsx +85 -85
- package/src/elements/core/UIIcon.tsx +8 -8
- package/src/elements/core/UIInclude.tsx +40 -40
- package/src/elements/core/UIInput.tsx +69 -69
- package/src/elements/core/UILink.tsx +17 -17
- package/src/elements/core/UIList.tsx +133 -133
- package/src/elements/core/UIListItem.tsx +32 -32
- package/src/elements/core/UIListRow.tsx +117 -117
- package/src/elements/core/UIModal.tsx +181 -181
- package/src/elements/core/UIOption.tsx +17 -17
- package/src/elements/core/UIQuantity.tsx +97 -97
- package/src/elements/core/UIRadio.tsx +17 -17
- package/src/elements/core/UISelect.tsx +135 -135
- package/src/elements/core/UISwitch.tsx +27 -27
- package/src/elements/core/UIToggle.tsx +102 -102
- package/src/elements/core/UIView.tsx +55 -55
- package/src/elements/index.ts +1 -1
- package/src/elements/tabs/ElTabs.tsx +178 -178
- package/src/hooks/useIsVisible.ts +39 -39
- package/src/index.ts +1 -1
|
@@ -1,135 +1,135 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
ChildType,
|
|
4
|
-
MethodType,
|
|
5
|
-
useTheme,
|
|
6
|
-
Utils,
|
|
7
|
-
ViewUtils,
|
|
8
|
-
} from 'react-crud-utils';
|
|
9
|
-
import {
|
|
10
|
-
Text,
|
|
11
|
-
TouchableOpacity,
|
|
12
|
-
StyleSheet,
|
|
13
|
-
Modal,
|
|
14
|
-
View,
|
|
15
|
-
StatusBar,
|
|
16
|
-
SafeAreaView,
|
|
17
|
-
} from 'react-native';
|
|
18
|
-
import { Ionicons } from '@expo/vector-icons';
|
|
19
|
-
import UI from '../UI';
|
|
20
|
-
|
|
21
|
-
export default function UISelect(props: ChildType) {
|
|
22
|
-
const [modalVisible, setModalVisible] = useState(false);
|
|
23
|
-
const scope = props.scope;
|
|
24
|
-
const items = Utils.nvl(scope.getOptions(), []);
|
|
25
|
-
const placeholder = scope.attr('placeholder', 'Selecione...');
|
|
26
|
-
const value = scope.getDisplayValue();
|
|
27
|
-
const theme = useTheme();
|
|
28
|
-
const main = ViewUtils.getCrud('view');
|
|
29
|
-
|
|
30
|
-
const handlePress = () => {
|
|
31
|
-
const _modalVisible = !modalVisible;
|
|
32
|
-
|
|
33
|
-
main.data.selectIsOpen = _modalVisible;
|
|
34
|
-
setModalVisible(_modalVisible);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const onClick = ({ crud, value }: MethodType) => {
|
|
38
|
-
scope.changeValue(value);
|
|
39
|
-
handlePress();
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const style = (part: string, extra?: any) => {
|
|
43
|
-
return { ...styles[part], ...scope.getStyle(part), ...extra };
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const isModalVisible = () => {
|
|
47
|
-
return modalVisible;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<View style={style('selectRoot')}>
|
|
52
|
-
<TouchableOpacity onPress={handlePress} style={style('selectInput')}>
|
|
53
|
-
<Text style={style('selectLabel')}>
|
|
54
|
-
{Utils.nvl(value, placeholder)}
|
|
55
|
-
</Text>
|
|
56
|
-
<Ionicons name="arrow-down" size={20} color="#888" />
|
|
57
|
-
</TouchableOpacity>
|
|
58
|
-
<Modal
|
|
59
|
-
animationType="slide"
|
|
60
|
-
transparent={true}
|
|
61
|
-
visible={isModalVisible()}
|
|
62
|
-
onRequestClose={() => setModalVisible(false)}
|
|
63
|
-
>
|
|
64
|
-
<StatusBar
|
|
65
|
-
barStyle="dark-content"
|
|
66
|
-
backgroundColor={theme.colors.primary}
|
|
67
|
-
/>
|
|
68
|
-
<SafeAreaView style={style('modalSafe')}>
|
|
69
|
-
<View style={style('modalHeader')}>
|
|
70
|
-
<TouchableOpacity
|
|
71
|
-
onPress={() => setModalVisible(false)}
|
|
72
|
-
style={style('modalCloseButton')}
|
|
73
|
-
>
|
|
74
|
-
<Text style={style('modalCloseText')}>X</Text>
|
|
75
|
-
</TouchableOpacity>
|
|
76
|
-
<Text style={style('modalTitle')}>{placeholder}</Text>
|
|
77
|
-
</View>
|
|
78
|
-
<View style={style('modalContent')}>
|
|
79
|
-
<UI.List data={items} name={scope.getName('list')} click={onClick}>
|
|
80
|
-
<UI.Value value="#{@this.label}" />
|
|
81
|
-
</UI.List>
|
|
82
|
-
</View>
|
|
83
|
-
</SafeAreaView>
|
|
84
|
-
</Modal>
|
|
85
|
-
</View>
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const styles = StyleSheet.create({
|
|
90
|
-
selectRoot: {
|
|
91
|
-
justifyContent: 'flex-start',
|
|
92
|
-
alignItems: 'flex-start',
|
|
93
|
-
flex: 1,
|
|
94
|
-
},
|
|
95
|
-
selectInput: {
|
|
96
|
-
width: '100%',
|
|
97
|
-
flexDirection: 'row',
|
|
98
|
-
borderRadius: 20,
|
|
99
|
-
paddingHorizontal: 15,
|
|
100
|
-
paddingVertical: 10,
|
|
101
|
-
},
|
|
102
|
-
selectLabel: { flex: 1 },
|
|
103
|
-
modalSafe: {
|
|
104
|
-
flex: 1,
|
|
105
|
-
backgroundColor: '#f5f5f5',
|
|
106
|
-
paddingTop: StatusBar.currentHeight || 0, // Considera a altura da barra de status no Android
|
|
107
|
-
},
|
|
108
|
-
modalHeader: {
|
|
109
|
-
flexDirection: 'row',
|
|
110
|
-
alignItems: 'center',
|
|
111
|
-
padding: 15,
|
|
112
|
-
backgroundColor: '#6200ea',
|
|
113
|
-
},
|
|
114
|
-
modalCloseButton: {
|
|
115
|
-
padding: 10,
|
|
116
|
-
},
|
|
117
|
-
modalCloseText: {
|
|
118
|
-
fontSize: 18,
|
|
119
|
-
color: 'white',
|
|
120
|
-
},
|
|
121
|
-
modalTitle: {
|
|
122
|
-
fontSize: 18,
|
|
123
|
-
color: 'white',
|
|
124
|
-
fontWeight: 'bold',
|
|
125
|
-
marginLeft: 10,
|
|
126
|
-
},
|
|
127
|
-
modalContent: {
|
|
128
|
-
flex: 1,
|
|
129
|
-
width: '100%',
|
|
130
|
-
alignSelf: 'flex-start',
|
|
131
|
-
flexDirection: 'row',
|
|
132
|
-
flexWrap: 'wrap',
|
|
133
|
-
padding: 20,
|
|
134
|
-
},
|
|
135
|
-
});
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
ChildType,
|
|
4
|
+
MethodType,
|
|
5
|
+
useTheme,
|
|
6
|
+
Utils,
|
|
7
|
+
ViewUtils,
|
|
8
|
+
} from 'react-crud-utils';
|
|
9
|
+
import {
|
|
10
|
+
Text,
|
|
11
|
+
TouchableOpacity,
|
|
12
|
+
StyleSheet,
|
|
13
|
+
Modal,
|
|
14
|
+
View,
|
|
15
|
+
StatusBar,
|
|
16
|
+
SafeAreaView,
|
|
17
|
+
} from 'react-native';
|
|
18
|
+
import { Ionicons } from '@expo/vector-icons';
|
|
19
|
+
import UI from '../UI';
|
|
20
|
+
|
|
21
|
+
export default function UISelect(props: ChildType) {
|
|
22
|
+
const [modalVisible, setModalVisible] = useState(false);
|
|
23
|
+
const scope = props.scope;
|
|
24
|
+
const items = Utils.nvl(scope.getOptions(), []);
|
|
25
|
+
const placeholder = scope.attr('placeholder', 'Selecione...');
|
|
26
|
+
const value = scope.getDisplayValue();
|
|
27
|
+
const theme = useTheme();
|
|
28
|
+
const main = ViewUtils.getCrud('view');
|
|
29
|
+
|
|
30
|
+
const handlePress = () => {
|
|
31
|
+
const _modalVisible = !modalVisible;
|
|
32
|
+
|
|
33
|
+
main.data.selectIsOpen = _modalVisible;
|
|
34
|
+
setModalVisible(_modalVisible);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const onClick = ({ crud, value }: MethodType) => {
|
|
38
|
+
scope.changeValue(value);
|
|
39
|
+
handlePress();
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const style = (part: string, extra?: any) => {
|
|
43
|
+
return { ...styles[part], ...scope.getStyle(part), ...extra };
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const isModalVisible = () => {
|
|
47
|
+
return modalVisible;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<View style={style('selectRoot')}>
|
|
52
|
+
<TouchableOpacity onPress={handlePress} style={style('selectInput')}>
|
|
53
|
+
<Text style={style('selectLabel')}>
|
|
54
|
+
{Utils.nvl(value, placeholder)}
|
|
55
|
+
</Text>
|
|
56
|
+
<Ionicons name="arrow-down" size={20} color="#888" />
|
|
57
|
+
</TouchableOpacity>
|
|
58
|
+
<Modal
|
|
59
|
+
animationType="slide"
|
|
60
|
+
transparent={true}
|
|
61
|
+
visible={isModalVisible()}
|
|
62
|
+
onRequestClose={() => setModalVisible(false)}
|
|
63
|
+
>
|
|
64
|
+
<StatusBar
|
|
65
|
+
barStyle="dark-content"
|
|
66
|
+
backgroundColor={theme.colors.primary}
|
|
67
|
+
/>
|
|
68
|
+
<SafeAreaView style={style('modalSafe')}>
|
|
69
|
+
<View style={style('modalHeader')}>
|
|
70
|
+
<TouchableOpacity
|
|
71
|
+
onPress={() => setModalVisible(false)}
|
|
72
|
+
style={style('modalCloseButton')}
|
|
73
|
+
>
|
|
74
|
+
<Text style={style('modalCloseText')}>X</Text>
|
|
75
|
+
</TouchableOpacity>
|
|
76
|
+
<Text style={style('modalTitle')}>{placeholder}</Text>
|
|
77
|
+
</View>
|
|
78
|
+
<View style={style('modalContent')}>
|
|
79
|
+
<UI.List data={items} name={scope.getName('list')} click={onClick}>
|
|
80
|
+
<UI.Value value="#{@this.label}" />
|
|
81
|
+
</UI.List>
|
|
82
|
+
</View>
|
|
83
|
+
</SafeAreaView>
|
|
84
|
+
</Modal>
|
|
85
|
+
</View>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const styles = StyleSheet.create({
|
|
90
|
+
selectRoot: {
|
|
91
|
+
justifyContent: 'flex-start',
|
|
92
|
+
alignItems: 'flex-start',
|
|
93
|
+
flex: 1,
|
|
94
|
+
},
|
|
95
|
+
selectInput: {
|
|
96
|
+
width: '100%',
|
|
97
|
+
flexDirection: 'row',
|
|
98
|
+
borderRadius: 20,
|
|
99
|
+
paddingHorizontal: 15,
|
|
100
|
+
paddingVertical: 10,
|
|
101
|
+
},
|
|
102
|
+
selectLabel: { flex: 1 },
|
|
103
|
+
modalSafe: {
|
|
104
|
+
flex: 1,
|
|
105
|
+
backgroundColor: '#f5f5f5',
|
|
106
|
+
paddingTop: StatusBar.currentHeight || 0, // Considera a altura da barra de status no Android
|
|
107
|
+
},
|
|
108
|
+
modalHeader: {
|
|
109
|
+
flexDirection: 'row',
|
|
110
|
+
alignItems: 'center',
|
|
111
|
+
padding: 15,
|
|
112
|
+
backgroundColor: '#6200ea',
|
|
113
|
+
},
|
|
114
|
+
modalCloseButton: {
|
|
115
|
+
padding: 10,
|
|
116
|
+
},
|
|
117
|
+
modalCloseText: {
|
|
118
|
+
fontSize: 18,
|
|
119
|
+
color: 'white',
|
|
120
|
+
},
|
|
121
|
+
modalTitle: {
|
|
122
|
+
fontSize: 18,
|
|
123
|
+
color: 'white',
|
|
124
|
+
fontWeight: 'bold',
|
|
125
|
+
marginLeft: 10,
|
|
126
|
+
},
|
|
127
|
+
modalContent: {
|
|
128
|
+
flex: 1,
|
|
129
|
+
width: '100%',
|
|
130
|
+
alignSelf: 'flex-start',
|
|
131
|
+
flexDirection: 'row',
|
|
132
|
+
flexWrap: 'wrap',
|
|
133
|
+
padding: 20,
|
|
134
|
+
},
|
|
135
|
+
});
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import { ChildType, Utils } from 'react-crud-utils';
|
|
3
|
-
import { Switch } from 'react-native';
|
|
4
|
-
|
|
5
|
-
export default function UISwitch(props: ChildType) {
|
|
6
|
-
const scope = props.scope;
|
|
7
|
-
const initial = Utils.nvl(scope.getValue(), false) as boolean;
|
|
8
|
-
const [value, setValue] = useState(initial);
|
|
9
|
-
|
|
10
|
-
let onChange = v => {
|
|
11
|
-
scope.changeValue(v);
|
|
12
|
-
|
|
13
|
-
setValue(v);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<Switch
|
|
18
|
-
value={value}
|
|
19
|
-
style={scope.getStyle('element')}
|
|
20
|
-
onValueChange={onChange} // Alterna o estado
|
|
21
|
-
/>
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const styles = {
|
|
26
|
-
link: {},
|
|
27
|
-
};
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { ChildType, Utils } from 'react-crud-utils';
|
|
3
|
+
import { Switch } from 'react-native';
|
|
4
|
+
|
|
5
|
+
export default function UISwitch(props: ChildType) {
|
|
6
|
+
const scope = props.scope;
|
|
7
|
+
const initial = Utils.nvl(scope.getValue(), false) as boolean;
|
|
8
|
+
const [value, setValue] = useState(initial);
|
|
9
|
+
|
|
10
|
+
let onChange = v => {
|
|
11
|
+
scope.changeValue(v);
|
|
12
|
+
|
|
13
|
+
setValue(v);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Switch
|
|
18
|
+
value={value}
|
|
19
|
+
style={scope.getStyle('element')}
|
|
20
|
+
onValueChange={onChange} // Alterna o estado
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const styles = {
|
|
26
|
+
link: {},
|
|
27
|
+
};
|
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import { ChildType, Utils } from 'react-crud-utils';
|
|
3
|
-
import { StyleSheet, Text, TouchableHighlight, View } from 'react-native';
|
|
4
|
-
import UIListRow from './UIListRow';
|
|
5
|
-
|
|
6
|
-
export default function UIToggle(props: ChildType) {
|
|
7
|
-
const scope = props.scope;
|
|
8
|
-
const options = Utils.nvl(scope.getOptions(), []);
|
|
9
|
-
const value = scope.getInputValue();
|
|
10
|
-
|
|
11
|
-
let [index, setIndex] = useState(0);
|
|
12
|
-
|
|
13
|
-
const isSelected = (item: any) => {
|
|
14
|
-
return item?.value === value;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const onClick = (item: any) => {
|
|
18
|
-
scope.changeValue(item.object);
|
|
19
|
-
setIndex(++index);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const Item = ({ item, index }) => {
|
|
23
|
-
let selected = isSelected(item);
|
|
24
|
-
let style: any = { ...styles.text };
|
|
25
|
-
|
|
26
|
-
if (selected) style.color = '#ffffff';
|
|
27
|
-
|
|
28
|
-
if (Utils.isEmpty(props.children)) {
|
|
29
|
-
return <Text style={style}>{item.label}</Text>;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<UIListRow scope={scope} item={item.object} index={index}>
|
|
34
|
-
{props.children}
|
|
35
|
-
</UIListRow>
|
|
36
|
-
);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const getItemStyle = (item: any) => {
|
|
40
|
-
let style = { ...styles.item, ...scope.getStyle('item') };
|
|
41
|
-
|
|
42
|
-
let wPart = 100 / options.length;
|
|
43
|
-
let width = Math.floor(wPart) + '%';
|
|
44
|
-
|
|
45
|
-
if (isSelected(item)) {
|
|
46
|
-
let selectedColor = scope.getPart('selectedColor', undefined, 'primary');
|
|
47
|
-
let st = scope.getStyle('selected', {
|
|
48
|
-
backgroundColor: selectedColor,
|
|
49
|
-
color: '#ffffff',
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
style = { ...style, ...st };
|
|
53
|
-
|
|
54
|
-
if (!style.color) {
|
|
55
|
-
style.color = '#ffffff';
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
style.width = width;
|
|
60
|
-
|
|
61
|
-
return style;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<>
|
|
66
|
-
{options.map((item: any, i: number) => (
|
|
67
|
-
<TouchableHighlight
|
|
68
|
-
key={`k-${i}`}
|
|
69
|
-
style={getItemStyle(item)}
|
|
70
|
-
onPress={e => {
|
|
71
|
-
onClick(item);
|
|
72
|
-
}}
|
|
73
|
-
>
|
|
74
|
-
<Item item={item} index={i} />
|
|
75
|
-
</TouchableHighlight>
|
|
76
|
-
))}
|
|
77
|
-
</>
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const styles = StyleSheet.create({
|
|
82
|
-
container: {
|
|
83
|
-
flex: 1,
|
|
84
|
-
width: '100%',
|
|
85
|
-
gap: 10,
|
|
86
|
-
justifyContent: 'center',
|
|
87
|
-
flexDirection: 'row',
|
|
88
|
-
},
|
|
89
|
-
item: {
|
|
90
|
-
padding: 15,
|
|
91
|
-
marginVertical: 8,
|
|
92
|
-
backgroundColor: '#f5f5f5',
|
|
93
|
-
borderRadius: 8,
|
|
94
|
-
justifyContent: 'center',
|
|
95
|
-
width: 'auto',
|
|
96
|
-
flexDirection: 'row',
|
|
97
|
-
},
|
|
98
|
-
text: {
|
|
99
|
-
fontSize: 16,
|
|
100
|
-
fontWeight: '500',
|
|
101
|
-
},
|
|
102
|
-
});
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { ChildType, Utils } from 'react-crud-utils';
|
|
3
|
+
import { StyleSheet, Text, TouchableHighlight, View } from 'react-native';
|
|
4
|
+
import UIListRow from './UIListRow';
|
|
5
|
+
|
|
6
|
+
export default function UIToggle(props: ChildType) {
|
|
7
|
+
const scope = props.scope;
|
|
8
|
+
const options = Utils.nvl(scope.getOptions(), []);
|
|
9
|
+
const value = scope.getInputValue();
|
|
10
|
+
|
|
11
|
+
let [index, setIndex] = useState(0);
|
|
12
|
+
|
|
13
|
+
const isSelected = (item: any) => {
|
|
14
|
+
return item?.value === value;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const onClick = (item: any) => {
|
|
18
|
+
scope.changeValue(item.object);
|
|
19
|
+
setIndex(++index);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const Item = ({ item, index }) => {
|
|
23
|
+
let selected = isSelected(item);
|
|
24
|
+
let style: any = { ...styles.text };
|
|
25
|
+
|
|
26
|
+
if (selected) style.color = '#ffffff';
|
|
27
|
+
|
|
28
|
+
if (Utils.isEmpty(props.children)) {
|
|
29
|
+
return <Text style={style}>{item.label}</Text>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<UIListRow scope={scope} item={item.object} index={index}>
|
|
34
|
+
{props.children}
|
|
35
|
+
</UIListRow>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const getItemStyle = (item: any) => {
|
|
40
|
+
let style = { ...styles.item, ...scope.getStyle('item') };
|
|
41
|
+
|
|
42
|
+
let wPart = 100 / options.length;
|
|
43
|
+
let width = Math.floor(wPart) + '%';
|
|
44
|
+
|
|
45
|
+
if (isSelected(item)) {
|
|
46
|
+
let selectedColor = scope.getPart('selectedColor', undefined, 'primary');
|
|
47
|
+
let st = scope.getStyle('selected', {
|
|
48
|
+
backgroundColor: selectedColor,
|
|
49
|
+
color: '#ffffff',
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
style = { ...style, ...st };
|
|
53
|
+
|
|
54
|
+
if (!style.color) {
|
|
55
|
+
style.color = '#ffffff';
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
style.width = width;
|
|
60
|
+
|
|
61
|
+
return style;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<>
|
|
66
|
+
{options.map((item: any, i: number) => (
|
|
67
|
+
<TouchableHighlight
|
|
68
|
+
key={`k-${i}`}
|
|
69
|
+
style={getItemStyle(item)}
|
|
70
|
+
onPress={e => {
|
|
71
|
+
onClick(item);
|
|
72
|
+
}}
|
|
73
|
+
>
|
|
74
|
+
<Item item={item} index={i} />
|
|
75
|
+
</TouchableHighlight>
|
|
76
|
+
))}
|
|
77
|
+
</>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const styles = StyleSheet.create({
|
|
82
|
+
container: {
|
|
83
|
+
flex: 1,
|
|
84
|
+
width: '100%',
|
|
85
|
+
gap: 10,
|
|
86
|
+
justifyContent: 'center',
|
|
87
|
+
flexDirection: 'row',
|
|
88
|
+
},
|
|
89
|
+
item: {
|
|
90
|
+
padding: 15,
|
|
91
|
+
marginVertical: 8,
|
|
92
|
+
backgroundColor: '#f5f5f5',
|
|
93
|
+
borderRadius: 8,
|
|
94
|
+
justifyContent: 'center',
|
|
95
|
+
width: 'auto',
|
|
96
|
+
flexDirection: 'row',
|
|
97
|
+
},
|
|
98
|
+
text: {
|
|
99
|
+
fontSize: 16,
|
|
100
|
+
fontWeight: '500',
|
|
101
|
+
},
|
|
102
|
+
});
|
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import { ScrollView, StyleSheet, View } from 'react-native';
|
|
2
|
-
|
|
3
|
-
import UIChildren from '../UIChildren';
|
|
4
|
-
import { ChildType, useTheme, Utils, ViewUtils } from 'react-crud-utils';
|
|
5
|
-
import { useEffect } from 'react';
|
|
6
|
-
import { StatusBar } from 'react-native';
|
|
7
|
-
|
|
8
|
-
export default function UIView({ scope, children }: ChildType) {
|
|
9
|
-
const theme = useTheme();
|
|
10
|
-
const header = scope.getPart('header', null, []);
|
|
11
|
-
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
StatusBar.setBarStyle('light-content');
|
|
14
|
-
StatusBar.setBackgroundColor?.(theme.colors.primary);
|
|
15
|
-
}, []);
|
|
16
|
-
|
|
17
|
-
const onScroll = () => {
|
|
18
|
-
const crud = ViewUtils.getCrud();
|
|
19
|
-
|
|
20
|
-
Utils.each(crud.scroll, s => {
|
|
21
|
-
if (s.onScroll) {
|
|
22
|
-
s.onScroll.call(s);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<>
|
|
29
|
-
{header}
|
|
30
|
-
<View style={scope.getStyle('container', styles.container)}>
|
|
31
|
-
<ScrollView
|
|
32
|
-
onScroll={onScroll}
|
|
33
|
-
scrollEventThrottle={16}
|
|
34
|
-
keyboardShouldPersistTaps="handled"
|
|
35
|
-
contentContainerStyle={scope.getStyle('contentContainer', {})}
|
|
36
|
-
style={scope.getStyle('scroll', styles.scroll)}
|
|
37
|
-
>
|
|
38
|
-
<UIChildren scope={scope}>{children}</UIChildren>
|
|
39
|
-
</ScrollView>
|
|
40
|
-
</View>
|
|
41
|
-
</>
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const styles = StyleSheet.create({
|
|
46
|
-
scroll: {
|
|
47
|
-
padding: 10,
|
|
48
|
-
},
|
|
49
|
-
container: {
|
|
50
|
-
backgroundColor: 'primary',
|
|
51
|
-
},
|
|
52
|
-
view: {
|
|
53
|
-
backgroundColor: 'primary',
|
|
54
|
-
},
|
|
55
|
-
});
|
|
1
|
+
import { ScrollView, StyleSheet, View } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import UIChildren from '../UIChildren';
|
|
4
|
+
import { ChildType, useTheme, Utils, ViewUtils } from 'react-crud-utils';
|
|
5
|
+
import { useEffect } from 'react';
|
|
6
|
+
import { StatusBar } from 'react-native';
|
|
7
|
+
|
|
8
|
+
export default function UIView({ scope, children }: ChildType) {
|
|
9
|
+
const theme = useTheme();
|
|
10
|
+
const header = scope.getPart('header', null, []);
|
|
11
|
+
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
StatusBar.setBarStyle('light-content');
|
|
14
|
+
StatusBar.setBackgroundColor?.(theme.colors.primary);
|
|
15
|
+
}, []);
|
|
16
|
+
|
|
17
|
+
const onScroll = () => {
|
|
18
|
+
const crud = ViewUtils.getCrud();
|
|
19
|
+
|
|
20
|
+
Utils.each(crud.scroll, s => {
|
|
21
|
+
if (s.onScroll) {
|
|
22
|
+
s.onScroll.call(s);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<>
|
|
29
|
+
{header}
|
|
30
|
+
<View style={scope.getStyle('container', styles.container)}>
|
|
31
|
+
<ScrollView
|
|
32
|
+
onScroll={onScroll}
|
|
33
|
+
scrollEventThrottle={16}
|
|
34
|
+
keyboardShouldPersistTaps="handled"
|
|
35
|
+
contentContainerStyle={scope.getStyle('contentContainer', {})}
|
|
36
|
+
style={scope.getStyle('scroll', styles.scroll)}
|
|
37
|
+
>
|
|
38
|
+
<UIChildren scope={scope}>{children}</UIChildren>
|
|
39
|
+
</ScrollView>
|
|
40
|
+
</View>
|
|
41
|
+
</>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const styles = StyleSheet.create({
|
|
46
|
+
scroll: {
|
|
47
|
+
padding: 10,
|
|
48
|
+
},
|
|
49
|
+
container: {
|
|
50
|
+
backgroundColor: 'primary',
|
|
51
|
+
},
|
|
52
|
+
view: {
|
|
53
|
+
backgroundColor: 'primary',
|
|
54
|
+
},
|
|
55
|
+
});
|
package/src/elements/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as UI } from "./UI";
|
|
1
|
+
export { default as UI } from "./UI";
|