44 lines
1.6 KiB
Swift
44 lines
1.6 KiB
Swift
//
|
|
// ActionTopScrollModel.swift
|
|
// MVMCoreUI
|
|
//
|
|
// Created by Nadigadda, Sumanth on 31/03/22.
|
|
// Copyright © 2022 Verizon Wireless. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import MVMCore
|
|
import MVMCoreUI
|
|
|
|
public protocol MVMCoreActionScrollProtocol: MVMCoreActionDelegateProtocol {
|
|
|
|
@MainActor
|
|
func handleScrollTopAction(action: ActionModelProtocol, additionalData: [AnyHashable: Any]?)
|
|
}
|
|
|
|
public struct ActionScrollToTopModel: ActionModelProtocol {
|
|
//--------------------------------------------------
|
|
// MARK: - Properties
|
|
//--------------------------------------------------
|
|
|
|
public static var identifier: String = "scrollToTop"
|
|
public var actionType: String = ActionScrollToTopModel.identifier
|
|
public var extraParameters: JSONValueDictionary?
|
|
public var analyticsData: JSONValueDictionary?
|
|
}
|
|
|
|
public struct ScrollToTopActionHandler: MVMCoreActionHandlerProtocol {
|
|
public init(){}
|
|
public func execute(with model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws {
|
|
guard let model = model as? ActionScrollToTopModel else { return }
|
|
await (delegateObject?.actionDelegate as? MVMCoreActionScrollProtocol)?.handleScrollTopAction(action: model, additionalData: additionalData)
|
|
}
|
|
}
|
|
|
|
extension ScrollingViewController: MVMCoreActionScrollProtocol {
|
|
@MainActor
|
|
public func handleScrollTopAction(action: ActionModelProtocol, additionalData: [AnyHashable: Any]?) {
|
|
scrollView.setContentOffset(CGPoint(x: 0, y: -scrollView.adjustedContentInset.top), animated: true)
|
|
}
|
|
}
|