@eohjsc/react-native-smart-city 0.3.88 → 0.3.90

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.3.88",
4
+ "version": "0.3.90",
5
5
  "description": "TODO",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -46,7 +46,7 @@ const FlatListItems = memo(({ data, style, title, offsetTitle }) => {
46
46
  }
47
47
  return items.map((item, index) => (
48
48
  <QualityIndicatorItem
49
- key={item?.id}
49
+ key={(item?.id || index).toString()}
50
50
  standard={item.standard}
51
51
  value={item.value}
52
52
  measure={item.unit}
@@ -162,7 +162,7 @@ const HistoryChart = memo(
162
162
  return roundedSum.toFixed();
163
163
  }, [configuration, datas, chartConfig]);
164
164
 
165
- const renderChart = useCallback(() => {
165
+ const renderChart = useMemo(() => {
166
166
  if (configuration.type === 'line_chart') {
167
167
  return (
168
168
  <View style={styles.chartContainer}>
@@ -228,7 +228,7 @@ const HistoryChart = memo(
228
228
  </View>
229
229
  </View>
230
230
  )}
231
- {renderChart()}
231
+ {renderChart}
232
232
  {configuration.config === 'power_consumption' && !!chartConfig.price && (
233
233
  <Text type="H4">
234
234
  {t('total_power_price')} <Text bold>{formatMoney(totalPrice)}</Text>
@@ -108,6 +108,7 @@ function LinearChart({ datas }) {
108
108
 
109
109
  return (
110
110
  <View style={styles.container}>
111
+ {/* // TODO : Hinh will research to fix warning Highchart*/}
111
112
  <HighchartsReactNative
112
113
  styles={styles.chartStyle}
113
114
  webviewStyles={styles.webviewStyle}
@@ -3,12 +3,8 @@ import { View } from 'react-native';
3
3
  import { FlatList } from 'react-native';
4
4
  import QualityIndicatorItem from '../WaterQualitySensor/QualityIndicatorsItem';
5
5
  import styles from './PMSensorIndicatorStyles';
6
- import { roundNumber } from '../../../utils/Utils';
6
+ import { keyExtractor, roundNumber } from '../../../utils/Utils';
7
7
 
8
- //using for PM2.5-10, CO, UV, Rainflow Sensor
9
- const keyExtractor = (item, index) => {
10
- return index;
11
- };
12
8
  const PMSensorIndicator = memo(({ data = [], style }) => {
13
9
  const renderItem = useCallback(
14
10
  ({ item }) => {
@@ -36,14 +36,13 @@ describe('Test ProgressBar', () => {
36
36
  configuration: { max_value: 100 },
37
37
  value: 8,
38
38
  };
39
- const data = [{ value: 10 }];
39
+ const data = [{ value: 10, unit: 'oC' }];
40
40
  await act(async () => {
41
41
  tree = renderer.create(wrapComponent(item, data));
42
42
  });
43
43
  const instance = tree.root;
44
44
  const texts = instance.findAllByType(Text);
45
45
  expect(texts[0].props.children).toBe('Value bar');
46
- expect(texts[1].props.children).toEqual(['Max value', ': ', 100]);
47
- expect(texts[2].props.children).toEqual([10, ' ', undefined]);
46
+ expect(texts[1].props.children).toEqual('Max value: 100 oC');
48
47
  });
49
48
  });
@@ -23,7 +23,7 @@ const ProgressBar = memo(({ data = [], item }) => {
23
23
  </Text>
24
24
 
25
25
  <Text size={16} style={styles.textMaxValue}>
26
- {t('max_value')}: {maxValue}
26
+ {`${t('max_value')}: ${maxValue} ${unit || measure}`}
27
27
  </Text>
28
28
 
29
29
  <View style={styles.wrapProgressBar}>
@@ -36,9 +36,11 @@ const ProgressBar = memo(({ data = [], item }) => {
36
36
  borderWidth={0}
37
37
  borderRadius={10}
38
38
  />
39
- <Text style={styles.textValue}>
40
- {value} {unit || measure}
41
- </Text>
39
+ <View>
40
+ <Text numberOfLines={1} style={styles.textValue}>
41
+ {value}
42
+ </Text>
43
+ </View>
42
44
  </View>
43
45
  </View>
44
46
  );
@@ -6,29 +6,32 @@ export default StyleSheet.create({
6
6
  container: {
7
7
  flex: 1,
8
8
  flexDirection: 'column', //column direction
9
- marginRight: 60,
10
- marginLeft: 60,
9
+ marginHorizontal: 30,
11
10
  borderWidth: 1,
12
- padding: 12,
11
+ padding: 16,
13
12
  borderRadius: 8,
14
13
  borderColor: Colors.Gray4,
15
14
  marginBottom: 12,
16
15
  },
17
16
  textLabel: {
18
- paddingHorizontal: 16,
17
+ paddingHorizontal: 15,
19
18
  paddingTop: 8,
20
19
  },
21
20
  textMaxValue: {
22
- textAlign: 'right',
21
+ marginTop: 20,
22
+ marginLeft: 14,
23
+ textAlign: 'left',
24
+ fontWeight: 'bold',
25
+ textTransform: 'uppercase',
23
26
  },
24
27
  wrapProgressBar: {
25
28
  flex: 1,
26
29
  flexDirection: 'row',
27
30
  justifyContent: 'center',
28
31
  alignItems: 'center',
29
- padding: 8,
30
32
  },
31
33
  textValue: {
32
34
  marginLeft: 8,
35
+ width: 45,
33
36
  },
34
37
  });
@@ -41,6 +41,7 @@ const Compass = memo(({ data = [], ...props }) => {
41
41
  toValue: value,
42
42
  duration: 200,
43
43
  easing: Easing.linear,
44
+ useNativeDriver: false,
44
45
  }).start();
45
46
  }, [currentRotation, value]);
46
47
 
@@ -49,6 +49,7 @@ const SubUnitAutomate = ({ isOwner, listAutomate, unit, wrapItemStyle }) => {
49
49
  >
50
50
  {listAutomate.map((item, index) => (
51
51
  <TouchableOpacity
52
+ key={(item?.id || index).toString()}
52
53
  style={
53
54
  indexAutomate === index
54
55
  ? styles.borderSelection
@@ -79,7 +80,7 @@ const SubUnitAutomate = ({ isOwner, listAutomate, unit, wrapItemStyle }) => {
79
80
  isOwner={isOwner}
80
81
  automate={item}
81
82
  unit={unit}
82
- key={item.id}
83
+ key={item.id.toString()}
83
84
  />
84
85
  ))}
85
86
  <ItemAddNew
@@ -146,7 +146,7 @@ const AirQuality = memo(({ summaryDetail }) => {
146
146
  {!!advices &&
147
147
  advices.map((item, index) => {
148
148
  return (
149
- <View key={index} style={styles.boxContentHealth}>
149
+ <View key={index.toString()} style={styles.boxContentHealth}>
150
150
  <View
151
151
  style={[styles.boxDot, { backgroundColor: outdoorColor }]}
152
152
  />
@@ -91,7 +91,7 @@ export const SCWrapper = (props) => {
91
91
  return (
92
92
  <>
93
93
  <SCProvider {...props} />
94
- <Toast config={toastConfig} ref={(ref) => Toast.setRef(ref)} />
94
+ <Toast config={toastConfig} />
95
95
  </>
96
96
  );
97
97
  };
@@ -131,6 +131,7 @@ const MultiUnits = () => {
131
131
  <View style={styles.wrapItem}>
132
132
  {sortedListItems.map((item, index) => (
133
133
  <ItemOneTap
134
+ key={(item?.id || index).toString()}
134
135
  isOwner={isOwner}
135
136
  automate={item}
136
137
  wrapSyles={[
@@ -25,8 +25,7 @@ import {
25
25
  AccessibilityLabel,
26
26
  UNIT_TYPES,
27
27
  } from '../../configs/Constants';
28
-
29
- const keyExtractor = (item) => item.id;
28
+ import { keyExtractor } from '../../utils/Utils';
30
29
 
31
30
  const Automate = () => {
32
31
  const t = useTranslations();
@@ -706,7 +706,7 @@ const DeviceDetail = ({ route }) => {
706
706
  return (
707
707
  <SensorDisplayItem
708
708
  accessibilityLabel={AccessibilityLabel.SENSOR_DISPLAY_ITEM}
709
- key={index}
709
+ key={(item?.id || index).toString()}
710
710
  item={item}
711
711
  evaluate={evaluate}
712
712
  emergency={onEmergencyButtonPress}
@@ -1,6 +1,7 @@
1
1
  import React, { memo, useEffect, useRef, useState } from 'react';
2
2
  import { View, Text, TouchableOpacity, FlatList } from 'react-native';
3
3
  import { AccessibilityLabel } from '../../../configs/Constants';
4
+ import { keyExtractor } from '../../../utils/Utils';
4
5
  import styles from './StationStyles';
5
6
 
6
7
  const Station = ({ listStation = [], onSnapToItem, indexStation }) => {
@@ -63,10 +64,10 @@ const Station = ({ listStation = [], onSnapToItem, indexStation }) => {
63
64
  return (
64
65
  <View style={styles.container}>
65
66
  <FlatList
67
+ keyExtractor={keyExtractor}
66
68
  removeClippedSubviews={false}
67
69
  onScroll={onScroll}
68
70
  ref={flatListRef}
69
- keyExtractor={(item) => item.id}
70
71
  horizontal
71
72
  data={data}
72
73
  extraData={data}
@@ -107,7 +107,11 @@ const Summaries = memo(({ unit }) => {
107
107
  accessibilityLabel={AccessibilityLabel.UNIT_DETAIL_UNIT_SUMMARY_VIEW}
108
108
  >
109
109
  {unitSummaries.map((item, index) => (
110
- <SummaryItem key={index} item={item} goToSummary={goToSummary} />
110
+ <SummaryItem
111
+ key={(item?.id || index).toString()}
112
+ item={item}
113
+ goToSummary={goToSummary}
114
+ />
111
115
  ))}
112
116
  </ScrollView>
113
117
  )}
@@ -675,7 +675,7 @@
675
675
  "text_notification_content_turbility_high": "The Turbility at **unit_name** is **status**. Water is not safe to drink.",
676
676
  "text_notification_content_smoke": "Smoke appears in **unit_name**. Please check your home and call the rescue team if there is a fire.",
677
677
  "text_notification_content_fire": "There is a fire at **unit_name**, Please move out of the house immediately and call the rescue team.",
678
- "text_notification_content_active_sos": "**device_name** is activating at **unit_name** - **station_name**, Please check it NOW.",
678
+ "text_notification_content_active_sos": "**device_name** is activating at **unit_name** - **station_name**. Please check it NOW.",
679
679
  "text_notification_content_replace_water_filter": "Filter **config_name** of **device_name** in **station_name** has less than 10h remaining. Check and replace now.",
680
680
  "text_notification_content_low_battery": "Battery of **device_name** in **unit_name**: **station_name** has less than 20%. Check and replace now.",
681
681
  "text_notification_content_remove_unit_to_owner": "Unit **unit_name** has been removed successfully.",
@@ -230,6 +230,8 @@ export const PIN_MAPPING = {
230
230
  },
231
231
  };
232
232
 
233
+ export const keyExtractor = (item, index) => (item?.id || index).toString();
234
+
233
235
  export default {
234
236
  validateEmail,
235
237
  isObjectEmpty,