• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 { Dispatch, getStore, OhCombinedState } from '../../redux/store'
21import ReportUtil from '../../utils/ReportUtil'
22
23class StateStruct {
24  isThirdPartyCall: boolean = false
25}
26
27class ScreenSizeType {
28  width: number = 0
29  height: number = 0
30}
31
32class TabBarDispatcher {
33  public setDispatch(dispatch: Dispatch) {
34    this.mDispatch = dispatch;
35  }
36
37  public showSettingView(isShowSettingView: boolean): void {
38    this.mDispatch(Action.showSettingView(isShowSettingView));
39  }
40
41  private mDispatch: Dispatch = (data) => data;
42}
43
44@Component
45export struct TabBarLand {
46  @State state: StateStruct = new StateStruct();
47  @State opacityTabBar: number = 0;
48  @State isShowTabBarOther: boolean = false;
49  @Link screenSize: ScreenSizeType;
50  appEventBus: EventBus = EventBusManager.getInstance().getEventBus();
51  private TAG: string = '[TabBarLand]';
52  private mAction: TabBarDispatcher = new TabBarDispatcher();
53
54  aboutToAppear(): void {
55    Log.info(`${this.TAG} aboutToAppear invoke E`);
56    getStore().subscribe((state: OhCombinedState) => {
57      this.state = {
58        isThirdPartyCall: state.contextReducer.isThirdPartyCall
59      };
60    }, (dispatch: Dispatch) => {
61      this.mAction.setDispatch(dispatch);
62    });
63
64    Log.info(`${this.TAG} aboutToAppear invoke X`)
65  }
66
67  build() {
68    Flex({ direction: FlexDirection.ColumnReverse, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) {
69      if (this.state.isThirdPartyCall) {
70        Row() {
71          Image($r('app.media.ic_public_back')).width(24).height(24)
72            .onClick(() => {
73              this.onBackClicked()
74            })
75        }.width(48).height(48)
76        .padding({ left: 12 })
77        .margin({ bottom: 12 })
78      }
79
80      Row() {
81        Image($r('app.media.setting')).width(24).height(24)
82          .onClick(() => {
83            ReportUtil.write(ReportUtil.CLICK_SETTINGS)
84            this.mAction.showSettingView(true);
85          })
86      }.width(48).height(48)
87      .padding({ left: 12 })
88      .position(this.state.isThirdPartyCall ? { x: 0, y: 12 } : { x: 0, y: this.screenSize.height - 144 })
89    }.width(48).height('100%')
90  }
91
92  private onBackClicked: Function = () => {
93  };
94}