• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022-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 { Log } from '../../utils/Log';
17import { Action } from './Action';
18import { ActionBar } from '../actionbar/ActionBar';
19import { ActionBarProp } from './ActionBarProp';
20import { ActionBarMode } from './ActionBarMode';
21import { ScreenManager } from '../../model/common/ScreenManager';
22import { MediaOperationType } from '../../model/common/MediaOperationType';
23import { Constants } from '../../model/common/Constants';
24
25const TAG: string = 'common_MediaOperationActionBar';
26
27@Component
28export struct MediaOperationActionBar {
29  @Consume pageType: string;
30  @Consume @Watch('createActionBar') loadingFinish: boolean;
31  onMenuClicked: Function = (): void => {};
32  @StorageLink('isHorizontal') @Watch('createActionBar') isHorizontal: boolean
33    = ScreenManager.getInstance().isHorizontal();
34  @State actionBarProp: ActionBarProp = new ActionBarProp();
35  @StorageLink('statusBarHeight') statusBarHeight: number = 0;
36  @Provide moreMenuList: Action[] = new Array<Action>();
37  @Provide hidePopup: boolean = false;
38
39  aboutToAppear(): void {
40    this.createActionBar();
41  }
42
43  build() {
44    Column() {
45      ActionBar({
46        actionBarProp: $actionBarProp,
47        onMenuClicked: this.onMenuClicked,
48        isNeedPlaceholder: false
49      })
50    }
51    .padding({
52      top: this.isHorizontal ? Constants.NUMBER_0 : px2vp(this.statusBarHeight)
53    })
54  }
55
56  private createActionBar(): void {
57    let menuList: Array<Action> = new Array<Action>();
58    let actionBarProp: ActionBarProp = new ActionBarProp();
59    if (this.loadingFinish) {
60      menuList.push(Action.NEW);
61    }
62    actionBarProp
63      .setHasTabBar(false)
64      .setTitle((this.pageType == MediaOperationType.Move) ? $r('app.string.move_to') : $r('app.string.add_to'))
65      .setMode(ActionBarMode.STANDARD_MODE)
66      .setMenuList(menuList)
67      .setBackgroundColor($r('app.color.transparent'))
68      .setLeftAction(Action.CANCEL);
69    this.actionBarProp = actionBarProp;
70  }
71}