@eohjsc/react-native-smart-city 0.2.88 → 0.2.91

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.88",
4
+ "version": "0.2.91",
5
5
  "description": "TODO",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -98,6 +98,7 @@
98
98
  "@ant-design/icons-react-native": "^2.2.1",
99
99
  "@ant-design/react-native": "^4.0.5",
100
100
  "@eohjsc/highcharts": "^1.0.6",
101
+ "@eohjsc/react-native-keyboard-aware-scroll-view": "^0.9.5",
101
102
  "@formatjs/intl-getcanonicallocales": "^1.4.5",
102
103
  "@formatjs/intl-numberformat": "^5.6.2",
103
104
  "@formatjs/intl-pluralrules": "^3.4.7",
@@ -161,7 +162,6 @@
161
162
  "react-native-image-resizer": "^1.4.5",
162
163
  "react-native-input-credit-card": "^0.5.5",
163
164
  "react-native-iphone-x-helper": "^1.2.1",
164
- "react-native-keyboard-aware-scroll-view": "https://github.com/hinh-eoh/react-native-keyboard-aware-scroll-view.git",
165
165
  "react-native-linear-gradient": "^2.5.6",
166
166
  "react-native-localize": "^1.4.1",
167
167
  "react-native-maps": "0.27.1",
@@ -8,7 +8,6 @@ import React, {
8
8
  import { View, TouchableOpacity } from 'react-native';
9
9
  import { useTranslations } from '../../hooks/Common/useTranslations';
10
10
  import moment from 'moment';
11
- import _ from 'lodash';
12
11
  import { get } from 'lodash';
13
12
  import { useSelector } from 'react-redux';
14
13
  import { IconFill, IconOutline } from '@ant-design/icons-react-native';
@@ -463,10 +462,14 @@ const DeviceDetail = ({ route }) => {
463
462
  setDisplayValues((currentDisplayValues) => {
464
463
  for (const [configId, value] of Object.entries(configValues)) {
465
464
  const intId = parseInt(configId);
466
- const index = _.findIndex(currentDisplayValues, (o) => o.id === intId);
465
+ const index = currentDisplayValues.findIndex(
466
+ (element) => element.id === intId
467
+ );
468
+
469
+ const item = currentDisplayValues[index];
467
470
  if (index !== -1) {
468
471
  currentDisplayValues[index].value = value;
469
- currentDisplayValues[index].evaluate = null;
472
+ currentDisplayValues[index].evaluate = item.evaluate;
470
473
  } else {
471
474
  currentDisplayValues.push({
472
475
  id: intId,
@@ -496,7 +499,19 @@ const DeviceDetail = ({ route }) => {
496
499
  params: { unitId: unit?.id, group },
497
500
  });
498
501
  }, [navigation, unit?.group, unit?.id]);
499
-
502
+ const isHaveColorSliderTemplate = useMemo(() => {
503
+ let isFlag = false;
504
+ display?.items.some((item) => {
505
+ switch (item?.configuration?.template) {
506
+ case 'color_picker_template':
507
+ case 'slider_range_template':
508
+ return (isFlag = true);
509
+ default:
510
+ return (isFlag = false);
511
+ }
512
+ });
513
+ return isFlag;
514
+ }, [display]);
500
515
  // replace isConnected=True to see template
501
516
  const renderSensorConnected = () => {
502
517
  return (
@@ -536,31 +551,33 @@ const DeviceDetail = ({ route }) => {
536
551
  );
537
552
  }
538
553
  })}
539
- <Card title={t('controller')}>
540
- {display.items.map((item) => {
541
- switch (item?.configuration?.template) {
542
- case 'color_picker_template':
543
- case 'slider_range_template':
544
- return (
545
- <SensorDisplayItem
546
- testID={TESTID.SENSOR_DISPLAY_ITEM}
547
- key={item.id.toString()}
548
- item={item}
549
- emergency={onEmergencyButtonPress}
550
- sensor={sensor}
551
- getData={getData}
552
- maxValue={maxValue}
553
- offsetTitle={offsetTitle}
554
- setOffsetTitle={setOffsetTitle}
555
- setShowWindDirection={setShowWindDirection}
556
- background={station?.background}
557
- />
558
- );
559
- default:
560
- return <></>;
561
- }
562
- })}
563
- </Card>
554
+ {!!isHaveColorSliderTemplate && (
555
+ <Card title={t('controller')}>
556
+ {display.items.map((item) => {
557
+ switch (item?.configuration?.template) {
558
+ case 'color_picker_template':
559
+ case 'slider_range_template':
560
+ return (
561
+ <SensorDisplayItem
562
+ testID={TESTID.SENSOR_DISPLAY_ITEM}
563
+ key={item.id.toString()}
564
+ item={item}
565
+ emergency={onEmergencyButtonPress}
566
+ sensor={sensor}
567
+ getData={getData}
568
+ maxValue={maxValue}
569
+ offsetTitle={offsetTitle}
570
+ setOffsetTitle={setOffsetTitle}
571
+ setShowWindDirection={setShowWindDirection}
572
+ background={station?.background}
573
+ />
574
+ );
575
+ default:
576
+ return <></>;
577
+ }
578
+ })}
579
+ </Card>
580
+ )}
564
581
  </SensorConnectStatusViewHeader>
565
582
  );
566
583
  };