@eohjsc/react-native-smart-city 0.4.49 → 0.4.51

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.49",
4
+ "version": "0.4.51",
5
5
  "description": "TODO",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -7,8 +7,7 @@ import { useConfigGlobalState } from '../../iot/states';
7
7
  import IconComponent from '../IconComponent';
8
8
 
9
9
  const ItemQuickAction = memo(
10
- ({ sensor, wrapperStyle, setStatus, iconSize = 40 }) => {
11
- const [isSendingCommand, setIsSendingCommand] = useState(false);
10
+ ({ sensor, wrapperStyle, setStatus, iconSize = 30 }) => {
12
11
  const [action, setAction] = useState(sensor.action);
13
12
  // eslint-disable-next-line no-unused-vars
14
13
  const [configValues, _] = useConfigGlobalState('configValues');
@@ -64,7 +63,6 @@ const ItemQuickAction = memo(
64
63
  data = JSON.stringify(data);
65
64
  }
66
65
  await sendRemoteCommand(sensor, action, data, userId);
67
- setIsSendingCommand(true);
68
66
 
69
67
  if (!sensor.quick_action.will_auto_update_status) {
70
68
  setTimeout(() => {
@@ -86,7 +84,7 @@ const ItemQuickAction = memo(
86
84
  <View style={wrapperStyle}>
87
85
  <IconComponent
88
86
  icon={action?.icon_kit || action?.icon || 'PoweroffOutlined'}
89
- isSendingCommand={isSendingCommand}
87
+ isOn={isOn}
90
88
  iconSize={iconSize}
91
89
  size={iconSize}
92
90
  />
@@ -36,7 +36,7 @@ const OnOffButtonTemplate = memo(
36
36
  <IconComponent
37
37
  icon={icon}
38
38
  iconSize={30}
39
- active={isOn}
39
+ isOn={isOn}
40
40
  colorInActive={Colors.Gray6}
41
41
  color={Colors.Green7}
42
42
  />
@@ -28,15 +28,16 @@ const OptionsDropdownActionTemplate = ({
28
28
  isWidgetOrder,
29
29
  }) => {
30
30
  const t = useTranslations();
31
- const { configuration = {}, title = '' } = item;
32
31
  const {
32
+ title,
33
33
  action_data,
34
34
  options = [],
35
35
  icon_kit_data,
36
36
  icon,
37
37
  config,
38
38
  allow_config_store_value,
39
- } = configuration;
39
+ } = item?.configuration || {};
40
+
40
41
  // eslint-disable-next-line no-unused-vars
41
42
  const [configValues, setConfigValues] = useConfigGlobalState('configValues');
42
43
  const checkIcon = /\d/.test(icon); // to do check icon svg and icon antDesign
@@ -96,7 +97,7 @@ const OptionsDropdownActionTemplate = ({
96
97
  hideAlertAction,
97
98
  ]);
98
99
 
99
- useUnwatchLGDeviceConfigControl(sensor, [configuration.config]);
100
+ useUnwatchLGDeviceConfigControl(sensor, [config]);
100
101
 
101
102
  const iconKit = !!icon_kit_data && icon_kit_data.icon;
102
103
 
@@ -117,7 +118,6 @@ const OptionsDropdownActionTemplate = ({
117
118
  {!checkIcon && (
118
119
  <IconComponent
119
120
  icon={iconKit || icon}
120
- isSendingCommand={false}
121
121
  iconSize={27}
122
122
  size={27}
123
123
  style={styles.marginRight}
@@ -79,7 +79,7 @@ const GridItem = ({ item, doAction, sensor }) => {
79
79
  {!checkIcon && (
80
80
  <IconComponent
81
81
  icon={iconKit || icon}
82
- active={active}
82
+ isOn={active}
83
83
  color={Colors.White}
84
84
  style={styles.iconComponent}
85
85
  />
@@ -56,8 +56,8 @@ describe('Test OptionsDropdownActionTemplate', () => {
56
56
  beforeEach(() => {
57
57
  watchMultiConfigs.mockClear();
58
58
  displayItem = {
59
- title: 'Fan Speed',
60
59
  configuration: {
60
+ title: 'Fan Speed',
61
61
  action_data: actionData,
62
62
  config: 5,
63
63
  action: 'e5d23347-ee31-4fe3-9fb5-bbce05bf4b61',
@@ -8,14 +8,13 @@ import FImage from '../FImage';
8
8
  const IconComponent = memo(
9
9
  ({
10
10
  icon,
11
- isSendingCommand = false,
11
+ isOn = false,
12
12
  size = 30,
13
13
  iconSize = 30,
14
14
  style,
15
15
  antIconStyle,
16
16
  color,
17
17
  colorInActive,
18
- active,
19
18
  }) => {
20
19
  let extraStyle = {
21
20
  width: size,
@@ -49,11 +48,8 @@ const IconComponent = memo(
49
48
  }, [icon]);
50
49
 
51
50
  const colorIcon = useMemo(() => {
52
- if (isSendingCommand || !active) {
53
- return colorInActive || Colors.TextGray;
54
- }
55
- return color || Colors.Green7;
56
- }, [active, color, colorInActive, isSendingCommand]);
51
+ return isOn ? color || Colors.Green7 : colorInActive || Colors.TextGray;
52
+ }, [color, colorInActive, isOn]);
57
53
 
58
54
  if (!icon) {
59
55
  return null;
@@ -100,6 +100,8 @@ const SCDefaultConfig = {
100
100
  intervalWatchConfigTime: 30000,
101
101
  setCurrentSensorDisplay: () => {},
102
102
  appName: 'E-Ra',
103
+ packageName: 'com.eohjsc.eohmobile.staging',
104
+ versionCode: 1
103
105
  };
104
106
 
105
107
  export class SCConfig {
@@ -117,6 +119,8 @@ export class SCConfig {
117
119
  static intervalWatchConfigTime = SCDefaultConfig.intervalWatchConfigTime;
118
120
  static setCurrentSensorDisplay = SCDefaultConfig.setCurrentSensorDisplay;
119
121
  static appName = SCDefaultConfig.appName;
122
+ static packageName = SCDefaultConfig.packageName;
123
+ static versionCode = SCDefaultConfig.versionCode;
120
124
  }
121
125
 
122
126
  export const initSCConfig = (config) => {
@@ -143,4 +147,6 @@ export const initSCConfig = (config) => {
143
147
  SCConfig.setCurrentSensorDisplay =
144
148
  config.setCurrentSensorDisplay ?? SCDefaultConfig.setCurrentSensorDisplay;
145
149
  SCConfig.appName = config.appName ?? SCDefaultConfig.appName;
150
+ SCConfig.packageName = config.packageName ?? SCConfig.packageName,
151
+ SCConfig.versionCode = config.version ?? SCConfig.versionCode
146
152
  };
@@ -11,6 +11,8 @@ import { isHTML } from '../Validation';
11
11
  const api = create({
12
12
  headers: {
13
13
  'Content-Type': 'application/json',
14
+ 'App-Version-Code': SCConfig.versionCode,
15
+ 'App-Package-Name': SCConfig.packageName,
14
16
  },
15
17
  timeout: 30000,
16
18
  });