• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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;
22    action: Action;
23    isLeft = true;
24    isAutoTint = true;
25    colorMode: ActionBarColorMode;
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) function commonButtonStyle () {
49    .height($r('app.float.icon_size'))
50    .width($r('app.float.icon_size'))
51}