• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development 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 | null = null;
19  @State isClickScrollBar: boolean = false;
20  @Consume isHideScrollBar: boolean;
21  hasSideBar: boolean = true;
22
23  build() {
24    if (this.scroller !== null && this.scroller !== undefined) {
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): void => {
43        if (event.type === TouchType.Down) {
44          this.isClickScrollBar = true;
45        } else if (event.type === TouchType.Up) {
46          this.isClickScrollBar = false;
47        }
48      })
49    }
50
51  }
52}