• 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 './browserOperation/Action';
17import { ActionBar } from './actionbar/ActionBar';
18import { ActionBarProp } from './browserOperation/ActionBarProp';
19import { ActionBarMode, ActionBarColorMode, ActionBarSelectionMode } from './browserOperation/ActionBarMode';
20import { Constants } from '../model/common/Constants';
21
22@Component
23export struct ThirdSelectPhotoBrowserActionBar {
24    @StorageLink('leftBlank') leftBlank: [number, number, number, number] = [0, 0, 0, 0];
25    @State isMultiPick: boolean = false;
26    @Consume @Watch('updateActionBar') isSelected: boolean;
27    onMenuClicked: Function;
28    @State actionBarProp: ActionBarProp = new ActionBarProp;
29
30    aboutToAppear(): void {
31        this.actionBarProp = this.createActionBar();
32    }
33
34    updateActionBar(): void {
35        this.actionBarProp = this.createActionBar();
36    }
37
38    private createActionBar(): ActionBarProp {
39        let actionBarProp: ActionBarProp = new ActionBarProp();
40        let menuList
41            = [this.isMultiPick ? (this.isSelected ? Action.SELECTED : Action.MATERIAL_SELECT) : Action.OK];
42        actionBarProp
43            .setLeftAction(Action.BACK)
44            .setMode(ActionBarMode.SELECTION_MODE)
45            .setSelectionMode(this.isMultiPick ? ActionBarSelectionMode.MULTI : ActionBarSelectionMode.SINGLE)
46            .setColorMode(ActionBarColorMode.TRANSPARENT)
47            .setAlpha(ActionBarProp.PHOTO_BROWSER_ACTIONBAR_ALPHA)
48            .setMenuList(menuList);
49        return actionBarProp;
50    }
51
52    build() {
53        Stack({ alignContent: Alignment.TopStart }) {
54            Image($r('app.media.gradientBasePlate')).width('100%')
55                .height('100%').objectFit(ImageFit.Fill)
56            ActionBar({
57                actionBarProp: $actionBarProp,
58                onMenuClicked: this.onMenuClicked
59            })
60        }
61        .height(Constants.ActionBarHeight)
62        .hitTestBehavior(HitTestMode.Transparent)
63        .markAnchor({ x: '0%', y: '0%' })
64        .position({ x: '0%', y: '0%' })
65    }
66}