Skip to content

Commit

Permalink
合并master
Browse files Browse the repository at this point in the history
  • Loading branch information
wangcuijuan committed Dec 19, 2024
2 parents c3743a5 + 3dfe8ac commit 479d6aa
Show file tree
Hide file tree
Showing 19 changed files with 289 additions and 357 deletions.
4 changes: 2 additions & 2 deletions examples/mpx-webview/H5/webviewbridge.min.js

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

6 changes: 6 additions & 0 deletions packages/api-proxy/@types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ export const enableAlertBeforeUnload: WechatMiniprogram.Wx['enableAlertBeforeUnl
export const disableAlertBeforeUnload: WechatMiniprogram.Wx['disableAlertBeforeUnload']
export const getMenuButtonBoundingClientRect: WechatMiniprogram.Wx['getMenuButtonBoundingClientRect']
export const getImageInfo: WechatMiniprogram.Wx['getImageInfo']
export const vibrateShort: WechatMiniprogram.Wx['vibrateShort']
export const vibrateLong: WechatMiniprogram.Wx['vibrateLong']
export const getExtConfig: WechatMiniprogram.Wx['getExtConfig']
export const getExtConfigSync: WechatMiniprogram.Wx['getExtConfigSync']
export const openLocation: WechatMiniprogram.Wx['openLocation']
export const chooseLocation: WechatMiniprogram.Wx['chooseLocation']

declare const install: (...args: any) => any

Expand Down
148 changes: 67 additions & 81 deletions packages/api-proxy/src/platform/api/action-sheet/rnActionSheet.jsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,17 @@
import { View, TouchableHighlight, Text, StyleSheet, Button, Animated } from 'react-native'
import { View, TouchableHighlight, Text, StyleSheet, TouchableOpacity } from 'react-native'
import { successHandle, failHandle } from '../../../common/js'
import { Portal } from '@ant-design/react-native'
import { getWindowInfo } from '../system/rnSystem'
import Animated, {
useSharedValue,
useAnimatedStyle,
withTiming
} from 'react-native-reanimated'
function showActionSheet (options = {}) {
const { alertText, itemList = [], itemColor = '#000000', success, fail, complete } = options
let actionSheetKey
const slideAnim = new Animated.Value(500)
const slideIn = () => {
// Will change fadeAnim value to 1 in 5 seconds
Animated.timing(slideAnim, {
toValue: 0,
duration: 200,
useNativeDriver: true,
}).start()
}
const slideOut = () => {
// Will change fadeAnim value to 1 in 5 seconds
Animated.timing(slideAnim, {
toValue: 500,
duration: 200,
useNativeDriver: true,
}).start(() => {
})
}
if (itemList.length === 0 || itemList.length > 6) {
const result = {
errMsg: 'showActionSheet:fail parameter error: itemList should not be large than 6'
}
if (itemList.length === 0) {
result.errno = 1001
result.errMsg = 'showActionSheet:fail parameter error: parameter.itemList should have at least 1 item;'
}
failHandle(result, fail, complete)
return
}
const windowInfo = getWindowInfo()
const bottom = windowInfo.screenHeight - windowInfo.safeArea.bottom
let actionSheetKey = null
const styles = StyleSheet.create({
actionActionMask: {
left: 0,
Expand All @@ -44,16 +23,14 @@ function showActionSheet (options = {}) {
zIndex: 1000
},
actionSheetContent: {
left: 0,
right: 0,
position: 'absolute',
bottom: 0,
backgroundColor: '#ffffff',
borderTopLeftRadius: 10,
borderTopRightRadius: 10,
transform: [{
translateY: -500
}]
position: 'absolute',
bottom: 0,
left: 0,
right: 0,
paddingBottom: bottom
},
itemStyle: {
paddingTop: 15,
Expand All @@ -73,53 +50,62 @@ function showActionSheet (options = {}) {
paddingBottom: 10
}
})
const remove = function () {
if (actionSheetKey) {
slideOut()
setTimeout(() => {
Portal.remove(actionSheetKey)
actionSheetKey = null
}, 200)
function ActionSheet () {
const offset = useSharedValue(1000);

const animatedStyles = useAnimatedStyle(() => ({
transform: [{ translateY: offset.value }],
}))

const slideOut = () => {
// Will change fadeAnim value to 1 in 5 seconds
offset.value = withTiming(1000)
}
}
const selectAction = function (index) {
const result = {
errMsg: 'showActionSheet:ok',
tapIndex: index

offset.value = withTiming(0)

const selectAction = function (index) {
const result = {
errMsg: 'showActionSheet:ok',
tapIndex: index
}
successHandle(result, success, complete)
remove()
}
successHandle(result, success, complete)
remove()
}
const cancelAction = function () {
const result = {
errMsg: 'showActionSheet:fail cancel'

const remove = function () {
if (actionSheetKey) {
slideOut()
setTimeout(() => {
Portal.remove(actionSheetKey)
actionSheetKey = null
}, 200)
}
}
failHandle(result, fail, complete)
remove()
}
let alertTextList = []
if (alertText) {
alertTextList = [alertText]

const cancelAction = function () {
const result = {
errMsg: 'showActionSheet:fail cancel'
}
failHandle(result, fail, complete)
remove()
}
return (
<TouchableHighlight underlayColor="rgba(0,0,0,0.6)" onPress={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 ? {
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>
</Animated.View>
</TouchableHighlight>
)
}
const ActionSheetView = <TouchableHighlight underlayColor="rgba(0,0,0,0.6)" onPress={cancelAction} style={styles.actionActionMask}>
<Animated.View
style={[
styles.actionSheetContent,
{
transform: [{translateY: slideAnim}]
}
]}>
{ alertTextList.map((item, index) => <View key={index} style={ styles.itemStyle }><Text style={[styles.itemTextStyle, { color: '#666666' }]}>{item}</Text></View>) }
{ itemList.map((item, index) => <TouchableHighlight key={index} underlayColor="#ececec" onPress={() => selectAction(index)} 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}><Button color={'#000000'} title={'取消'} onPress={cancelAction}></Button></View>
</Animated.View>
</TouchableHighlight>
actionSheetKey = Portal.add(ActionSheetView)
slideIn()

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

export {
Expand Down
15 changes: 7 additions & 8 deletions packages/api-proxy/src/platform/api/modal/rnModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const showModal = function (options = {}) {
fail,
complete
} = options
const modalWidth = width - 60
const modalWidth = width * 0.8
const styles = StyleSheet.create({
modalTask: {
left: 0,
Expand Down Expand Up @@ -53,7 +53,8 @@ const showModal = function (options = {}) {
lineHeight: 26,
color: '#808080',
paddingLeft: 20,
paddingRight: 20
paddingRight: 20,
textAlign: 'center'
},
modalBtnBox: {
borderTopWidth: StyleSheet.hairlineWidth,
Expand All @@ -67,8 +68,8 @@ const showModal = function (options = {}) {
modalBtn: {
flex: 1,
textAlign: 'center',
paddingTop: 10,
paddingBottom: 10,
paddingTop: width * 0.04,
paddingBottom: width * 0.04,
},
modalButton: {
width: '100%',
Expand All @@ -88,9 +89,8 @@ const showModal = function (options = {}) {
let editableContent = []
let modalButton = [{
text: confirmText,
confirmColor,
type: 'confirm',
color: 'rgb(87, 107, 149)'
color: confirmColor
}]
let contentText = content
const onChangeText = function (text) {
Expand Down Expand Up @@ -128,10 +128,9 @@ const showModal = function (options = {}) {
if (showCancel) {
modalButton.unshift({
text: cancelText,
cancelColor,
type: 'cancel',
style: styles.cancelStyle,
color: '#000000'
color: cancelColor
})
}
ModalView = <View style={styles.modalTask}>
Expand Down
4 changes: 2 additions & 2 deletions packages/api-proxy/src/platform/api/system/rnSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const getWindowInfo = function () {
const insets = Object.assign(initialWindowMetricsInset, navigationInsets)
let safeArea = {}
const { top = 0, bottom = 0, left = 0, right = 0 } = insets
const screenHeight = dimensionsScreen.height
const screenWidth = dimensionsScreen.width
const screenHeight = __mpx_mode__ === 'ios' ? dimensionsScreen.height : dimensionsScreen.height - bottom // 解决安卓开启屏幕内三建导航安卓把安全区计算进去后产生的影响
const screenWidth = __mpx_mode__ === 'ios' ? dimensionsScreen.width : dimensionsScreen.width - right
const layout = navigation.layout || {}
const layoutHeight = layout.height || 0
const layoutWidth = layout.width || 0
Expand Down
Loading

0 comments on commit 479d6aa

Please sign in to comment.