• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 PreviewState = {
19  surfaceId: number,
20  xComponentWidth: number,
21  xComponentHeight: number,
22  isShowPreview: boolean,
23  isShowFlashBlack: boolean,
24}
25
26const initState: PreviewState = {
27  surfaceId: 0,
28  xComponentWidth: 0,
29  xComponentHeight: 0,
30  isShowPreview: false,
31  isShowFlashBlack: false,
32}
33
34export default function PreviewReducer(state = initState, action: ActionData): PreviewState {
35  switch (action.type) {
36  case Action.ACTION_UPDATE_SURFACE_ID:
37    return { ...state, surfaceId: action.data.surfaceId }
38  case Action.ACTION_PREPARE_SURFACE:
39    return { ...state, surfaceId: action.data.surfaceId }
40  case Action.ACTION_CHANGE_X_COMPONENT_SIZE:
41    return { ...state, xComponentWidth: action.data.xComponentWidth, xComponentHeight: action.data.xComponentHeight}
42  case Action.ACTION_UPDATE_SHOW_PREVIEW_FLAG:
43    return { ...state, isShowPreview: action.data.isShowPreview }
44  case Action.ACTION_UPDATE_SHOW_FLASH_BLACK_FLAG:
45    return { ...state, isShowFlashBlack: action.data.isShowFlashBlack }
46  default:
47    return state;
48  }
49}