@ledvance/base 1.0.32 → 1.0.34

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
@@ -4,7 +4,7 @@
4
4
  "name": "@ledvance/base",
5
5
  "pid": [],
6
6
  "uiid": "",
7
- "version": "1.0.32",
7
+ "version": "1.0.34",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@reduxjs/toolkit": "^1.8.6",
package/src/api/native.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { NativeModules } from 'react-native'
1
+ import { NativeModules, Platform } from 'react-native'
2
2
  import { NativeResult, Result } from '../models/modules/Result'
3
3
 
4
4
  interface LDVDevicePanelManager {
@@ -12,8 +12,10 @@ interface LDVDevicePanelManager {
12
12
  putJson: (deviceId: string, featureType: string, json: string, callback: (res: NativeResult<any>) => void) => void
13
13
  getJson: (deviceId: string, featureType: string, callback: (res: NativeResult<string>) => void) => void
14
14
  getInitiativeQueryDpsInfoWithDpsArray: (dpIds: string, deviceId: string, callback: (res: NativeResult<string>) => void) => void
15
- openDownloadFile: (filePath: string) => void
15
+ openDownloadFile: (filePath: string) => void
16
16
  formatNumber: (num: number, fixed: number) => string
17
+ getTimeZone: () => string
18
+
17
19
  }
18
20
 
19
21
  const devicePanel: LDVDevicePanelManager = NativeModules.LDVDevicePanelManager
@@ -33,6 +35,7 @@ const showObj = (objc) => {
33
35
  }
34
36
  }
35
37
 
38
+
36
39
  const control = (devId, dps, callback) => {
37
40
  devicePanel.control({ devId, dps: JSON.stringify(dps) }, res => {
38
41
  callback && callback(res)
@@ -216,20 +219,24 @@ export class NativeApi {
216
219
  // 打开下载文件
217
220
  export const openDownloadFile = (filePath: string) => {
218
221
  return new Promise((_reject) => {
219
- devicePanel.openDownloadFile(filePath)
222
+ devicePanel.openDownloadFile(filePath)
220
223
  })
221
- }
222
-
223
- export const queryDpIds = (dpIds: string, deviceId: string) => {
224
+ }
225
+
226
+ export const queryDpIds = (dpIds: string, deviceId: string) => {
224
227
  return new Promise((resolve, _reject) => {
225
- devicePanel.getInitiativeQueryDpsInfoWithDpsArray(dpIds, deviceId, res => {
226
- resolve(res)
227
- })
228
+ devicePanel.getInitiativeQueryDpsInfoWithDpsArray(dpIds, deviceId, res => {
229
+ resolve(res)
230
+ })
228
231
  })
229
- }
230
-
231
- export const formatNumber: (num: number, fixed: number) => string = (num, fixed) => {
232
+ }
233
+
234
+ export const formatNumber: (num: number, fixed: number) => string = (num, fixed) => {
232
235
  const res = devicePanel.formatNumber(num, fixed)
233
236
  log(`formatNumber: num=${num}, fixed=${fixed}, res=${res}`)
234
237
  return res
235
- }
238
+ }
239
+
240
+ export const getTimeZone: () => string = () => {
241
+ return Platform.OS === 'android' ? devicePanel.getTimeZone() || '' : Intl.DateTimeFormat().resolvedOptions().timeZone
242
+ }
@@ -10,8 +10,10 @@ interface PageProps extends PropsWithChildren<ViewProps> {
10
10
  rightButtonIcon?: string
11
11
  rightButtonIconClick?: () => void
12
12
  headlineText?: string
13
- headlineIcon?: string
13
+ headlineIcon?: string | number
14
14
  onHeadlineIconClick?: () => void
15
+ showGreenery?: boolean
16
+ greeneryIcon?: string | undefined | number
15
17
  }
16
18
 
17
19
  const Page = (props: PageProps) => {
@@ -31,7 +33,10 @@ const Page = (props: PageProps) => {
31
33
  <LdvTopName
32
34
  title={props.headlineText}
33
35
  rightIcon={props.headlineIcon}
34
- rightIconClick={props.onHeadlineIconClick} />}
36
+ rightIconClick={props.onHeadlineIconClick}
37
+ showGreenery={props.showGreenery}
38
+ greeneryIcon={props.greeneryIcon}
39
+ />}
35
40
  {props.children}
36
41
  </View>
37
42
  )
@@ -8,10 +8,13 @@ interface LdvTopNameProps {
8
8
  title: string,
9
9
  rightIcon?: string | undefined | number,
10
10
  rightIconClick?: () => void
11
+ showGreenery?: boolean
12
+ greeneryIcon?: string | undefined | number
11
13
  }
12
14
 
13
15
  const LdvTopName = (props: LdvTopNameProps) => {
14
- const icon = typeof props.rightIcon === 'number' ? props.rightIcon : { uri: props.rightIcon }
16
+ const rightIcon = typeof props.rightIcon === 'number' ? props.rightIcon : {uri : props.rightIcon}
17
+ const greeneryIcon = typeof props.greeneryIcon === 'number' ? props.greeneryIcon : {uri : props.greeneryIcon}
15
18
  return (
16
19
  <View style={styles.container}>
17
20
  <View
@@ -21,12 +24,21 @@ const LdvTopName = (props: LdvTopNameProps) => {
21
24
  alignItems: 'center',
22
25
  marginTop: cx(38),
23
26
  }}>
24
- <Text style={styles.title}>{props.title}</Text>
27
+ <View style={{ flexDirection: 'row', flex: 1 }}>
28
+ <Text style={styles.title}>
29
+ {props.title}
30
+ </Text>
31
+ {props.showGreenery && <Image
32
+ source={greeneryIcon}
33
+ resizeMode="contain"
34
+ style={{ height: cx(16), width: cx(16), left: 0 }}
35
+ /> || null}
36
+ </View>
25
37
  {props.rightIcon && <TouchableOpacity
26
38
  onPress={props.rightIconClick}>
27
39
  <Image
28
40
  style={{ width: cx(24), height: cx(24), tintColor: '#ff6600' }}
29
- source={icon} />
41
+ source={rightIcon} />
30
42
  </TouchableOpacity>}
31
43
  </View>
32
44
  </View>
@@ -39,7 +51,6 @@ const styles = StyleSheet.create({
39
51
  marginBottom: cx(12),
40
52
  },
41
53
  title: {
42
- flex: 1,
43
54
  color: '#f60',
44
55
  fontSize: cx(24),
45
56
  },