• 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 tabBarMState = (state) => {
24  return {
25    widthTabBar: state.PreviewReducer.widthTabBar
26  }
27}
28
29let tabBarMDispatcher = (dispatch) => {
30  return {
31    updateShowTabBarWidth: (widthTabBar: String) => {
32      dispatch(Action.updateShowTabBarWidth(widthTabBar))
33    }
34  }
35}
36
37@Component
38export struct TabBarSame {
39  private TAG: string = '[TabBarSame]:'
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(tabBarMState, tabBarMDispatcher)(this.state)
46    this.appEventBus.on(Action.ACTION_ON_MODE_CHANGED,this.updateTabBarWidth.bind(this))
47    Log.info(`${this.TAG} aboutToAppear invoke X`)
48  }
49
50  private updateTabBarWidth(data) {
51    Log.info(`${this.TAG} updateTabBarWidth invoke E`)
52    switch (data.mode) {
53      case CaptureMode.PHOTO:
54        this.state.updateShowTabBarWidth('40%')
55        break;
56      case CaptureMode.VIDEO:
57        this.state.updateShowTabBarWidth('10%')
58        break;
59      default:
60        this.state.updateShowTabBarWidth('30%')
61        break;
62    }
63    Log.info(`${this.TAG} updateTabBarWidth invoke X`)
64  }
65
66  build() {
67    Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
68      Column() {
69      }
70      .width(this.state.widthTabBar)
71      .height('100%')
72      .animation({
73        duration: 2000,
74        curve: Curve.Sharp,
75        delay: 0,
76        iterations: 1,
77        playMode: PlayMode.Normal
78      })
79
80      Column() {
81        Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
82          Image($r("app.media.delete"))
83            .width(24)
84            .height(24)
85        }.width('100%').height('100%')
86      }.width('20%').height('100%')
87    }
88    .width('100%')
89    .height('100%')
90  }
91}