react-crud-mobile 1.3.73 → 1.3.75

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.3.73",
2
+ "version": "1.3.75",
3
3
  "license": "MIT",
4
4
  "description": "Uma biblioteca de componentes para React Native",
5
5
  "main": "dist/index.js",
@@ -0,0 +1,38 @@
1
+ import { Text, View } from 'react-native';
2
+
3
+ import { ChildType, HtmlUtils, Utils } from 'react-crud-utils';
4
+
5
+ export default function UIHeader({ scope }: ChildType) {
6
+ const theme = scope.getTheme();
7
+ const header = scope.getPart('header', null, []);
8
+ const headerStyle = Utils.nvl(theme.styles?.defaults?.header, {});
9
+ const headerTextStyle = Utils.nvl(theme.styles?.defaults?.headerText, {});
10
+
11
+ let headerStyleFull = Utils.call(() => {
12
+ let css = scope.getStyle('header', headerStyle);
13
+ let bg = css.backgroundColor;
14
+
15
+ if (bg) {
16
+ css.color = HtmlUtils.getTextColor(bg);
17
+ }
18
+ return css;
19
+ });
20
+
21
+ let hasHeader = !Utils.isEmpty(header);
22
+ let AuxHeader = () => {
23
+ if (typeof header === 'string') {
24
+ return <Text style={headerTextStyle}>{header}</Text>;
25
+ }
26
+ return <>{header}</>;
27
+ };
28
+
29
+ return (
30
+ <>
31
+ {hasHeader && (
32
+ <View style={headerStyleFull}>
33
+ <AuxHeader />
34
+ </View>
35
+ )}
36
+ </>
37
+ );
38
+ }
@@ -7,6 +7,7 @@ import DraggableFlatList, {
7
7
  ScaleDecorator,
8
8
  } from 'react-native-draggable-flatlist';
9
9
  import { GestureHandlerRootView } from 'react-native-gesture-handler';
10
+ import UIHeader from './UIHeader';
10
11
 
11
12
  export default function UIOrder(props: ChildType) {
12
13
  const scope = props.scope;
@@ -91,6 +92,7 @@ export default function UIOrder(props: ChildType) {
91
92
  ...scope.getStyle('order', { justifyContent: 'flex-start' }),
92
93
  }}
93
94
  >
95
+ <UIHeader scope={scope} />
94
96
  <DraggableFlatList
95
97
  data={data}
96
98
  renderItem={renderItem}
@@ -1,4 +1,4 @@
1
- import { useEffect, useRef, useState } from 'react';
1
+ import { useRef, useState } from 'react';
2
2
  import { ChildType, MethodType, Utils, ViewUtils } from 'react-crud-utils';
3
3
  import {
4
4
  Text,
@@ -6,13 +6,11 @@ import {
6
6
  StyleSheet,
7
7
  Modal,
8
8
  View,
9
- StatusBar,
10
9
  SafeAreaView,
11
10
  ScrollView,
12
11
  } from 'react-native';
13
12
  import { Ionicons } from '@expo/vector-icons';
14
13
  import UI from '../UI';
15
- import MobileUtils from '../../utils/MobileUtils';
16
14
 
17
15
  export default function UISelect(props: ChildType) {
18
16
  const [modalVisible, setModalVisible] = useState(false);
@@ -56,10 +54,6 @@ export default function UISelect(props: ChildType) {
56
54
  };
57
55
  //v4
58
56
 
59
- useEffect(() => {
60
- MobileUtils.syncTheme();
61
- }, [modalVisible]);
62
-
63
57
  return (
64
58
  <View
65
59
  key={scope.getName(`${scope.getPart('modal')}_${modalVisible}`)}
@@ -1,29 +1,15 @@
1
1
  import { ScrollView, StyleSheet, Text, View } from 'react-native';
2
2
 
3
3
  import UIChildren from '../UIChildren';
4
- import {
5
- ChildType,
6
- ComponentUtils,
7
- HtmlUtils,
8
- Utils,
9
- ViewUtils,
10
- } from 'react-crud-utils';
11
- import { useEffect, useRef } from 'react';
4
+ import { ChildType, ComponentUtils, Utils, ViewUtils } from 'react-crud-utils';
5
+ import { useRef } from 'react';
12
6
  import UIToast from './UIToast';
13
- import MobileUtils from '../../utils/MobileUtils';
7
+ import UIHeader from './UIHeader';
14
8
 
15
9
  export default function UIView({ scope, children }: ChildType) {
16
- const theme = scope.getTheme();
17
- const header = scope.getPart('header', null, []);
18
- const headerStyle = Utils.nvl(theme.styles?.defaults?.header, {});
19
- const headerTextStyle = Utils.nvl(theme.styles?.defaults?.headerText, {});
20
10
  const scrollRef = useRef(null);
21
11
  const original = scope.original;
22
12
 
23
- useEffect(() => {
24
- MobileUtils.syncTheme();
25
- }, []);
26
-
27
13
  const onScroll = () => {
28
14
  const crud = ViewUtils.getCrud();
29
15
 
@@ -34,24 +20,6 @@ export default function UIView({ scope, children }: ChildType) {
34
20
  });
35
21
  };
36
22
 
37
- let headerStyleFull = Utils.call(() => {
38
- let css = scope.getStyle('header', headerStyle);
39
- let bg = css.backgroundColor;
40
-
41
- if (bg) {
42
- css.color = HtmlUtils.getTextColor(bg);
43
- }
44
- return css;
45
- });
46
-
47
- let hasHeader = !Utils.isEmpty(header);
48
- let AuxHeader = () => {
49
- if (typeof header === 'string') {
50
- return <Text style={headerTextStyle}>{header}</Text>;
51
- }
52
- return <>{header}</>;
53
- };
54
-
55
23
  scope.put('scrollRef', scrollRef);
56
24
 
57
25
  ComponentUtils.setViewScope(scope);
@@ -81,11 +49,7 @@ export default function UIView({ scope, children }: ChildType) {
81
49
  };
82
50
  return (
83
51
  <>
84
- {hasHeader && (
85
- <View style={headerStyleFull}>
86
- <AuxHeader />
87
- </View>
88
- )}
52
+ <UIHeader scope={scope} />
89
53
  <Container />
90
54
  <UIToast /> {/* <- este componente precisa estar aqui */}
91
55
  </>