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 { Log } from '../../utils/Log'; 17import { Dispatch, getStore, OhCombinedState } from '../../redux/store'; 18import { Action } from '../../redux/actions/Action'; 19 20class StateStruct { 21 isThirdPartyCall: boolean = false; 22} 23 24class TabBarDispatcher { 25 public setDispatch(dispatch: Dispatch) { 26 this.mDispatch = dispatch; 27 } 28 29 public showSettingView(isShowSettingView: boolean): void { 30 this.mDispatch(Action.showSettingView(isShowSettingView)); 31 } 32 33 private mDispatch: Dispatch = (data) => data; 34} 35 36 37@Component 38export struct TabBar { 39 @State state: StateStruct = new StateStruct(); 40 private TAG: string = '[TabBar]'; 41 private mAction: TabBarDispatcher = new TabBarDispatcher(); 42 43 aboutToAppear(): void { 44 Log.info(`${this.TAG} aboutToAppear invoke E`) 45 getStore().subscribe((state: OhCombinedState) => { 46 this.state = { 47 isThirdPartyCall: state.contextReducer.isThirdPartyCall, 48 }; 49 }, (dispatch: Dispatch) => { 50 this.mAction.setDispatch(dispatch); 51 }); 52 Log.info(`${this.TAG} aboutToAppear invoke X`) 53 } 54 55 build() { 56 Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { 57 Column() { 58 // TabBarOther() 59 }.width('40%').height('100%') 60 61 Column() { 62 if (this.state.isThirdPartyCall) { 63 Row() { 64 Image($r('app.media.ic_public_back')).width(24).height(24) 65 .onClick(() => { 66 this.mAction.showSettingView(false) 67 this.onBackClicked() 68 }) 69 }.width(48).height(48) 70 .padding({ left: 12 }) 71 .margin({ bottom: 12 }) 72 } 73 }.width('40%').height('100%') 74 75 Column() { 76 Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { 77 Image($r('app.media.setting')).width(24).height(24) 78 }.width('100%').height('100%') 79 }.width('20%').height('100%').onClick(() => { 80 this.mAction.showSettingView(true) 81 }) 82 }.width('100%').height('100%') 83 } 84 85 private onBackClicked: Function = () => { 86 }; 87}