• 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 */
15
16import router from '@ohos.router';
17import doubleButtonComponent from '../component/autoManager/doubleButtonComponent'
18import utils from '../../common/utils'
19
20@Entry
21@Component
22struct SetFinishSuccess {
23  @State textContext: Resource = $r('app.string.setupComplete');
24  @State textManager: string = getContext().resourceManager.getStringSync($r('app.string.unitManage').id);
25  private textContent: string = getContext()
26    .resourceManager
27    .getStringSync($r('app.string.textManageSuccessContent').id, this.textManager);
28  private getTextList: (source: string, target: string) => Array<string> = (source: string, target: string) => {
29    let result: string[] = [];
30    if (source) {
31      let position: number = source.indexOf(target);
32      let before: string = source.substring(0, position);
33      let after: string = source.substring(position + target.length);
34      result.push(before);
35      result.push(target);
36      result.push(after);
37    }
38    return result;
39  }
40
41  build() {
42    Column() {
43      GridContainer({
44        columns: utils.isLargeDevice(),
45        sizeType: SizeType.Auto,
46        gutter: '12vp',
47        margin: '12vp'
48      }) {
49        Column() {
50          Image($r('app.media.ic_public_todo'))
51            .width($r('app.float.wh_value_40'))
52            .height($r('app.float.wh_value_40'))
53            .margin({ top: '72vp', bottom: '16vp' })
54            .objectFit(ImageFit.Contain)
55
56          Text(this.textContext)
57            .height('40vp')
58            .textAlign(TextAlign.Center)
59            .fontWeight(FontWeight.Medium)
60            .lineHeight($r('app.float.lineHeight_vp_41'))
61            .fontSize($r('app.float.font_vp_30'))
62            .fontFamily('HarmonyHeiTi')
63        }
64        .useSizeType({
65          xs: { span: 8, offset: 0 }, sm: { span: 8, offset: 0 },
66          md: { span: 8, offset: 0 }, lg: { span: 8, offset: 2 }
67        })
68        .width('100%')
69        .align(Alignment.Center)
70
71        Column() {
72          Row() {
73            Text() {
74              ForEach(this.getTextList(this.textContent, this.textManager), (item: string) => {
75                Span(item)
76                  .fontColor(item === this.textManager ? 0x007DFF : 0x000000)
77                  .onClick(() => {
78                    if (item === this.textManager) {
79                      router.pushUrl({ url: 'pages/autoManager/unitManagerShowPage' })
80                    }
81                  })
82              })
83            }
84            .fontWeight(FontWeight.Regular)
85            .fontSize($r('app.float.font_vp_16'))
86            .fontFamily('HarmonyHeiTi')
87            .lineHeight($r('app.float.lineHeight_vp_21_5'))
88          }
89          .useSizeType({
90            xs: { span: 8, offset: 0 }, sm: { span: 8, offset: 0 },
91            md: { span: 8, offset: 0 }, lg: { span: 8, offset: 2 }
92          })
93          .width('100%')
94          .margin({ top: '48vp' })
95          .justifyContent(FlexAlign.Center)
96        }
97        .width('100%')
98      }
99
100      Blank()
101
102      GridContainer({
103        columns: utils.isLargeDevice(),
104        sizeType: SizeType.Auto,
105        gutter: '12vp',
106        margin: '12vp'
107      }) {
108        Column() {
109          doubleButtonComponent()
110        }
111        .useSizeType({
112          xs: { span: 8, offset: 0 }, sm: { span: 8, offset: 0 },
113          md: { span: 8, offset: 0 }, lg: { span: 12, offset: 0 }
114        })
115        .width('100%')
116        .margin({ bottom: '16vp' })
117      }
118    }
119    .backgroundColor(0xF1F3F5)
120    .width('100%')
121    .height('100%')
122  }
123}