• 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 { CaptureMode } from '../../../setting/settingitem/CaptureMode'
18import { Log } from '../../../utils/Log'
19import { EventBus } from '../../../worker/eventbus/EventBus'
20import { EventBusManager } from '../../../worker/eventbus/EventBusManager'
21import { getStore } from '../../../redux/store'
22
23let tabBarLandState = (state) => {
24  return {
25    opacityValueForTabBar: state.SettingReducer.opacityValueForTabBar
26  }
27}
28
29let tabBarLandDispatcher = (dispatch) => {
30  return {
31    updateOpacityForTabBar: (opacityValue) => {
32      dispatch(Action.updateOpacityForTabBar(opacityValue))
33    }
34  }
35}
36
37class StateStruct {
38  opacityValueForTabBar
39  updateOpacityForTabBar: Function
40}
41
42@Component
43export struct TabBarOther {
44  private TAG: string = '[TabBarOther]:'
45  @State state: StateStruct = new StateStruct()
46  appEventBus: EventBus = EventBusManager.getInstance().getEventBus()
47
48  private aboutToAppear(): void {
49    Log.info(`${this.TAG} aboutToAppear invoke E`)
50    getStore().connect(tabBarLandState, tabBarLandDispatcher)(this.state)
51    this.appEventBus.on(Action.ACTION_ON_MODE_CHANGED, this.updateOpacityTabBar.bind(this))
52    Log.info(`${this.TAG} aboutToAppear invoke X`)
53  }
54
55  private aboutToDisappear(): void {
56    Log.info(`${this.TAG} aboutToDisappear invoke E`)
57    this.appEventBus.off(Action.ACTION_ON_MODE_CHANGED, this.updateOpacityTabBar.bind(this))
58    Log.info(`${this.TAG} aboutToDisappear invoke X`)
59  }
60
61  private updateOpacityTabBar(data) {
62    Log.info(`${this.TAG} updateOpacityTabBar invoke E`)
63    if (data.mode === CaptureMode.VIDEO) {
64      this.state.updateOpacityForTabBar(1)
65    } else {
66      this.state.updateOpacityForTabBar(0)
67    }
68    Log.info(`${this.TAG} updateOpacityTabBar invoke X`)
69  }
70
71  build() {
72      Column() {
73        Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
74          Image($r("app.media.sd_card")).width(24).height(24)
75        }
76      }
77  }
78}