@eohjsc/react-native-smart-city 0.4.79 → 0.4.81

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.79",
4
+ "version": "0.4.81",
5
5
  "description": "TODO",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -18,6 +18,7 @@ const ItemQuickAction = memo(
18
18
  off_status,
19
19
  interval,
20
20
  will_auto_update_status,
21
+ on_state_values,
21
22
  } = quick_action || {};
22
23
  const [action, setAction] = useState(sensor?.action);
23
24
  // eslint-disable-next-line no-unused-vars
@@ -29,9 +30,16 @@ const ItemQuickAction = memo(
29
30
  const sendRemoteCommand = useRemoteControl();
30
31
  const [processing, setProcessing] = useState(false);
31
32
 
33
+ const getIsOnValue = useCallback(() => {
34
+ if (on_state_values && on_state_values.length > 0) {
35
+ return on_state_values.includes(currentValue);
36
+ }
37
+ return !!currentValue;
38
+ }, [currentValue, on_state_values]);
39
+
32
40
  useEffect(() => {
33
- setIsOn(currentValue);
34
- }, [currentValue]);
41
+ setIsOn(getIsOnValue());
42
+ }, [getIsOnValue]);
35
43
 
36
44
  useEffect(() => {
37
45
  if (!quick_action) {
@@ -33,14 +33,14 @@ describe('Test ItemQuickAction', () => {
33
33
  config_id: 51,
34
34
  interval: 5000,
35
35
  off_action: {
36
- icon: 'down',
36
+ icon: 'on',
37
37
  command_prefer_over_bluetooth: true,
38
38
  command_prefer_over_googlehome: false,
39
39
  command_prefer_over_internet: false,
40
40
  id: 10,
41
41
  },
42
42
  on_action: {
43
- icon: 'up',
43
+ icon: 'off',
44
44
  command_prefer_over_bluetooth: true,
45
45
  command_prefer_over_googlehome: false,
46
46
  command_prefer_over_internet: false,
@@ -258,4 +258,30 @@ describe('Test ItemQuickAction', () => {
258
258
  });
259
259
  expect(Toast.show).not.toBeCalled();
260
260
  });
261
+ it('test config value 0 on_state_values 0', async () => {
262
+ sensor.quick_action.on_state_values = [0];
263
+ const globalStates = require('../../../iot/states');
264
+ globalStates.useConfigGlobalState = () => [{ 51: { value: 0 } }, null];
265
+
266
+ await act(async () => {
267
+ tree = await create(
268
+ <ItemQuickAction sensor={sensor} wrapperStyle={style} />
269
+ );
270
+ });
271
+ const icon = tree.root.findByType(IconComponent);
272
+ expect(icon.props.icon).toEqual(sensor.quick_action.off_action.icon);
273
+ });
274
+ it('test config value 0 on_state_values 1', async () => {
275
+ sensor.quick_action.on_state_values = [1];
276
+ const globalStates = require('../../../iot/states');
277
+ globalStates.useConfigGlobalState = () => [{ 51: { value: 0 } }, null];
278
+
279
+ await act(async () => {
280
+ tree = await create(
281
+ <ItemQuickAction sensor={sensor} wrapperStyle={style} />
282
+ );
283
+ });
284
+ const icon = tree.root.findByType(IconComponent);
285
+ expect(icon.props.icon).toEqual(sensor.quick_action.on_action.icon);
286
+ });
261
287
  });
@@ -46,7 +46,7 @@ const QualityIndicatorItem = memo(
46
46
  <Text size={24} color={Colors.Gray9} style={styles.txtValue}>
47
47
  {measure && measure.length ? `${value} ${measure}` : `${value}`}
48
48
  </Text>
49
- {!!evaluate && (
49
+ {!!evaluate?.color && (
50
50
  <Text size={12} color={evaluate.color} style={styles.txtEvaluate}>
51
51
  {evaluate.text}
52
52
  </Text>
@@ -162,4 +162,8 @@ export default StyleSheet.create({
162
162
  flex1: {
163
163
  flex: 1,
164
164
  },
165
+ iconEndDevice: {
166
+ marginTop: 5,
167
+ marginRight: 15,
168
+ },
165
169
  });
@@ -21,7 +21,6 @@ import MenuActionMore from '../../../commons/MenuActionMore';
21
21
  import Add from '../../../../assets/images/Add.svg';
22
22
  import { useNavigation, useRoute } from '@react-navigation/native';
23
23
  import { axiosGet, axiosPost } from '../../../utils/Apis/axios';
24
- import FImage from '../../../commons/FImage';
25
24
  import Routes from '../../../utils/Route';
26
25
  import { ToastBottomHelper } from '../../../utils/Utils';
27
26
  import ItemAutomate from '../../../commons/Automate/ItemAutomate';
@@ -31,6 +30,7 @@ import RenameScript from './Components/RenameScript';
31
30
  import DeleteScript from './Components/DeleteScript';
32
31
  import Images from '../../../configs/Images';
33
32
  import { useBackendPermission } from '../../../utils/Permission/backend';
33
+ import IconComponent from '../../../commons/IconComponent';
34
34
 
35
35
  const PreventDoubleTouch = withPreventDoubleClick(TouchableOpacity);
36
36
 
@@ -265,9 +265,9 @@ const Item = ({ item, index }) => {
265
265
  </Text>
266
266
  </View>
267
267
  <View style={styles.rightItem}>
268
- <FImage
269
- source={{ uri: item?.sensor_icon_kit }}
270
- style={styles.iconItem}
268
+ <IconComponent
269
+ icon={item?.sensor_icon_kit}
270
+ style={styles.iconEndDevice}
271
271
  />
272
272
  <View style={styles.contentItem}>
273
273
  <View style={styles.titleItem}>
@@ -148,6 +148,7 @@ const SharingInviteMembers = ({ route }) => {
148
148
  </View>
149
149
  </TouchableWithoutFeedback>
150
150
  <ViewButtonBottom
151
+ disableKeyBoardAnimated={true}
151
152
  leftTitle={t('back')}
152
153
  onLeftClick={() => navigation.goBack()}
153
154
  rightTitle={t('done')}
@@ -64,7 +64,6 @@ export default StyleSheet.create({
64
64
  fontStyle: 'normal',
65
65
  },
66
66
  wrapViewButtonStyle: {
67
- paddingTop: 90,
68
- marginBottom: 30,
67
+ paddingTop: 70,
69
68
  },
70
69
  });