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