@eohjsc/react-native-smart-city 0.4.40 → 0.4.41

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.
Files changed (49) hide show
  1. package/package.json +1 -1
  2. package/src/commons/Action/ItemQuickAction.js +1 -0
  3. package/src/commons/ActionGroup/ColorPickerTemplate.js +3 -4
  4. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +3 -3
  5. package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +2 -2
  6. package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +4 -5
  7. package/src/commons/ActionGroup/OnOffTemplate/SwitchButtonTemplate.js +4 -4
  8. package/src/commons/ActionGroup/OnOffTemplate/index.js +6 -5
  9. package/src/commons/ActionGroup/OneBigButtonTemplate.js +4 -4
  10. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +6 -17
  11. package/src/commons/ActionGroup/SliderRangeTemplate.js +5 -3
  12. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +7 -7
  13. package/src/commons/ActionGroup/StatesGridActionTemplate.js +6 -20
  14. package/src/commons/ActionGroup/ThreeButtonTemplate/__test__/ThreeButtonTemplate.test.js +6 -6
  15. package/src/commons/ActionGroup/ThreeButtonTemplate/index.js +2 -2
  16. package/src/commons/ActionGroup/TimerActionTemplate.js +3 -2
  17. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +133 -135
  18. package/src/commons/ActionGroup/__test__/ColorPickerTemplate.test.js +35 -13
  19. package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +71 -31
  20. package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +11 -11
  21. package/src/commons/ActionGroup/__test__/OnOffSmartLock.test.js +13 -17
  22. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +44 -48
  23. package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +56 -22
  24. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +123 -21
  25. package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +12 -16
  26. package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +73 -38
  27. package/src/commons/ActionGroup/__test__/SwitchButtonTemplate.test.js +11 -15
  28. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +11 -15
  29. package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +9 -9
  30. package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +20 -20
  31. package/src/commons/ActionGroup/__test__/index.test.js +36 -21
  32. package/src/commons/ActionGroup/index.js +4 -7
  33. package/src/commons/HeaderAni/index.js +12 -2
  34. package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +5 -3
  35. package/src/commons/SubUnit/OneTap/ItemOneTap.js +1 -0
  36. package/src/commons/icon/index.js +57 -0
  37. package/src/configs/AccessibilityLabel.js +1 -0
  38. package/src/iot/mqtt.js +2 -0
  39. package/src/navigations/UnitStack.js +2 -2
  40. package/src/screens/Device/__test__/detail.test.js +40 -45
  41. package/src/screens/Device/__test__/sensorDisplayItem.test.js +14 -2
  42. package/src/screens/Device/components/SensorDisplayItem.js +18 -2
  43. package/src/screens/Device/detail.js +31 -13
  44. package/src/screens/Device/styles.js +3 -0
  45. package/src/screens/Sharing/MemberList.js +16 -3
  46. package/src/screens/Unit/SelectAddToFavorites.js +1 -0
  47. package/src/screens/Unit/__test__/SelectAddress.test.js +1 -1
  48. package/src/utils/I18n/translations/en.js +2 -0
  49. package/src/utils/I18n/translations/vi.js +2 -0
@@ -107,11 +107,27 @@ export const SensorDisplayItem = ({
107
107
  />
108
108
  </View>
109
109
  );
110
- case 'action':
110
+ // change response format, todo Bang refactor after fix
111
+ case 'three_button_action_template': // todo refactor later with backend
112
+ case 'ThreeButtonActionTemplate':
113
+ case 'on_off_button_action_template': // todo refactor later with backend
114
+ case 'OnOffButtonActionTemplate':
115
+ case 'OnOffSimpleActionTemplate':
116
+ case 'OnOffSmartLockActionTemplate':
117
+ case 'one_button_action_template': // todo refactor later with backend
118
+ case 'OneBigButtonActionTemplate':
119
+ case 'NumberUpDownActionTemplate':
120
+ case 'StatesGridActionTemplate':
121
+ case 'OptionsDropdownActionTemplate':
122
+ case 'TimerActionTemplate':
123
+ case 'SmartTiviActionTemplate':
124
+ case 'color_picker_template':
125
+ case 'slider_range_template':
126
+ case 'two_button_action_template':
127
+ case 'switch_button_action_template':
111
128
  return (
112
129
  <ActionGroup
113
130
  accessibilityLabel={AccessibilityLabel.DEVICE_DETAIL_ACTION_GROUP}
114
- actionGroup={configuration}
115
131
  doAction={doAction}
116
132
  sensor={sensor}
117
133
  id={idTemplate}
@@ -701,7 +701,12 @@ const DeviceDetail = ({ route }) => {
701
701
  ref={refMenuAction}
702
702
  accessibilityLabel={AccessibilityLabel.HEADER_DEVICE_BUTTON_MORE}
703
703
  >
704
- <Icon name={'more'} size={27} color={Colors.Black} />
704
+ <Icon
705
+ name={'ellipsis'}
706
+ size={27}
707
+ color={Colors.Black}
708
+ style={styles.moreIcon}
709
+ />
705
710
  </TouchableOpacity>
706
711
  </View>
707
712
  ),
@@ -754,18 +759,31 @@ const DeviceDetail = ({ route }) => {
754
759
  >
755
760
  {display.items.map((item, index) => {
756
761
  return (
757
- <SensorDisplayItem
758
- accessibilityLabel={AccessibilityLabel.SENSOR_DISPLAY_ITEM}
759
- key={(item?.id || index).toString()}
760
- item={item}
761
- evaluate={evaluate}
762
- emergency={onEmergencyButtonPress}
763
- sensor={sensor}
764
- offsetTitle={offsetTitle}
765
- setOffsetTitle={setOffsetTitle}
766
- setShowWindDirection={setShowWindDirection}
767
- background={station?.background}
768
- />
762
+ <>
763
+ {!item.is_configuration_ready && (
764
+ <Text center>{t('bellow_widget_is_not_configured')}</Text>
765
+ )}
766
+ {!!item.is_configuration_ready &&
767
+ !!item.configuration_error && (
768
+ <Text center>
769
+ {t('bellow_widget_is_wrongly_configured')}
770
+ </Text>
771
+ )}
772
+ <SensorDisplayItem
773
+ accessibilityLabel={
774
+ AccessibilityLabel.SENSOR_DISPLAY_ITEM
775
+ }
776
+ key={(item?.id || index).toString()}
777
+ item={item}
778
+ evaluate={evaluate}
779
+ emergency={onEmergencyButtonPress}
780
+ sensor={sensor}
781
+ offsetTitle={offsetTitle}
782
+ setOffsetTitle={setOffsetTitle}
783
+ setShowWindDirection={setShowWindDirection}
784
+ background={station?.background}
785
+ />
786
+ </>
769
787
  );
770
788
  })}
771
789
  </SensorConnectStatusViewHeader>
@@ -97,4 +97,7 @@ export default StyleSheet.create({
97
97
  marginLeft: 16,
98
98
  marginBottom: 16,
99
99
  },
100
+ moreIcon: {
101
+ transform: [{ rotate: '90deg' }],
102
+ },
100
103
  });
@@ -1,7 +1,7 @@
1
1
  import React, { useCallback, useEffect } from 'react';
2
2
  import { IconOutline } from '@ant-design/icons-react-native';
3
3
  import { useNavigation, useIsFocused } from '@react-navigation/native';
4
- import { StyleSheet, TouchableOpacity, View } from 'react-native';
4
+ import { Platform, StyleSheet, TouchableOpacity, View } from 'react-native';
5
5
  import { useTranslations } from '../../hooks/Common/useTranslations';
6
6
 
7
7
  import { Colors } from '../../configs';
@@ -17,6 +17,8 @@ import { useSCContextSelector } from '../../context';
17
17
  import { useBackendPermission } from '../../utils/Permission/backend';
18
18
  import { ToastBottomHelper } from '../../utils/Utils';
19
19
 
20
+ const isAndroid = Platform.OS === 'android';
21
+
20
22
  const MemberList = ({ route }) => {
21
23
  const t = useTranslations();
22
24
  const { navigate } = useNavigation();
@@ -69,6 +71,16 @@ const MemberList = ({ route }) => {
69
71
  hideStateAlertSharingMenu();
70
72
  }, [hideStateAlertSharingMenu, isOwner, leaveUnit, unit.name]);
71
73
 
74
+ const getIconRight = useCallback(() => {
75
+ if (isOwner) {
76
+ if (isAndroid) {
77
+ return 'plus-square';
78
+ }
79
+ return 'plus';
80
+ }
81
+ return 'ellipsis';
82
+ }, [isOwner]);
83
+
72
84
  useEffect(() => {
73
85
  if (isFocused) {
74
86
  onRefresh();
@@ -79,12 +91,13 @@ const MemberList = ({ route }) => {
79
91
  <TouchableOpacity
80
92
  accessibilityLabel={AccessibilityLabel.MEMBER_LIST_RIGHT_HEADER_TOUCH}
81
93
  onPress={onPressRightHeader}
82
- style={styles.rightHeader}
94
+ style={[styles.rightHeader]}
83
95
  >
84
96
  <IconOutline
85
- name={isOwner ? 'plus' : 'more'}
97
+ name={getIconRight()}
86
98
  size={30}
87
99
  color={Colors.Black}
100
+ style={{ transform: [{ rotate: isOwner ? '0deg' : '90deg' }] }}
88
101
  />
89
102
  </TouchableOpacity>
90
103
  );
@@ -214,6 +214,7 @@ const SelectAddToFavorites = memo(({ route }) => {
214
214
  ? 'disabled'
215
215
  : 'primary'
216
216
  }
217
+ accessibilityLabelPrefix={AccessibilityLabel.BUTTON_SELECT_FAVORITES}
217
218
  />
218
219
  {loading && <FullLoading />}
219
220
  </View>
@@ -175,7 +175,7 @@ describe('Test SelectAddress', () => {
175
175
  const animateToRegion = jest.fn();
176
176
  const mapRef = {
177
177
  current: {
178
- mapRef,
178
+ animateToRegion,
179
179
  },
180
180
  };
181
181
  jest.spyOn(React, 'useRef').mockReturnValue(mapRef);
@@ -1425,4 +1425,6 @@ export default {
1425
1425
  actions: 'actions',
1426
1426
  value_must_be_less_than_8_character:
1427
1427
  'Value must be less than or equal to 8 characters',
1428
+ bellow_widget_is_not_configured: 'Bellow widget is not configured',
1429
+ bellow_widget_is_wrongly_configured: 'Bellow widget is wrongly configured',
1428
1430
  };
@@ -1436,4 +1436,6 @@ export default {
1436
1436
  you_can_only_add_more: 'Bạn chỉ có thể thêm {number}',
1437
1437
  actions: 'hành động',
1438
1438
  value_must_be_less_than_8_character: 'Giá trị phải ít hơn hoặc bằng 8 kí tự',
1439
+ bellow_widget_is_not_configured: 'Tiện ích bên dưới chưa được cấu hình',
1440
+ bellow_widget_is_wrongly_configured: 'Tiện ích bên dưới được cấu hình sai',
1439
1441
  };