1/* 2 * Copyright (c) 2023 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 { Log } from '../../../utils/Log'; 17import { SetResolution } from './SetResolution'; 18import { SetToggle } from './SetToggle'; 19import { SettingData, SettingGroupItem } from '../model/SettingData'; 20 21@Component 22export struct SettingItem { 23 @Link settingsList: SettingGroupItem[]; 24 @Link closeFlag: Boolean; 25 private TAG: string = '[SettingItem]:'; 26 private item: SettingGroupItem = {}; 27 private index: number = 0; 28 private WH_100_100: string = "100%"; 29 30 aboutToAppear() { 31 Log.info(`${this.TAG} aboutToAppear start`) 32 Log.info(`${this.TAG} aboutToAppear ${JSON.stringify(this.item.settingChildren)}`) 33 Log.info(`${this.TAG} aboutToAppear end`) 34 } 35 36 build() { 37 Flex({ 38 direction: FlexDirection.Column, 39 alignItems: ItemAlign.Center, 40 justifyContent: FlexAlign.SpaceBetween 41 }) { 42 Column() { 43 Row() { 44 Text(this.item.settingTitle) 45 .margin({ 46 top: $r('app.float.margin_value_20'), 47 left: $r('sys.float.ohos_id_card_margin_start'), 48 bottom: $r('app.float.margin_value_8') 49 }) 50 .fontColor($r('app.color.font_color_FFFFFF')) 51 .opacity($r('app.float.opacity_6')) 52 .fontSize($r('app.float.font_14')) 53 .fontWeight(FontWeight.Medium) 54 } 55 .width(this.WH_100_100) 56 .height(this.WH_100_100) 57 } 58 .width(this.WH_100_100) 59 .height(48) 60 61 Column() { 62 List() { 63 ForEach(this.item.settingChildren, (itemValue: SettingData) => { 64 ListItem() { 65 Column() { 66 if (itemValue.selectType === "radio") { 67 SetResolution({ 68 closeFlag: $closeFlag, 69 settingsList: $settingsList, 70 itemValue: itemValue 71 }) 72 } 73 if (itemValue.selectType === "toggle") { 74 SetToggle({ 75 settingsList: $settingsList, 76 itemValue: itemValue 77 }) 78 } 79 } 80 } 81 }) 82 } 83 .listDirection(Axis.Vertical) 84 .divider({ 85 strokeWidth: 0.5, 86 color: '#33FFFFFF', 87 startMargin: 56, 88 endMargin: 12 89 }) 90 .borderRadius($r('sys.float.ohos_id_corner_radius_card')) 91 .backgroundColor('#202224') 92 .padding({ top: 4, bottom: 4 }) 93 }.width(this.WH_100_100) 94 } 95 } 96}