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 { ActionBarProp } from '../browserOperation/ActionBarProp'; 18import { Action } from '../browserOperation/Action'; 19import { ActionBarButton } from './ActionBarButton'; 20 21const TAG: string = 'common_MenuPanel'; 22 23// MenuPanel,Right menu button panel 24@Component 25export struct MenuPanel { 26 @Link @Watch('onActionBarPropChanged') actionBarProp: ActionBarProp; 27 @State menuList: Action[] = []; 28 onMenuClicked: Function = (): void => {}; 29 30 aboutToAppear(): void { 31 Log.info(TAG, 'aboutToAppear.'); 32 this.onActionBarPropChanged(); 33 } 34 35 build() { 36 Row() { 37 ForEach(this.menuList, (menu: Action) => { 38 ActionBarButton({ 39 res: menu.iconRes, 40 action: menu, 41 onMenuClicked: this.onMenuClicked, 42 isLeft: false, 43 isAutoTint: menu.isAutoTint, 44 colorMode: this.actionBarProp.getColorMode() 45 }) 46 .margin({ right: $r('app.float.max_padding_end') }) 47 }, (menu: Action) => String(menu.actionID)) 48 } 49 .alignItems(VerticalAlign.Center) 50 } 51 52 private onActionBarPropChanged(): void { 53 this.menuList = this.actionBarProp.getMenuList(); 54 Log.info(TAG, `onActionBarPropChanged, menu's size: ${this.menuList.length}`); 55 this.menuList.forEach((menu: Action) => { 56 Log.info(TAG, `ActionId: ${menu.actionID}`) 57 }) 58 } 59 60 private onBuildDone(): void { 61 Log.info(TAG, `onBuildDone, menu's size: ${this.menuList.length}`); 62 } 63}