@tarojs/taro-rn 4.0.0-beta.13 → 4.0.0-beta.131

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 (182) hide show
  1. package/LICENSE +8 -8
  2. package/apiList.js +31 -31
  3. package/dist/api/index.js +1 -1
  4. package/dist/api/index.js.map +1 -1
  5. package/dist/lib/Mask.js +2 -2
  6. package/dist/lib/Mask.js.map +1 -1
  7. package/dist/lib/Popup.js +20 -13
  8. package/dist/lib/Popup.js.map +1 -1
  9. package/dist/lib/StyleSheet.js +1 -1
  10. package/dist/lib/StyleSheet.js.map +1 -1
  11. package/dist/lib/accelerometer.js +1 -1
  12. package/dist/lib/accelerometer.js.map +1 -1
  13. package/dist/lib/chooseMedia/index.js.map +1 -1
  14. package/dist/lib/clearStorage/index.js +2 -2
  15. package/dist/lib/clearStorage/index.js.map +1 -1
  16. package/dist/lib/compressImage/index.js +1 -1
  17. package/dist/lib/compressImage/index.js.map +1 -1
  18. package/dist/lib/connectSocket/index.js.map +1 -1
  19. package/dist/lib/connectSocket/socketTask.js +1 -1
  20. package/dist/lib/connectSocket/socketTask.js.map +1 -1
  21. package/dist/lib/createCameraContext/index.js +3 -3
  22. package/dist/lib/createCameraContext/index.js.map +1 -1
  23. package/dist/lib/createInnerAudioContext/index.js +2 -2
  24. package/dist/lib/createInnerAudioContext/index.js.map +1 -1
  25. package/dist/lib/createVideoContext/index.js +7 -7
  26. package/dist/lib/createVideoContext/index.js.map +1 -1
  27. package/dist/lib/deviceMotion.js +2 -2
  28. package/dist/lib/deviceMotion.js.map +1 -1
  29. package/dist/lib/file.js +4 -4
  30. package/dist/lib/file.js.map +1 -1
  31. package/dist/lib/getAppBaseInfo/index.js +2 -2
  32. package/dist/lib/getAppBaseInfo/index.js.map +1 -1
  33. package/dist/lib/getClipboardData/index.js.map +1 -1
  34. package/dist/lib/getImageInfo/index.js +2 -2
  35. package/dist/lib/getImageInfo/index.js.map +1 -1
  36. package/dist/lib/getLocation/index.js +8 -4
  37. package/dist/lib/getLocation/index.js.map +1 -1
  38. package/dist/lib/getRecorderManager/index.js +5 -5
  39. package/dist/lib/getRecorderManager/index.js.map +1 -1
  40. package/dist/lib/getStorage/index.js.map +1 -1
  41. package/dist/lib/getStorageInfo/index.js +2 -2
  42. package/dist/lib/getStorageInfo/index.js.map +1 -1
  43. package/dist/lib/getSystemInfo/index.js +1 -1
  44. package/dist/lib/getSystemInfo/index.js.map +1 -1
  45. package/dist/lib/getSystemInfoSync/index.js +2 -2
  46. package/dist/lib/getSystemInfoSync/index.js.map +1 -1
  47. package/dist/lib/gyroscope.js +1 -1
  48. package/dist/lib/gyroscope.js.map +1 -1
  49. package/dist/lib/keyboard.js +3 -3
  50. package/dist/lib/keyboard.js.map +1 -1
  51. package/dist/lib/location.js.map +1 -1
  52. package/dist/lib/makePhoneCall/index.js +1 -1
  53. package/dist/lib/makePhoneCall/index.js.map +1 -1
  54. package/dist/lib/media.js +15 -13
  55. package/dist/lib/media.js.map +1 -1
  56. package/dist/lib/network.js +1 -1
  57. package/dist/lib/network.js.map +1 -1
  58. package/dist/lib/offWindowResize/index.js.map +1 -1
  59. package/dist/lib/onWindowResize/index.js +1 -1
  60. package/dist/lib/onWindowResize/index.js.map +1 -1
  61. package/dist/lib/openUrl/index.js +1 -1
  62. package/dist/lib/openUrl/index.js.map +1 -1
  63. package/dist/lib/permission.js +6 -5
  64. package/dist/lib/permission.js.map +1 -1
  65. package/dist/lib/previewImage/index.js +3 -3
  66. package/dist/lib/previewImage/index.js.map +1 -1
  67. package/dist/lib/request/index.js +1 -1
  68. package/dist/lib/request/index.js.map +1 -1
  69. package/dist/lib/scanCode/index.js +22 -22
  70. package/dist/lib/scanCode/index.js.map +1 -1
  71. package/dist/lib/screen.js +2 -2
  72. package/dist/lib/screen.js.map +1 -1
  73. package/dist/lib/setClipboardData/index.js +2 -2
  74. package/dist/lib/setClipboardData/index.js.map +1 -1
  75. package/dist/lib/setKeepScreenOn/index.js +1 -1
  76. package/dist/lib/setKeepScreenOn/index.js.map +1 -1
  77. package/dist/lib/setStorage/index.js.map +1 -1
  78. package/dist/lib/showActionSheet/ActionSheet.js +11 -23
  79. package/dist/lib/showActionSheet/ActionSheet.js.map +1 -1
  80. package/dist/lib/showActionSheet/index.js.map +1 -1
  81. package/dist/lib/showModal/Dialog.js +22 -36
  82. package/dist/lib/showModal/Dialog.js.map +1 -1
  83. package/dist/lib/showModal/index.js.map +1 -1
  84. package/dist/lib/showModal/toast.js +6 -6
  85. package/dist/lib/showModal/toast.js.map +1 -1
  86. package/dist/lib/unsupportedApi.js +2 -4
  87. package/dist/lib/unsupportedApi.js.map +1 -1
  88. package/dist/lib/variable.js +1 -1
  89. package/dist/lib/variable.js.map +1 -1
  90. package/dist/lib/vibrate.js +1 -1
  91. package/dist/lib/vibrate.js.map +1 -1
  92. package/dist/lib/window.js.map +1 -1
  93. package/dist/utils/callbackManager.js.map +1 -1
  94. package/dist/utils/index.js.map +1 -1
  95. package/package.json +66 -60
  96. package/src/api/index.ts +31 -31
  97. package/src/lib/ENV_TYPE/index.ts +1 -1
  98. package/src/lib/Mask.tsx +2 -2
  99. package/src/lib/Popup.tsx +26 -19
  100. package/src/lib/StyleSheet.ts +1 -1
  101. package/src/lib/accelerometer.ts +2 -1
  102. package/src/lib/arrayBufferToBase64/index.ts +1 -1
  103. package/src/lib/base64ToArrayBuffer/index.ts +1 -1
  104. package/src/lib/chooseMedia/index.ts +1 -1
  105. package/src/lib/clearStorage/index.ts +1 -0
  106. package/src/lib/clearStorageSync/index.ts +1 -1
  107. package/src/lib/compressImage/index.ts +1 -0
  108. package/src/lib/connectSocket/socketTask.ts +7 -9
  109. package/src/lib/createCameraContext/index.ts +6 -4
  110. package/src/lib/createInnerAudioContext/index.ts +1 -0
  111. package/src/lib/createSelectorQuery/index.ts +1 -1
  112. package/src/lib/deviceMotion.ts +4 -3
  113. package/src/lib/file.ts +9 -8
  114. package/src/lib/getClipboardData/index.ts +1 -0
  115. package/src/lib/getEnv/index.ts +1 -1
  116. package/src/lib/getFileSystemManager/index.ts +1 -1
  117. package/src/lib/getLocation/index.ts +7 -2
  118. package/src/lib/getRecorderManager/index.ts +1 -1
  119. package/src/lib/getStorage/index.ts +1 -0
  120. package/src/lib/getStorageInfo/index.ts +1 -0
  121. package/src/lib/getStorageInfoSync/index.ts +1 -1
  122. package/src/lib/getStorageSync/index.ts +1 -1
  123. package/src/lib/getSystemInfo/index.ts +2 -2
  124. package/src/lib/getSystemInfoSync/index.ts +3 -3
  125. package/src/lib/gyroscope.ts +47 -46
  126. package/src/lib/keyboard.ts +5 -4
  127. package/src/lib/location.ts +6 -5
  128. package/src/lib/makePhoneCall/index.ts +2 -1
  129. package/src/lib/media.ts +21 -18
  130. package/src/lib/network.ts +5 -5
  131. package/src/lib/offLocationChange/index.ts +1 -1
  132. package/src/lib/offUserCaptureScreen/index.ts +1 -1
  133. package/src/lib/onLocationChange/index.ts +1 -1
  134. package/src/lib/onUserCaptureScreen/index.ts +1 -1
  135. package/src/lib/onWindowResize/index.ts +2 -2
  136. package/src/lib/openUrl/index.d.ts +23 -22
  137. package/src/lib/openUrl/index.ts +2 -1
  138. package/src/lib/permission.ts +33 -25
  139. package/src/lib/previewImage/index.tsx +4 -3
  140. package/src/lib/removeStorageSync/index.ts +1 -1
  141. package/src/lib/request/index.ts +2 -2
  142. package/src/lib/scanCode/index.tsx +17 -15
  143. package/src/lib/screen.ts +1 -0
  144. package/src/lib/setClipboardData/index.ts +3 -2
  145. package/src/lib/setKeepScreenOn/index.ts +2 -1
  146. package/src/lib/setStorage/index.ts +1 -0
  147. package/src/lib/setStorageSync/index.ts +1 -1
  148. package/src/lib/showActionSheet/ActionSheet.tsx +34 -43
  149. package/src/lib/showActionSheet/index.tsx +1 -0
  150. package/src/lib/showModal/Dialog.tsx +34 -39
  151. package/src/lib/showModal/index.tsx +1 -0
  152. package/src/lib/showModal/toast.tsx +14 -13
  153. package/src/lib/startGyroscope/index.ts +1 -1
  154. package/src/lib/startLocationUpdate/index.ts +1 -1
  155. package/src/lib/unsupportedApi.ts +3 -5
  156. package/src/lib/vibrate.ts +11 -10
  157. package/src/lib/window.ts +3 -2
  158. package/src/utils/callbackManager.ts +5 -5
  159. package/src/utils/index.ts +4 -4
  160. package/{src/types → types}/vue/index.d.ts +2 -3
  161. package/dist/setup.js +0 -58
  162. package/dist/setup.js.map +0 -1
  163. package/src/__tests__/__mock__/mockRNCCameraRoll.js +0 -7
  164. package/src/__tests__/__mock__/mockRNCGeolocation.js +0 -13
  165. package/src/__tests__/__snapshots__/scanCode.test.tsx.snap +0 -154
  166. package/src/__tests__/clipboard.test.ts +0 -88
  167. package/src/__tests__/deviceMotion.test.ts +0 -37
  168. package/src/__tests__/geolocation.test.ts +0 -60
  169. package/src/__tests__/interactive.test.tsx +0 -101
  170. package/src/__tests__/keyboard.test.ts +0 -46
  171. package/src/__tests__/media.test.ts +0 -104
  172. package/src/__tests__/network.test.ts +0 -57
  173. package/src/__tests__/others.test.ts +0 -25
  174. package/src/__tests__/phone.test.ts +0 -31
  175. package/src/__tests__/request.test.ts +0 -146
  176. package/src/__tests__/scanCode.test.tsx +0 -14
  177. package/src/__tests__/storage.test.ts +0 -202
  178. package/src/__tests__/system.test.ts +0 -69
  179. package/src/__tests__/vibrate.test.ts +0 -27
  180. package/src/__tests__/websocket.test.ts +0 -170
  181. package/src/setup.ts +0 -64
  182. /package/{src/types → types}/definition.d.ts +0 -0
@@ -1,9 +1,10 @@
1
1
  import React from 'react'
2
- import { View, ActivityIndicator, StyleSheet, Alert, Modal } from 'react-native'
3
- import RootSiblings from 'react-native-root-siblings'
2
+ import { ActivityIndicator, Alert, Modal, StyleSheet, View } from 'react-native'
4
3
  import ImageViewer from 'react-native-image-zoom-viewer'
5
- import { saveMedia } from '../media'
4
+ import RootSiblings from 'react-native-root-siblings'
5
+
6
6
  import { downloadFile } from '../file'
7
+ import { saveMedia } from '../media'
7
8
 
8
9
  const styles = StyleSheet.create({
9
10
  mask: {
@@ -1 +1 @@
1
- export { removeStorageSync } from '../unsupportedApi'
1
+ export { removeStorageSync } from '../unsupportedApi'
@@ -1,4 +1,4 @@
1
- import { errorHandler, successHandler } from "../../utils"
1
+ import { errorHandler, successHandler } from '../../utils'
2
2
 
3
3
  function serializeParams(params) {
4
4
  if (!params) {
@@ -53,7 +53,7 @@ function _request<T = any>(options: Taro.request.Option): Taro.RequestTask<T> {
53
53
  params.method = method
54
54
  let controller
55
55
  // eslint-disable-next-line no-undef
56
- if (typeof(AbortController) !== 'undefined' ) {
56
+ if (typeof (AbortController) !== 'undefined') {
57
57
  // eslint-disable-next-line no-undef
58
58
  controller = new AbortController()
59
59
  const signal = controller.signal
@@ -1,12 +1,13 @@
1
- import { initialWindowMetrics } from 'react-native-safe-area-context'
2
- import { Camera } from 'expo-camera'
3
1
  import { BarCodeScanner, requestPermissionsAsync } from 'expo-barcode-scanner'
4
- import { BackHandler, Image, TouchableOpacity, StyleSheet, View, Dimensions, Platform, StatusBar } from 'react-native'
5
- import iconClose from './icon_close.png'
6
- import iconPic from './icon_pic.png'
2
+ import { BarcodeType, CameraView } from 'expo-camera'
3
+ import React from 'react'
4
+ import { BackHandler, Dimensions, Image, Platform, StatusBar, StyleSheet, TouchableOpacity, View } from 'react-native'
7
5
  import RootSiblings from 'react-native-root-siblings'
6
+ import { initialWindowMetrics } from 'react-native-safe-area-context'
7
+
8
8
  import { chooseMedia, MEDIA_TYPE } from '../media'
9
- import React from 'react'
9
+ import iconClose from './icon_close.png'
10
+ import iconPic from './icon_pic.png'
10
11
 
11
12
  export let scannerView
12
13
 
@@ -47,13 +48,15 @@ function findKey (value:string, data, compare = (a, b) => a === b):string {
47
48
 
48
49
  const { width, height } = Dimensions.get('screen')
49
50
 
50
- function getBarCodeTypes(types:string[]):string[] {
51
- const result:string[] = []
51
+ function getBarCodeTypes(types:string[]): BarcodeType[] {
52
+ const result: BarcodeType[] = []
53
+
52
54
  for (const t of types) {
53
55
  result.push(...typeMap[t].map(type => {
54
56
  return BarCodeType[type]
55
57
  }))
56
58
  }
59
+
57
60
  return result.filter(r => !!r)
58
61
  }
59
62
 
@@ -148,20 +151,20 @@ function scanFromPhoto(callback, errorCallBack) {
148
151
 
149
152
  export async function scanCode(option: Taro.scanCode.Option = {}): Promise<Taro.scanCode.SuccessCallbackResult> {
150
153
  const { success, fail, complete, onlyFromCamera, scanType = ['barCode', 'qrCode'] } = option
151
- const { granted } = await requestPermissionsAsync();
154
+ const { granted } = await requestPermissionsAsync()
152
155
  if (!granted) {
153
156
  const res = { errMsg: 'Permissions denied!' }
154
157
  fail?.(res)
155
158
  complete?.(res)
156
159
  return Promise.reject(res)
157
160
  }
158
- const barCodeTypes = getBarCodeTypes(scanType)
161
+ const barcodeTypes = getBarCodeTypes(scanType)
159
162
  return new Promise((resolve, reject) => {
160
163
  scannerView = new RootSiblings(
161
164
  (<View style={[styles.container]}>
162
165
  <StatusBar backgroundColor="rgba(0, 0, 0, 0)" translucent hidden={Platform.OS === 'ios'} />
163
- <Camera
164
- onBarCodeScanned={({ type, data }: {type: string, data: string}) => {
166
+ <CameraView
167
+ onBarcodeScanned={({ type, data }: {type: string, data: string}) => {
165
168
  const res = {
166
169
  charSet: 'UTF-8', // todo
167
170
  path: '', // todo
@@ -175,11 +178,10 @@ export async function scanCode(option: Taro.scanCode.Option = {}): Promise<Taro.
175
178
  hide(scannerView)
176
179
  resolve(res)
177
180
  }}
178
- barCodeScannerSettings={{
179
- barCodeTypes,
181
+ barcodeScannerSettings={{
182
+ barcodeTypes,
180
183
  }}
181
184
  style={{ width, height }}
182
- ratio='16:9'
183
185
  />
184
186
  <TouchableOpacity accessibilityLabel="Close" style={styles.closeIcon} onPress={() => hide(scannerView)}>
185
187
  {safeViewWrapper(<Image source={iconClose} style={styles.closeImg}/>)}
package/src/lib/screen.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as Brightness from 'expo-brightness'
2
+
2
3
  import { errorHandler, shouldBeObject, successHandler } from '../utils'
3
4
 
4
5
  /**
@@ -1,6 +1,7 @@
1
1
  import Clipboard from '@react-native-clipboard/clipboard'
2
+
3
+ import { errorHandler, successHandler } from '../../utils'
2
4
  import { showToast } from '../showModal/toast'
3
- import { successHandler, errorHandler } from '../../utils'
4
5
 
5
6
  export function setClipboardData(opts: Taro.setClipboardData.Option): Promise<Taro.setClipboardData.Promised> {
6
7
  const { data, success, fail, complete } = opts
@@ -18,7 +19,7 @@ export function setClipboardData(opts: Taro.setClipboardData.Option): Promise<Ta
18
19
  data,
19
20
  }
20
21
  showToast({
21
- icon: "none",
22
+ icon: 'none',
22
23
  title: '内容已复制'
23
24
  })
24
25
  return successHandler(success, complete)(res)
@@ -1,5 +1,6 @@
1
1
  import { activateKeepAwake, deactivateKeepAwake } from 'expo-keep-awake'
2
- import { successHandler, errorHandler } from '../../utils'
2
+
3
+ import { errorHandler, successHandler } from '../../utils'
3
4
 
4
5
  /**
5
6
  * keepScreenOn
@@ -1,4 +1,5 @@
1
1
  import AsyncStorage from '@react-native-async-storage/async-storage'
2
+
2
3
  import { errorHandler, successHandler } from '../../utils'
3
4
 
4
5
  export async function setStorage(option: Taro.setStorage.Option): Promise<TaroGeneral.CallbackResult> {
@@ -1 +1 @@
1
- export { setStorageSync } from '../unsupportedApi'
1
+ export { setStorageSync } from '../unsupportedApi'
@@ -1,19 +1,20 @@
1
- import React from 'react'
1
+ import { ViewPropTypes } from 'deprecated-react-native-prop-types'
2
2
  import PropTypes from 'prop-types'
3
+ import React from 'react'
3
4
  import {
4
- View,
5
+ Platform,
6
+ StyleSheet,
5
7
  Text,
6
8
  TouchableHighlight,
7
- StyleSheet,
8
- Platform
9
+ View
9
10
  } from 'react-native'
10
- import { ViewPropTypes } from 'deprecated-react-native-prop-types'
11
- import { initialWindowMetrics } from 'react-native-safe-area-context';
11
+ import { initialWindowMetrics } from 'react-native-safe-area-context'
12
+
12
13
  import { Popup } from '../Popup'
13
14
  import V from '../variable'
14
15
 
15
16
  const styles = StyleSheet.create({
16
- iosActionsheet: {
17
+ actionsheet: {
17
18
  backgroundColor: V.weuiBgColorDefault
18
19
  },
19
20
  androidActionsheetWrapper: {
@@ -21,11 +22,6 @@ const styles = StyleSheet.create({
21
22
  alignItems: 'center',
22
23
  justifyContent: 'center'
23
24
  },
24
- androidActionsheet: {
25
- width: 274,
26
- backgroundColor: V.weuiBgColorDefault,
27
- borderRadius: V.weuiActionSheetAndroidBorderRadius
28
- },
29
25
  actionsheetMenu: {
30
26
  backgroundColor: '#fff'
31
27
  },
@@ -36,29 +32,23 @@ const styles = StyleSheet.create({
36
32
  actionsheetCell: {
37
33
  borderTopWidth: StyleSheet.hairlineWidth,
38
34
  borderColor: V.weuiCellBorderColor,
39
- borderStyle: 'solid'
40
- },
41
- iosActionsheetCell: {
35
+ borderStyle: 'solid',
42
36
  paddingTop: 10,
43
- paddingBottom: 10
44
- },
45
- androidActionsheetCell: {
46
- paddingTop: 13,
47
- paddingBottom: 13,
37
+ paddingBottom: 10,
48
38
  paddingLeft: 24,
49
39
  paddingRight: 24
50
40
  },
41
+
51
42
  firstActionsheetCell: {
52
43
  borderTopWidth: 0
53
44
  },
54
- iosActionsheetCellText: {
45
+ actionSheetCellText: {
55
46
  textAlign: 'center',
56
47
  fontSize: 18,
57
48
  marginTop: ((18 * V.baseLineHeight) - 18) / 2,
58
49
  marginBottom: ((18 * V.baseLineHeight) - 18) / 2
59
50
  },
60
51
  androidActionsheetCellText: {
61
- textAlign: 'center',
62
52
  fontSize: 16,
63
53
  marginTop: ((16 * 1.4) - 16) / 2,
64
54
  marginBottom: ((16 * 1.4) - 16) / 2
@@ -105,7 +95,6 @@ const Index: React.FC<any> = ({
105
95
  underlayColor={underlayColor}
106
96
  style={[
107
97
  styles.actionsheetCell,
108
- styles[`${_type}ActionsheetCell`],
109
98
  idx === 0 ? styles.firstActionsheetCell : {},
110
99
  btnStyle
111
100
  ]}
@@ -113,6 +102,8 @@ const Index: React.FC<any> = ({
113
102
  >
114
103
  <Text
115
104
  style={[
105
+
106
+ styles.actionSheetCellText,
116
107
  styles[`${_type}ActionsheetCellText`],
117
108
  styles[`${btnType}ActionsheetCellText`],
118
109
  textStyle
@@ -128,7 +119,6 @@ const Index: React.FC<any> = ({
128
119
  underlayColor={underlayColor}
129
120
  style={[
130
121
  styles.actionsheetCell,
131
- styles[`${_type}ActionsheetCell`],
132
122
  idx === 0 ? styles.firstActionsheetCell : {},
133
123
  btnStyle
134
124
  ]}
@@ -136,6 +126,7 @@ const Index: React.FC<any> = ({
136
126
  >
137
127
  <Text
138
128
  style={[
129
+ styles.actionSheetCellText,
139
130
  styles[`${_type}ActionsheetCellText`],
140
131
  styles[`${btnType}ActionsheetCellText`],
141
132
  textStyle
@@ -145,29 +136,29 @@ const Index: React.FC<any> = ({
145
136
  )
146
137
 
147
138
  return <Popup
148
- visible={visible}
149
- style={[styles.iosActionsheet, style]}
150
- maskStyle={maskStyle}
151
- onShow={onShow}
152
- onClose={onClose}
153
- >
154
- {menus.length
155
- ? <View style={[styles.actionsheetMenu]}>
156
- {_renderMenuItems()}
157
- </View>
158
- : false}
159
- {actions.length
160
- ? <View style={[styles.actionsheetAction]}>
161
- {_renderActions()}
162
- </View>
163
- : false}
164
- <View style={{paddingBottom: Math.max(initialWindowMetrics?.insets.bottom || 0, 16), backgroundColor: '#fff'}}></View>
165
- </Popup>
139
+ visible={visible}
140
+ style={[styles.actionsheet, style]}
141
+ maskStyle={maskStyle}
142
+ onShow={onShow}
143
+ onClose={onClose}
144
+ >
145
+ {menus.length
146
+ ? <View style={[styles.actionsheetMenu]}>
147
+ {_renderMenuItems()}
148
+ </View>
149
+ : false}
150
+ {actions.length
151
+ ? <View style={[styles.actionsheetAction]}>
152
+ {_renderActions()}
153
+ </View>
154
+ : false}
155
+ <View style={{ paddingBottom: Math.max(initialWindowMetrics?.insets.bottom || 0, 16), backgroundColor: '#fff' }}></View>
156
+ </Popup>
166
157
  }
167
158
 
168
159
  Index.propTypes = {
169
160
  autoDectect: PropTypes.bool,
170
- type: PropTypes.oneOf(['ios', 'android']),
161
+ type: PropTypes.oneOf(['ios', 'android', 'harmony']),
171
162
  menus: PropTypes.any,
172
163
  actions: PropTypes.any,
173
164
  visible: PropTypes.bool,
@@ -1,5 +1,6 @@
1
1
  import React from 'react'
2
2
  import RootSiblings from 'react-native-root-siblings'
3
+
3
4
  import ActionSheet from './ActionSheet'
4
5
 
5
6
  function showActionSheet (obj: Taro.showActionSheet.Option): Promise<Taro.showActionSheet.SuccessCallbackResult> {
@@ -1,14 +1,15 @@
1
- import React from 'react'
1
+ import { TextPropTypes, ViewPropTypes } from 'deprecated-react-native-prop-types'
2
2
  import PropTypes from 'prop-types'
3
+ import React from 'react'
3
4
  import {
4
- View,
5
- Text,
6
- TouchableHighlight,
7
5
  Dimensions,
6
+ Platform,
8
7
  StyleSheet,
9
- Platform
8
+ Text,
9
+ TouchableHighlight,
10
+ View
10
11
  } from 'react-native'
11
- import { ViewPropTypes, TextPropTypes } from 'deprecated-react-native-prop-types'
12
+
12
13
  import { Mask } from '../Mask'
13
14
  import { create } from '../StyleSheet'
14
15
  import V from '../variable'
@@ -33,49 +34,42 @@ const styles = create({
33
34
  paddingRight: V.weuiDialogGapWidth
34
35
  },
35
36
  dialogTitle: {
36
- fontWeight: '400'
37
- },
38
- iosDialogTitle: {
39
- fontSize: 18,
37
+ fontWeight: '700',
38
+ fontSize: 17,
40
39
  textAlign: 'center'
41
40
  },
41
+
42
42
  androidDialogTitle: {
43
43
  fontSize: 21,
44
44
  textAlign: 'left'
45
45
  },
46
+
46
47
  dialogBody: {
47
48
  paddingLeft: V.weuiDialogGapWidth,
48
- paddingRight: V.weuiDialogGapWidth
49
- },
50
- iosDialogBody: {
51
- paddingBottom: (0.8 * 15) + 20
52
- },
53
- androidDialogBody: {
54
- paddingTop: 0.25 * 17,
55
- paddingBottom: (17 * 2) + 20
49
+ paddingRight: V.weuiDialogGapWidth,
50
+ marginBottom: 32
56
51
  },
52
+
57
53
  dialogBodyText: {
58
54
  color: V.weuiTextColorGray,
59
- lineHeight: 15 * 1.3,
55
+ fontSize: 17,
56
+ textAlign: 'center',
57
+ lineHeight: 17 * 1.4,
60
58
  android: {
61
- lineHeight: Math.round(15 * 1.3)
59
+ lineHeight: Math.round(17 * 1.4)
62
60
  }
63
61
  },
64
- iosDialogBodyText: {
65
- fontSize: 15,
66
- textAlign: 'center'
67
- },
62
+
68
63
  androidDialogBodyText: {
69
- fontSize: 17,
70
64
  textAlign: 'left'
71
65
  },
72
66
  dialogFooter: {
73
- flexDirection: 'row'
74
- },
75
- iosDialogFooter: {
67
+ flexDirection: 'row',
76
68
  height: 48,
77
69
  alignItems: 'center',
78
70
  justifyContent: 'center',
71
+ },
72
+ dialogFooterBorder: {
79
73
  borderTopWidth: StyleSheet.hairlineWidth,
80
74
  borderColor: V.weuiDialogLineColor,
81
75
  borderStyle: 'solid'
@@ -90,17 +84,16 @@ const styles = create({
90
84
  },
91
85
  dialogFooterOpr: {
92
86
  alignItems: 'center',
93
- justifyContent: 'center'
94
- },
95
- iosDialogFooterOpr: {
87
+ justifyContent: 'center',
96
88
  height: 48,
97
- flex: 1
89
+ flex: 1,
98
90
  },
99
91
  androidDialogFooterOpr: {
100
92
  height: 42,
101
93
  paddingLeft: 16 * 0.8,
102
94
  paddingRight: 16 * 0.8
103
95
  },
96
+
104
97
  dialogFooterOprWithNegativeMarginRight: {
105
98
  marginRight: 0 - (16 * 0.8)
106
99
  },
@@ -109,12 +102,13 @@ const styles = create({
109
102
  borderColor: V.weuiDialogLineColor,
110
103
  borderStyle: 'solid'
111
104
  },
112
- iosDialogFooterOprText: {
105
+ dialogFooterOprText: {
113
106
  fontSize: 18
114
107
  },
115
108
  androidDialogFooterOprText: {
116
109
  fontSize: 16
117
110
  },
111
+
118
112
  defaultDialogFooterOprText: {
119
113
  color: '#353535'
120
114
  },
@@ -170,14 +164,15 @@ const Index: React.FC<any> = (
170
164
  style={[
171
165
  styles.dialogFooterOpr,
172
166
  styles[`${_type}DialogFooterOpr`],
173
- _type === 'ios' && idx > 0 ? styles.dialogFooterOprWithBorder : {},
174
- _type === 'android' && idx === buttons.length - 1 ? styles.dialogFooterOprWithNegativeMarginRight : {}
167
+ _type === 'android' && idx === buttons.length - 1 ? styles.dialogFooterOprWithNegativeMarginRight : (
168
+ idx > 0 ? styles.dialogFooterOprWithBorder : {}
169
+ ),
175
170
  ]}
176
171
  underlayColor={underlayColor}
177
172
  {...others}
178
173
  >
179
174
  <Text
180
- style={[styles[`${_type}DialogFooterOprText`], { color: btnType }]}
175
+ style={[styles.dialogFooterOprText, styles[`${_type}DialogFooterOprText`], { color: btnType }]}
181
176
  >{label}</Text>
182
177
  </TouchableHighlight>
183
178
  )
@@ -200,10 +195,10 @@ const Index: React.FC<any> = (
200
195
  <View style={[styles.dialogHeader, headerStyle]}>
201
196
  <Text style={[styles.dialogTitle, styles[`${_type}DialogTitle`], titleStyle]}>{title}</Text>
202
197
  </View>
203
- <View style={[styles.dialogBody, styles[`${_type}DialogBody`], bodyStyle]}>
198
+ <View style={[styles.dialogBody, bodyStyle]}>
204
199
  {childrenWithProps}
205
200
  </View>
206
- <View style={[styles.dialogFooter, styles[`${_type}DialogFooter`], footerStyle]}>
201
+ <View style={[styles.dialogFooter, styles[`${_type}DialogFooter`], _type !== 'android' ? styles.dialogFooterBorder : {}, footerStyle]}>
207
202
  {_renderButtons()}
208
203
  </View>
209
204
  </View>
@@ -214,7 +209,7 @@ const Index: React.FC<any> = (
214
209
 
215
210
  Index.propTypes = {
216
211
  autoDectect: PropTypes.bool,
217
- type: PropTypes.oneOf(['ios', 'android']),
212
+ type: PropTypes.oneOf(['ios', 'android', 'harmony']),
218
213
  title: PropTypes.string,
219
214
  buttons: PropTypes.arrayOf(PropTypes.object),
220
215
  visible: PropTypes.bool,
@@ -1,6 +1,7 @@
1
1
  import React from 'react'
2
2
  import { Text } from 'react-native'
3
3
  import RootSiblings from 'react-native-root-siblings'
4
+
4
5
  import Dialog from './Dialog'
5
6
 
6
7
  function showModal (obj: Taro.showModal.Option): Promise<Taro.showModal.SuccessCallbackResult> {
@@ -1,10 +1,11 @@
1
- import React from 'react'
2
1
  import PropTypes from 'prop-types'
3
- import { View, Text, Image, StyleSheet, ActivityIndicator } from 'react-native'
2
+ import React from 'react'
3
+ import { ActivityIndicator, Image, StyleSheet, Text, View } from 'react-native'
4
4
  import RootSiblings from 'react-native-root-siblings'
5
- import successPng from './success.png'
6
- import errorPng from './error.png'
5
+
7
6
  import { errorHandler, shouldBeObject, successHandler } from '../../utils'
7
+ import errorPng from './error.png'
8
+ import successPng from './success.png'
8
9
 
9
10
  const globalAny: any = global
10
11
 
@@ -118,7 +119,7 @@ function showToast (options: Taro.showToast.Option): Promise<TaroGeneral.Callbac
118
119
  return Promise.reject(res)
119
120
  }
120
121
 
121
- let {title = '', icon = 'success', image, duration = 1500, mask = false, success, fail, complete} = options || {} // eslint-disable-line
122
+ let { title = '', icon = 'success', image, duration = 1500, mask = false, success, fail, complete } = options || {} // eslint-disable-line
122
123
 
123
124
  const isLoading = (icon === 'loading')
124
125
 
@@ -138,7 +139,7 @@ function showToast (options: Taro.showToast.Option): Promise<TaroGeneral.Callbac
138
139
  </View>
139
140
  </View>
140
141
  } else if (isLoading) {
141
- ToastView = <WXLoading title={title} mask={mask}/>
142
+ ToastView = <WXLoading title={title} mask={mask} />
142
143
  } else if (icon === 'none') {
143
144
  ToastView = <View style={maskStyle}>
144
145
  <View style={styles.textGrayBlock}>
@@ -159,7 +160,7 @@ function showToast (options: Taro.showToast.Option): Promise<TaroGeneral.Callbac
159
160
  try {
160
161
  // setTimeout fires incorrectly when using chrome debug #4470
161
162
  // https://github.com/facebook/react-native/issues/4470
162
- globalAny.wxToastRootSiblings && globalAny.wxToastRootSiblings.destroy();
163
+ globalAny.wxToastRootSiblings && globalAny.wxToastRootSiblings.destroy()
163
164
 
164
165
  globalAny.wxToastRootSiblings = new RootSiblings(ToastView)
165
166
  setTimeout(() => {
@@ -177,7 +178,7 @@ function showToast (options: Taro.showToast.Option): Promise<TaroGeneral.Callbac
177
178
  }
178
179
  }
179
180
 
180
- function showLoading (options: Taro.showLoading.Option): Promise<TaroGeneral.CallbackResult> {
181
+ function showLoading (options: Taro.showLoading.Option = { title: '加载中' }): Promise<TaroGeneral.CallbackResult> {
181
182
  const isObject = shouldBeObject(options)
182
183
  if (!isObject.res) {
183
184
  const res = { errMsg: `showLoading${isObject.msg}` }
@@ -202,7 +203,7 @@ function hideToast (opts: Taro.hideToast.Option = {}): void {
202
203
  const { success, fail, complete } = opts
203
204
 
204
205
  try {
205
- globalAny.wxToastRootSiblings && globalAny.wxToastRootSiblings.destroy();
206
+ globalAny.wxToastRootSiblings && globalAny.wxToastRootSiblings.destroy()
206
207
  globalAny.wxToastRootSiblings = undefined
207
208
  const res = { errMsg: 'showToast:ok' }
208
209
  success?.(res)
@@ -218,7 +219,7 @@ function hideLoading (opts: Taro.hideLoading.Option = {}): void {
218
219
  const { success, fail, complete } = opts
219
220
 
220
221
  try {
221
- globalAny.wxToastRootSiblings && globalAny.wxToastRootSiblings.destroy();
222
+ globalAny.wxToastRootSiblings && globalAny.wxToastRootSiblings.destroy()
222
223
  globalAny.wxToastRootSiblings = undefined
223
224
  const res = { errMsg: 'showLoading:ok' }
224
225
  success?.(res)
@@ -231,8 +232,8 @@ function hideLoading (opts: Taro.hideLoading.Option = {}): void {
231
232
  }
232
233
 
233
234
  export {
234
- showToast,
235
- showLoading,
235
+ hideLoading,
236
236
  hideToast,
237
- hideLoading
237
+ showLoading,
238
+ showToast
238
239
  }
@@ -1 +1 @@
1
- export { startGyroscope } from '../gyroscope'
1
+ export { startGyroscope } from '../gyroscope'
@@ -1 +1 @@
1
- export { startLocationUpdate } from '../location'
1
+ export { startLocationUpdate } from '../location'
@@ -1,14 +1,12 @@
1
- function temporarilyNotSupport(apiName: String, recommended?: String, isSync = true) {
1
+ function temporarilyNotSupport(apiName: string, recommended?: string, isSync = true) {
2
2
  return () => {
3
3
  let errMsg = `RN 端暂不支持 API ${apiName}`
4
- if (!!recommended) {
4
+ if (recommended) {
5
5
  errMsg += `, 请使用 ${recommended}`
6
6
  }
7
7
  console.error(errMsg)
8
8
  if (!isSync) {
9
- return Promise.reject({
10
- errMsg
11
- })
9
+ return Promise.reject(new Error(errMsg))
12
10
  } else {
13
11
  return new Error(errMsg)
14
12
  }
@@ -1,16 +1,17 @@
1
1
  import { Vibration } from 'react-native'
2
+
2
3
  import { errorHandler, successHandler } from '../utils'
3
4
 
4
5
  function vibrate (DURATION, API, OPTS): Promise<TaroGeneral.CallbackResult> {
5
6
  const res = { errMsg: `${API}:ok` }
6
- const { success, fail, complete } = OPTS
7
- try {
8
- Vibration.vibrate(DURATION)
9
- return successHandler(success, complete)(res)
10
- } catch (err) {
11
- res.errMsg = err.message
12
- return errorHandler(fail, complete)(res)
13
- }
7
+ const { success, fail, complete } = OPTS
8
+ try {
9
+ Vibration.vibrate(DURATION)
10
+ return successHandler(success, complete)(res)
11
+ } catch (err) {
12
+ res.errMsg = err.message
13
+ return errorHandler(fail, complete)(res)
14
+ }
14
15
  }
15
16
 
16
17
  function vibrateShort (opts: Taro.vibrateShort.Option = {}): Promise<TaroGeneral.CallbackResult> {
@@ -22,6 +23,6 @@ function vibrateLong (opts: Taro.vibrateLong.Option = {}): Promise<TaroGeneral.C
22
23
  }
23
24
 
24
25
  export {
25
- vibrateShort,
26
- vibrateLong
26
+ vibrateLong,
27
+ vibrateShort
27
28
  }
package/src/lib/window.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { ScaledSize, Dimensions, EmitterSubscription } from 'react-native'
1
+ import { Dimensions, EmitterSubscription, ScaledSize } from 'react-native'
2
+
2
3
  import { createCallbackManager } from '../utils'
3
4
 
4
5
  let listener: EmitterSubscription
@@ -18,4 +19,4 @@ export const addListener = () => {
18
19
 
19
20
  export const removeListener = () => {
20
21
  listener?.remove()
21
- }
22
+ }
@@ -1,9 +1,9 @@
1
1
  interface CallbackManager {
2
- add: (opt: any) => void;
3
- remove: (opt: any) => void;
4
- clear: () => void;
5
- count: () => number;
6
- trigger: (...args: any[]) => void;
2
+ add: (opt: any) => void
3
+ remove: (opt: any) => void
4
+ clear: () => void
5
+ count: () => number
6
+ trigger: (...args: any[]) => void
7
7
  }
8
8
 
9
9
  export function createCallbackManager(): CallbackManager {