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 './Action' 17import { ActionBarMode, ActionBarColorMode, ActionBarSelectionMode } from './ActionBarMode' 18 19// ActionBarProp 20export class ActionBarProp { 21 public static NORMAL_BACKGROUND_COLOR: Resource = $r('app.color.default_background_color'); 22 public static TRANSPARENT_BACKGROUND_COLOR: Resource = $r('app.color.transparent'); 23 public static NORMAL_TEXT_COLOR: Resource = $r('sys.color.ohos_id_color_titlebar_text'); 24 public static NORMAL_SUBTITLE_TEXT_COLOR: Resource = $r('sys.color.ohos_id_color_titlebar_subtitle_text'); 25 public static ICON_COLOR: Resource = $r('sys.color.ohos_id_color_primary'); 26 public static TRANSPARENT_TEXT_COLOR: Resource = $r('app.color.title_text_color_on_transparent_bg'); 27 public static TRANSPARENT_SUBTITLE_TEXT_COLOR: Resource = $r('app.color.subtitle_text_color_on_transparent_bg'); 28 public static HEAD_TITLE_TEXT_SIZE: Resource = $r('sys.float.ohos_id_text_size_headline6'); 29 public static HEAD_TITLE_ONE_LINE_TEXT_SIZE: Resource = $r('sys.float.ohos_id_text_size_headline7'); 30 public static TITLE_TEXT_SIZE: Resource = $r('sys.float.ohos_id_text_size_headline8'); 31 public static TITLE_FONT_WEIGHT = 500; 32 public static SUBTITLE_TEXT_SIZE: Resource = $r('sys.float.ohos_id_text_size_body2'); 33 public static MEDIUM_FONT: Resource = $r('app.string.id_text_font_family_medium'); 34 public static REGULAR_FONT: Resource = $r('app.string.id_text_font_family_regular'); 35 public static SINGLE_UNSELECT_TITLE: Resource = $r('app.string.title_select_photos'); 36 public static SINGLE_SELECT_ALBUM_TITLE: Resource = $r('app.string.title_select_album'); 37 public static MULTI_UNSELECT_TITLE: Resource = $r('app.string.title_none_selected'); 38 public static PHOTO_BROWSER_ACTIONBAR_ALPHA = 0.95; 39 private hasTabBar = false; 40 private leftAction = Action.NONE; 41 private isHeadTitle = false; 42 private title: Resource | string = null; 43 private subTitle: Resource | string = null; 44 private menuList: Action[] = []; 45 private backgroundColor: Resource = ActionBarProp.NORMAL_BACKGROUND_COLOR; 46 private alpha = 1; 47 private selectionMode: ActionBarSelectionMode = ActionBarSelectionMode.MULTI; 48 private colorMode: ActionBarColorMode = ActionBarColorMode.NORMAL; 49 private mode: ActionBarMode = ActionBarMode.STANDARD_MODE; 50 private maxSelectCount = 0; 51 52 constructor() { 53 } 54 55 public static getCountDetailSelectedTitle(count: number): Resource { 56 return $r('app.plural.count_details_selected', count, count); 57 } 58 59 /** 60 * External selection quantity display 61 * @param count The selected quantity, same as the current count above 62 * @param maxSelectCount Maximum number of options 63 */ 64 public static getCountDetailExternalSelectedTitle(count: number, maxSelectCount: number): Resource { 65 return $r('app.string.count_details_external_selected', count, maxSelectCount); 66 } 67 68 public setHasTabBar(hasTabBar: boolean): ActionBarProp { 69 this.hasTabBar = hasTabBar; 70 return this; 71 } 72 73 public getHasTabBar(): boolean { 74 return this.hasTabBar; 75 } 76 77 public setLeftAction(leftAction: Action): ActionBarProp { 78 this.leftAction = leftAction; 79 return this; 80 } 81 82 public getLeftAction(): Action { 83 return this.leftAction; 84 } 85 86 public setIsHeadTitle(isHeadTitle: boolean): ActionBarProp { 87 this.isHeadTitle = isHeadTitle; 88 return this; 89 } 90 91 public getIsHeadTitle(): boolean { 92 return this.isHeadTitle; 93 } 94 95 public setTitle(title: Resource | string): ActionBarProp { 96 this.title = title; 97 return this; 98 } 99 100 public getTitle(): Resource | string { 101 return this.title; 102 } 103 104 public setSubTitle(subTitle: Resource | string): ActionBarProp { 105 this.subTitle = subTitle; 106 return this; 107 } 108 109 public getSubTitle(): Resource | string { 110 return this.subTitle; 111 } 112 113 public setMenuList(menuList: Action[]): ActionBarProp { 114 this.menuList = menuList; 115 return this; 116 } 117 118 public getMenuList(): Action[] { 119 return this.menuList; 120 } 121 122 public setBackgroundColor(backgroundColor: Resource): ActionBarProp { 123 this.backgroundColor = backgroundColor; 124 return this; 125 } 126 127 public getBackgroundColor(): Resource { 128 return this.colorMode == ActionBarColorMode.TRANSPARENT 129 ? ActionBarProp.TRANSPARENT_BACKGROUND_COLOR : this.backgroundColor; 130 } 131 132 public setAlpha(alpha: number): ActionBarProp { 133 this.alpha = alpha; 134 return this; 135 } 136 137 public getAlpha(): number { 138 return this.alpha; 139 } 140 141 public setMode(mode: ActionBarMode): ActionBarProp { 142 this.mode = mode; 143 return this; 144 } 145 146 public getMode(): ActionBarMode { 147 return this.mode; 148 } 149 150 public setColorMode(colorMode: ActionBarColorMode): ActionBarProp { 151 this.colorMode = colorMode; 152 return this; 153 } 154 155 public getColorMode(): ActionBarColorMode { 156 return this.colorMode; 157 } 158 159 public setSelectionMode(selectionMode: ActionBarSelectionMode): ActionBarProp { 160 this.selectionMode = selectionMode; 161 return this; 162 } 163 164 public getSelectionMode(): ActionBarSelectionMode { 165 return this.selectionMode; 166 } 167 168 public setMaxSelectCount(maxSelectCount: number): ActionBarProp { 169 this.maxSelectCount = maxSelectCount; 170 return this; 171 } 172 173 public getMaxSelectCount(): number { 174 return this.maxSelectCount; 175 } 176}