tab-bar.js 1.4 KB
Newer Older
fxy060608's avatar
fxy060608 已提交
1 2 3 4
import {
  isTabBarPage
} from '../util'

fxy060608's avatar
fxy060608 已提交
5
import tabBar from '../../framework/tab-bar'
fxy060608's avatar
fxy060608 已提交
6 7 8 9 10 11

export function setTabBarBadge ({
  index,
  text,
  type
}) {
fxy060608's avatar
fxy060608 已提交
12
  tabBar.setTabBarBadge(type, index, text)
fxy060608's avatar
fxy060608 已提交
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
  return {
    errMsg: 'setTabBarBadge:ok'
  }
}

export function setTabBarItem ({
  index,
  text,
  iconPath,
  selectedIconPath
}) {
  if (!isTabBarPage()) {
    return {
      errMsg: 'setTabBarItem:fail not TabBar page'
    }
  }
fxy060608's avatar
fxy060608 已提交
29
  tabBar.setTabBarItem(index, text, iconPath, selectedIconPath)
fxy060608's avatar
fxy060608 已提交
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
  return {
    errMsg: 'setTabBarItem:ok'
  }
}

export function setTabBarStyle ({
  color,
  selectedColor,
  backgroundColor,
  borderStyle
}) {
  if (!isTabBarPage()) {
    return {
      errMsg: 'setTabBarStyle:fail not TabBar page'
    }
  }
fxy060608's avatar
fxy060608 已提交
46
  tabBar.setTabBarStyle({
fxy060608's avatar
fxy060608 已提交
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
    color,
    selectedColor,
    backgroundColor,
    borderStyle
  })
  return {
    errMsg: 'setTabBarStyle:ok'
  }
}

export function hideTabBar ({
  animation
}) {
  if (!isTabBarPage()) {
    return {
      errMsg: 'hideTabBar:fail not TabBar page'
    }
  }
fxy060608's avatar
fxy060608 已提交
65
  tabBar.hideTabBar(animation)
fxy060608's avatar
fxy060608 已提交
66 67 68 69 70 71 72 73 74 75 76 77 78
  return {
    errMsg: 'hideTabBar:ok'
  }
}

export function showTabBar ({
  animation
}) {
  if (!isTabBarPage()) {
    return {
      errMsg: 'showTabBar:fail not TabBar page'
    }
  }
fxy060608's avatar
fxy060608 已提交
79
  tabBar.showTabBar(animation)
fxy060608's avatar
fxy060608 已提交
80 81 82 83
  return {
    errMsg: 'showTabBar:ok'
  }
}