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 { ActionData } from '../actions/Action' 17import { ACTION_CHANGE_PREVIEW_SIZE, ACTION_CHANGE_SHUTTER_BUTTON } from '../actions/ModeChange' 18import { UIDATA_TAB_ITEM } from '../actions/UiData' 19 20export type ModeChangeState = { 21 number: number, 22 res: Resource, 23 tabItem: string[] 24} 25 26const initState: ModeChangeState = { 27 number: 154, 28 res: $r('app.media.icon'), 29 tabItem: ['', 'flash', 'zoom', 'focus', 'setup'] 30} 31 32export default function ModeChangeReducer(state = initState, action: ActionData): ModeChangeState { 33 switch (action.type) { 34 case ACTION_CHANGE_PREVIEW_SIZE: 35 return { ...state, number: action.data.size} 36 case ACTION_CHANGE_SHUTTER_BUTTON: 37 return { ...state, res: action.data.res} 38 case UIDATA_TAB_ITEM: 39 return { ...state, tabItem: action.data.tabItem} 40 default: 41 return state; 42 } 43}