提交 4fb59f5c 编写于 作者: 辛宝Otto's avatar 辛宝Otto 🥊

feat(x): iOS 新增 tabBarBorderColor 选项

上级 7d94fbe5
......@@ -5,8 +5,7 @@ import {
SetTabBarStyleProtocol,
defineAsyncApi,
} from '@dcloudio/uni-api'
import { getBorderStyle, getTabBar } from '../../framework/app/tabBar'
import { isString } from '@vue/shared'
import { fixBorderStyle, getTabBar } from '../../framework/app/tabBar'
export const setTabBarStyle = defineAsyncApi<API_TYPE_SET_TAB_BAR_STYLE>(
API_SET_TAB_BAR_STYLE,
......@@ -22,10 +21,10 @@ export const setTabBarStyle = defineAsyncApi<API_TYPE_SET_TAB_BAR_STYLE>(
['backgroundColor', options.backgroundColor],
['backgroundImage', options.backgroundImage],
['backgroundRepeat', options.backgroundRepeat],
['borderStyle', options.borderStyle],
['borderColor', options.borderColor],
])
if (isString(options.borderStyle)) {
style.set('borderStyle', getBorderStyle(options.borderStyle as string))
}
if (!!options.midButton) {
const midButtonOptions = options.midButton!
const midButton: Map<string, any> = new Map<string, any>([
......@@ -50,6 +49,8 @@ export const setTabBarStyle = defineAsyncApi<API_TYPE_SET_TAB_BAR_STYLE>(
}
style.set('midButton', midButton)
}
fixBorderStyle(style)
tabBar!.setTabBarStyle(style)
resolve()
},
......
......@@ -23,7 +23,7 @@ const BORDER_COLORS = new Map<string, string>([
['black', 'rgba(0, 0, 0, 0.33)'],
])
export function getBorderStyle(borderStyle: string): string {
function getBorderStyle(borderStyle: string): string {
const value = BORDER_COLORS.get(borderStyle)
return value ?? borderStyle
}
......@@ -34,7 +34,15 @@ export function fixBorderStyle(tabBarConfig: Map<string, any>) {
if (!isString(borderStyle)) {
borderStyle = 'black'
}
tabBarConfig.set('borderStyle', getBorderStyle(borderStyle as string))
let borderColor = getBorderStyle(borderStyle as string)
// 同时存在 borderColor>borderStyle,前者没有颜色限制,也不做格式化
if (tabBarConfig.has('borderColor')) {
borderColor = tabBarConfig.get('borderColor')
tabBarConfig.delete('borderColor')
}
tabBarConfig.set('borderStyle', borderColor)
}
function getTabList() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册