Revision control
Copy as Markdown
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
import Foundation
import UIKit
/// The view model used to configure a `BottomSheetViewController`
public struct BottomSheetViewModel {
public struct UX {
public static var cornerRadius: CGFloat {
if #available(iOS 26.0, *) {
return 24
} else {
return 8
}
}
public static let animationTransitionDuration: CGFloat = 0.3
public static let shadowOpacity: Float = 0.3
}
let cornerRadius: CGFloat
let backgroundColor: UIColor
let animationTransitionDuration: TimeInterval
let shouldDismissForTapOutside: Bool
let shadowOpacity: Float
let closeButtonA11yLabel: String
let closeButtonA11yIdentifier: String
public init(
cornerRadius: CGFloat = BottomSheetViewModel.UX.cornerRadius,
animationTransitionDuration: TimeInterval = BottomSheetViewModel.UX.animationTransitionDuration,
backgroundColor: UIColor = .clear,
shouldDismissForTapOutside: Bool = true,
shadowOpacity: Float = BottomSheetViewModel.UX.shadowOpacity,
closeButtonA11yLabel: String,
closeButtonA11yIdentifier: String
) {
self.cornerRadius = cornerRadius
self.animationTransitionDuration = animationTransitionDuration
self.backgroundColor = backgroundColor
self.shouldDismissForTapOutside = shouldDismissForTapOutside
self.shadowOpacity = shadowOpacity
self.closeButtonA11yLabel = closeButtonA11yLabel
self.closeButtonA11yIdentifier = closeButtonA11yIdentifier
}
}