• 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 */
15import { WindowConstants } from '../constants/WindowConstants';
16
17// New style
18@Component
19export struct EmptyAlbumComponent {
20    @Consume gridHeight: number;
21    @Consume isBigCard: boolean;
22    @State icHeight: number = 0;
23    gridAspectRatio = WindowConstants.CARD_ASPECT_RATIO;
24
25    aboutToAppear(): void {
26        let numberHeight = px2vp(fp2px(WindowConstants.TEXT_SIZE_BODY2));
27        let nameHeight = px2vp(fp2px(WindowConstants.TEXT_SIZE_SUB_TITLE1));
28        this.icHeight = this.gridHeight - WindowConstants.ALBUM_SET_NEW_ICON_MARGIN - numberHeight - nameHeight;
29    }
30
31    build() {
32        if (this.isBigCard) {
33            Flex({
34                direction: FlexDirection.Column,
35                justifyContent: FlexAlign.Center,
36                alignItems: ItemAlign.Center
37            }) {
38                Image($r('app.media.ic_goto_photos'))
39                    .width($r('app.float.recycle_album_cover_icon_size'))
40                    .height($r('app.float.recycle_album_cover_icon_size'))
41                    .fillColor($r('app.color.empty_or_recycle_album_icon'))
42            }
43            .width('100%')
44            .height(this.gridHeight)
45            .backgroundColor($r('app.color.empty_or_recycle_album_back'))
46            .border({ radius: $r('sys.float.ohos_id_corner_radius_default_l') })
47        } else {
48            Flex({
49                direction: FlexDirection.Column,
50                justifyContent: FlexAlign.Start,
51                alignItems: ItemAlign.Start
52            }) {
53                Stack({ alignContent: Alignment.Center }) {
54                    Image($r('app.media.ic_goto_photos'))
55                        .width($r('app.float.recycle_album_cover_icon_size'))
56                        .height($r('app.float.recycle_album_cover_icon_size'))
57                        .fillColor($r('app.color.empty_or_recycle_album_icon'))
58                }
59                .height(this.icHeight)
60                .width('100%')
61            }
62            .aspectRatio(this.gridAspectRatio)
63            .backgroundColor($r('app.color.empty_or_recycle_album_back'))
64            .border({ radius: $r('sys.float.ohos_id_corner_radius_default_l') })
65        }
66    }
67}
68
69// Traditional style
70@Component
71export struct EmptyAlbumComponentForTraditionalStyle {
72    build() {
73        Flex({
74            direction: FlexDirection.Column,
75            justifyContent: FlexAlign.Center,
76            alignItems: ItemAlign.Center
77        }) {
78            Image($r('app.media.ic_goto_photos'))
79                .width($r('app.float.album_set_icon_size'))
80                .aspectRatio(1)
81                .fillColor($r('sys.color.ohos_id_color_secondary'))
82        }
83        .aspectRatio(1)
84        .backgroundColor($r('app.color.album_set_empty_album_bright')) // bright and dark mode
85        .border({ radius: $r('sys.float.ohos_id_corner_radius_default_s') })
86    }
87}