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