Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix actionsheet 0106 #1803

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ca907fe
修正settitle合丢代码
Dec 23, 2024
f2abc48
改成ontouchend
Dec 24, 2024
95c6f5f
合并master
Dec 24, 2024
6c8f977
修改webview通信
Dec 24, 2024
cd18eb8
fix webview跳转提交
Dec 25, 2024
b46c42a
开发完portal add提交
Dec 28, 2024
fb45c28
提交一版
Dec 28, 2024
486c65c
补充webview加载失败兜底
Dec 28, 2024
83e264c
补充picker兜底数据
Dec 29, 2024
2437c1c
修复所有连点
Dec 30, 2024
5fea8d9
Merge branch 'fix-back' into fix-actionsheet-1217
Dec 30, 2024
971d5db
优化编写方式
Dec 30, 2024
5c03178
解决合并冲突丢失的代码
Dec 30, 2024
fbacf3f
修正consumer更新处理有问题的逻辑
Dec 30, 2024
abd29de
修改router跳转
Dec 30, 2024
9596940
修正返回逻辑
Dec 30, 2024
1ecbb57
补充getWindowInfo声明
Dec 31, 2024
5ba850b
拉webview addlistener齐统一写法
Jan 2, 2025
23bd943
解决actionsheet回调跳转的情况actionaction未被删除的bug
Jan 2, 2025
0a68b71
干掉兜底渲染逻辑
Jan 2, 2025
896ca00
fix路由跳转
Jan 2, 2025
366c837
修改navigation调用方式
Jan 6, 2025
6a3b10c
合并master解决冲突
Jan 6, 2025
75872f9
修改toast位置
Jan 7, 2025
1fe518d
fix toast不消失的问题
Jan 8, 2025
411f00d
fix back逻辑以及actionsheet超过6这个报错
Jan 9, 2025
2feeb9b
合并fix actionsheet和webview改动逻辑
Jan 9, 2025
0f05cd5
合并master
Jan 9, 2025
77c7ec8
支持portal.update能力
Jan 9, 2025
6e569d2
干掉无用逻辑
Jan 9, 2025
381f655
合并改动
Jan 9, 2025
64055e2
去掉无用的provider,修改portal逻辑
Jan 9, 2025
10a9fd3
修改extendObject引入
Jan 9, 2025
5c6bdc6
补充黑名单
Jan 13, 2025
638bc95
修改router逻辑
Jan 14, 2025
34f1e0a
改造portal
Jan 21, 2025
2abcd9c
修改router lock逻辑
Jan 21, 2025
dc28f2f
改造逻辑
Jan 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/mpx-webview/H5/webviewbridge.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/api-proxy/@types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export const clearStorage: WechatMiniprogram.Wx['clearStorage']
export const clearStorageSync: WechatMiniprogram.Wx['clearStorageSync']
export const getSystemInfo: WechatMiniprogram.Wx['getSystemInfo']
export const getSystemInfoSync: WechatMiniprogram.Wx['getSystemInfoSync']
export const getWindowInfo: WechatMiniprogram.Wx['getWindowInfo']
export const setTabBarItem: WechatMiniprogram.Wx['setTabBarItem']
export const setTabBarStyle: WechatMiniprogram.Wx['setTabBarStyle']
export const showTabBar: WechatMiniprogram.Wx['showTabBar']
Expand Down
29 changes: 21 additions & 8 deletions packages/api-proxy/src/common/js/promisify.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,37 @@ const blackList = [
'stopBackgroundAudio',
'showNavigationBarLoading',
'hideNavigationBarLoading',
'createAnimation',
'createAnimationVideo',
'createSelectorQuery',
'createIntersectionObserver',
'getPerformance',
'hideKeyboard',
'stopPullDownRefresh',
'createWorker',
'pageScrollTo',
'reportAnalytics',
'getMenuButtonBoundingClientRect',
'reportMonitor',
'createOffscreenCanvas',
'reportEvent',
'connectSocket',
'base64ToArrayBuffer',
'arrayBufferToBase64',
'getDeviceInfo',
'getWindowInfo'
'getWindowInfo',
'getAppBaseInfo',
'getAppAuthorizeSetting',
'getApiCategory',
'postMessageToReferrerPage',
'postMessageToReferrerMiniProgram',
'reportPerformance',
'getPerformance',
'preDownloadSubpackage',
'router',
'nextTick',
'checkIsPictureInPictureActive',
'worklet',
'revokeBufferURL',
'reportEvent',
'getExptInfoSync',
'reserveChannelsLive',
'getNFCAdapter',
'isVKSupport'
]

function getMapFromList (list) {
Expand All @@ -55,7 +68,7 @@ function promisify (listObj, whiteList, customBlackList) {
} else {
return !(blackListMap[key] || // 特别指定的方法
/^get\w*Manager$/.test(key) || // 获取manager的api
/^create\w*Context$/.test(key) || // 创建上下文相关api
/^create(?!BLEConnection|BLEPeripheralServer)\w*$/.test(key) || // 创建上下文相关api
/^(on|off)/.test(key) || // 以 on* 或 off开头的方法
/\w+Sync$/.test(key) // 以Sync结尾的方法
)
Expand Down
12 changes: 11 additions & 1 deletion packages/api-proxy/src/common/js/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { hasOwn, noop, getEnvObj, getFocusedNavigation } from '@mpxjs/utils'
import { getCurrentInstance } from '@mpxjs/core'

/**
*
Expand Down Expand Up @@ -87,6 +88,14 @@ function failHandle (result, fail, complete) {
typeof complete === 'function' && complete(result)
}

function getPageId () {
const navigation = getFocusedNavigation()
const currentInstance = getCurrentInstance()
console.log(currentInstance, currentInstance?.getPageId, navigation, navigation?.pageId)
const id = currentInstance?.getPageId || navigation?.pageId || null
return id
}

const ENV_OBJ = getEnvObj()

export {
Expand All @@ -101,5 +110,6 @@ export {
defineUnsupportedProps,
successHandle,
failHandle,
getFocusedNavigation
getFocusedNavigation,
getPageId
}
46 changes: 33 additions & 13 deletions packages/api-proxy/src/platform/api/action-sheet/rnActionSheet.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
import { View, TouchableHighlight, Text, StyleSheet, TouchableOpacity } from 'react-native'
import { successHandle, failHandle } from '../../../common/js'
import { Portal } from '@ant-design/react-native'
import { View, Text, StyleSheet } from 'react-native'
import { successHandle, failHandle, getPageId, error } from '../../../common/js'
import Portal from '@mpxjs/webpack-plugin/lib/runtime/components/react/dist/mpx-portal/index'
import { getWindowInfo } from '../system/rnSystem'
import Animated, {
useSharedValue,
useAnimatedStyle,
withTiming
} from 'react-native-reanimated'

function showActionSheet (options = {}) {
const id = getPageId()
const { alertText, itemList = [], itemColor = '#000000', success, fail, complete } = options
if (id === null) {
error('showActionSheet cannot be invoked outside the mpx life cycle in React Native environments')
const result = {
errMsg: 'showActionSheet:fail cannot be invoked outside the mpx life cycle in React Native environments'
}
failHandle(result, fail, complete)
return
}
if (itemList.length > 6) {
const result = {
errMsg: 'showActionSheet:fail parameter error: itemList should not be large than 6'
}
failHandle(result, fail, complete)
return
}
const windowInfo = getWindowInfo()
const bottom = windowInfo.screenHeight - windowInfo.safeArea.bottom
let actionSheetKey = null
Expand Down Expand Up @@ -64,7 +81,8 @@ function showActionSheet (options = {}) {

offset.value = withTiming(0)

const selectAction = function (index) {
const selectAction = function (index, e) {
e.stopPropagation()
const result = {
errMsg: 'showActionSheet:ok',
tapIndex: index
Expand All @@ -76,36 +94,38 @@ function showActionSheet (options = {}) {
const remove = function () {
if (actionSheetKey) {
slideOut()
Portal.remove(actionSheetKey)
actionSheetKey = null
setTimeout(() => {
Portal.remove(actionSheetKey)
actionSheetKey = null
}, 200)
}
}

const cancelAction = function () {
const cancelAction = function (e) {
e.stopPropagation()
const result = {
errMsg: 'showActionSheet:fail cancel'
}
failHandle(result, fail, complete)
remove()
}
return (
<TouchableHighlight underlayColor="rgba(0,0,0,0.6)" activeOpacity={1} onPress={cancelAction} style={styles.actionActionMask}>
<Animated.View style={[styles.actionSheetContent, animatedStyles]} >
<View onTouchEnd={cancelAction} style={styles.actionActionMask}>
<Animated.View style={[styles.actionSheetContent, animatedStyles]}>
{ alertText ? <View style={ styles.itemStyle }><Text style={[styles.itemTextStyle, { color: '#666666' }]}>{alertText}</Text></View> : null }
{ itemList.map((item, index) => <TouchableHighlight key={index} underlayColor="#ececec" onPress={() => selectAction(index)} style={ [styles.itemStyle, itemList.length -1 === index ? {
{ itemList.map((item, index) => <View key={index} onTouchEnd={(e) => selectAction(index, e)} style={ [styles.itemStyle, itemList.length -1 === index ? {
borderBottomWidth: 6,
borderBottomStyle: 'solid',
borderBottomColor: '#f7f7f7'
} : {}] }><Text style={[styles.itemTextStyle, { color: itemColor }]}>{item}</Text></TouchableHighlight>) }
<View style={styles.buttonStyle}><TouchableOpacity onPress={cancelAction}><Text style={{ color: "#000000", width: "100%", textAlign: "center" }}>取消</Text></TouchableOpacity></View>
} : {}] }><Text style={[styles.itemTextStyle, { color: itemColor }]}>{item}</Text></View>) }
<View style={styles.buttonStyle} onTouchEnd={cancelAction}><Text style={{ color: "#000000", width: "100%", textAlign: "center" }}>取消</Text></View>
</Animated.View>
</TouchableHighlight>
</View>
)
}

actionSheetKey = Portal.add(<ActionSheet/>)
actionSheetKey = Portal.add(<ActionSheet />, id)
}

export {
Expand Down
15 changes: 12 additions & 3 deletions packages/api-proxy/src/platform/api/modal/rnModal.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { View, Dimensions, Text, StyleSheet, TouchableOpacity, ScrollView, TextInput } from 'react-native'
import { successHandle, failHandle } from '../../../common/js'
import { Portal } from '@ant-design/react-native'
import { successHandle, failHandle, getPageId, error } from '../../../common/js'
import Portal from '@mpxjs/webpack-plugin/lib/runtime/components/react/dist/mpx-portal/index'
const { width, height } = Dimensions.get('window')
const showModal = function (options = {}) {
const id = getPageId()
const {
title,
content,
Expand All @@ -17,6 +18,14 @@ const showModal = function (options = {}) {
fail,
complete
} = options
if (id === null) {
error('showModal cannot be invoked outside the mpx life cycle in React Native environments')
const result = {
errMsg: 'showModal:fail cannot be invoked outside the mpx life cycle in React Native environments'
}
failHandle(result, fail, complete)
return
}
const modalWidth = width * 0.8
const styles = StyleSheet.create({
modalTask: {
Expand Down Expand Up @@ -156,7 +165,7 @@ const showModal = function (options = {}) {
</View>
</View>
try {
modalKey = Portal.add(ModalView)
modalKey = Portal.add(ModalView, id)
} catch (e) {
const result = {
errMsg: `showModal:fail invalid ${e}`
Expand Down
Loading
Loading