react-crud-mobile 1.1.3 → 1.3.2
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/elements/UI.d.ts +47 -0
- package/dist/elements/UIChildren.d.ts +15 -0
- package/dist/elements/UIComplete.d.ts +3 -0
- package/dist/elements/UIElement.d.ts +3 -0
- package/dist/elements/UITag.d.ts +7 -0
- package/dist/elements/charts/ElChart.d.ts +3 -0
- package/dist/elements/core/SafeView.d.ts +9 -0
- package/dist/elements/core/UIAutoComplete.d.ts +2 -0
- package/dist/elements/core/UIButton.d.ts +3 -0
- package/dist/elements/core/UIIcon.d.ts +3 -0
- package/dist/elements/core/UIInclude.d.ts +3 -0
- package/dist/elements/core/UIInput.d.ts +3 -0
- package/dist/elements/core/UILink.d.ts +2 -0
- package/dist/elements/core/UIList.d.ts +3 -0
- package/dist/elements/core/UIListItem.d.ts +7 -0
- package/dist/elements/core/UIListRow.d.ts +8 -0
- package/dist/elements/core/UIModal.d.ts +3 -0
- package/dist/elements/core/UIOption.d.ts +2 -0
- package/dist/elements/core/UIQuantity.d.ts +3 -0
- package/dist/elements/core/UIRadio.d.ts +2 -0
- package/dist/elements/core/UISelect.d.ts +3 -0
- package/dist/elements/core/UISlider.d.ts +3 -0
- package/dist/elements/core/UISwitch.d.ts +3 -0
- package/dist/elements/core/UIToast.d.ts +2 -0
- package/dist/elements/core/UIToggle.d.ts +3 -0
- package/dist/elements/core/UIView.d.ts +3 -0
- package/dist/elements/index.d.ts +1 -0
- package/dist/elements/tabs/ElTabs.d.ts +3 -0
- package/dist/hooks/useIsVisible.d.ts +2 -0
- package/dist/index.d.ts +1 -2
- package/dist/react-crud-mobile.cjs.development.js +2367 -0
- package/dist/react-crud-mobile.cjs.development.js.map +1 -0
- package/dist/react-crud-mobile.cjs.production.min.js +2 -0
- package/dist/react-crud-mobile.cjs.production.min.js.map +1 -0
- package/dist/react-crud-mobile.esm.js +2359 -0
- package/dist/react-crud-mobile.esm.js.map +1 -0
- package/dist/utils/MobileUtils.d.ts +3 -0
- package/package.json +54 -30
- package/src/elements/UI.tsx +34 -18
- package/src/elements/UIChildren.tsx +38 -16
- package/src/elements/UIComplete.tsx +1 -2
- package/src/elements/UIElement.tsx +542 -225
- package/src/elements/core/SafeView.tsx +69 -0
- package/src/elements/core/{Link.tsx → UIAutoComplete.tsx} +17 -18
- package/src/elements/core/UIButton.tsx +139 -0
- package/src/elements/core/UIIcon.tsx +25 -0
- package/src/elements/{grid/ElInclude.tsx → core/UIInclude.tsx} +3 -3
- package/src/elements/core/UIInput.tsx +96 -0
- package/src/elements/core/{Icon.tsx → UILink.tsx} +17 -18
- package/src/elements/core/UIList.tsx +168 -0
- package/src/elements/core/UIListItem.tsx +32 -0
- package/src/elements/core/UIListRow.tsx +123 -0
- package/src/elements/core/UIModal.tsx +204 -0
- package/src/elements/core/{Input.tsx → UIOption.tsx} +17 -18
- package/src/elements/core/UIQuantity.tsx +98 -0
- package/src/elements/core/{Radio.tsx → UIRadio.tsx} +17 -18
- package/src/elements/core/UISelect.tsx +135 -0
- package/src/elements/core/UISlider.tsx +61 -0
- package/src/elements/core/UISwitch.tsx +27 -0
- package/src/elements/core/UIToast.tsx +44 -0
- package/src/elements/core/UIToggle.tsx +102 -0
- package/src/elements/core/UIView.tsx +94 -0
- package/src/elements/grid/ElInclude +0 -0
- package/src/hooks/useIsVisible.ts +39 -0
- package/src/index.ts +1 -1
- package/src/utils/MobileUtils.ts +12 -0
- package/src/elements/card/ElCard.tsx +0 -26
- package/src/elements/core/AutoComplete.tsx +0 -18
- package/src/elements/core/Button.tsx +0 -18
- package/src/elements/core/Option.tsx +0 -18
- package/src/elements/core/Select.tsx +0 -18
- package/src/elements/core/Switch.tsx +0 -18
- package/src/elements/grid/ElGrid.tsx +0 -50
- package/src/elements/grid/ElGridBotom.tsx +0 -21
- package/src/elements/grid/ElGridCheck.tsx +0 -67
- package/src/elements/grid/ElGridColumn.tsx +0 -32
- package/src/elements/grid/ElGridFilter.tsx +0 -5
- package/src/elements/grid/ElGridPaginator.tsx +0 -82
- package/src/elements/grid/ElGridRow.tsx +0 -123
- package/src/elements/grid/ElGridTop.tsx +0 -45
- package/src/elements/grid/ElLabel.tsx +0 -50
- package/src/elements/grid/ElRepeat.tsx +0 -24
- package/src/elements/grid/ElRepeatRow.tsx +0 -40
|
@@ -0,0 +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
|
+
});
|
|
@@ -0,0 +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,18 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
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
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
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: 0,
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
height: 30,
|
|
22
|
+
width: 30,
|
|
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
|
+
fontWeight: '500',
|
|
42
|
+
},
|
|
43
|
+
buttonInner: {
|
|
44
|
+
flexDirection: 'row',
|
|
45
|
+
alignItems: 'center',
|
|
46
|
+
justifyContent: 'center',
|
|
47
|
+
},
|
|
48
|
+
buttonIcon: {
|
|
49
|
+
color: '#fff',
|
|
50
|
+
fontSize: 18,
|
|
51
|
+
},
|
|
52
|
+
button: btn,
|
|
53
|
+
addButton: {
|
|
54
|
+
...btn,
|
|
55
|
+
},
|
|
56
|
+
delButton: {
|
|
57
|
+
...btn,
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const change = (val: number) => {
|
|
62
|
+
scope.changeValue(value + val);
|
|
63
|
+
setIndex(++index);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const onClickAdd = () => {
|
|
67
|
+
change(1);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const onClickDel = () => {
|
|
71
|
+
change(-1);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const style = (part: string, extra?: any) => {
|
|
75
|
+
let s = { ...styles[part], ...extra };
|
|
76
|
+
return scope.getStyle(part, s);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<>
|
|
81
|
+
<TouchableHighlight
|
|
82
|
+
underlayColor={'transparent'}
|
|
83
|
+
onPress={onClickDel}
|
|
84
|
+
style={style('delButton')}
|
|
85
|
+
>
|
|
86
|
+
<Ionicons size={30} style={style('buttonIcon')} name="remove" />
|
|
87
|
+
</TouchableHighlight>
|
|
88
|
+
<Text style={style('value')}>{Utils.nvl(value, 0)}</Text>
|
|
89
|
+
<TouchableHighlight
|
|
90
|
+
underlayColor={'transparent'}
|
|
91
|
+
onPress={onClickAdd}
|
|
92
|
+
style={style('addButton')}
|
|
93
|
+
>
|
|
94
|
+
<Ionicons size={30} style={style('buttonIcon')} name="add" />
|
|
95
|
+
</TouchableHighlight>
|
|
96
|
+
</>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
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
|
+
};
|
|
@@ -0,0 +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: 5,
|
|
99
|
+
paddingHorizontal: 15,
|
|
100
|
+
paddingVertical: 10,
|
|
101
|
+
},
|
|
102
|
+
selectLabel: { flex: 1 },
|
|
103
|
+
modalSafe: {
|
|
104
|
+
flex: 1,
|
|
105
|
+
backgroundColor: 'background',
|
|
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
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { ChildType, ComponentUtils, Utils } from 'react-crud-utils';
|
|
3
|
+
import { Switch } from 'react-native';
|
|
4
|
+
import Slider from '@react-native-community/slider';
|
|
5
|
+
|
|
6
|
+
export default function UISlider(props: ChildType) {
|
|
7
|
+
const scope = props.scope;
|
|
8
|
+
const initial = Utils.nvl(scope.getValue(), 0);
|
|
9
|
+
const [value, setValue] = useState(initial);
|
|
10
|
+
|
|
11
|
+
//redeploy 0
|
|
12
|
+
|
|
13
|
+
let onChange = v => {
|
|
14
|
+
v = Utils.nvl(v, 0);
|
|
15
|
+
|
|
16
|
+
console.log(v);
|
|
17
|
+
|
|
18
|
+
scope.changeValue(v);
|
|
19
|
+
|
|
20
|
+
setValue(v);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
let step = scope.attr('step', 1);
|
|
24
|
+
let min = scope.attr('min', 0);
|
|
25
|
+
let max = scope.attr('min', 100);
|
|
26
|
+
|
|
27
|
+
let onSlideScroll = (scrollEnabled: boolean) => {
|
|
28
|
+
let viewScope = ComponentUtils.getViewScope();
|
|
29
|
+
|
|
30
|
+
if (scope.original.debug) {
|
|
31
|
+
console.log(viewScope);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (viewScope) {
|
|
35
|
+
let scrollRef = viewScope.get('scrollRef');
|
|
36
|
+
|
|
37
|
+
if (scrollRef) scrollRef.current?.setNativeProps?.({ scrollEnabled });
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
return (
|
|
41
|
+
<>
|
|
42
|
+
<Slider
|
|
43
|
+
minimumValue={min}
|
|
44
|
+
maximumValue={max}
|
|
45
|
+
step={step}
|
|
46
|
+
minimumTrackTintColor="#1EB1FC"
|
|
47
|
+
maximumTrackTintColor="#d3d3d3"
|
|
48
|
+
thumbTintColor="#1EB1FC"
|
|
49
|
+
value={value}
|
|
50
|
+
onSlidingStart={() => onSlideScroll(false)}
|
|
51
|
+
onSlidingComplete={() => onSlideScroll(true)}
|
|
52
|
+
style={{ width: '100%', height: 40, ...scope.getStyle('element') }}
|
|
53
|
+
onValueChange={onChange} // Alterna o estado
|
|
54
|
+
/>
|
|
55
|
+
</>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const styles = {
|
|
60
|
+
link: {},
|
|
61
|
+
};
|