react-crud-mobile 1.3.1 → 1.3.3
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 +5 -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 +5 -1
- package/dist/react-crud-mobile.esm.js.map +1 -1
- package/package.json +75 -75
- package/src/elements/UI.tsx +73 -73
- package/src/elements/UIChildren.tsx +139 -139
- package/src/elements/UIComplete.tsx +14 -14
- package/src/elements/UIElement.tsx +696 -692
- package/src/elements/UITag.tsx +13 -13
- package/src/elements/charts/ElChart.tsx +10 -10
- package/src/elements/core/SafeView.tsx +69 -69
- package/src/elements/core/UIAutoComplete.tsx +17 -17
- package/src/elements/core/UIButton.tsx +139 -139
- package/src/elements/core/UIIcon.tsx +25 -25
- package/src/elements/core/UIInclude.tsx +40 -40
- package/src/elements/core/UIInput.tsx +96 -96
- package/src/elements/core/UILink.tsx +17 -17
- package/src/elements/core/UIList.tsx +168 -168
- package/src/elements/core/UIListItem.tsx +32 -32
- package/src/elements/core/UIListRow.tsx +123 -123
- package/src/elements/core/UIModal.tsx +204 -204
- package/src/elements/core/UIOption.tsx +17 -17
- package/src/elements/core/UIQuantity.tsx +98 -98
- package/src/elements/core/UIRadio.tsx +17 -17
- package/src/elements/core/UISelect.tsx +135 -135
- package/src/elements/core/UISlider.tsx +61 -61
- package/src/elements/core/UISwitch.tsx +27 -27
- package/src/elements/core/UIToast.tsx +44 -44
- package/src/elements/core/UIToggle.tsx +102 -102
- package/src/elements/core/UIView.tsx +94 -94
- 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
- package/src/utils/MobileUtils.ts +12 -12
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
import React, { useRef, useState } from 'react';
|
|
2
|
-
import { ChildType, ScopeUtils, Utils } from 'react-crud-utils';
|
|
3
|
-
import UIChildren from '../UIChildren';
|
|
4
|
-
import { StyleSheet, TouchableHighlight, View } from 'react-native';
|
|
5
|
-
import { useIsVisible } from '../../hooks/useIsVisible';
|
|
6
|
-
|
|
7
|
-
interface UIListRowType extends ChildType {
|
|
8
|
-
item: any;
|
|
9
|
-
index: number;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export default function UIListRow(props: UIListRowType) {
|
|
13
|
-
const scope = props.scope;
|
|
14
|
-
const index = props.index;
|
|
15
|
-
const original = scope.original;
|
|
16
|
-
const item = props.item;
|
|
17
|
-
const cols = scope.getPart('cols', undefined, -1);
|
|
18
|
-
const rowWidth = Math.floor(100 / cols) + '%';
|
|
19
|
-
const styles = { repeat: stylesRepeat, list: stylesList }?.[original.type];
|
|
20
|
-
const name = `${scope.key('row', index, '')}`;
|
|
21
|
-
const [row] = useState(
|
|
22
|
-
ScopeUtils.create({
|
|
23
|
-
...original,
|
|
24
|
-
parent: scope,
|
|
25
|
-
name,
|
|
26
|
-
crud: scope.crud,
|
|
27
|
-
index,
|
|
28
|
-
type: 'row',
|
|
29
|
-
data: item,
|
|
30
|
-
})
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
const targetRef = useRef(null);
|
|
34
|
-
const isVisible = useIsVisible(targetRef, row);
|
|
35
|
-
|
|
36
|
-
const onClick = (item: any) => {
|
|
37
|
-
row.call('click', { value: item, item, edit: true, index });
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const Child = () => {
|
|
41
|
-
if (!isVisible && original.useIsInView && !row.visible && index > 20) {
|
|
42
|
-
return <></>;
|
|
43
|
-
}
|
|
44
|
-
return (
|
|
45
|
-
<>
|
|
46
|
-
<UIChildren scope={row} crud={row.crud}>
|
|
47
|
-
{props.children}
|
|
48
|
-
</UIChildren>
|
|
49
|
-
</>
|
|
50
|
-
);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const ListItem = () => {
|
|
54
|
-
let [updateIndex, setUpdateIndex] = useState(0);
|
|
55
|
-
let key = scope.key('item');
|
|
56
|
-
|
|
57
|
-
const getRowStyle = () => {
|
|
58
|
-
let css = row.getStyle('row', { ...styles.row, minHeight: 40 });
|
|
59
|
-
|
|
60
|
-
if (cols > 0) {
|
|
61
|
-
css.width = rowWidth;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return css;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
row.update = () => {
|
|
68
|
-
scope.updateIndex = scope.updateIndex + 1;
|
|
69
|
-
|
|
70
|
-
setUpdateIndex(++updateIndex);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
let renderedRow = row.getPart('renderedItem', undefined, true);
|
|
74
|
-
|
|
75
|
-
if (renderedRow === false) {
|
|
76
|
-
return <></>;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (!original.click) {
|
|
80
|
-
return (
|
|
81
|
-
<View key={key} style={getRowStyle()} ref={targetRef}>
|
|
82
|
-
<Child />
|
|
83
|
-
</View>
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
return (
|
|
87
|
-
<TouchableHighlight
|
|
88
|
-
key={key}
|
|
89
|
-
style={getRowStyle()}
|
|
90
|
-
underlayColor={'transparent'}
|
|
91
|
-
ref={targetRef}
|
|
92
|
-
onPress={e => {
|
|
93
|
-
e.stopPropagation();
|
|
94
|
-
onClick(item);
|
|
95
|
-
}}
|
|
96
|
-
>
|
|
97
|
-
<Child />
|
|
98
|
-
</TouchableHighlight>
|
|
99
|
-
);
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
return <ListItem />;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const stylesList = StyleSheet.create({
|
|
106
|
-
row: {
|
|
107
|
-
padding: 5,
|
|
108
|
-
margin: 0,
|
|
109
|
-
width: '100%',
|
|
110
|
-
backgroundColor: 'background',
|
|
111
|
-
gap: 10,
|
|
112
|
-
borderRadius: 8,
|
|
113
|
-
justifyContent: 'center',
|
|
114
|
-
},
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
const stylesRepeat = StyleSheet.create({
|
|
118
|
-
row: {
|
|
119
|
-
padding: 0,
|
|
120
|
-
width: '100%',
|
|
121
|
-
justifyContent: 'center',
|
|
122
|
-
},
|
|
123
|
-
});
|
|
1
|
+
import React, { useRef, useState } from 'react';
|
|
2
|
+
import { ChildType, ScopeUtils, Utils } from 'react-crud-utils';
|
|
3
|
+
import UIChildren from '../UIChildren';
|
|
4
|
+
import { StyleSheet, TouchableHighlight, View } from 'react-native';
|
|
5
|
+
import { useIsVisible } from '../../hooks/useIsVisible';
|
|
6
|
+
|
|
7
|
+
interface UIListRowType extends ChildType {
|
|
8
|
+
item: any;
|
|
9
|
+
index: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default function UIListRow(props: UIListRowType) {
|
|
13
|
+
const scope = props.scope;
|
|
14
|
+
const index = props.index;
|
|
15
|
+
const original = scope.original;
|
|
16
|
+
const item = props.item;
|
|
17
|
+
const cols = scope.getPart('cols', undefined, -1);
|
|
18
|
+
const rowWidth = Math.floor(100 / cols) + '%';
|
|
19
|
+
const styles = { repeat: stylesRepeat, list: stylesList }?.[original.type];
|
|
20
|
+
const name = `${scope.key('row', index, '')}`;
|
|
21
|
+
const [row] = useState(
|
|
22
|
+
ScopeUtils.create({
|
|
23
|
+
...original,
|
|
24
|
+
parent: scope,
|
|
25
|
+
name,
|
|
26
|
+
crud: scope.crud,
|
|
27
|
+
index,
|
|
28
|
+
type: 'row',
|
|
29
|
+
data: item,
|
|
30
|
+
})
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const targetRef = useRef(null);
|
|
34
|
+
const isVisible = useIsVisible(targetRef, row);
|
|
35
|
+
|
|
36
|
+
const onClick = (item: any) => {
|
|
37
|
+
row.call('click', { value: item, item, edit: true, index });
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const Child = () => {
|
|
41
|
+
if (!isVisible && original.useIsInView && !row.visible && index > 20) {
|
|
42
|
+
return <></>;
|
|
43
|
+
}
|
|
44
|
+
return (
|
|
45
|
+
<>
|
|
46
|
+
<UIChildren scope={row} crud={row.crud}>
|
|
47
|
+
{props.children}
|
|
48
|
+
</UIChildren>
|
|
49
|
+
</>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const ListItem = () => {
|
|
54
|
+
let [updateIndex, setUpdateIndex] = useState(0);
|
|
55
|
+
let key = scope.key('item');
|
|
56
|
+
|
|
57
|
+
const getRowStyle = () => {
|
|
58
|
+
let css = row.getStyle('row', { ...styles.row, minHeight: 40 });
|
|
59
|
+
|
|
60
|
+
if (cols > 0) {
|
|
61
|
+
css.width = rowWidth;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return css;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
row.update = () => {
|
|
68
|
+
scope.updateIndex = scope.updateIndex + 1;
|
|
69
|
+
|
|
70
|
+
setUpdateIndex(++updateIndex);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
let renderedRow = row.getPart('renderedItem', undefined, true);
|
|
74
|
+
|
|
75
|
+
if (renderedRow === false) {
|
|
76
|
+
return <></>;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (!original.click) {
|
|
80
|
+
return (
|
|
81
|
+
<View key={key} style={getRowStyle()} ref={targetRef}>
|
|
82
|
+
<Child />
|
|
83
|
+
</View>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
return (
|
|
87
|
+
<TouchableHighlight
|
|
88
|
+
key={key}
|
|
89
|
+
style={getRowStyle()}
|
|
90
|
+
underlayColor={'transparent'}
|
|
91
|
+
ref={targetRef}
|
|
92
|
+
onPress={e => {
|
|
93
|
+
e.stopPropagation();
|
|
94
|
+
onClick(item);
|
|
95
|
+
}}
|
|
96
|
+
>
|
|
97
|
+
<Child />
|
|
98
|
+
</TouchableHighlight>
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
return <ListItem />;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const stylesList = StyleSheet.create({
|
|
106
|
+
row: {
|
|
107
|
+
padding: 5,
|
|
108
|
+
margin: 0,
|
|
109
|
+
width: '100%',
|
|
110
|
+
backgroundColor: 'background',
|
|
111
|
+
gap: 10,
|
|
112
|
+
borderRadius: 8,
|
|
113
|
+
justifyContent: 'center',
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
const stylesRepeat = StyleSheet.create({
|
|
118
|
+
row: {
|
|
119
|
+
padding: 0,
|
|
120
|
+
width: '100%',
|
|
121
|
+
justifyContent: 'center',
|
|
122
|
+
},
|
|
123
|
+
});
|
|
@@ -1,204 +1,204 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
ChildType,
|
|
4
|
-
ComponentUtils,
|
|
5
|
-
CrudUtils,
|
|
6
|
-
MethodType,
|
|
7
|
-
useTheme,
|
|
8
|
-
Utils,
|
|
9
|
-
ViewUtils,
|
|
10
|
-
} from 'react-crud-utils';
|
|
11
|
-
import {
|
|
12
|
-
Text,
|
|
13
|
-
TouchableOpacity,
|
|
14
|
-
StyleSheet,
|
|
15
|
-
Modal,
|
|
16
|
-
View,
|
|
17
|
-
StatusBar,
|
|
18
|
-
SafeAreaView,
|
|
19
|
-
ScrollView,
|
|
20
|
-
} from 'react-native';
|
|
21
|
-
import UIChildren from '../UIChildren';
|
|
22
|
-
import Ionicons from '@expo/vector-icons/Ionicons';
|
|
23
|
-
import UIToast from './UIToast';
|
|
24
|
-
import MobileUtils from '../../utils/MobileUtils';
|
|
25
|
-
|
|
26
|
-
export default function UIModal(props: ChildType) {
|
|
27
|
-
let [modalVisible, setModalVisible] = useState(false);
|
|
28
|
-
let [index, setIndex] = useState(0);
|
|
29
|
-
let main = ViewUtils.getCrud('view');
|
|
30
|
-
|
|
31
|
-
const scope = props.scope;
|
|
32
|
-
const label = scope.getLabel();
|
|
33
|
-
const theme = scope.getTheme();
|
|
34
|
-
const headerStyle = Utils.nvl(theme.styles?.defaults?.header, {});
|
|
35
|
-
const scrollRef = useRef(null);
|
|
36
|
-
|
|
37
|
-
const style = (part: string, extra?: any) => {
|
|
38
|
-
let st = { ...styles[part], ...extra };
|
|
39
|
-
|
|
40
|
-
return { ...scope.getStyle(part, st) };
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const onClose = () => {
|
|
44
|
-
scope.close({ scope, crud: scope.currentDialog, event: {} });
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const toggle = vis => {
|
|
48
|
-
modalVisible = vis;
|
|
49
|
-
setModalVisible(modalVisible);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
scope.update = () => {
|
|
53
|
-
setIndex(++index);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
scope.dialogShow = (args?: MethodType) => {
|
|
57
|
-
let { crud } = args;
|
|
58
|
-
let name = scope.getName('modal');
|
|
59
|
-
let edit = args.edit === true;
|
|
60
|
-
let def: any = {};
|
|
61
|
-
let rowItem = null;
|
|
62
|
-
|
|
63
|
-
if (crud.is('row')) {
|
|
64
|
-
def.parent = crud.parent.parent;
|
|
65
|
-
def.search = crud.parent;
|
|
66
|
-
|
|
67
|
-
rowItem = crud.data;
|
|
68
|
-
} else if (crud.is('search')) {
|
|
69
|
-
def.parent = crud.parent;
|
|
70
|
-
def.search = crud;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
let data = Utils.nvl(args.item, rowItem, {});
|
|
74
|
-
|
|
75
|
-
let d = CrudUtils.create('dialog', {
|
|
76
|
-
parent: crud,
|
|
77
|
-
root: crud,
|
|
78
|
-
name,
|
|
79
|
-
dialog: main.dialog,
|
|
80
|
-
data,
|
|
81
|
-
edit,
|
|
82
|
-
scope,
|
|
83
|
-
...def,
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
main.dialog = d;
|
|
87
|
-
|
|
88
|
-
scope.currentDialog = d;
|
|
89
|
-
|
|
90
|
-
toggle(true);
|
|
91
|
-
scope.update();
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
scope.dialogHide = (args?: MethodType) => {
|
|
95
|
-
let old = scope.currentDialog;
|
|
96
|
-
|
|
97
|
-
main.dialog = Utils.nvl(old.dialog, null);
|
|
98
|
-
scope.currentDialog = null;
|
|
99
|
-
|
|
100
|
-
toggle(false);
|
|
101
|
-
|
|
102
|
-
if (main.dialog?.scope) {
|
|
103
|
-
main.dialog.scope.update();
|
|
104
|
-
}
|
|
105
|
-
scope.update();
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
useEffect(() => {
|
|
109
|
-
MobileUtils.syncTheme();
|
|
110
|
-
}, [modalVisible]);
|
|
111
|
-
|
|
112
|
-
let curr = scope.currentDialog;
|
|
113
|
-
|
|
114
|
-
if (!curr) {
|
|
115
|
-
return <></>;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (curr.uuid !== main.dialog?.uuid) {
|
|
119
|
-
return <></>;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const headerRight = ComponentUtils.getDefine(props, 'header', 'right');
|
|
123
|
-
|
|
124
|
-
scope.put('scrollRef', scrollRef);
|
|
125
|
-
|
|
126
|
-
ComponentUtils.setViewScope(scope);
|
|
127
|
-
|
|
128
|
-
let color = Utils.nvl(headerStyle.color, 'white');
|
|
129
|
-
let defaults = { color };
|
|
130
|
-
|
|
131
|
-
return (
|
|
132
|
-
<Modal
|
|
133
|
-
animationType="slide"
|
|
134
|
-
transparent={true}
|
|
135
|
-
visible={modalVisible}
|
|
136
|
-
onRequestClose={onClose}
|
|
137
|
-
>
|
|
138
|
-
<SafeAreaView style={style('modalTop')} />
|
|
139
|
-
<SafeAreaView style={style('modalSafe')}>
|
|
140
|
-
<View style={scope.getStyle('header', headerStyle)}>
|
|
141
|
-
<TouchableOpacity onPress={onClose} style={style('modalCloseButton')}>
|
|
142
|
-
<Ionicons
|
|
143
|
-
name="chevron-back-outline"
|
|
144
|
-
size={24}
|
|
145
|
-
color={color}
|
|
146
|
-
style={style('modalCloseText', defaults)}
|
|
147
|
-
/>
|
|
148
|
-
</TouchableOpacity>
|
|
149
|
-
<Text style={style('modalTitle', defaults)}>{label}</Text>
|
|
150
|
-
{!Utils.isEmpty(headerRight) && (
|
|
151
|
-
<UIChildren scope={scope} crud={scope.currentDialog} transient>
|
|
152
|
-
{headerRight}
|
|
153
|
-
</UIChildren>
|
|
154
|
-
)}
|
|
155
|
-
</View>
|
|
156
|
-
<ScrollView
|
|
157
|
-
contentContainerStyle={{ flexGrow: 1, paddingBottom: 50 }}
|
|
158
|
-
style={style('modalContent')}
|
|
159
|
-
nestedScrollEnabled={true}
|
|
160
|
-
ref={scrollRef}
|
|
161
|
-
>
|
|
162
|
-
<View style={{ flex: 1 }}>
|
|
163
|
-
<UIChildren scope={scope} crud={scope.currentDialog}>
|
|
164
|
-
{props.children}
|
|
165
|
-
</UIChildren>
|
|
166
|
-
</View>
|
|
167
|
-
</ScrollView>
|
|
168
|
-
</SafeAreaView>
|
|
169
|
-
<UIToast />
|
|
170
|
-
</Modal>
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const styles = StyleSheet.create({
|
|
175
|
-
modalTop: {
|
|
176
|
-
backgroundColor: 'primary',
|
|
177
|
-
width: '100%',
|
|
178
|
-
},
|
|
179
|
-
modalSafe: {
|
|
180
|
-
flex: 1,
|
|
181
|
-
width: '100%',
|
|
182
|
-
backgroundColor: 'background',
|
|
183
|
-
},
|
|
184
|
-
modalCloseButton: {
|
|
185
|
-
padding: 10,
|
|
186
|
-
},
|
|
187
|
-
modalCloseText: {
|
|
188
|
-
fontSize: 18,
|
|
189
|
-
color: 'white',
|
|
190
|
-
},
|
|
191
|
-
modalTitle: {
|
|
192
|
-
fontSize: 18,
|
|
193
|
-
fontWeight: 'bold',
|
|
194
|
-
marginLeft: 10,
|
|
195
|
-
},
|
|
196
|
-
modalContent: {
|
|
197
|
-
flex: 1,
|
|
198
|
-
backgroundColor: 'background',
|
|
199
|
-
paddingTop: 10,
|
|
200
|
-
paddingBottom: 10,
|
|
201
|
-
paddingLeft: 15,
|
|
202
|
-
paddingRight: 15,
|
|
203
|
-
},
|
|
204
|
-
});
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
ChildType,
|
|
4
|
+
ComponentUtils,
|
|
5
|
+
CrudUtils,
|
|
6
|
+
MethodType,
|
|
7
|
+
useTheme,
|
|
8
|
+
Utils,
|
|
9
|
+
ViewUtils,
|
|
10
|
+
} from 'react-crud-utils';
|
|
11
|
+
import {
|
|
12
|
+
Text,
|
|
13
|
+
TouchableOpacity,
|
|
14
|
+
StyleSheet,
|
|
15
|
+
Modal,
|
|
16
|
+
View,
|
|
17
|
+
StatusBar,
|
|
18
|
+
SafeAreaView,
|
|
19
|
+
ScrollView,
|
|
20
|
+
} from 'react-native';
|
|
21
|
+
import UIChildren from '../UIChildren';
|
|
22
|
+
import Ionicons from '@expo/vector-icons/Ionicons';
|
|
23
|
+
import UIToast from './UIToast';
|
|
24
|
+
import MobileUtils from '../../utils/MobileUtils';
|
|
25
|
+
|
|
26
|
+
export default function UIModal(props: ChildType) {
|
|
27
|
+
let [modalVisible, setModalVisible] = useState(false);
|
|
28
|
+
let [index, setIndex] = useState(0);
|
|
29
|
+
let main = ViewUtils.getCrud('view');
|
|
30
|
+
|
|
31
|
+
const scope = props.scope;
|
|
32
|
+
const label = scope.getLabel();
|
|
33
|
+
const theme = scope.getTheme();
|
|
34
|
+
const headerStyle = Utils.nvl(theme.styles?.defaults?.header, {});
|
|
35
|
+
const scrollRef = useRef(null);
|
|
36
|
+
|
|
37
|
+
const style = (part: string, extra?: any) => {
|
|
38
|
+
let st = { ...styles[part], ...extra };
|
|
39
|
+
|
|
40
|
+
return { ...scope.getStyle(part, st) };
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const onClose = () => {
|
|
44
|
+
scope.close({ scope, crud: scope.currentDialog, event: {} });
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const toggle = vis => {
|
|
48
|
+
modalVisible = vis;
|
|
49
|
+
setModalVisible(modalVisible);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
scope.update = () => {
|
|
53
|
+
setIndex(++index);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
scope.dialogShow = (args?: MethodType) => {
|
|
57
|
+
let { crud } = args;
|
|
58
|
+
let name = scope.getName('modal');
|
|
59
|
+
let edit = args.edit === true;
|
|
60
|
+
let def: any = {};
|
|
61
|
+
let rowItem = null;
|
|
62
|
+
|
|
63
|
+
if (crud.is('row')) {
|
|
64
|
+
def.parent = crud.parent.parent;
|
|
65
|
+
def.search = crud.parent;
|
|
66
|
+
|
|
67
|
+
rowItem = crud.data;
|
|
68
|
+
} else if (crud.is('search')) {
|
|
69
|
+
def.parent = crud.parent;
|
|
70
|
+
def.search = crud;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
let data = Utils.nvl(args.item, rowItem, {});
|
|
74
|
+
|
|
75
|
+
let d = CrudUtils.create('dialog', {
|
|
76
|
+
parent: crud,
|
|
77
|
+
root: crud,
|
|
78
|
+
name,
|
|
79
|
+
dialog: main.dialog,
|
|
80
|
+
data,
|
|
81
|
+
edit,
|
|
82
|
+
scope,
|
|
83
|
+
...def,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
main.dialog = d;
|
|
87
|
+
|
|
88
|
+
scope.currentDialog = d;
|
|
89
|
+
|
|
90
|
+
toggle(true);
|
|
91
|
+
scope.update();
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
scope.dialogHide = (args?: MethodType) => {
|
|
95
|
+
let old = scope.currentDialog;
|
|
96
|
+
|
|
97
|
+
main.dialog = Utils.nvl(old.dialog, null);
|
|
98
|
+
scope.currentDialog = null;
|
|
99
|
+
|
|
100
|
+
toggle(false);
|
|
101
|
+
|
|
102
|
+
if (main.dialog?.scope) {
|
|
103
|
+
main.dialog.scope.update();
|
|
104
|
+
}
|
|
105
|
+
scope.update();
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
MobileUtils.syncTheme();
|
|
110
|
+
}, [modalVisible]);
|
|
111
|
+
|
|
112
|
+
let curr = scope.currentDialog;
|
|
113
|
+
|
|
114
|
+
if (!curr) {
|
|
115
|
+
return <></>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (curr.uuid !== main.dialog?.uuid) {
|
|
119
|
+
return <></>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const headerRight = ComponentUtils.getDefine(props, 'header', 'right');
|
|
123
|
+
|
|
124
|
+
scope.put('scrollRef', scrollRef);
|
|
125
|
+
|
|
126
|
+
ComponentUtils.setViewScope(scope);
|
|
127
|
+
|
|
128
|
+
let color = Utils.nvl(headerStyle.color, 'white');
|
|
129
|
+
let defaults = { color };
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<Modal
|
|
133
|
+
animationType="slide"
|
|
134
|
+
transparent={true}
|
|
135
|
+
visible={modalVisible}
|
|
136
|
+
onRequestClose={onClose}
|
|
137
|
+
>
|
|
138
|
+
<SafeAreaView style={style('modalTop')} />
|
|
139
|
+
<SafeAreaView style={style('modalSafe')}>
|
|
140
|
+
<View style={scope.getStyle('header', headerStyle)}>
|
|
141
|
+
<TouchableOpacity onPress={onClose} style={style('modalCloseButton')}>
|
|
142
|
+
<Ionicons
|
|
143
|
+
name="chevron-back-outline"
|
|
144
|
+
size={24}
|
|
145
|
+
color={color}
|
|
146
|
+
style={style('modalCloseText', defaults)}
|
|
147
|
+
/>
|
|
148
|
+
</TouchableOpacity>
|
|
149
|
+
<Text style={style('modalTitle', defaults)}>{label}</Text>
|
|
150
|
+
{!Utils.isEmpty(headerRight) && (
|
|
151
|
+
<UIChildren scope={scope} crud={scope.currentDialog} transient>
|
|
152
|
+
{headerRight}
|
|
153
|
+
</UIChildren>
|
|
154
|
+
)}
|
|
155
|
+
</View>
|
|
156
|
+
<ScrollView
|
|
157
|
+
contentContainerStyle={{ flexGrow: 1, paddingBottom: 50 }}
|
|
158
|
+
style={style('modalContent')}
|
|
159
|
+
nestedScrollEnabled={true}
|
|
160
|
+
ref={scrollRef}
|
|
161
|
+
>
|
|
162
|
+
<View style={{ flex: 1 }}>
|
|
163
|
+
<UIChildren scope={scope} crud={scope.currentDialog}>
|
|
164
|
+
{props.children}
|
|
165
|
+
</UIChildren>
|
|
166
|
+
</View>
|
|
167
|
+
</ScrollView>
|
|
168
|
+
</SafeAreaView>
|
|
169
|
+
<UIToast />
|
|
170
|
+
</Modal>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const styles = StyleSheet.create({
|
|
175
|
+
modalTop: {
|
|
176
|
+
backgroundColor: 'primary',
|
|
177
|
+
width: '100%',
|
|
178
|
+
},
|
|
179
|
+
modalSafe: {
|
|
180
|
+
flex: 1,
|
|
181
|
+
width: '100%',
|
|
182
|
+
backgroundColor: 'background',
|
|
183
|
+
},
|
|
184
|
+
modalCloseButton: {
|
|
185
|
+
padding: 10,
|
|
186
|
+
},
|
|
187
|
+
modalCloseText: {
|
|
188
|
+
fontSize: 18,
|
|
189
|
+
color: 'white',
|
|
190
|
+
},
|
|
191
|
+
modalTitle: {
|
|
192
|
+
fontSize: 18,
|
|
193
|
+
fontWeight: 'bold',
|
|
194
|
+
marginLeft: 10,
|
|
195
|
+
},
|
|
196
|
+
modalContent: {
|
|
197
|
+
flex: 1,
|
|
198
|
+
backgroundColor: 'background',
|
|
199
|
+
paddingTop: 10,
|
|
200
|
+
paddingBottom: 10,
|
|
201
|
+
paddingLeft: 15,
|
|
202
|
+
paddingRight: 15,
|
|
203
|
+
},
|
|
204
|
+
});
|
|
@@ -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
|
+
};
|