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