• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2 * Copyright (c) 2021-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 ConfigData from '../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData';
17import SettingListModel from '../../../../../../product/phone/src/main/ets/model/settingListImpl/SettingListModel';
18import prompt from "@ohos.prompt"
19
20@Component
21export struct SettingItemComponent {
22  private targetPage: string;
23  private settingTitle: string | Resource;
24  @Link settingEndText: any;
25  private settingIcon: string | Resource;
26  @State isTouched: boolean = false;
27
28  onPageShow() {
29    console.info(`CCCC onPageShow: ${this.targetPage}`)
30  }
31
32  aboutToAppear(): void {
33    console.info(`CCCC aboutToAppear: ${this.targetPage}`)
34  }
35
36  build() {
37    Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
38      Row() {
39        Image(this.settingIcon)
40          .width($r("app.float.wh_value_24"))
41          .height($r("app.float.wh_value_24"))
42          .margin({
43            left: $r("app.float.distance_8"),
44            top: $r("app.float.distance_15"),
45            bottom: $r("app.float.distance_17")
46          })
47
48        Text(this.settingTitle)
49          .fontSize($r("app.float.font_16"))
50          .lineHeight($r("app.float.lineHeight_22"))
51          .fontWeight(FontWeight.Medium)
52          .fontFamily('HarmonyHeiTi')
53          .fontColor($r("sys.color.ohos_id_color_text_primary"))
54          .align(Alignment.Start)
55          .margin({
56            left: $r("app.float.distance_16"),
57            top: $r("app.float.distance_17"),
58            bottom: $r("app.float.distance_17")
59          })
60      }
61      .align(Alignment.Start)
62      .height(ConfigData.WH_100_100)
63
64      Row() {
65        Text(this.settingEndText)
66          .fontSize($r("app.float.font_14"))
67          .lineHeight($r("app.float.lineHeight_19"))
68          .align(Alignment.End)
69          .fontWeight(FontWeight.Regular)
70          .fontFamily('HarmonyHeiTi')
71          .fontColor($r('sys.color.ohos_id_color_text_secondary'))
72          .margin({ top: $r("app.float.distance_19"), bottom: $r("app.float.distance_18") });
73
74        Image('/res/image/ic_settings_arrow.svg')
75          .width($r("app.float.wh_value_12"))
76          .height($r("app.float.wh_value_24"))
77          .margin({
78            left: $r("app.float.distance_4"),
79            right: $r("app.float.distance_8"),
80            top: $r("app.float.distance_16"),
81            bottom: $r("app.float.distance_16")
82          })
83          .fillColor($r("sys.color.ohos_id_color_fourth"))
84      }
85      .align(Alignment.End)
86      .height(ConfigData.WH_100_100);
87    }
88    .width(ConfigData.WH_100_100)
89    .height($r("app.float.wh_value_56"))
90    .borderRadius($r("app.float.radius_20"))
91    .linearGradient(this.isTouched ? {
92                                       angle: 90,
93                                       direction: GradientDirection.Right,
94                                       colors: [[$r("app.color.DCEAF9"), 0.0], [$r("app.color.FAFAFA"), 1.0]]
95                                     } : {
96                                           angle: 90,
97                                           direction: GradientDirection.Right,
98                                           colors: [[$r("sys.color.ohos_id_color_foreground_contrary"), 1], [$r("sys.color.ohos_id_color_foreground_contrary"), 1]]
99                                         })
100    .onTouch((event: TouchEvent) => {
101      if (event.type === TouchType.Down) {
102        this.isTouched = true;
103      }
104      if (event.type === TouchType.Up) {
105        this.isTouched = false;
106      }
107    })
108    .onClick(() => {
109      SettingListModel.onSettingItemClick(this.targetPage);
110    })
111  }
112}