100aff185Sopenharmony_ci/* 200aff185Sopenharmony_ci * Copyright (c) 2022-2023 Huawei Device Co., Ltd. 300aff185Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 400aff185Sopenharmony_ci * you may not use this file except in compliance with the License. 500aff185Sopenharmony_ci * You may obtain a copy of the License at 600aff185Sopenharmony_ci * 700aff185Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 800aff185Sopenharmony_ci * 900aff185Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1000aff185Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1100aff185Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1200aff185Sopenharmony_ci * See the License for the specific language governing permissions and 1300aff185Sopenharmony_ci * limitations under the License. 1400aff185Sopenharmony_ci */ 1500aff185Sopenharmony_ci 1600aff185Sopenharmony_ciimport { Action } from './browserOperation/Action'; 1700aff185Sopenharmony_ciimport { ActionBar } from './actionbar/ActionBar'; 1800aff185Sopenharmony_ciimport { ActionBarProp } from './browserOperation/ActionBarProp'; 1900aff185Sopenharmony_ciimport { ActionBarColorMode, ActionBarMode, ActionBarSelectionMode } from './browserOperation/ActionBarMode'; 2000aff185Sopenharmony_ciimport { ScreenManager } from '../model/common/ScreenManager'; 2100aff185Sopenharmony_ciimport { Constants } from '../model/common/Constants'; 2200aff185Sopenharmony_ci 2300aff185Sopenharmony_ciconst TAG: string = 'common_ThirdSelectPhotoBrowserActionBar'; 2400aff185Sopenharmony_ci 2500aff185Sopenharmony_ci@Component 2600aff185Sopenharmony_ciexport struct ThirdSelectPhotoBrowserActionBar { 2700aff185Sopenharmony_ci @StorageLink('leftBlank') leftBlank: number[] = 2800aff185Sopenharmony_ci [0, ScreenManager.getInstance().getStatusBarHeight(), 0, ScreenManager.getInstance().getNaviBarHeight()]; 2900aff185Sopenharmony_ci @State isMultiPick: boolean = false; 3000aff185Sopenharmony_ci @Consume @Watch('createActionBar') isSelected: boolean; 3100aff185Sopenharmony_ci onMenuClicked: Function = (): void => {}; 3200aff185Sopenharmony_ci @StorageLink('isHorizontal') @Watch('createActionBar') isHorizontal: boolean = ScreenManager.getInstance() 3300aff185Sopenharmony_ci .isHorizontal(); 3400aff185Sopenharmony_ci @State actionBarProp: ActionBarProp = new ActionBarProp(); 3500aff185Sopenharmony_ci @StorageLink('statusBarHeight') statusBarHeight: number = 0; 3600aff185Sopenharmony_ci @Link isShowBar: boolean; 3700aff185Sopenharmony_ci @Provide('selectedCount') selectedCount: number = 0; 3800aff185Sopenharmony_ci @Link @Watch('onSelectedCountChanged') totalSelectedCount: number; 3900aff185Sopenharmony_ci @Provide moreMenuList: Action[] = []; 4000aff185Sopenharmony_ci @Provide hidePopup: boolean = false; 4100aff185Sopenharmony_ci private title: string | Resource = ''; 4200aff185Sopenharmony_ci private isThird: boolean = false; 4300aff185Sopenharmony_ci @Consume canEdit: boolean; 4400aff185Sopenharmony_ci 4500aff185Sopenharmony_ci aboutToAppear() { 4600aff185Sopenharmony_ci this.createActionBar(); 4700aff185Sopenharmony_ci this.onSelectedCountChanged(); 4800aff185Sopenharmony_ci } 4900aff185Sopenharmony_ci 5000aff185Sopenharmony_ci build() { 5100aff185Sopenharmony_ci Stack({ alignContent: Alignment.TopStart }) { 5200aff185Sopenharmony_ci Image($r('app.media.gradientBasePlate')).width(Constants.PERCENT_100) 5300aff185Sopenharmony_ci .height(Constants.PERCENT_100).objectFit(ImageFit.Fill) 5400aff185Sopenharmony_ci ActionBar({ 5500aff185Sopenharmony_ci actionBarProp: $actionBarProp, 5600aff185Sopenharmony_ci onMenuClicked: this.onMenuClicked, 5700aff185Sopenharmony_ci isNeedPlaceholder: false 5800aff185Sopenharmony_ci }) 5900aff185Sopenharmony_ci .padding({ 6000aff185Sopenharmony_ci top: (this.isHorizontal && !ScreenManager.getInstance().isUIExtensionEnv()) ? 6100aff185Sopenharmony_ci $r('app.float.third_selected_actionbar_padding_top') : px2vp(this.statusBarHeight) 6200aff185Sopenharmony_ci }) 6300aff185Sopenharmony_ci } 6400aff185Sopenharmony_ci .height(this.isHorizontal ? Constants.ActionBarHeight * Constants.PHOTO_BAR_MULTIPLES_1_5 : 6500aff185Sopenharmony_ci Constants.ActionBarHeight * Constants.PHOTO_BAR_MULTIPLES_1_5 + 6600aff185Sopenharmony_ci px2vp(this.statusBarHeight)) 6700aff185Sopenharmony_ci .markAnchor({ x: Constants.PERCENT_0, y: Constants.PERCENT_0 }) 6800aff185Sopenharmony_ci .position({ x: Constants.PERCENT_0, y: Constants.PERCENT_0 }) 6900aff185Sopenharmony_ci .visibility(this.isShowBar ? Visibility.Visible : Visibility.Hidden) 7000aff185Sopenharmony_ci } 7100aff185Sopenharmony_ci 7200aff185Sopenharmony_ci private onSelectedCountChanged() { 7300aff185Sopenharmony_ci this.selectedCount = this.totalSelectedCount; 7400aff185Sopenharmony_ci } 7500aff185Sopenharmony_ci 7600aff185Sopenharmony_ci private createActionBar(): void { 7700aff185Sopenharmony_ci let actionBarProp: ActionBarProp = new ActionBarProp(); 7800aff185Sopenharmony_ci 7900aff185Sopenharmony_ci let menuList: Action[] = []; 8000aff185Sopenharmony_ci if (this.canEdit) { 8100aff185Sopenharmony_ci menuList.push(Action.EDIT); 8200aff185Sopenharmony_ci } 8300aff185Sopenharmony_ci 8400aff185Sopenharmony_ci actionBarProp 8500aff185Sopenharmony_ci .setLeftAction(Action.BACK) 8600aff185Sopenharmony_ci .setMode(ActionBarMode.SELECTION_MODE) 8700aff185Sopenharmony_ci .setSelectionMode(this.isMultiPick ? ActionBarSelectionMode.MULTI : ActionBarSelectionMode.SINGLE) 8800aff185Sopenharmony_ci .setColorMode(ActionBarColorMode.TRANSPARENT) 8900aff185Sopenharmony_ci .setAlpha(ActionBarProp.PHOTO_BROWSER_ACTIONBAR_ALPHA) 9000aff185Sopenharmony_ci 9100aff185Sopenharmony_ci if (this.isMultiPick && !this.isThird) { 9200aff185Sopenharmony_ci menuList.push(this.isSelected ? Action.SELECTED : Action.MATERIAL_SELECT); 9300aff185Sopenharmony_ci } 9400aff185Sopenharmony_ci actionBarProp.setMenuList(menuList) 9500aff185Sopenharmony_ci 9600aff185Sopenharmony_ci if (this.title) { 9700aff185Sopenharmony_ci actionBarProp 9800aff185Sopenharmony_ci .setIsNeedTitle(false); 9900aff185Sopenharmony_ci } 10000aff185Sopenharmony_ci this.actionBarProp = actionBarProp; 10100aff185Sopenharmony_ci } 10200aff185Sopenharmony_ci}