@eohjsc/react-native-smart-city 0.2.63 → 0.2.67

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@eohjsc/react-native-smart-city",
3
3
  "title": "React Native Smart Home",
4
- "version": "0.2.63",
4
+ "version": "0.2.67",
5
5
  "description": "TODO",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -62,7 +62,11 @@ const ItemDevice = memo(
62
62
  <TouchableOpacity onPress={goToSensorDisplay}>
63
63
  {displayIconSensor()}
64
64
  </TouchableOpacity>
65
- <ItemQuickAction sensor={sensor} unit={unit} />
65
+ <ItemQuickAction
66
+ sensor={sensor}
67
+ unit={unit}
68
+ wrapperStyle={styles.iconCircle}
69
+ />
66
70
  </View>
67
71
  <TouchableOpacity onPress={goToSensorDisplay}>
68
72
  <Text
@@ -133,4 +137,12 @@ const styles = StyleSheet.create({
133
137
  height: 40,
134
138
  resizeMode: 'contain',
135
139
  },
140
+ iconCircle: {
141
+ width: 32,
142
+ height: 32,
143
+ backgroundColor: Colors.Gray3,
144
+ borderRadius: 16,
145
+ justifyContent: 'center',
146
+ alignItems: 'center',
147
+ },
136
148
  });
@@ -12,7 +12,7 @@ import Routes from '../utils/Route';
12
12
  const Stack = createStackNavigator();
13
13
  const SharedStack = memo(() => {
14
14
  const t = useTranslations();
15
- const navigation = useNavigation();
15
+ const { toggleDrawer, goBack } = useNavigation();
16
16
  const { params } = useRoute();
17
17
  return (
18
18
  <Stack.Navigator>
@@ -21,15 +21,17 @@ const SharedStack = memo(() => {
21
21
  component={Shared}
22
22
  options={{
23
23
  title: t('text_shared_with_me'),
24
- headerLeft: () =>
25
- params?.isMainSource && (
26
- <TouchableOpacity
27
- style={styles.btnMenu}
28
- onPress={() => navigation.toggleDrawer()}
29
- >
30
- <Icon name={'menu'} color={Colors.Black} />
31
- </TouchableOpacity>
32
- ),
24
+ headerLeft: () => (
25
+ <TouchableOpacity
26
+ style={styles.btnMenu}
27
+ onPress={() => (params?.isMainSource ? toggleDrawer() : goBack())}
28
+ >
29
+ <Icon
30
+ name={params?.isMainSource ? 'menu' : 'arrow-left'}
31
+ color={Colors.Black}
32
+ />
33
+ </TouchableOpacity>
34
+ ),
33
35
  headerTitleAlign: 'left',
34
36
  headerStyle: {
35
37
  backgroundColor: Colors.Gray2,
@@ -17,11 +17,13 @@ const AddCommonSelectSubUnit = ({ route }) => {
17
17
  const t = useTranslations();
18
18
  const navigation = useNavigation();
19
19
  const isFocused = useIsFocused();
20
- const { addType, unit_id } = route.params;
20
+ const { addType, unit_id, sensor_data, listSelectDevice, smart_account_id } =
21
+ route.params;
21
22
  const [selectedIndex, setSelectedIndex] = useState(-1);
22
23
  const [unit, setUnit] = useState([]);
23
24
  const [title, setTitle] = useState('');
24
25
  const [subTitle, setSubTitle] = useState('');
26
+ const [nameSubUnit, setNameSubUnit] = useState('');
25
27
 
26
28
  useEffect(() => {
27
29
  switch (addType) {
@@ -72,6 +74,10 @@ const AddCommonSelectSubUnit = ({ route }) => {
72
74
  navigation.navigate(Routes.SmartAccountConnecting, {
73
75
  listSensorIds: route.params.listSensorIds,
74
76
  station: subUnits[selectedIndex]?.id,
77
+ nameSubUnit: nameSubUnit,
78
+ sensor_data: sensor_data,
79
+ listSelectDevice: listSelectDevice,
80
+ smart_account_id: smart_account_id,
75
81
  });
76
82
  break;
77
83
  case 'AddVconnexDevice':
@@ -95,9 +101,14 @@ const AddCommonSelectSubUnit = ({ route }) => {
95
101
  unit?.name,
96
102
  unit.user_id,
97
103
  route.params,
104
+ nameSubUnit,
105
+ sensor_data,
106
+ listSelectDevice,
107
+ smart_account_id,
98
108
  ]);
99
109
 
100
110
  const handleSelectIndex = (index) => {
111
+ setNameSubUnit(subUnits[index].name);
101
112
  if (index !== selectedIndex) {
102
113
  setSelectedIndex(index);
103
114
  } else {
@@ -1,10 +1,15 @@
1
- import { StyleSheet } from 'react-native';
1
+ import { StyleSheet, StatusBar, Platform } from 'react-native';
2
2
  import { Colors } from '../../configs';
3
3
 
4
4
  export default StyleSheet.create({
5
5
  wrap: {
6
6
  flex: 1,
7
7
  backgroundColor: Colors.Gray2,
8
+ ...Platform.select({
9
+ android: {
10
+ paddingTop: StatusBar.currentHeight,
11
+ },
12
+ }),
8
13
  },
9
14
  textHeader: {
10
15
  marginTop: 16,
@@ -59,7 +59,7 @@ const AllCamera = () => {
59
59
  navigate(Routes.PlaybackCamera, { item, thumbnail });
60
60
  };
61
61
 
62
- const CameraItem = ({ item }) => {
62
+ const CameraItem = ({ item, width, height }) => {
63
63
  return (
64
64
  <View style={styles.wrap}>
65
65
  {!!item && (
@@ -74,6 +74,8 @@ const AllCamera = () => {
74
74
  amount={amount}
75
75
  handleFullScreen={handleFullScreen}
76
76
  goToPlayBack={goToPlayBack(item, thumbnail)}
77
+ width={width}
78
+ height={height}
77
79
  />
78
80
  )}
79
81
  </View>
@@ -88,12 +90,32 @@ const AllCamera = () => {
88
90
  ) : amount === 4 ? (
89
91
  <>
90
92
  <View style={styles.row}>
91
- <CameraItem key={item?.id} item={item[0]} />
92
- <CameraItem key={item?.id} item={item[1]} />
93
+ <CameraItem
94
+ key={item?.id}
95
+ item={item[0]}
96
+ width={188}
97
+ height={112}
98
+ />
99
+ <CameraItem
100
+ key={item?.id}
101
+ item={item[1]}
102
+ width={188}
103
+ height={112}
104
+ />
93
105
  </View>
94
106
  <View style={styles.row}>
95
- <CameraItem key={item?.id} item={item[2]} />
96
- <CameraItem key={item?.id} item={item[3]} />
107
+ <CameraItem
108
+ key={item?.id}
109
+ item={item[2]}
110
+ width={188}
111
+ height={112}
112
+ />
113
+ <CameraItem
114
+ key={item?.id}
115
+ item={item[3]}
116
+ width={188}
117
+ height={112}
118
+ />
97
119
  </View>
98
120
  </>
99
121
  ) : (
@@ -23,7 +23,7 @@ const EditDevice = memo(() => {
23
23
  const navigation = useNavigation();
24
24
  const { params = {} } = useRoute();
25
25
  const { sensor, setSensorNameDetail, sensorNameDetail } = params;
26
- const [inputName, setInputName] = useState('');
26
+ const [inputName, setInputName] = useState(sensorNameDetail || '');
27
27
  const [sensorName, setSensorName] = useState(sensorNameDetail || '');
28
28
  const { stateAlertAction, hideAlertAction, onShowRename, onShowDelete } =
29
29
  useEditDevice();
@@ -130,8 +130,8 @@ const EditDevice = memo(() => {
130
130
  >
131
131
  {!stateAlertAction.isDelete && (
132
132
  <_TextInput
133
- onChange={(text) => setInputName(text)}
134
- defaultValue={sensorName}
133
+ onChange={setInputName}
134
+ value={inputName}
135
135
  textInputStyle={styles.textInputStyle}
136
136
  wrapStyle={styles.textInputWrapStyle}
137
137
  selectionColor={Colors.Primary}
@@ -159,4 +159,7 @@ export default StyleSheet.create({
159
159
  paddingRight4: {
160
160
  paddingRight: 4,
161
161
  },
162
+ flex1: {
163
+ flex: 1,
164
+ },
162
165
  });
@@ -269,7 +269,12 @@ const ScriptDetail = ({ route }) => {
269
269
  >
270
270
  {item?.unit_name}
271
271
  </Text>
272
- <Text numberOfLines={1} type="Label" color={Colors.Gray7}>
272
+ <Text
273
+ numberOfLines={1}
274
+ type="Label"
275
+ color={Colors.Gray7}
276
+ style={styles.flex1}
277
+ >
273
278
  {item?.station_name}
274
279
  </Text>
275
280
  </View>
@@ -13,7 +13,6 @@ import {
13
13
  SafeAreaView,
14
14
  } from 'react-native';
15
15
  import { useNavigation } from '@react-navigation/native';
16
- import ImageResizer from 'react-native-image-resizer';
17
16
  import { useTranslations } from '../../hooks/Common/useTranslations';
18
17
 
19
18
  import { API, Colors } from '../../configs';
@@ -26,26 +25,6 @@ import { ToastBottomHelper } from '../../utils/Utils';
26
25
  import { TESTID } from '../../configs/Constants';
27
26
  import styles from './AddSubUnitStyles';
28
27
 
29
- const MAX_FILE_SIZE_BYTES = 1.5 * 1024 * 1024; // 1.5mb
30
-
31
- const prepareImageToUpload = async (image) => {
32
- if (!image || image.size < MAX_FILE_SIZE_BYTES) {
33
- return image;
34
- }
35
- const result = await ImageResizer.createResizedImage(
36
- image.path,
37
- 1280,
38
- 1280,
39
- 'JPEG',
40
- 70
41
- );
42
- return {
43
- fileName: result?.name,
44
- type: 'image/jpeg',
45
- uri: result?.uri,
46
- };
47
- };
48
-
49
28
  const AddSubUnit = ({ route }) => {
50
29
  const t = useTranslations();
51
30
  const { navigate, goBack } = useNavigation();
@@ -56,6 +35,13 @@ const AddSubUnit = ({ route }) => {
56
35
  const [showImagePicker, setShowImagePicker] = useState(false);
57
36
  let awaitCreate = useRef(false);
58
37
 
38
+ const cleanData = () => {
39
+ setRoomName('');
40
+ setWallpaper('');
41
+ setImageUrl('');
42
+ awaitCreate.current = false;
43
+ };
44
+
59
45
  const goDone = useCallback(async () => {
60
46
  if (isAddUnit) {
61
47
  if (!awaitCreate.current) {
@@ -65,7 +51,6 @@ const AddSubUnit = ({ route }) => {
65
51
  address: location,
66
52
  background: wallpaper,
67
53
  };
68
- dataObj.background = await prepareImageToUpload(dataObj.background);
69
54
  const formData = createFormData(dataObj, ['background']);
70
55
  const { success, data } = await axiosPost(
71
56
  API.UNIT.CREATE_UNIT(),
@@ -82,6 +67,7 @@ const AddSubUnit = ({ route }) => {
82
67
  routeName: Routes.DashboardStack,
83
68
  },
84
69
  });
70
+ cleanData();
85
71
  } else {
86
72
  awaitCreate.current = false;
87
73
  ToastBottomHelper.error(t('text_create_unit_fail'));
@@ -91,9 +77,8 @@ const AddSubUnit = ({ route }) => {
91
77
  if (!awaitCreate.current) {
92
78
  awaitCreate.current = true;
93
79
  const dataObj = { name: roomName, background: wallpaper };
94
- dataObj.background = await prepareImageToUpload(dataObj.background);
95
80
  const formData = createFormData(dataObj, ['background']);
96
- const { success, data } = await axiosPost(
81
+ const { success } = await axiosPost(
97
82
  API.SUB_UNIT.CREATE_SUB_UNIT(unit.id),
98
83
  formData,
99
84
  {
@@ -115,10 +100,12 @@ const AddSubUnit = ({ route }) => {
115
100
  screen: Routes.UnitDetail,
116
101
  params: {
117
102
  unitId: unit.id,
118
- unitData: data,
103
+ unitData: unit,
119
104
  isAddSubUnit: true,
105
+ routeName: Routes.DashboardStack,
120
106
  },
121
107
  });
108
+ cleanData();
122
109
  } else {
123
110
  awaitCreate.current = false;
124
111
  ToastBottomHelper.error(t('text_create_sub_unit_fail'));
@@ -188,6 +175,7 @@ const AddSubUnit = ({ route }) => {
188
175
  textInputStyle={styles.roomName}
189
176
  wrapStyle={styles.textInput}
190
177
  selectionColor={Colors.Primary}
178
+ value={roomName}
191
179
  />
192
180
 
193
181
  {isAddUnit && (
@@ -161,7 +161,8 @@ describe('Test AddSubUnit', () => {
161
161
  screen: Routes.UnitDetail,
162
162
  params: {
163
163
  unitId: route.params.unit.id,
164
- unitData: response.data,
164
+ unitData: route.params.unit,
165
+ routeName: 'DashboardStack',
165
166
  isAddSubUnit: true,
166
167
  },
167
168
  });
@@ -22,12 +22,12 @@ const TDSGuide = memo(() => {
22
22
  >
23
23
  {t('what_is_tds_title')}
24
24
  </Text>
25
- <Text type="Body">{t('what_is_tds_text')}</Text>
25
+ <Text style={styles.tdsText}>{t('what_is_tds_text')}</Text>
26
26
  <Text type="H3" semibold style={styles.titlePadding}>
27
27
  {t('tds_guidlines_title')}
28
28
  </Text>
29
29
  <>
30
- <Text type="Body">
30
+ <Text style={styles.tdsText}>
31
31
  {t('tds_guidlines_text_1')}
32
32
  {'\n'}
33
33
  {'\n'}
@@ -56,4 +56,7 @@ const styles = StyleSheet.create({
56
56
  paddingTop: 20,
57
57
  paddingBottom: 10,
58
58
  },
59
+ tdsText: {
60
+ fontSize: 15,
61
+ },
59
62
  });
@@ -30,7 +30,9 @@ import { AUTOMATE_TYPE } from '../../configs/Constants';
30
30
 
31
31
  const UnitDetail = ({ route }) => {
32
32
  const t = useTranslations();
33
+
33
34
  const { unitId, unitData, isOneTap, routeName, isAddSubUnit } = route.params;
35
+
34
36
  const isFocused = useIsFocused();
35
37
  const { stateData, setAction } = useContext(SCContext);
36
38
  const { navigate } = useNavigation();
@@ -253,13 +255,14 @@ const UnitDetail = ({ route }) => {
253
255
  };
254
256
 
255
257
  const renderDetailSubUnit = () => {
256
- if (station.isFavorites) {
258
+ if (station?.isFavorites) {
257
259
  return (
258
260
  <SubUnitFavorites
259
261
  unit={unit}
260
262
  isOwner={isOwner}
261
263
  favorites={favorites}
262
264
  wrapItemStyle={styles.wrapItemStyle}
265
+ isGGHomeConnected={isGGHomeConnected}
263
266
  />
264
267
  );
265
268
  }
@@ -450,9 +450,9 @@ const styles = StyleSheet.create({
450
450
  position: 'absolute',
451
451
  fontSize: 20,
452
452
  transform: [{ rotate: '90deg' }],
453
- left: -28,
453
+ left: -40,
454
454
  bottom: 8,
455
- width: 115,
455
+ width: 150,
456
456
  height: 28,
457
457
  textAlign: 'center',
458
458
  },
@@ -2,7 +2,6 @@ import axios from 'axios';
2
2
  import { deleteData, getData, storeData } from '../Storage';
3
3
  import { ToastBottomHelper } from '../Utils';
4
4
  import NetInfo from '@react-native-community/netinfo';
5
- import { Platform } from 'react-native';
6
5
 
7
6
  export const replaceParams = (apiURL, params) => {
8
7
  let _result = apiURL;
@@ -166,9 +165,9 @@ export function createFormData(data, list_file_field) {
166
165
  }
167
166
 
168
167
  formData.append(key, {
169
- uri: Platform.OS === 'ios' ? item.sourceURL : item.path,
170
- type: item.mime,
171
168
  name: item.filename || item.path?.split('/').pop(),
169
+ type: item.mime,
170
+ uri: item.path,
172
171
  });
173
172
  return;
174
173
  }