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 type { ActionData } from '../actions/Action'; 17import { Action } from '../actions/Action'; 18 19export type RecordState = { 20 useThumbnail: boolean, 21 isResumeVideo: boolean, 22 isContinueVideo: boolean, 23 isStartVideo: boolean, 24 isRecordingPaused: boolean, 25 videoState: string, 26 isBigVideoTimerVisible: boolean, 27 isSmallVideoTimerVisible: boolean, 28 isRecordingSpotVisible: boolean, 29 recordingTime: number, 30 recordingTimeDisplay: string 31} 32 33const initState: RecordState = { 34 useThumbnail: false, 35 isResumeVideo: false, 36 isContinueVideo: false, 37 isStartVideo: false, 38 isRecordingPaused: false, 39 videoState: 'beforeTakeVideo', 40 isBigVideoTimerVisible: false, 41 isSmallVideoTimerVisible: false, 42 isRecordingSpotVisible: true, 43 recordingTime: 0, 44 recordingTimeDisplay: '00:00' 45} 46 47export function recordReducer(state = initState, action: ActionData): RecordState { 48 switch (action.type) { 49 case Action.ACTION_START_VIDEO_FLAG: 50 return { ...state, isStartVideo: action.data.isStartVideo }; 51 case Action.ACTION_UPDATE_RECORDING_TIME: 52 return { ...state, recordingTime: action.data.recordingTime }; 53 case Action.ACTION_UPDATE_RECORDING_TIME_DISPLAY: 54 return { ...state, recordingTimeDisplay: action.data.recordingTimeDisplay }; 55 case Action.ACTION_UPDATE_VIDEO_STATE: 56 return { ...state, videoState: action.data.videoState }; 57 case Action.ACTION_UPDATE_RECORDING_PAUSED: 58 return { ...state, isRecordingPaused: action.data.isRecordingPaused }; 59 case Action.ACTION_UPDATE_BIG_VIDEO_TIMER_VISIBLE: 60 return { ...state, isBigVideoTimerVisible: action.data.isBigVideoTimerVisible }; 61 case Action.ACTION_UPDATE_SMALL_VIDEO_TIMER_VISIBLE: 62 return { ...state, isSmallVideoTimerVisible: action.data.isSmallVideoTimerVisible }; 63 case Action.ACTION_UPDATE_RECORDING_SPOT_VISIBLE: 64 return { ...state, isRecordingSpotVisible: action.data.isRecordingSpotVisible }; 65 default: 66 return state; 67 } 68}