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 16@Component 17export struct AlbumScrollBar { 18 scroller: Scroller; 19 @State isClickScrollBar: boolean = false; 20 @Consume isHideScrollBar: boolean; 21 hasSideBar: boolean = true; 22 @Consume('tabBarShow') hasTabBarShow: boolean; 23 24 build() { 25 ScrollBar({ scroller: this.scroller, direction: ScrollBarDirection.Vertical, 26 state: this.isHideScrollBar ? BarState.Off : BarState.Auto }) { 27 Row() { 28 } 29 .width(this.isClickScrollBar ? 30 $r('app.float.album_scrollbar_select_size') : $r('app.float.album_scrollbar_normal_size')) 31 .height($r('app.float.album_scrollbar_height_size')) 32 .border({ radius: $r('app.float.album_scrollbar_radius') }) 33 .backgroundColor($r('app.color.album_scrollbar_color')) 34 } 35 .height('100%') 36 .position({ x: '100%', y: 0 }) 37 .markAnchor({ 38 x: this.isClickScrollBar 39 ? $r('app.float.album_scrollbar_select_size') : $r('app.float.album_scrollbar_normal_size'), 40 y: 0 41 }) 42 .onTouch((event: TouchEvent) => { 43 if (event.type == TouchType.Down) { 44 this.isClickScrollBar = true; 45 } else if (event.type == TouchType.Up) { 46 this.isClickScrollBar = false; 47 } 48 }) 49 .padding({ 50 bottom: this.hasTabBarShow 51 ? (this.hasSideBar ? $r('app.float.album_set_page_padding_end_112') : $r('app.float.album_set_page_padding_end_168')) 52 : (this.hasSideBar ? $r('app.float.album_set_tab_bar_height') : $r('app.float.album_set_page_padding_end_112')) 53 }) 54 } 55}