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 { CameraPlatformCapability } from '../../camera/CameraPlatformCapability' 17import { Action, ActionData } from '../actions/Action' 18 19export type CameraInitState = { 20 platformCapability: CameraPlatformCapability | undefined, 21 thumbnail: Resource, 22 resourceUri: string, 23 videoUri: string 24} 25 26const initState: CameraInitState = { 27 platformCapability: undefined, 28 thumbnail: $r('app.media.ic_camera_thumbnail_default_white'), 29 resourceUri: '', 30 videoUri: '' 31} 32 33export default function CameraInitReducer(state = initState, action: ActionData): CameraInitState { 34 switch (action.type) { 35 case Action.ACTION_INIT_DONE: 36 return { ...state, platformCapability: action.data.platformCapability} 37 case Action.ACTION_UPDATE_THUMBNAIL: 38 return { ...state, thumbnail: action.data.thumbnail, resourceUri: action.data.resourceUri } 39 case Action.ACTION_LOAD_THUMBNAIL: 40 return { ...state, thumbnail: action.data.thumbnail } 41 case Action.ACTION_UPDATE_VIDEO_URI: 42 return { ...state, videoUri: action.data.videoUri } 43 default: 44 return state; 45 } 46}