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 { Action } from '../../../redux/actions/Action' 17import AspectRatio from '../../../setting/settingitem/AspectRatio' 18import Resolution from '../../../setting/settingitem/Resolution' 19import Timer from '../../../setting/settingitem/Timer' 20import { CustomDialogView, CustomDialogDetails } from '../../customdialog/dialogComponent/CustomDialogView' 21import { Log } from '../../../utils/Log' 22import { getStore } from '../../../redux/store' 23import { SettingManager } from '../../../setting/SettingManager' 24import { BaseData } from '../model/BaseData' 25import { SettingData } from '../model/SettingData' 26 27let localState = (state) => { 28 return {} 29} 30 31let localDispatcher = (dispatch) => { 32 return { 33 closeDialog: (isCloseFlag: boolean) => { 34 dispatch(Action.closeDialog(isCloseFlag)) 35 } 36 } 37} 38 39class StateStruct { 40 closeDialog : Function 41} 42 43@Component 44export struct SetResolution { 45 private TAG: string = '[SetResolution]:' 46 @Link settingsList: any[] 47 @Link @Watch('onCloseDialog') closeFlag: boolean 48 private itemValue: SettingData 49 private getCheckValue: Promise<string> 50 private WH_100_100: string = "100%" 51 private settingManager = SettingManager.getInstance() 52 private setAlias: string= undefined 53 @StorageLink("settingDialogFlag") settingDialogFlag: boolean = true 54 55 @State curCheckName: Resource = $r("app.string.default_value") 56 57 @State state: StateStruct = new StateStruct() 58 59 @Provide customDialogDetails: CustomDialogDetails = { 60 confirmCallback: null, 61 confirmItem: true, 62 height: 256, 63 width: 256, 64 setAlias: this.setAlias, 65 childrenList: [], 66 settingTitle: '' 67 } 68 CustomDialogView: CustomDialogController = new CustomDialogController({ 69 builder: CustomDialogView({ cancel: this.existView.bind(this) }), 70 autoCancel: true, 71 alignment: DialogAlignment.Bottom, 72 cancel: this.existView, 73 customStyle: true 74 }) 75 76 existView() { 77 Log.info(`${this.TAG} existView E`) 78 if (this.settingManager.getSettingValue(this.itemValue.settingAlias) !== undefined) { 79 this.curCheckName = JSON.parse(JSON.stringify(this.settingManager.getSettingValue(this.itemValue.settingAlias))) 80 Log.info(`${this.TAG} existView curCheckName: ${this.curCheckName} X`) 81 } 82 this.state.closeDialog(false) 83 } 84 85 aboutToAppear(): void { 86 Log.info(`${this.TAG} aboutToAppear settingsList: ${JSON.stringify(this.settingsList)} E`) 87 getStore().connect(localState, localDispatcher)(this.state) 88 if (this.settingManager.getSettingValue(this.itemValue.settingAlias) !== undefined) { 89 this.curCheckName = JSON.parse(JSON.stringify(this.settingManager.getSettingValue(this.itemValue.settingAlias))) 90 Log.info(`${this.TAG} aboutToAppear curCheckName: ${this.curCheckName} X`) 91 } 92 } 93 94 public onCloseDialog() { 95 Log.info(`${this.TAG} onCloseDialog E`) 96 if (this.customDialogDetails.setAlias !== undefined) { 97 this.state.closeDialog(false) 98 this.CustomDialogView.close() 99 } 100 Log.info(`${this.TAG} onCloseDialog X`) 101 } 102 103 public formatCurCheckName(name) { 104 if (name.id === Timer.DEFAULT_VALUE.id) { 105 name = Timer.RESOURCE_OFF_ALREADY 106 } 107 return name 108 } 109 110 build() { 111 Row() { 112 Flex({ 113 direction: FlexDirection.Row, 114 alignItems: ItemAlign.Center, 115 justifyContent: FlexAlign.SpaceBetween 116 }) { 117 Row() { 118 Image(this.itemValue.imagePath) 119 .width(24) 120 .height(24) 121 .fillColor("#FFFFFF") 122 Text(this.itemValue.settingName) 123 .margin({ left: $r("sys.float.ohos_id_elements_margin_horizontal_l") }) 124 .fontColor("#FFFFFF") 125 .fontSize($r("sys.float.ohos_id_text_size_sub_title2")) 126 .fontWeight(FontWeight.Regular) 127 } 128 129 Row() { 130 Text(this.formatCurCheckName(this.curCheckName)) 131 .fontColor($r('app.color.font_color_FFFFFF')) 132 .fontSize($r("sys.float.ohos_id_text_size_body2")) 133 .opacity(0.6) 134 .fontWeight(FontWeight.Regular) 135 Image($r("app.media.ic_public_arrow_right")) 136 .width(12) 137 .height(24) 138 .fillColor('#33FFFFFF') 139 .opacity(0.4) 140 .opacity($r('app.float.opacity_4')) 141 .margin({ left: 4 }) 142 } 143 } 144 .height("100%") 145 } 146 .padding({ left: 12, right: 12 }) 147 .width(this.WH_100_100) 148 .height(56) 149 .onClick(() => { 150 if (this.settingDialogFlag) { 151 this.settingDialogFlag = false 152 setTimeout(() => { 153 this.settingDialogFlag = true 154 }, 200) 155 this.openDetailsDialog(this.itemValue) 156 } 157 }) 158 } 159 160 async openDetailsDialog(itemValue): Promise<void> { 161 Log.info(`${this.TAG} openDetailsDialog start`) 162 Log.info(`${this.TAG} openDetailsDialog dataInfo ${JSON.stringify(itemValue)}`) 163 // 需要根据相机能力更新这个childrenList,目前是写死状态 164 this.customDialogDetails.childrenList = itemValue.radio 165 this.customDialogDetails.settingTitle = itemValue.settingName 166 this.customDialogDetails.setAlias = itemValue.settingAlias 167 Log.info(`${this.TAG} childrenList: ${JSON.stringify(itemValue.radio)}`) 168 this.state.closeDialog(true) 169 this.CustomDialogView.open() 170 Log.info(`${this.TAG} openDetailsDialog end`) 171 } 172} 173