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 '../../../common/view/browserOperation/Action'; 17import { ActionBar } from '../../../common/view/actionbar/ActionBar'; 18import { ActionBarProp } from '../../../common/view/browserOperation/ActionBarProp'; 19import { ActionBarMode, ActionBarColorMode } from '../../../common/view/browserOperation/ActionBarMode'; 20import { Constants } from '../../../common/model/common/Constants'; 21import { Log } from '@ohos/base/src/main/ets/utils/Log'; 22 23@Component 24export struct PhotoBrowserActionBar { 25 @Consume @Watch('updateActionBar') menuList: Action[]; 26 onMenuClicked: Function; 27 isVideoPage: boolean = false; 28 @State actionBarProp: ActionBarProp = new ActionBarProp(); 29 30 updateActionBar(): void { 31 Log.info('PhotoBrowserActionBar', 'updateActionBar'); 32 this.actionBarProp = this.createActionBar(); 33 } 34 35 private createActionBar(): ActionBarProp { 36 let actionBarProp: ActionBarProp = new ActionBarProp(); 37 actionBarProp 38 .setHasTabBar(false) 39 .setLeftAction(Action.BACK) 40 .setAlpha(ActionBarProp.PHOTO_BROWSER_ACTIONBAR_ALPHA) 41 .setMode(ActionBarMode.TOP_MODE) 42 .setColorMode(this.isVideoPage ? ActionBarColorMode.TRANSPARENT : ActionBarColorMode.NORMAL) 43 .setMenuList(this.menuList) 44 return actionBarProp; 45 } 46 47 aboutToAppear(): void { 48 this.actionBarProp = this.createActionBar(); 49 } 50 51 build() { 52 Column() { 53 ActionBar({ 54 actionBarProp: $actionBarProp, 55 onMenuClicked: this.onMenuClicked, 56 isVideoPage: this.isVideoPage 57 }).sharedTransition("actionBar", { 58 type:SharedTransitionEffectType.Static, 59 duration: Constants.SHARE_TRANSITION_DURATION, 60 zIndex: 2, 61 }) 62 63 } 64 .markAnchor({ x: '0%', y: '0%' }) 65 .position({ x: '0%', y: '0%' }) 66 } 67}