Tabbar.uvue 2.7 KB
<template>
	<HomeFrameTabbarLandscape v-if="!isPortraitMode"
	                          :user-name="userName"
	                          :current-tab-index="currentTabIndex"
	                          :scene-type-list="sceneTypeList"
	                          :show-scene-popup="showScenePopup"
	                          :show-setting="showSetting"
	                          @tab-change="onTabChange"
	                          @scene-popup-visible="onScenePopupVisible"
	                          @setting-visible="onSettingVisible"
	                          @scene-change="onSceneChange"
	                          @setting="onSetting"
	                          @choose-scene="onChooseScene"
	                          @jump-person-center="jumpPersonCenter" />
	<HomeFrameTabbarPortrait v-else
	                         :current-tab-index="currentTabIndex"
	                         :scene-type-list="sceneTypeList"
	                         :show-scene-popup="showScenePopup"
	                         :show-setting="showSetting"
	                         @tab-change="onTabChange"
	                         @scene-popup-visible="onScenePopupVisible"
	                         @setting-visible="onSettingVisible"
	                         @choose-scene="onChooseScene" />
</template>

<script setup lang="uts">
import { computed, type Ref } from "vue";

import { useOrientation } from "@/services/adapter/hooks/index.uts";

import HomeFrameTabbarLandscape from "./TabbarLandscape.uvue";
import HomeFrameTabbarPortrait from "./TabbarPortrait.uvue";
import type { HomeFrameTabbarSource } from "./tabbarShared.uts";
import { useHomeFrameTabbar } from "./tabbarShared.uts";

const props = defineProps<{
  tabIndex?: number
  userInfo?: null | UTSJSONObject
}>();

const orientationHook = useOrientation();
const isPortraitMode = computed((): boolean => {
	const ip = orientationHook.isPortrait as Ref<boolean>;
	return ip.value == true;
});

const tabbarSource: HomeFrameTabbarSource = {
	getTabIndex: (): number => props.tabIndex != null ? (props.tabIndex as number) : 0,
	getUserInfo: (): null | UTSJSONObject => props.userInfo as null | UTSJSONObject
};

const _tabbar = useHomeFrameTabbar(tabbarSource);
const currentTabIndex = _tabbar.currentTabIndex;
const sceneTypeList = _tabbar.sceneTypeList;
const userName = _tabbar.userName;
const showScenePopup = _tabbar.showScenePopup;
const showSetting = _tabbar.showSetting;
const onTabChange = _tabbar.onTabChange;
const onScenePopupVisible = _tabbar.onScenePopupVisible;
const onSettingVisible = _tabbar.onSettingVisible;
const onSceneChange = _tabbar.onSceneChange;
const onSetting = _tabbar.onSetting;
const onChooseScene = _tabbar.onChooseScene;
const jumpPersonCenter = _tabbar.jumpPersonCenter;
</script>