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 { ActionBarColorMode } from '../browserOperation/ActionBarMode'; 18 19@Component 20export struct ToolBarButton { 21 @State res: Resource | undefined = undefined; 22 action: Action = Action.NONE; 23 isLeft = true; 24 isAutoTint = true; 25 colorMode: ActionBarColorMode = ActionBarColorMode.NORMAL; 26 27 build() { 28 Flex({ 29 direction: FlexDirection.Column, 30 justifyContent: FlexAlign.Center, 31 alignItems: ItemAlign.Center 32 }) { 33 if (this.isAutoTint) { 34 Image(this.res) 35 .commonButtonStyle() 36 .fillColor(this.colorMode == ActionBarColorMode.TRANSPARENT 37 ? Action.ICON_DEFAULT_COLOR_CONTRARY : this.action.fillColor) 38 } else { 39 Image(this.res) 40 .commonButtonStyle() 41 } 42 } 43 .height($r('app.float.icon_size')) 44 .width($r('app.float.icon_size')) 45 } 46} 47 48@Extend(Image) 49function commonButtonStyle() { 50 .height($r('app.float.icon_size')) 51 .width($r('app.float.icon_size')) 52}