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 SettingState = {
20  isAssGridViewShow: string,
21  isShowtimeLapse: boolean,
22  isCloseFlag: boolean,
23  isShowSettingView: boolean,
24  opacityValueForTabBar: number
25}
26
27const initState = {
28  isAssGridViewShow: '0',
29  isShowtimeLapse: false,
30  isCloseFlag: false,
31  isShowSettingView: false,
32  opacityValueForTabBar: 0
33}
34
35export function settingReducer(state = initState, action: ActionData): SettingState {
36  switch (action.type) {
37    case Action.ACTION_ASSISTIVE_GRID_VIEW:
38      return {
39        ...state, isAssGridViewShow: action.data.isAssGridViewShow
40      };
41    case Action.ACTION_CHANGE_TIME_LAPSE:
42      return {
43        ...state, isShowtimeLapse: action.data.isShowtimeLapse
44      };
45    case Action.ACTION_CLOSE_DIALOG:
46      return {
47        ...state, isCloseFlag: action.data.isCloseFlag
48      };
49    case Action.ACTION_SHOW_SETTING_VIEW:
50      return {
51        ...state, isShowSettingView: action.data.isShowSettingView
52      };
53    case Action.ACTION_UPDATE_OPACITY_TAB_BAR:
54      return {
55        ...state, opacityValueForTabBar: action.data.opacityValueForTabBar
56      };
57    default:
58      return state;
59  }
60}