@eohjsc/react-native-smart-city 0.4.74 → 0.4.76

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.4.74",
4
+ "version": "0.4.76",
5
5
  "description": "TODO",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -138,7 +138,6 @@
138
138
  "lottie-react-native": "4.0.3",
139
139
  "moment": "^2.27.0",
140
140
  "moment-timezone": "^0.5.32",
141
- "mqtt": "^5.0.5",
142
141
  "numeral": "^2.0.6",
143
142
  "patch-package": "^6.2.2",
144
143
  "pluralize": "^8.0.0",
@@ -127,7 +127,7 @@ const ItemDevice = memo(
127
127
  size={14}
128
128
  color={Colors.Gray9}
129
129
  style={
130
- Platform.OS === 'ios' ? styles.lineHeight22 : styles.marginBottom
130
+ Platform.OS === 'ios' ? styles.iosStyle : styles.androidStyle
131
131
  }
132
132
  >
133
133
  {title}
@@ -163,11 +163,13 @@ const styles = StyleSheet.create({
163
163
  justifyContent: 'space-between',
164
164
  alignItems: 'center',
165
165
  },
166
- marginBottom: {
167
- marginBottom: 8,
166
+ iosStyle: {
167
+ lineHeight: 22,
168
168
  },
169
- lineHeight22: {
169
+ androidStyle: {
170
170
  lineHeight: 22,
171
+ includeFontPadding: false,
172
+ marginBottom: 8,
171
173
  },
172
174
  lineHeight20: {
173
175
  lineHeight: 20,
@@ -4,18 +4,32 @@ import Text from '../Text';
4
4
  import { Colors } from '../../configs';
5
5
  import React, { memo } from 'react';
6
6
  import { StyleSheet } from 'react-native';
7
+ import moment from 'moment';
8
+ import AccessibilityLabel from '../../configs/AccessibilityLabel';
7
9
 
8
10
  const styles = StyleSheet.create({
9
11
  txtLastUpdate: {
10
- marginLeft: 8,
11
12
  lineHeight: 20,
12
- marginTop: 8,
13
+ marginTop: 6,
13
14
  },
14
15
  });
15
16
 
16
- const LastUpdatedText = memo(({ lastUpdated, showText }) => {
17
+ const LastUpdatedText = memo(({ lastUpdated, showText, format = null }) => {
17
18
  const t = useTranslations();
18
19
 
20
+ if (format === 'DDMMYYYY') {
21
+ const dayMonthYear = moment(lastUpdated).format('HH:mm DD-MM-YYYY');
22
+ return (
23
+ <Text
24
+ accessibilityLabel={AccessibilityLabel.LAST_UPDATED_TEXT}
25
+ color={Colors.Gray7}
26
+ size={12}
27
+ style={styles.txtLastUpdate}
28
+ >
29
+ {dayMonthYear}
30
+ </Text>
31
+ );
32
+ }
19
33
  const lastUpdatedStr = lastUpdated
20
34
  ? timeDifference(new Date(), lastUpdated)
21
35
  : `5 ${t('seconds_ago')}`;
@@ -25,7 +25,6 @@ const MenuActionList = memo(
25
25
  return (
26
26
  <TouchableOpacity
27
27
  accessibilityLabel={AccessibilityLabel.MENU_ACTION_LIST_TOUCHABLE}
28
- testID={AccessibilityLabel.MENU_ACTION_LIST_TOUCHABLE}
29
28
  onPress={onPress(item)}
30
29
  style={styles.item}
31
30
  >
@@ -4,29 +4,40 @@ import { View } from 'react-native';
4
4
  import Text from '../../../Text';
5
5
  import LastUpdatedText from '../../../Device/LastUpdatedText';
6
6
  import { EvaluationConfigWrapper } from '../EvaluationOverConfig/EvaluationOverConfig';
7
+ import IconComponent from '../../../IconComponent';
8
+ import { IconOutline } from '@ant-design/icons-react-native';
7
9
 
8
10
  const ConfigAndEvaluationDisplay = memo(
9
- ({ valueEvaluation, stationItem, configValue }) => {
11
+ ({ device, valueEvaluation, stationItem, configValue }) => {
12
+ const { icon_kit, icon } = device || {};
10
13
  return (
11
14
  <>
12
15
  <View>
13
16
  <View style={styles.rowTop}>
14
- <Text type="H4" bold>
15
- {stationItem?.configuration?.config_data?.name}
17
+ <IconComponent icon={icon_kit || icon} />
18
+ </View>
19
+ <View style={styles.rowTop}>
20
+ <Text bold>{stationItem?.configuration?.config_data?.name}</Text>
21
+ </View>
22
+ <View style={styles.rowBottom}>
23
+ <Text style={styles.textValue} bold>
24
+ {configValue?.value}{' '}
25
+ {stationItem?.configuration?.config_data?.unit}
16
26
  </Text>
17
27
  </View>
18
- <Text type="Body" color={valueEvaluation?.color}>
28
+ <Text style={styles.textStatus} color={valueEvaluation?.color}>
19
29
  {valueEvaluation?.text}
20
30
  </Text>
21
31
  </View>
22
- <View style={styles.rowBottom}>
23
- <Text style={styles.textValue} bold>
24
- {configValue?.value || '-'}
25
- </Text>
26
- <Text type="H4">{stationItem?.configuration?.config_data?.unit}</Text>
27
- </View>
32
+
28
33
  {configValue?.last_updated && (
29
- <LastUpdatedText lastUpdated={configValue?.last_updated} />
34
+ <View style={styles.lastUpdate}>
35
+ <LastUpdatedText
36
+ lastUpdated={configValue?.last_updated}
37
+ format={'DDMMYYYY'}
38
+ />
39
+ <IconOutline style={styles.marginTop10} name="right" size={12} />
40
+ </View>
30
41
  )}
31
42
  </>
32
43
  );
@@ -5,6 +5,8 @@ import Text from '../../../Text';
5
5
  import { useConfigGlobalState } from '../../../../iot/states';
6
6
  import { useWatchConfigs } from '../../../../hooks/IoT';
7
7
  import LastUpdatedText from '../../../Device/LastUpdatedText';
8
+ import IconComponent from '../../../IconComponent';
9
+ import { IconOutline } from '@ant-design/icons-react-native';
8
10
 
9
11
  const ConfigValue = ({ device, stationItem }) => {
10
12
  // eslint-disable-next-line no-unused-vars
@@ -13,27 +15,33 @@ const ConfigValue = ({ device, stationItem }) => {
13
15
  const configIds = useMemo(() => {
14
16
  return [stationItem.configuration?.config];
15
17
  }, [stationItem.configuration?.config]);
16
-
18
+ const { icon_kit, icon } = device || {};
17
19
  useWatchConfigs(configIds);
18
20
 
19
21
  return (
20
22
  <>
21
23
  <View>
22
24
  <View style={styles.rowTop}>
23
- <Text type="H4" bold>
24
- {stationItem?.configuration?.config_data?.name}
25
+ <IconComponent icon={icon_kit || icon} />
26
+ </View>
27
+ <View style={styles.rowTop}>
28
+ <Text bold>{stationItem?.configuration?.config_data?.name}</Text>
29
+ </View>
30
+ <View style={styles.rowBottom}>
31
+ <Text style={styles.textValue} bold>
32
+ {configValue?.value} {stationItem?.configuration?.config_data?.unit}
25
33
  </Text>
26
34
  </View>
35
+ {configValue?.last_updated && (
36
+ <View style={styles.lastUpdate}>
37
+ <LastUpdatedText
38
+ lastUpdated={configValue?.last_updated}
39
+ format={'DDMMYYYY'}
40
+ />
41
+ <IconOutline style={styles.marginTop10} name="right" size={12} />
42
+ </View>
43
+ )}
27
44
  </View>
28
- <View style={styles.rowBottom}>
29
- <Text style={styles.textValue} bold>
30
- {configValue?.value || '-'}
31
- </Text>
32
- <Text type="H4">{stationItem?.configuration?.config_data?.unit}</Text>
33
- </View>
34
- {configValue?.last_updated && (
35
- <LastUpdatedText lastUpdated={configValue?.last_updated} />
36
- )}
37
45
  </>
38
46
  );
39
47
  };
@@ -9,6 +9,8 @@ import {
9
9
  } from '../../../../screens/Device/hooks/useEvaluateValue';
10
10
  import { useWatchConfigs } from '../../../../hooks/IoT';
11
11
  import LastUpdatedText from '../../../Device/LastUpdatedText';
12
+ import IconComponent from '../../../IconComponent';
13
+ import { IconOutline } from '@ant-design/icons-react-native';
12
14
 
13
15
  export const EvaluationConfigWrapper = memo(
14
16
  ({ device, stationItem, Child }) => {
@@ -31,9 +33,9 @@ export const EvaluationConfigWrapper = memo(
31
33
  configValue?.value,
32
34
  valueEvaluationObject
33
35
  );
34
-
35
36
  return (
36
37
  <Child
38
+ device={device}
37
39
  valueEvaluation={valueEvaluation}
38
40
  stationItem={stationItem}
39
41
  configValue={configValue}
@@ -43,24 +45,34 @@ export const EvaluationConfigWrapper = memo(
43
45
  );
44
46
 
45
47
  const EvaluationOverConfigDisplay = memo(
46
- ({ valueEvaluation, stationItem, configValue }) => {
48
+ ({ device, valueEvaluation, stationItem, configValue }) => {
49
+ const { icon_kit, icon } = device || {};
47
50
  return (
48
51
  <>
49
52
  <View>
50
53
  <View style={styles.rowTop}>
51
- <Text type="H4" bold>
52
- {stationItem?.configuration?.config_data?.name}
54
+ <IconComponent icon={icon_kit || icon} />
55
+ </View>
56
+ <View style={styles.rowTop}>
57
+ <Text bold>{stationItem?.configuration?.config_data?.name}</Text>
58
+ </View>
59
+
60
+ <View style={styles.rowBottom}>
61
+ <Text style={styles.textValue} bold color={valueEvaluation?.color}>
62
+ {valueEvaluation?.text}
53
63
  </Text>
54
64
  </View>
65
+
66
+ {configValue?.last_updated && (
67
+ <View style={styles.lastUpdate}>
68
+ <LastUpdatedText
69
+ lastUpdated={configValue?.last_updated}
70
+ format={'DDMMYYYY'}
71
+ />
72
+ <IconOutline style={styles.marginTop10} name="right" size={12} />
73
+ </View>
74
+ )}
55
75
  </View>
56
- <View style={styles.rowBottom}>
57
- <Text style={styles.textValue} bold color={valueEvaluation?.color}>
58
- {valueEvaluation?.text}
59
- </Text>
60
- </View>
61
- {configValue?.last_updated && (
62
- <LastUpdatedText lastUpdated={configValue?.last_updated} />
63
- )}
64
76
  </>
65
77
  );
66
78
  }
@@ -16,8 +16,19 @@ export default StyleSheet.create({
16
16
  alignItems: 'center',
17
17
  },
18
18
  textValue: {
19
- fontSize: 28,
20
- lineHeight: 32,
21
- marginRight: 8,
19
+ marginTop: 6,
20
+ lineHeight: 16,
21
+ },
22
+ textStatus: {
23
+ marginTop: 6,
24
+ fontSize: 12,
25
+ },
26
+ lastUpdate: {
27
+ flexDirection: 'row',
28
+ justifyContent: 'space-between',
29
+ alignItems: 'center',
30
+ },
31
+ marginTop10: {
32
+ marginTop: 10,
22
33
  },
23
34
  });
@@ -13,6 +13,7 @@ import ItemDevice from '../../Device/ItemDevice';
13
13
  import { DeviceTemplate } from '../DeviceTemplate/DeviceTemplate';
14
14
  import ItemHanetDevice from '../../Device/Hanet/ItemHanetDevice';
15
15
  import { watchMultiConfigs } from '../../../iot/Monitor';
16
+ import Text from '../../Text';
16
17
 
17
18
  jest.mock('../../../iot/Monitor');
18
19
 
@@ -37,6 +38,9 @@ jest.mock('@react-navigation/native', () => {
37
38
  useFocusEffect: jest.fn((handler) => handler()),
38
39
  };
39
40
  });
41
+ jest.mock('../../../iot/states', () => ({
42
+ useConfigGlobalState: () => [{}, null],
43
+ }));
40
44
 
41
45
  describe('test ShortDetail Subunit', () => {
42
46
  let tree, props;
@@ -189,6 +193,18 @@ describe('test ShortDetail Subunit', () => {
189
193
  ['ConfigAndEvaluation', 'ConfigValue', 'EvaluationOverConfig'].forEach(
190
194
  (template) => {
191
195
  it(`render with device template ${template}`, async () => {
196
+ const globalStates = require('../../../iot/states');
197
+ globalStates.useConfigGlobalState = () => [
198
+ {
199
+ 1: {
200
+ value: 10,
201
+ status: null,
202
+ last_updated: '2023-10-10T04:36:04.010471Z',
203
+ status_of_value: 'NO_CHANGE',
204
+ },
205
+ },
206
+ null,
207
+ ];
192
208
  props.station.devices = [
193
209
  {
194
210
  action: {
@@ -203,14 +219,18 @@ describe('test ShortDetail Subunit', () => {
203
219
  icon: '',
204
220
  id: 1,
205
221
  name: 'People Counting',
222
+ icon_kit: 'https://xxx.png',
206
223
  quick_action: null,
207
- remote_control_options: {},
208
224
  station: {},
209
225
  status: null,
210
226
  status2: null,
211
227
  station_items: [
212
228
  {
213
229
  template: template,
230
+ configuration: {
231
+ config: 1,
232
+ config_data: { id: 29520, name: 'Moving', unit: '' },
233
+ },
214
234
  },
215
235
  ],
216
236
  },
@@ -222,6 +242,14 @@ describe('test ShortDetail Subunit', () => {
222
242
  const instance = tree.root;
223
243
  const itemDevices = instance.findAllByType(DeviceTemplate);
224
244
  expect(itemDevices.length).toBe(1);
245
+
246
+ const lastUpdate = instance.findAll(
247
+ (el) =>
248
+ el.props.accessibilityLabel ===
249
+ `${AccessibilityLabel.LAST_UPDATED_TEXT}` && el.type === Text
250
+ );
251
+ expect(lastUpdate).toHaveLength(1);
252
+ expect(lastUpdate[0].props.children).toEqual('05:36 10-10-2023');
225
253
  });
226
254
  }
227
255
  );
@@ -684,4 +684,7 @@ export default {
684
684
 
685
685
  //MemberInfo
686
686
  CHANGE_ROLE: 'CHANGE_ROLE',
687
+
688
+ //LastUpdatedText
689
+ LAST_UPDATED_TEXT: 'LAST_UPDATED_TEXT',
687
690
  };
@@ -722,7 +722,6 @@ const DeviceDetail = ({ route }) => {
722
722
  loading.displayTemplate === false &&
723
723
  loading.isConnected === false &&
724
724
  isNetworkConnected !== null;
725
-
726
725
  return (
727
726
  <View style={styles.wrap}>
728
727
  <WrapHeaderScrollable