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 HeadComponent from '../../../../../../common/component/src/main/ets/default/headComponent';
18import RestoreFactorySettingsController from '../controller/restoreFactorySettings/RestoreFactorySettingsController';
19
20/**
21 * Developer options
22 */
23@Entry
24@Component
25struct restoreFactorySettings {
26  @State isTouched: boolean = false;
27  private controller: RestoreFactorySettingsController = new RestoreFactorySettingsController();
28
29  build() {
30    Column() {
31      GridContainer({ gutter: ConfigData.GRID_CONTAINER_GUTTER_24, margin: ConfigData.GRID_CONTAINER_MARGIN_24 }) {
32        Column() {
33          HeadComponent({ headName: $r("app.string.resetPhone"), isActive: true });
34
35          Text($r("app.string.resetPhonePromptInfo"))
36            .fontFamily('HarmonyHeiTi')
37            .fontWeight(FontWeight.Medium)
38            .fontSize($r("app.float.font_18"))
39            .align(Alignment.Start)
40            .margin({
41              left: $r('app.float.distance_12'),
42              right: $r("app.float.distance_18"),
43              top: $r("app.float.distance_24"),
44            })
45            .width(ConfigData.WH_100_100)
46
47          Blank()
48
49          Button() {
50            Text($r("app.string.resetPhone"))
51              .fontColor(Color.Red)
52              .fontSize($r('sys.float.ohos_id_text_size_button1'))
53              .fontWeight(500)
54          }
55          .width($r('app.float.wh_263'))
56          .height($r('app.float.restore_factory_button_height'))
57          .align(Alignment.Center)
58          .margin({ top: $r("app.float.distance_16"), bottom: $r("app.float.distance_24") })
59          .backgroundColor(!this.isTouched ? '#E6E9EB' : $r("sys.color.ohos_id_color_foreground_contrary"))
60          .onClick(() => {
61            this.controller.restoreFactorySettings();
62          })
63          .onTouch((event?: TouchEvent | undefined) => {
64            if (event?.type === TouchType.Down) {
65              this.isTouched = true;
66            }
67
68            if (event?.type === TouchType.Up) {
69              this.isTouched = false;
70            }
71          })
72        }
73        .height(ConfigData.WH_100_100)
74        .useSizeType({
75          sm: { span: 4, offset: 0 },
76          md: { span: 6, offset: 1 },
77          lg: { span: 8, offset: 2 }
78        })
79      }
80      .width(ConfigData.WH_100_100)
81      .height(ConfigData.WH_100_100)
82    }
83    .backgroundColor($r("sys.color.ohos_id_color_sub_background"))
84    .width(ConfigData.WH_100_100)
85    .height(ConfigData.WH_100_100)
86  }
87}
88