1 2/** 3 * Copyright (c) 2022 Huawei Device Co., Ltd. 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17import AspectRatio from '../../../setting/settingitem/AspectRatio' 18import AssistiveGrid from '../../../setting/settingitem/AssistiveGrid' 19import SaveGeoLocation from '../../../setting/settingitem/SaveGeoLocation' 20import SelfMirror from '../../../setting/settingitem/SelfMirror' 21import Resolution from '../../../setting/settingitem/Resolution' 22import Timer from '../../../setting/settingitem/Timer' 23import VideoCodec from '../../../setting/settingitem/VideoCodec' 24import { Voice } from '../../../setting/settingitem/Voice' 25 26type RadioItem = { 27 itemValue?: any 28} 29 30type SettingItem = { 31 imagePath?: Resource, 32 settingName?: Resource, 33 description?: any, 34 checkedName?: any, 35 settingAlias?: any, 36 selectType?: any, 37 radio?: RadioItem[], 38 toggle?: boolean, 39} 40 41type SettingGroupItem = { 42 settingTitle?: Resource, 43 settingChildren?: SettingItem[], 44} 45 46/** 47 * app setting homepage service class 48 */ 49export class SettingListModel { 50 private settingsList: SettingGroupItem[] = [] 51 constructor() { 52 this.buildSettingsList() 53 } 54 55 private buildSettingsList() { 56 this.settingsList[0] = this.buildPhotoModeSettings() 57 this.settingsList[1] = this.buildVideoModeSettings() 58 this.settingsList[2] = this.buildGeneralSettings() 59 } 60 61 private buildPhotoModeSettings() { 62 let result: SettingGroupItem = {} 63 result.settingTitle = $r('app.string.photo_mode') 64 result.settingChildren = [] 65 result.settingChildren[0] = this.buildPhotoResolutionSettingItem() 66 return result; 67 } 68 69 private buildPhotoResolutionSettingItem() { 70 let result: SettingItem = {} 71 result.imagePath = $r("app.media.ic_camera_setting_resolution_photo") 72 result.settingName = $r('app.string.aspect_ratio') 73 result.settingAlias = AspectRatio.ALIAS 74 result.selectType = "radio" 75 result.radio = this.buildPhotoResolutionRadio() 76 result.checkedName = result.radio[0].itemValue 77 return result; 78 } 79 80 private buildPhotoResolutionRadio() { 81 let result: RadioItem[] = [] 82 result[0] = { "itemValue": AspectRatio.RESOURCE_RATIO_4_3} 83 result[1] = { "itemValue": AspectRatio.RESOURCE_RATIO_1_1} 84 result[2] = { "itemValue": AspectRatio.RESOURCE_RATIO_16_9} 85 return result; 86 } 87 88 private buildVideoModeSettings() { 89 let result: SettingGroupItem = {} 90 result.settingTitle = $r('app.string.video_mode') 91 result.settingChildren = [] 92 result.settingChildren[0] = this.buildVideoResolutionSettingItem() 93// result.settingChildren[1] = this.buildVideoCodecSettingItem() 94 return result; 95 } 96 97 private buildVideoResolutionSettingItem() { 98 let result :SettingItem = {} 99 result.imagePath = $r("app.media.ic_camera_setting_resolution_video") 100 result.settingName = $r('app.string.video_resolution') 101 result.settingAlias = Resolution.ALIAS 102 result.selectType = "radio" 103 result.radio = this.buildVideoResolutionRadio() 104 result.checkedName = result.radio[0].itemValue 105 return result; 106 } 107 108 private buildVideoResolutionRadio() { 109 let result: RadioItem[] = [] 110 result[0] = { "itemValue": Resolution.RESOURCE_16_9_720P} 111 result[1] = { "itemValue": Resolution.RESOURCE_16_9_1080P} 112 return result; 113 } 114 115 private buildVideoCodecSettingItem() { 116 let result: SettingItem = {} 117 result.imagePath = $r("app.media.ic_camera_setting_efficient_video_format") 118 result.settingName = $r('app.string.video_codec') 119 result.description = $r("app.string.video_codec_desp") 120 result.settingAlias = VideoCodec.ALIAS 121 result.selectType = "toggle" 122 result.checkedName = false 123 result.toggle = true 124 return result; 125 } 126 127 private buildGeneralSettings() { 128 let result: SettingGroupItem = {} 129 result.settingTitle = $r('app.string.general') 130 result.settingChildren = [] 131 result.settingChildren[0] = this.buildAssistiveGridSettingItem() 132 result.settingChildren[1] = this.buildTimerSettingItem() 133 result.settingChildren[2] = this.buildSaveGeoLocationSettingItem() 134 result.settingChildren[3] = this.buildSoundMuteSettingItem() 135 result.settingChildren[4] = this.buildSelfMirrorSettingItem() 136 return result; 137 } 138 139 private buildAssistiveGridSettingItem() { 140 let result: SettingItem = {} 141 result.imagePath = $r("app.media.ic_camera_setting_assistive_grid") 142 result.settingName = $r('app.string.assistive_grid') 143 result.settingAlias = AssistiveGrid.ALIAS 144 result.selectType = "toggle" 145 result.checkedName = false 146 result.toggle = true 147 return result; 148 } 149 150 private buildTimerSettingItem() { 151 let result :SettingItem = {} 152 result.imagePath = $r("app.media.ic_camera_rersolution") 153 result.settingName = $r('app.string.timer') 154 result.settingAlias = Timer.ALIAS 155 result.selectType = "radio" 156 result.radio = this.buildTimerRadio() 157 result.checkedName = result.radio[0].itemValue 158 return result; 159 } 160 161 private buildTimerRadio() { 162 let result: RadioItem[] = [] 163 result[0] = { "itemValue": Timer.RESOURCE_OFF } 164 result[1] = { "itemValue": Timer.RESOURCE_TWO_SECONDS } 165 result[2] = { "itemValue": Timer.RESOURCE_FIVE_SECONDS } 166 result[3] = { "itemValue": Timer.RESOURCE_TEN_SECONDS } 167 return result; 168 } 169 170 private buildSaveGeoLocationSettingItem() { 171 let result: SettingItem = {} 172 result.imagePath = $r("app.media.ic_camera_setting_location") 173 result.settingName = $r('app.string.save_geo_location') 174 result.description = $r("app.string.geo_location_desp") 175 result.settingAlias = SaveGeoLocation.ALIAS 176 result.selectType = "toggle" 177 result.checkedName = false 178 result.toggle = true 179 return result; 180 } 181 182 private buildSoundMuteSettingItem() { 183 let result: SettingItem = {} 184 result.imagePath = $r("app.media.ic_camera_sound_mute") 185 result.settingName = $r('app.string.sound_mute') 186 result.settingAlias = Voice.ALIAS 187 result.selectType = "toggle" 188 result.checkedName = false 189 result.toggle = true 190 return result; 191 } 192 193 private buildSelfMirrorSettingItem() { 194 let result: SettingItem = {} 195 result.imagePath = $r("app.media.ic_camera_mirrow_reflection") 196 result.settingName = $r('app.string.self_mirror') 197 result.description = $r("app.string.self_mirror_desp") 198 result.settingAlias = SelfMirror.ALIAS 199 result.selectType = "toggle" 200 result.checkedName = false 201 result.toggle = false 202 return result; 203 } 204 205 getSettingList() { 206 return this.settingsList; 207 } 208} 209 210let settingListModel = new SettingListModel(); 211 212export default settingListModel as SettingListModel;