@eohjsc/react-native-smart-city 0.4.97 → 0.4.98

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.97",
4
+ "version": "0.4.98",
5
5
  "description": "TODO",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -53,15 +53,17 @@ const OnOffTemplate = memo(({ item = {}, doAction, sensor = {} }) => {
53
53
 
54
54
  const [isOn, setIsOn] = useState(false);
55
55
  const [tempIsOn, setTempIsOn] = useState(getIsOnValue());
56
+ const [timeoutId, setTimeoutId] = useState();
56
57
 
57
58
  const updateStatusFromPusher = useCallback(() => {
58
- setTimeout(() => {
59
+ const timeout = setTimeout(() => {
59
60
  setTempIsOn(temp);
60
- }, 3000);
61
+ }, 7000);
62
+ setTimeoutId(timeout);
61
63
  }, []);
62
64
 
63
65
  const triggerAction = useCallback(async () => {
64
- const action_data = isOn ? action_off_data : action_on_data;
66
+ const action_data = tempIsOn ? action_off_data : action_on_data;
65
67
  if (!action_data) {
66
68
  return;
67
69
  }
@@ -76,8 +78,9 @@ const OnOffTemplate = memo(({ item = {}, doAction, sensor = {} }) => {
76
78
  config_value: isOn ? 0 : 1,
77
79
  };
78
80
  }
79
- setTempIsOn((prev) => !prev);
81
+ clearTimeout(timeoutId);
80
82
  await doAction(action_data, data);
83
+ setTempIsOn((prev) => !prev);
81
84
  updateStatusFromPusher(); // todo Bang read about this magic
82
85
 
83
86
  if (
@@ -88,15 +91,17 @@ const OnOffTemplate = memo(({ item = {}, doAction, sensor = {} }) => {
88
91
  watchMultiConfigs([config]);
89
92
  }
90
93
  }, [
91
- isOn,
94
+ tempIsOn,
92
95
  action_off_data,
93
96
  action_on_data,
94
- device_type,
95
- is_managed_by_backend,
96
97
  allow_config_store_value,
97
98
  config,
99
+ device_type,
100
+ timeoutId,
98
101
  doAction,
99
102
  updateStatusFromPusher,
103
+ is_managed_by_backend,
104
+ isOn,
100
105
  ]);
101
106
 
102
107
  useUnwatchLGDeviceConfigControl(sensor, [config]);
@@ -10,9 +10,11 @@ import styles from './TextBoxTemplateStyle';
10
10
  import { useTranslations } from '../../hooks/Common/useTranslations';
11
11
  import _TextInput from '../Form/TextInput';
12
12
  import AccessibilityLabel from '../../configs/AccessibilityLabel';
13
+ import useKeyboardAnimated from '../../hooks/Explore/useKeyboardAnimated';
13
14
 
14
15
  const TextBoxTemplate = ({ item, doAction, isWidgetOrder }) => {
15
16
  const t = useTranslations();
17
+ const transY = useKeyboardAnimated();
16
18
  const { label, configuration } = item;
17
19
  const { action_data, config } = configuration;
18
20
  const [configValues] = useConfigGlobalState('configValues');
@@ -53,6 +55,7 @@ const TextBoxTemplate = ({ item, doAction, isWidgetOrder }) => {
53
55
  rightButtonTitle={stateAlert.rightButton}
54
56
  rightButtonClick={onDone}
55
57
  rightDisabled={!value}
58
+ transY={transY}
56
59
  >
57
60
  <_TextInput
58
61
  wrapStyle={styles.wrapInputStyle}
@@ -20,8 +20,8 @@ const SliderRangeActionTemplate = ({ device, item, onSelectAction }) => {
20
20
  const [configValues] = useConfigGlobalState('configValues');
21
21
  const [value, setValue] = useState();
22
22
 
23
- const onInputChange = (value) => {
24
- setValue(value);
23
+ const onInputChange = (e) => {
24
+ setValue(e);
25
25
  };
26
26
 
27
27
  useEffect(() => {
@@ -30,7 +30,7 @@ const SliderRangeActionTemplate = ({ device, item, onSelectAction }) => {
30
30
  }, [configValues, config]);
31
31
 
32
32
  const onPressDone = useCallback(() => {
33
- let actionData = { value: value };
33
+ let actionData = { value: parseFloat(value) };
34
34
  setValue(value);
35
35
  onSelectAction &&
36
36
  onSelectAction({
@@ -64,7 +64,7 @@ describe('Test SliderRangeActionTemplate', () => {
64
64
  });
65
65
  expect(mockOnSelectAction).toHaveBeenCalledWith({
66
66
  action: 'b498234c-6c1a-452d-a1d1-87a314c20528',
67
- data: { value: '123' },
67
+ data: { value: 123 },
68
68
  index: undefined,
69
69
  template: 'slider_range_template',
70
70
  });