Skip to content

底部导航BottomBar

一、效果总览

二、描述

一般用于首页 或功能模块底部

三、构造函数及参数说明

参数名参数类型描述是否必填默认值
dataArray[OmniBottomBarItem]导航栏数据
defaultSelectedIndexnumber默认选中下标0
textModifierBarTextModifier非选中态下text的样式修改器见下方
textSelectedModifierBarSelectTextModifier选中态下text的样式修改器见下方
badgeTextModifierBarBadgeTextModifierbadge的样式修改器见下方
iconModifierBarIconModifier非选中态下icon的样式修改器见下方
iconSelectedModifierBarSelectedIconModifier选中态下icon的样式修改器见下方

OmniBottomBarItem

参数名参数类型描述是否必填默认值说明
textstring底部导航项文本--
selectedTextstring选中时导航项文本-未设置时使用text
iconstring | Resource未选中状态图标-
selectedIconstring | Resource选中状态图标-未设置时使用icon
badgeNonumber角标红点数--
maxBadgeNonumber角标红点最大数99-
action()=> void点击回调-

BarTextModifier

参数名参数类型描述是否必填默认值
fontSizenumber文字大小10
fontColorColor文字颜色#999999
fontWeightnumber文字粗细400

BarSelectTextModifier

参数名参数类型描述是否必填默认值
fontSizenumber选中状态文字大小10
fontColorColor选中状态文字颜色#333333
fontWeightnumber选中状态文字粗细400

BarBadgeTextModifier

参数名参数类型描述是否必填默认值
fontSizenumber徽标文字大小12
fontColorColor徽标文字颜色#FFFFFF
backgroundColorColor徽标背景颜色#FF0000
borderRadiusnumber徽标圆角大小7

BarIconModifier

参数名参数类型描述是否必填默认值
widthnumber选中图标宽度25
heightnumber选中图标高度25

BarSelectedIconModifier

参数名参数类型描述是否必填默认值
widthnumber选中图标宽度25
heightnumber选中图标高度25
backgroundColorColor选中图标背景色transparent

四、代码演示

typescript
OmniBottomTabBar({
  data: this.barItem,
  defaultSelectedIndex: 1,
  textModifier: new BarTextModifier().withFontColor(Color.Blue),
  textSelectedModifier: new BarSelectTextModifier().withFontColor(Color.Blue),
  iconSelectedModifier: new BarSelectedIconModifier().withBackgroundColor(Color.Green),
  iconModifier: new BarIconModifier().withHeight(20),
  badgeTextModifier: new BarBadgeTextModifier().withBackgroundColor(Color.Blue)
}).margin({ top: 10 })