• 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, OhCombinedState } from '../../redux/store'
21import { getStore } from '../../redux/store'
22import EventLog from '../../utils/EventLog'
23
24class StateStruct {
25  isThirdPartyCall: boolean = false
26}
27
28class ScreenSizeType {
29  width: number = 0
30  height: number = 0
31}
32
33class TabBarDispatcher {
34  private mDispatch: Dispatch = (data) => data;
35
36  public setDispatch(dispatch: Dispatch) {
37    this.mDispatch = dispatch;
38  }
39
40  public showSettingView(isShowSettingView: boolean): void {
41    this.mDispatch(Action.showSettingView(isShowSettingView));
42  }
43}
44
45@Component
46export struct TabBarLand {
47  private TAG: string = '[TabBarLand]';
48  @State state: StateStruct = new StateStruct();
49  @State opacityTabBar: number = 0;
50  @State isShowTabBarOther: boolean= false;
51  @Link screenSize: ScreenSizeType;
52  private onBackClicked:Function = ()=>{};
53  appEventBus: EventBus = EventBusManager.getInstance().getEventBus();
54  private mAction: TabBarDispatcher = new TabBarDispatcher();
55
56  aboutToAppear(): void {
57    Log.info(`${this.TAG} aboutToAppear invoke E`);
58    getStore().subscribe((state: OhCombinedState) => {
59      this.state = {
60        isThirdPartyCall: state.contextReducer.isThirdPartyCall
61      };
62    }, (dispatch: Dispatch) => {
63      this.mAction.setDispatch(dispatch);
64    });
65
66    Log.info(`${this.TAG} aboutToAppear invoke X`)
67  }
68
69  build() {
70    Flex({ direction: FlexDirection.ColumnReverse, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) {
71      if (this.state.isThirdPartyCall) {
72        Row() {
73          Image($r("app.media.ic_public_back")).width(24).height(24)
74            .onClick(() => {
75              this.onBackClicked()
76            })
77        }.width(48).height(48)
78        .padding({left: 12})
79        .margin({ bottom: 12 })
80      }
81
82      Row()  {
83        Image($r("app.media.setting")).width(24).height(24)
84          .onClick(() => {
85            EventLog.write(EventLog.CLICK_SETTINGS)
86            this.mAction.showSettingView(true);
87          })
88      }.width(48).height(48)
89      .padding({ left: 12 })
90      .position(this.state.isThirdPartyCall ? {x:0,y:12} : {x:0,y: this.screenSize.height - 144})
91      //        Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
92      //          TabBarOther()
93      //        }.width('100%').height('20%')
94      //        .opacity(this.state.opacityValueForTabBar)
95      //        .animation({
96      //          duration: 2000,
97      //          curve: Curve.Sharp,
98      //          delay: 0,
99      //          iterations: 1,
100      //          playMode: PlayMode.Normal
101      //        })
102      //
103      //        Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
104      //          TabBarSame()
105      //        }
106      //        .position({ y: this.state.widthTabBar })
107      //        .width('100%')
108      //        .height('20%')
109      //        .animation({
110      //          duration: 2000,
111      //          curve: Curve.Sharp,
112      //          delay: 0,
113      //          iterations: 1,
114      //          playMode: PlayMode.Normal
115      //        })
116    }.width(48).height('100%')
117  }
118}