@eohjsc/react-native-smart-city 0.4.75 → 0.4.77

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.75",
4
+ "version": "0.4.77",
5
5
  "description": "TODO",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -127,7 +127,7 @@ const ItemDevice = memo(
127
127
  size={14}
128
128
  color={Colors.Gray9}
129
129
  style={
130
- Platform.OS === 'ios' ? styles.lineHeight22 : styles.marginBottom
130
+ Platform.OS === 'ios' ? styles.iosStyle : styles.androidStyle
131
131
  }
132
132
  >
133
133
  {title}
@@ -163,11 +163,13 @@ const styles = StyleSheet.create({
163
163
  justifyContent: 'space-between',
164
164
  alignItems: 'center',
165
165
  },
166
- marginBottom: {
167
- marginBottom: 8,
166
+ iosStyle: {
167
+ lineHeight: 22,
168
168
  },
169
- lineHeight22: {
169
+ androidStyle: {
170
170
  lineHeight: 22,
171
+ includeFontPadding: false,
172
+ marginBottom: 8,
171
173
  },
172
174
  lineHeight20: {
173
175
  lineHeight: 20,
@@ -5,11 +5,13 @@ import MediaPlayerDetail from '../index';
5
5
  import PauseIcon from '../../../assets/images/Common/Pause.svg';
6
6
  import { SCProvider } from '../../../context';
7
7
  import { mockSCStore } from '../../../context/mockStore';
8
+ import { ToastBottomHelper } from '../../../utils/Utils';
9
+ import { getTranslate } from '../../../utils/I18n';
8
10
 
9
- const wrapComponent = () => (
11
+ const wrapComponent = (uri) => (
10
12
  <SCProvider initState={mockSCStore({})}>
11
13
  <MediaPlayerDetail
12
- uri={'rtsp://admin:hd111111:1111111/Streaming/Channels/101/'}
14
+ uri={uri}
13
15
  key={'camera-1'}
14
16
  thumbnail={{ uri: 'https://abc.com/image.png' }}
15
17
  cameraName={'cameraName'}
@@ -19,10 +21,12 @@ const wrapComponent = () => (
19
21
 
20
22
  describe('Test MediaPlayerDetail', () => {
21
23
  let wrapper;
24
+ const spyToastError = jest.spyOn(ToastBottomHelper, 'error');
22
25
 
23
26
  it('MediaPlayerDetail render when onTap setPause', async () => {
27
+ const uri = 'rtsp://admin:hd111111:1111111/Streaming/Channels/101/';
24
28
  await act(async () => {
25
- wrapper = await create(wrapComponent());
29
+ wrapper = await create(wrapComponent(uri));
26
30
  });
27
31
  const instance = wrapper.root;
28
32
  const buttons = instance.findAllByType(TouchableOpacity);
@@ -44,4 +48,11 @@ describe('Test MediaPlayerDetail', () => {
44
48
  expect(texts[1].child).toBeUndefined();
45
49
  expect(pauseIcon.child).toBeUndefined();
46
50
  });
51
+ it('MediaPlayerDetail uri wrong', async () => {
52
+ const uri = 'wrong://admin:hd111111:1111111/Streaming/Channels/101/';
53
+ await act(async () => {
54
+ wrapper = await create(wrapComponent(uri));
55
+ });
56
+ expect(spyToastError).toBeCalledWith(getTranslate('en', 'uri_invalid'));
57
+ });
47
58
  });
@@ -24,6 +24,8 @@ import { AccessibilityLabel } from '../../configs/Constants';
24
24
  import { SCContext, useSCContextSelector } from '../../context';
25
25
  import { Action } from '../../context/actionType';
26
26
  import VLCPlayer from 'react-native-vlc-media-player/VLCPlayer';
27
+ import { isValidURI } from '../../utils/Validation';
28
+ import { ToastBottomHelper } from '../../utils/Utils';
27
29
 
28
30
  const MediaPlayerDetail = ({
29
31
  id,
@@ -87,7 +89,8 @@ const MediaPlayerDetail = ({
87
89
  }, [amount]);
88
90
 
89
91
  const renderCamera = useMemo(() => {
90
- if (!uri) {
92
+ if (!uri || !isValidURI(uri)) {
93
+ ToastBottomHelper.error(t('uri_invalid'));
91
94
  return null;
92
95
  }
93
96
  return (
@@ -17,7 +17,9 @@ const ConfigAndEvaluationDisplay = memo(
17
17
  <IconComponent icon={icon_kit || icon} />
18
18
  </View>
19
19
  <View style={styles.rowTop}>
20
- <Text bold>{stationItem?.configuration?.config_data?.name}</Text>
20
+ <Text semibold>
21
+ {stationItem?.configuration?.config_data?.name}
22
+ </Text>
21
23
  </View>
22
24
  <View style={styles.rowBottom}>
23
25
  <Text style={styles.textValue} bold>
@@ -25,7 +25,7 @@ const ConfigValue = ({ device, stationItem }) => {
25
25
  <IconComponent icon={icon_kit || icon} />
26
26
  </View>
27
27
  <View style={styles.rowTop}>
28
- <Text bold>{stationItem?.configuration?.config_data?.name}</Text>
28
+ <Text semibold>{stationItem?.configuration?.config_data?.name}</Text>
29
29
  </View>
30
30
  <View style={styles.rowBottom}>
31
31
  <Text style={styles.textValue} bold>
@@ -54,7 +54,9 @@ const EvaluationOverConfigDisplay = memo(
54
54
  <IconComponent icon={icon_kit || icon} />
55
55
  </View>
56
56
  <View style={styles.rowTop}>
57
- <Text bold>{stationItem?.configuration?.config_data?.name}</Text>
57
+ <Text semibold>
58
+ {stationItem?.configuration?.config_data?.name}
59
+ </Text>
58
60
  </View>
59
61
 
60
62
  <View style={styles.rowBottom}>
@@ -16,6 +16,7 @@ export default StyleSheet.create({
16
16
  alignItems: 'center',
17
17
  },
18
18
  textValue: {
19
+ fontSize: 16,
19
20
  marginTop: 6,
20
21
  lineHeight: 16,
21
22
  },
@@ -1446,5 +1446,6 @@ export default {
1446
1446
  bellow_widget_is_not_configured: 'Bellow widget is not configured',
1447
1447
  bellow_widget_is_wrongly_configured: 'Bellow widget is wrongly configured',
1448
1448
  'customize...': 'Customize...',
1449
+ uri_invalid: 'URI invalid',
1449
1450
  when_value_is: 'When value is',
1450
1451
  };
@@ -1456,5 +1456,6 @@ export default {
1456
1456
  bellow_widget_is_not_configured: 'Tiện ích bên dưới chưa được cấu hình',
1457
1457
  bellow_widget_is_wrongly_configured: 'Tiện ích bên dưới được cấu hình sai',
1458
1458
  'customize...': 'Tùy chỉnh...',
1459
+ uri_invalid: 'URI không hợp lệ',
1459
1460
  when_value_is: 'Khi giá trị là',
1460
1461
  };
@@ -14,3 +14,8 @@ export const isValidPhoneNumberOrEmailAddress = (data) => {
14
14
 
15
15
  export const isHTML = (string) =>
16
16
  /<[a-z]+\d?(\s+[\w-]+=("[^"]*"|'[^']*'))*\s*\/?>|&#?\w+;/i.test(string);
17
+
18
+ export const isValidURI = (uri) => {
19
+ const uriRegex = /^(rtsp|http|https):\/\/[^\s/$.?#].[^\s]*$/;
20
+ return uriRegex.test(uri);
21
+ };