diff --git a/packages/taro-components-rn/.expo/settings.json b/packages/taro-components-rn/.expo/settings.json new file mode 100644 index 000000000000..8e4fcd22acd6 --- /dev/null +++ b/packages/taro-components-rn/.expo/settings.json @@ -0,0 +1,7 @@ +{ + "hostType": "lan", + "lanType": "ip", + "dev": true, + "minify": false, + "urlRandomness": null +} \ No newline at end of file diff --git a/packages/taro-rn/example/pages/index/index.js b/packages/taro-rn/example/pages/index/index.js index d175f713bfa2..116ec6ee3d94 100644 --- a/packages/taro-rn/example/pages/index/index.js +++ b/packages/taro-rn/example/pages/index/index.js @@ -2,6 +2,9 @@ import React from 'react' import Taro, { Component } from '@tarojs/taro-rn' import { View, Text, StyleSheet, Button } from 'react-native' import { chooseImage } from '../../../src/api/image' +import * as toast from '../../../src/api/interface' + +console.log('toast', toast) const styles = StyleSheet.create({ index: { diff --git a/packages/taro-rn/src/api/WxPreviewImage/index.js b/packages/taro-rn/src/api/WxPreviewImage/index.js deleted file mode 100644 index 6346bf45faae..000000000000 --- a/packages/taro-rn/src/api/WxPreviewImage/index.js +++ /dev/null @@ -1,57 +0,0 @@ -import { Modal } from 'react-native' -import RootSiblings from 'react-native-root-siblings' -import ImageViewer from 'react-native-image-zoom-viewer' - -function previewImage (obj) { - let { - current, - urls, - success, - fail, - complete - } = obj || {} - let index = urls.indexOf(current) - let sibling - - try { - sibling = new RootSiblings( - - { - return { - url: item, - props: '' - } - })} - index={index === -1 ? 0 : index} - onClick={onSuccess} - onSwipeDown={onSuccess} - enableSwipeDown - loadingRender={() => 'loading...'} - /> - - ) - } catch (e) { - onFail(e) - } - - function onSwipeDown () { - sibling && sibling.destroy() - sibling = undefined - } - - function onSuccess () { - const rsp = {errMsg: 'previewImage:ok'} - onSwipeDown() - success && success(rsp) - complete && complete(rsp) - } - - function onFail (e) { - onSwipeDown() - fail && fail({errMsg: 'err', ...e}) - complete && complete('err', ...e) - } -} - -export default {previewImage} diff --git a/packages/taro-rn/src/api/WxToast/LoadingView.js b/packages/taro-rn/src/api/interface/LoadingView.js similarity index 100% rename from packages/taro-rn/src/api/WxToast/LoadingView.js rename to packages/taro-rn/src/api/interface/LoadingView.js diff --git a/packages/taro-rn/src/api/interface/index.js b/packages/taro-rn/src/api/interface/index.js index 88e0110589b4..759c70deff9e 100644 --- a/packages/taro-rn/src/api/interface/index.js +++ b/packages/taro-rn/src/api/interface/index.js @@ -1 +1,3 @@ -export {showActionSheet} from './showActionSheet' +export { showActionSheet } from './showActionSheet' +export { showModal } from './showModal' +export { showLoading, showToast, hideToast, hideLoading } from './toast' diff --git a/packages/taro-rn/src/api/WxToast/loading.png b/packages/taro-rn/src/api/interface/loading.png similarity index 100% rename from packages/taro-rn/src/api/WxToast/loading.png rename to packages/taro-rn/src/api/interface/loading.png diff --git a/packages/taro-rn/src/api/WxModal/index.js b/packages/taro-rn/src/api/interface/showModal.js similarity index 97% rename from packages/taro-rn/src/api/WxModal/index.js rename to packages/taro-rn/src/api/interface/showModal.js index ff2a1cd560f7..11274ece9893 100644 --- a/packages/taro-rn/src/api/WxModal/index.js +++ b/packages/taro-rn/src/api/interface/showModal.js @@ -60,4 +60,4 @@ function showModal (obj) { } } -export default {showModal} +export { showModal } diff --git a/packages/taro-rn/src/api/WxToast/success.png b/packages/taro-rn/src/api/interface/success.png similarity index 100% rename from packages/taro-rn/src/api/WxToast/success.png rename to packages/taro-rn/src/api/interface/success.png diff --git a/packages/taro-rn/src/api/WxToast/index.js b/packages/taro-rn/src/api/interface/toast.js similarity index 98% rename from packages/taro-rn/src/api/WxToast/index.js rename to packages/taro-rn/src/api/interface/toast.js index 902f999880e9..b5e1dc9ec204 100644 --- a/packages/taro-rn/src/api/WxToast/index.js +++ b/packages/taro-rn/src/api/interface/toast.js @@ -90,7 +90,7 @@ function showToast (options) { console.error(res.errMsg) return Promise.reject(res) } - + const res = {errMsg: 'showToast:ok'} let {title = '', icon = 'success', image, duration = 1500, mask, success, fail, complete} = options || {} // eslint-disable-line let source @@ -156,11 +156,13 @@ function hideToast () { global.wxToastRootSiblings = undefined } -wx = { +function hideLoading () { + hideToast() +} + +export { showToast, showLoading, hideToast, - hideLoading: hideToast + hideLoading } - -export default wx diff --git a/packages/taro-rn/src/native-api.js b/packages/taro-rn/src/native-api.js index 38972c31dd72..06dc24190401 100644 --- a/packages/taro-rn/src/native-api.js +++ b/packages/taro-rn/src/native-api.js @@ -13,10 +13,8 @@ import others from './api/others' // import file from './api/file' import webSocket from './api/webSocket' // import geolocation from './api/geolocation' -import toast from './api/WxToast' -import showModal from './api/WxModal' -import { showActionSheet } from './api/interface' -import { previewImage } from './api/image' +import * as toast from './api/interface' +import * as image from './api/image' import web from './api/web' function processApis (taro) { @@ -57,9 +55,7 @@ export default function initNativeApi (taro) { webSocket, // geolocation, toast, - showModal, - showActionSheet, - previewImage, + image, others ) }