• 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, Log } from '@ohos/common';
17import { ToolBar } from '@ohos/common/CommonComponents';
18
19const TAG: string = 'browser_AlbumSetPageToolBar';
20
21@Component
22export struct AlbumSetPageToolBar {
23  @Provide isShowBar: boolean = true;
24  @Provide toolMenuList: Array<Action> = new Array<Action>();
25  @Provide moreMenuList: Action[] = new Array<Action>();
26  @Consume @Watch('updateToolbar') isAlbumSetSelectedMode: boolean;
27  @Consume('selectedCount') @Watch('updateToolbar') selectedAlbumsCount: number;
28  @Consume isDisableRename: boolean;
29  @Consume isDisableDelete: boolean;
30  onMenuClicked: Function = (): void => {};
31  @Provide hidePopup: boolean = false;
32
33  aboutToAppear(): void {
34    Log.info(TAG, 'aboutToAppear');
35    this.updateToolbar();
36  }
37
38  build() {
39    ToolBar({
40      onMenuClicked: this.onMenuClicked
41    })
42  }
43
44  private updateToolbar(): void {
45    Log.info(TAG, 'updateToolbar');
46    if (this.isAlbumSetSelectedMode) {
47      Log.info(TAG, 'pushToolbar');
48      this.toolMenuList = [];
49      this.toolMenuList.push(
50        ((!this.isDisableRename && this.selectedAlbumsCount == 1) ? Action.RENAME : Action.RENAME_INVALID),
51        ((!this.isDisableDelete && this.selectedAlbumsCount > 0) ? Action.DELETE : Action.DELETE_INVALID));
52    }
53  }
54}