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