* Copyright (c) Huawei Device Co., Ltd. 2024-2025. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type { ActionData } from '../../redux/actions/Action';
import lazy { ZoomActionType } from '../../redux/actions/ZoomActionType';
export class ZoomAction {
public static initZoomRatio(min: number, max: number): ActionData {
return {
type: ZoomActionType.ACTION_INIT_ZOOM_RATIO,
data: { minZoomRatio: min, maxZoomRatio: max }
};
}
public static updateStateZoomRatio(zoomRatio: number): ActionData {
if (zoomRatio) {
return {
isEvent: true,
type: ZoomActionType.ACTION_CHANGE_ZOOM_RATIO,
data: { zoomRatio: zoomRatio }
};
}
return {
isEvent: true,
type: ZoomActionType.ACTION_CHANGE_ZOOM_RATIO,
data: { zoomRatio: 1 }
};
}
public static updateShowZoomViewFlag(isShowZoomView: boolean): ActionData {
return {
type: ZoomActionType.ACTION_UPDATE_SHOW_ZOOM_VIEW_FLAG,
data: { isShowZoomView: isShowZoomView }
};
}
public static updateShowZoomTextFlag(isShowZoomText: boolean): ActionData {
return {
type: ZoomActionType.ACTION_UPDATE_SHOW_ZOOM_TEXT_FLAG,
data: { isShowZoomText: isShowZoomText }
};
}
public static updateZoomBigTextVisible(isShowZoomBigText: boolean): ActionData {
return {
type: ZoomActionType.ACTION_UPDATE_ZOOM_BIG_TEXT_VISIBLE,
data: { isShowZoomBigText: isShowZoomBigText }
};
}
public static updatePhotoZoomDetailsFlag(isPhotoZoomDetails: boolean): ActionData {
return {
type: ZoomActionType.ACTION_UPDATE_PHOTO_ZOOM_DETAILS_FLAG,
data: { isPhotoZoomDetails: isPhotoZoomDetails }
};
}
public static updateBaseZoom(baseZoom: number): ActionData {
return {
type: ZoomActionType.ACTION_UPDATE_BASE_ZOOM,
data: { baseZoom: baseZoom }
};
}
public static updateShowPinch(isShowPinch: boolean): ActionData {
return {
isEvent: true,
type: ZoomActionType.ACTION_UPDATE_SHOW_PINCH,
data: { isShowPinch: isShowPinch }
};
}
public static zoomSlide2QuickZoom(zoomValue: number): ActionData {
return {
isEvent: true,
type: ZoomActionType.ACTION_ZOOM_SLIDE_QUICK_ZOOM,
data: { zoomValue: zoomValue }
};
}
public static changeZoomState(zoomState: string): ActionData {
return {
isEvent: true,
type: ZoomActionType.ACTION_CHANGE_ZOOM_STATE,
data: { zoomState: zoomState }
};
}
public static resetZoomRatio(): ActionData {
return {
isEvent: true,
type: ZoomActionType.ACTION_RESET_ZOOM_RATIO,
data: { zoomRatio: 1 }
};
}
public static switchZoomRatio(toNext: boolean): ActionData {
return {
isEvent: true,
type: ZoomActionType.ACTION_SWITCH_ZOOM_RATIO,
data: { toNext: toNext }
};
}
public static smartControlZoomRatio(toNext: boolean): ActionData {
return {
isEvent: true,
type: ZoomActionType.ACTION_SMART_CONTROL_ZOOM_RATIO,
data: { toNext: toNext }
};
}
public static onClickZoomSmoothAnimDuration(duration: number): ActionData {
return {
isEvent: true,
type: ZoomActionType.ACTION_ON_CLICK_ZOOM_SMOOTH_ANIM_DURATION,
data: { duration: duration }
};
}
public static updateZoomBuilderOffsetY(offsetY: number): ActionData {
return {
isEvent: true,
type: ZoomActionType.UPDATE_ZOOM_BUILDER_OFFSETY,
data: { offsetY: offsetY }
};
}
public static onLemDoubleClick(index: number): ActionData {
return {
isEvent: true,
type: ZoomActionType.ACTION_LEM_DOUBLE_CLICK,
data: { index: index }
};
}
public static changedZoomByGesture(): ActionData {
return {
type: ZoomActionType.ACTION_CHANGED_ZOOM_BY_GESTURE,
data: {}
};
}
public static switchZoomToWideAngle(zoomRatio?: number): ActionData {
return {
isEvent: true,
type: ZoomActionType.ACTION_CHANGE_ZOOM_TO_WIDE_ANGLE,
data: { zoomRatio: zoomRatio }
};
}
public static switchZoomToDefault(): ActionData {
return {
isEvent: true,
type: ZoomActionType.ACTION_CHANGE_ZOOM_TO_DEFAULT,
data: {}
};
}
public static showColorfulZoomRing(isShow: boolean): ActionData {
return {
isEvent: true,
type: ZoomActionType.SHOW_COLORFUL_ZOOM_RING,
data: { isShow: isShow }
};
}
public static handleAutoCloseFlash(isAutoCloseFlash: boolean): ActionData {
return {
isEvent: true,
type: ZoomActionType.ACTION_AUTO_CLOSE_FLASH,
data: { isAutoCloseFlash: isAutoCloseFlash }
};
}
}