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