react-crud-mobile 1.0.520 → 1.0.522

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,63 +1,63 @@
1
- import {
2
- Keyboard,
3
- KeyboardAvoidingView,
4
- Platform,
5
- StatusBar,
6
- StyleProp,
7
- TouchableWithoutFeedback,
8
- ViewStyle,
9
- } from 'react-native';
10
- import {
11
- SafeAreaProvider,
12
- SafeAreaView as SafeAreaContextView,
13
- } from 'react-native-safe-area-context';
14
- import { useTheme } from 'react-crud-utils';
15
- import { useEffect } from 'react';
16
-
17
- interface SafeViewType {
18
- safeStyle?: StyleProp<ViewStyle> | any;
19
- viewStyle?: StyleProp<ViewStyle> | any;
20
- children?: any;
21
- }
22
-
23
- export default function SafeView(props: SafeViewType) {
24
- const theme = useTheme();
25
- const dismissKeyboard = () => {
26
- if (Platform.OS !== 'web') {
27
- Keyboard.dismiss();
28
- }
29
- };
30
-
31
- useEffect(() => {
32
- StatusBar.setBarStyle('light-content');
33
- StatusBar.setBackgroundColor?.(theme.colors.primary);
34
- }, []);
35
-
36
- return (
37
- <SafeAreaProvider>
38
- <StatusBar barStyle="light-content" />
39
- <SafeAreaContextView
40
- style={{
41
- backgroundColor: theme.colors?.primary,
42
- ...props.viewStyle,
43
- flex: 1,
44
- }}
45
- >
46
- <KeyboardAvoidingView
47
- behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
48
- style={{
49
- flex: 1, // 🔹 Ocupa 100% da tela
50
- justifyContent: 'center',
51
- }}
52
- >
53
- <TouchableWithoutFeedback
54
- onPress={dismissKeyboard}
55
- accessible={false}
56
- >
57
- <>{props.children}</>
58
- </TouchableWithoutFeedback>
59
- </KeyboardAvoidingView>
60
- </SafeAreaContextView>
61
- </SafeAreaProvider>
62
- );
63
- }
1
+ import {
2
+ Keyboard,
3
+ KeyboardAvoidingView,
4
+ Platform,
5
+ StatusBar,
6
+ StyleProp,
7
+ TouchableWithoutFeedback,
8
+ ViewStyle,
9
+ } from 'react-native';
10
+ import {
11
+ SafeAreaProvider,
12
+ SafeAreaView as SafeAreaContextView,
13
+ } from 'react-native-safe-area-context';
14
+ import { useTheme } from 'react-crud-utils';
15
+ import { useEffect } from 'react';
16
+
17
+ interface SafeViewType {
18
+ safeStyle?: StyleProp<ViewStyle> | any;
19
+ viewStyle?: StyleProp<ViewStyle> | any;
20
+ children?: any;
21
+ }
22
+
23
+ export default function SafeView(props: SafeViewType) {
24
+ const theme = useTheme();
25
+ const dismissKeyboard = () => {
26
+ if (Platform.OS !== 'web') {
27
+ Keyboard.dismiss();
28
+ }
29
+ };
30
+
31
+ useEffect(() => {
32
+ StatusBar.setBarStyle('light-content');
33
+ StatusBar.setBackgroundColor?.(theme.colors.primary);
34
+ }, []);
35
+
36
+ return (
37
+ <SafeAreaProvider>
38
+ <StatusBar barStyle="light-content" />
39
+ <SafeAreaContextView
40
+ style={{
41
+ backgroundColor: theme.colors?.primary,
42
+ ...props.viewStyle,
43
+ flex: 1,
44
+ }}
45
+ >
46
+ <KeyboardAvoidingView
47
+ behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
48
+ style={{
49
+ flex: 1, // 🔹 Ocupa 100% da tela
50
+ justifyContent: 'center',
51
+ }}
52
+ >
53
+ <TouchableWithoutFeedback
54
+ onPress={dismissKeyboard}
55
+ accessible={false}
56
+ >
57
+ <>{props.children}</>
58
+ </TouchableWithoutFeedback>
59
+ </KeyboardAvoidingView>
60
+ </SafeAreaContextView>
61
+ </SafeAreaProvider>
62
+ );
63
+ }
@@ -1,17 +1,17 @@
1
- import { Text, TouchableOpacity, Linking, StyleSheet } from 'react-native';
2
-
3
- export default function UIAutoComplete(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 UIAutoComplete(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,17 +1,17 @@
1
- import { Text, TouchableOpacity, Linking, StyleSheet } from 'react-native';
2
-
3
- export default function UILink(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 UILink(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,5 +1,5 @@
1
1
  import React, { useState } from 'react';
2
- import { ChildType, Utils } from 'react-crud-utils';
2
+ import { ChildType, ComponentUtils, Utils } from 'react-crud-utils';
3
3
  import { StyleSheet, Text, TouchableHighlight, View } from 'react-native';
4
4
  import UIListRow from './UIListRow';
5
5
  import UI from '../UI';
@@ -13,6 +13,8 @@ export default function UIList(props: ChildType) {
13
13
  const rowWidth = Math.floor(100 / cols) + '%';
14
14
  const items = Utils.nvl(scope.getItems(), []);
15
15
  const styles = { repeat: stylesRepeat, list: stylesList }?.[original.type];
16
+ const add = ComponentUtils.getDefine(props, 'add');
17
+ const hideAddWhenEmpty = original.hideAddWhenEmpty;
16
18
 
17
19
  const onClick = (item: any) => {
18
20
  scope.call('click', { value: item, item, edit: true });
@@ -42,6 +44,13 @@ export default function UIList(props: ChildType) {
42
44
  return row;
43
45
  };
44
46
 
47
+ const isShowAdd = () => {
48
+ if (!Utils.isEmpty(items)) {
49
+ return true;
50
+ }
51
+ return hideAddWhenEmpty !== true;
52
+ };
53
+
45
54
  let Empty = () => {
46
55
  if (!Utils.isEmpty(items)) {
47
56
  return <></>;
@@ -96,13 +105,12 @@ export default function UIList(props: ChildType) {
96
105
  onClick(item);
97
106
  }}
98
107
  >
99
- <View style={getStyle('rowInner')}>
100
- <UIListRow scope={scope} item={item} index={i}>
101
- {props.children}
102
- </UIListRow>
103
- </View>
108
+ <UIListRow scope={scope} item={item} index={i}>
109
+ {props.children}
110
+ </UIListRow>
104
111
  </TouchableHighlight>
105
112
  ))}
113
+ {isShowAdd() && <>{add}</>}
106
114
  </View>
107
115
  </>
108
116
  );
@@ -1,32 +1,32 @@
1
- import { useState } from 'react';
2
- import { ChildType, Utils } from 'react-crud-utils';
3
- import { FlatList, StyleSheet, Switch, Text, View } from 'react-native';
4
-
5
- interface UIListItemType extends ChildType {
6
- data: any;
7
- }
8
-
9
- export default function UIListItem(props: UIListItemType) {
10
- const scope = props.scope;
11
- const crud = props.crud;
12
-
13
- return <View style={styles.item}></View>;
14
- }
15
-
16
- const styles = StyleSheet.create({
17
- container: {
18
- flex: 1,
19
- padding: 20,
20
- backgroundColor: '#fff',
21
- },
22
- item: {
23
- padding: 15,
24
- marginVertical: 8,
25
- backgroundColor: '#f9c2ff',
26
- borderRadius: 8,
27
- },
28
- text: {
29
- fontSize: 18,
30
- fontWeight: 'bold',
31
- },
32
- });
1
+ import { useState } from 'react';
2
+ import { ChildType, Utils } from 'react-crud-utils';
3
+ import { FlatList, StyleSheet, Switch, Text, View } from 'react-native';
4
+
5
+ interface UIListItemType extends ChildType {
6
+ data: any;
7
+ }
8
+
9
+ export default function UIListItem(props: UIListItemType) {
10
+ const scope = props.scope;
11
+ const crud = props.crud;
12
+
13
+ return <View style={styles.item}></View>;
14
+ }
15
+
16
+ const styles = StyleSheet.create({
17
+ container: {
18
+ flex: 1,
19
+ padding: 20,
20
+ backgroundColor: '#fff',
21
+ },
22
+ item: {
23
+ padding: 15,
24
+ marginVertical: 8,
25
+ backgroundColor: '#f9c2ff',
26
+ borderRadius: 8,
27
+ },
28
+ text: {
29
+ fontSize: 18,
30
+ fontWeight: 'bold',
31
+ },
32
+ });
@@ -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,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
+ };
@@ -1,26 +1,26 @@
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
- onValueChange={onChange} // Alterna o estado
20
- />
21
- );
22
- }
23
-
24
- const styles = {
25
- link: {},
26
- };
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
+ onValueChange={onChange} // Alterna o estado
20
+ />
21
+ );
22
+ }
23
+
24
+ const styles = {
25
+ link: {},
26
+ };