react-crud-mobile 1.0.475 → 1.0.477

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.
@@ -1,134 +1,134 @@
1
- import { useEffect, useState } from 'react';
2
- import {
3
- ChildType,
4
- CrudUtils,
5
- MethodType,
6
- useTheme,
7
- Utils,
8
- } from 'react-crud-utils';
9
- import {
10
- Text,
11
- TouchableOpacity,
12
- StyleSheet,
13
- Modal,
14
- View,
15
- StatusBar,
16
- SafeAreaView,
17
- ScrollView,
18
- } from 'react-native';
19
- import UIChildren from '../UIChildren';
20
-
21
- export default function UIModal(props: ChildType) {
22
- let [modalVisible, setModalVisible] = useState(false);
23
-
24
- const scope = props.scope;
25
- const label = scope.getLabel();
26
- const theme = useTheme();
27
-
28
- const style = (part: string, extra?: any) => {
29
- let st = { ...styles[part], ...extra };
30
-
31
- return { ...scope.getStyle(part, st) };
32
- };
33
-
34
- const toggle = vis => {
35
- modalVisible = vis;
36
- setModalVisible(modalVisible);
37
- };
38
-
39
- scope.show = (args?: MethodType) => {
40
- let { crud } = args;
41
- let name = scope.getName('modal');
42
- let data = Utils.nvl(args.item, {});
43
- let edit = args.edit === true;
44
- let d = CrudUtils.create('dialog', {
45
- parent: crud,
46
- name,
47
- data,
48
- edit,
49
- scope,
50
- });
51
-
52
- scope.currentDialog = d;
53
-
54
- toggle(true);
55
- };
56
-
57
- scope.hide = (args?: MethodType) => {
58
- scope.currentDialog = null;
59
-
60
- toggle(false);
61
- };
62
-
63
- useEffect(() => {
64
- StatusBar.setBarStyle('light-content');
65
- StatusBar.setBackgroundColor?.(theme.colors.primary);
66
- }, [modalVisible]);
67
-
68
- if (!scope.currentDialog) {
69
- return <></>;
70
- }
71
-
72
- return (
73
- <Modal
74
- animationType="slide"
75
- transparent={true}
76
- visible={modalVisible}
77
- onRequestClose={() => setModalVisible(false)}
78
- >
79
- <SafeAreaView style={style('modalSafe')}>
80
- <View style={style('modalHeader')}>
81
- <TouchableOpacity
82
- onPress={() => setModalVisible(false)}
83
- style={style('modalCloseButton')}
84
- >
85
- <Text style={style('modalCloseText')}>X</Text>
86
- </TouchableOpacity>
87
- <Text style={style('modalTitle')}>{label}</Text>
88
- </View>
89
- <ScrollView
90
- contentContainerStyle={{ flexGrow: 1 }}
91
- style={style('modalContent')}
92
- >
93
- <View style={{ flex: 1 }}>
94
- <UIChildren scope={scope} crud={scope.currentDialog}>
95
- {props.children}
96
- </UIChildren>
97
- </View>
98
- </ScrollView>
99
- </SafeAreaView>
100
- </Modal>
101
- );
102
- }
103
-
104
- const styles = StyleSheet.create({
105
- modalSafe: {
106
- flex: 1,
107
- backgroundColor: 'primary',
108
- width: '100%',
109
- },
110
- modalHeader: {
111
- flexDirection: 'row',
112
- alignItems: 'center',
113
- padding: 15,
114
- backgroundColor: 'primary',
115
- },
116
- modalCloseButton: {
117
- padding: 10,
118
- },
119
- modalCloseText: {
120
- fontSize: 18,
121
- color: 'white',
122
- },
123
- modalTitle: {
124
- fontSize: 18,
125
- color: 'white',
126
- fontWeight: 'bold',
127
- marginLeft: 10,
128
- },
129
- modalContent: {
130
- flex: 1,
131
- backgroundColor: '#f5f5f5',
132
- padding: 20,
133
- },
134
- });
1
+ import { useEffect, useState } from 'react';
2
+ import {
3
+ ChildType,
4
+ CrudUtils,
5
+ MethodType,
6
+ useTheme,
7
+ Utils,
8
+ } from 'react-crud-utils';
9
+ import {
10
+ Text,
11
+ TouchableOpacity,
12
+ StyleSheet,
13
+ Modal,
14
+ View,
15
+ StatusBar,
16
+ SafeAreaView,
17
+ ScrollView,
18
+ } from 'react-native';
19
+ import UIChildren from '../UIChildren';
20
+
21
+ export default function UIModal(props: ChildType) {
22
+ let [modalVisible, setModalVisible] = useState(false);
23
+
24
+ const scope = props.scope;
25
+ const label = scope.getLabel();
26
+ const theme = useTheme();
27
+
28
+ const style = (part: string, extra?: any) => {
29
+ let st = { ...styles[part], ...extra };
30
+
31
+ return { ...scope.getStyle(part, st) };
32
+ };
33
+
34
+ const toggle = vis => {
35
+ modalVisible = vis;
36
+ setModalVisible(modalVisible);
37
+ };
38
+
39
+ scope.show = (args?: MethodType) => {
40
+ let { crud } = args;
41
+ let name = scope.getName('modal');
42
+ let data = Utils.nvl(args.item, {});
43
+ let edit = args.edit === true;
44
+ let d = CrudUtils.create('dialog', {
45
+ parent: crud,
46
+ name,
47
+ data,
48
+ edit,
49
+ scope,
50
+ });
51
+
52
+ scope.currentDialog = d;
53
+
54
+ toggle(true);
55
+ };
56
+
57
+ scope.hide = (args?: MethodType) => {
58
+ scope.currentDialog = null;
59
+
60
+ toggle(false);
61
+ };
62
+
63
+ useEffect(() => {
64
+ StatusBar.setBarStyle('light-content');
65
+ StatusBar.setBackgroundColor?.(theme.colors.primary);
66
+ }, [modalVisible]);
67
+
68
+ if (!scope.currentDialog) {
69
+ return <></>;
70
+ }
71
+
72
+ return (
73
+ <Modal
74
+ animationType="slide"
75
+ transparent={true}
76
+ visible={modalVisible}
77
+ onRequestClose={() => setModalVisible(false)}
78
+ >
79
+ <SafeAreaView style={style('modalSafe')}>
80
+ <View style={style('modalHeader')}>
81
+ <TouchableOpacity
82
+ onPress={() => setModalVisible(false)}
83
+ style={style('modalCloseButton')}
84
+ >
85
+ <Text style={style('modalCloseText')}>X</Text>
86
+ </TouchableOpacity>
87
+ <Text style={style('modalTitle')}>{label}</Text>
88
+ </View>
89
+ <ScrollView
90
+ contentContainerStyle={{ flexGrow: 1 }}
91
+ style={style('modalContent')}
92
+ >
93
+ <View style={{ flex: 1 }}>
94
+ <UIChildren scope={scope} crud={scope.currentDialog}>
95
+ {props.children}
96
+ </UIChildren>
97
+ </View>
98
+ </ScrollView>
99
+ </SafeAreaView>
100
+ </Modal>
101
+ );
102
+ }
103
+
104
+ const styles = StyleSheet.create({
105
+ modalSafe: {
106
+ flex: 1,
107
+ backgroundColor: 'primary',
108
+ width: '100%',
109
+ },
110
+ modalHeader: {
111
+ flexDirection: 'row',
112
+ alignItems: 'center',
113
+ padding: 15,
114
+ backgroundColor: 'primary',
115
+ },
116
+ modalCloseButton: {
117
+ padding: 10,
118
+ },
119
+ modalCloseText: {
120
+ fontSize: 18,
121
+ color: 'white',
122
+ },
123
+ modalTitle: {
124
+ fontSize: 18,
125
+ color: 'white',
126
+ fontWeight: 'bold',
127
+ marginLeft: 10,
128
+ },
129
+ modalContent: {
130
+ flex: 1,
131
+ backgroundColor: '#f5f5f5',
132
+ padding: 20,
133
+ },
134
+ });
@@ -1,17 +1,17 @@
1
- import { Text, TouchableOpacity, Linking, StyleSheet } from 'react-native';
2
-
3
- export default function UIOption(props: any) {
4
- const handlePress = () => {
5
- Linking.openURL('https://reactnative.dev/');
6
- };
7
-
8
- return (
9
- <TouchableOpacity onPress={handlePress}>
10
- <Text style={styles.link}>Clique aqui para acessar o React Native</Text>
11
- </TouchableOpacity>
12
- );
13
- }
14
-
15
- const styles = {
16
- link: {},
17
- };
1
+ import { Text, TouchableOpacity, Linking, StyleSheet } from 'react-native';
2
+
3
+ export default function UIOption(props: any) {
4
+ const handlePress = () => {
5
+ Linking.openURL('https://reactnative.dev/');
6
+ };
7
+
8
+ return (
9
+ <TouchableOpacity onPress={handlePress}>
10
+ <Text style={styles.link}>Clique aqui para acessar o React Native</Text>
11
+ </TouchableOpacity>
12
+ );
13
+ }
14
+
15
+ const styles = {
16
+ link: {},
17
+ };
@@ -1,97 +1,97 @@
1
- import { Ionicons } from '@expo/vector-icons';
2
- import { useState } from 'react';
3
- import { ChildType, Utils } from 'react-crud-utils';
4
- import { Text, TouchableHighlight, View } from 'react-native';
5
-
6
- export default function UIQuantity(props: ChildType) {
7
- const scope = props.scope;
8
- const element = scope.original;
9
-
10
- let [index, setIndex] = useState(0);
11
-
12
- const value = scope.getValue(0);
13
-
14
- let color = element.color;
15
-
16
- if (!color) color = 'primary';
17
-
18
- const btn = {
19
- padding: 10,
20
- alignItems: 'center',
21
- height: 44,
22
- width: 44,
23
- textAlign: 'center',
24
- verticalAling: 'middle',
25
- borderRadius: 24,
26
- backgroundColor: color,
27
- color: '#ffffff',
28
- justifyContent: 'center',
29
- };
30
-
31
- const styles: any = {
32
- buttonLabel: {
33
- color: '#ffffff',
34
- fontWeight: '500',
35
- fontSize: 16,
36
- },
37
- value: {
38
- flex: 1,
39
- flexDirection: 'row',
40
- textAlign: 'center',
41
- },
42
- buttonInner: {
43
- flexDirection: 'row',
44
- alignItems: 'center',
45
- justifyContent: 'center',
46
- },
47
- buttonIcon: {
48
- color: '#fff',
49
- fontSize: 18,
50
- },
51
- button: btn,
52
- addButton: {
53
- ...btn,
54
- },
55
- delButton: {
56
- ...btn,
57
- },
58
- };
59
-
60
- const change = (val: number) => {
61
- scope.changeValue(value + val);
62
- setIndex(++index);
63
- };
64
-
65
- const onClickAdd = () => {
66
- change(1);
67
- };
68
-
69
- const onClickDel = () => {
70
- change(-1);
71
- };
72
-
73
- const style = (part: string, extra?: any) => {
74
- let s = { ...styles[part], ...extra };
75
- return scope.getStyle(part, s);
76
- };
77
-
78
- return (
79
- <>
80
- <TouchableHighlight
81
- underlayColor={'transparent'}
82
- onPress={onClickDel}
83
- style={style('delButton')}
84
- >
85
- <Ionicons size={30} style={style('buttonIcon')} name="remove" />
86
- </TouchableHighlight>
87
- <Text style={style('value')}>{Utils.nvl(value, 0)}</Text>
88
- <TouchableHighlight
89
- underlayColor={'transparent'}
90
- onPress={onClickAdd}
91
- style={style('addButton')}
92
- >
93
- <Ionicons size={30} style={style('buttonIcon')} name="add" />
94
- </TouchableHighlight>
95
- </>
96
- );
97
- }
1
+ import { Ionicons } from '@expo/vector-icons';
2
+ import { useState } from 'react';
3
+ import { ChildType, Utils } from 'react-crud-utils';
4
+ import { Text, TouchableHighlight, View } from 'react-native';
5
+
6
+ export default function UIQuantity(props: ChildType) {
7
+ const scope = props.scope;
8
+ const element = scope.original;
9
+
10
+ let [index, setIndex] = useState(0);
11
+
12
+ const value = scope.getValue(0);
13
+
14
+ let color = element.color;
15
+
16
+ if (!color) color = 'primary';
17
+
18
+ const btn = {
19
+ padding: 10,
20
+ alignItems: 'center',
21
+ height: 44,
22
+ width: 44,
23
+ textAlign: 'center',
24
+ verticalAling: 'middle',
25
+ borderRadius: 24,
26
+ backgroundColor: color,
27
+ color: '#ffffff',
28
+ justifyContent: 'center',
29
+ };
30
+
31
+ const styles: any = {
32
+ buttonLabel: {
33
+ color: '#ffffff',
34
+ fontWeight: '500',
35
+ fontSize: 16,
36
+ },
37
+ value: {
38
+ flex: 1,
39
+ flexDirection: 'row',
40
+ textAlign: 'center',
41
+ },
42
+ buttonInner: {
43
+ flexDirection: 'row',
44
+ alignItems: 'center',
45
+ justifyContent: 'center',
46
+ },
47
+ buttonIcon: {
48
+ color: '#fff',
49
+ fontSize: 18,
50
+ },
51
+ button: btn,
52
+ addButton: {
53
+ ...btn,
54
+ },
55
+ delButton: {
56
+ ...btn,
57
+ },
58
+ };
59
+
60
+ const change = (val: number) => {
61
+ scope.changeValue(value + val);
62
+ setIndex(++index);
63
+ };
64
+
65
+ const onClickAdd = () => {
66
+ change(1);
67
+ };
68
+
69
+ const onClickDel = () => {
70
+ change(-1);
71
+ };
72
+
73
+ const style = (part: string, extra?: any) => {
74
+ let s = { ...styles[part], ...extra };
75
+ return scope.getStyle(part, s);
76
+ };
77
+
78
+ return (
79
+ <>
80
+ <TouchableHighlight
81
+ underlayColor={'transparent'}
82
+ onPress={onClickDel}
83
+ style={style('delButton')}
84
+ >
85
+ <Ionicons size={30} style={style('buttonIcon')} name="remove" />
86
+ </TouchableHighlight>
87
+ <Text style={style('value')}>{Utils.nvl(value, 0)}</Text>
88
+ <TouchableHighlight
89
+ underlayColor={'transparent'}
90
+ onPress={onClickAdd}
91
+ style={style('addButton')}
92
+ >
93
+ <Ionicons size={30} style={style('buttonIcon')} name="add" />
94
+ </TouchableHighlight>
95
+ </>
96
+ );
97
+ }
@@ -1,17 +1,17 @@
1
- import { Text, TouchableOpacity, Linking, StyleSheet } from 'react-native';
2
-
3
- export default function UIRadio(props: any) {
4
- const handlePress = () => {
5
- Linking.openURL('https://reactnative.dev/');
6
- };
7
-
8
- return (
9
- <TouchableOpacity onPress={handlePress}>
10
- <Text style={styles.link}>Clique aqui para acessar o React Native</Text>
11
- </TouchableOpacity>
12
- );
13
- }
14
-
15
- const styles = {
16
- link: {},
17
- };
1
+ import { Text, TouchableOpacity, Linking, StyleSheet } from 'react-native';
2
+
3
+ export default function UIRadio(props: any) {
4
+ const handlePress = () => {
5
+ Linking.openURL('https://reactnative.dev/');
6
+ };
7
+
8
+ return (
9
+ <TouchableOpacity onPress={handlePress}>
10
+ <Text style={styles.link}>Clique aqui para acessar o React Native</Text>
11
+ </TouchableOpacity>
12
+ );
13
+ }
14
+
15
+ const styles = {
16
+ link: {},
17
+ };