1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import { Action } from '../../redux/actions/Action' 17import { Log } from '../../utils/Log' 18import { EventBus } from '../../worker/eventbus/EventBus' 19import { EventBusManager } from '../../worker/eventbus/EventBusManager' 20import { getStore } from '../../redux/store' 21import EventLog from '../../utils/EventLog' 22 23let tabBarLandState = (state) => { 24 return { 25 isThirdPartyCall: state.ContextReducer.isThirdPartyCall 26 } 27} 28 29let tabBarLandDispatcher = (dispatch) => { 30 return { 31 showSettingView: () => { 32 dispatch(Action.showSettingView(true)) 33 }, 34 } 35} 36 37class StateStruct { 38 isThirdPartyCall 39 showSettingView: Function 40} 41 42type ScreenSizeType = { 43 width: number 44 height: number 45} 46 47@Component 48export struct TabBarLand { 49 private TAG: string = '[TabBarLand]' 50 @State state: StateStruct = new StateStruct() 51 @State opacityTabBar: number = 0 52 @State isShowTabBarOther: boolean= false 53 @Link screenSize: ScreenSizeType 54 private onBackClicked:Function 55 appEventBus: EventBus = EventBusManager.getInstance().getEventBus() 56 57 aboutToAppear(): void { 58 Log.info(`${this.TAG} aboutToAppear invoke E`) 59 getStore().connect(tabBarLandState, tabBarLandDispatcher)(this.state) 60 Log.info(`${this.TAG} aboutToAppear invoke X`) 61 } 62 63 build() { 64 Flex({ direction: FlexDirection.ColumnReverse, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) { 65 if (this.state.isThirdPartyCall) { 66 Row() { 67 Image($r("app.media.ic_public_back")).width(24).height(24) 68 .onClick(() => { 69 this.onBackClicked() 70 }) 71 }.width(48).height(48) 72 .padding({left: 12}) 73 .margin({ bottom: 12 }) 74 } 75 76 Row() { 77 Image($r("app.media.setting")).width(24).height(24) 78 .onClick(() => { 79 EventLog.write(EventLog.CLICK_SETTINGS) 80 this.state.showSettingView() 81 }) 82 }.width(48).height(48) 83 .padding({ left: 12 }) 84 .position(this.state.isThirdPartyCall ? {x:0,y:12} : {x:0,y: this.screenSize.height - 144}) 85 // Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { 86 // TabBarOther() 87 // }.width('100%').height('20%') 88 // .opacity(this.state.opacityValueForTabBar) 89 // .animation({ 90 // duration: 2000, 91 // curve: Curve.Sharp, 92 // delay: 0, 93 // iterations: 1, 94 // playMode: PlayMode.Normal 95 // }) 96 // 97 // Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { 98 // TabBarSame() 99 // } 100 // .position({ y: this.state.widthTabBar }) 101 // .width('100%') 102 // .height('20%') 103 // .animation({ 104 // duration: 2000, 105 // curve: Curve.Sharp, 106 // delay: 0, 107 // iterations: 1, 108 // playMode: PlayMode.Normal 109 // }) 110 }.width(48).height('100%') 111 } 112}