• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 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
37@Component
38export struct TabBarOther {
39  private TAG: string = '[TabBarOther]:'
40  @State state: any = {}
41  appEventBus: EventBus = EventBusManager.getInstance().getEventBus()
42
43  private aboutToAppear() {
44    Log.info(`${this.TAG} aboutToAppear invoke E`)
45    getStore().connect(tabBarLandState, tabBarLandDispatcher)(this.state)
46    this.appEventBus.on(Action.ACTION_ON_MODE_CHANGED, this.updateOpacityTabBar.bind(this))
47    Log.info(`${this.TAG} aboutToAppear invoke X`)
48  }
49
50  private aboutToDisappear(): void {
51    Log.info(`${this.TAG} aboutToDisappear invoke E`)
52    this.appEventBus.off(Action.ACTION_ON_MODE_CHANGED, this.updateOpacityTabBar.bind(this))
53    Log.info(`${this.TAG} aboutToDisappear invoke X`)
54  }
55
56  private updateOpacityTabBar(data) {
57    Log.info(`${this.TAG} updateOpacityTabBar invoke E`)
58    if (data.mode === CaptureMode.VIDEO) {
59      animateTo({ duration: 2000,
60        curve: Curve.Sharp,
61        delay: 0
62      }, () => {
63        this.state.updateOpacityForTabBar(1)
64      })
65    } else {
66      animateTo({ duration: 2000,
67        curve: Curve.Sharp,
68        delay: 0
69      }, () => {
70        this.state.updateOpacityForTabBar(0)
71      })
72    }
73    Log.info(`${this.TAG} updateOpacityTabBar invoke X`)
74  }
75
76  build() {
77    Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
78      Column() {
79        Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
80          Image($r("app.media.sd_card")).width(24).height(24)
81        }.width('100%').height('100%')
82      }
83      .width('100%')
84      .height('100%')
85      .opacity(this.state.opacityValueForTabBar)
86    }
87    .width('100%')
88    .height('100%')
89  }
90}