2019-09-23 21:16:52 +00:00
|
|
|
//
|
|
|
|
// Detent.swift
|
|
|
|
// SheetImagePicker
|
|
|
|
//
|
|
|
|
// Created by Shadowfacts on 9/23/19.
|
|
|
|
// Copyright © 2019 Shadowfacts. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
2019-09-24 15:43:46 +00:00
|
|
|
public enum Detent: Equatable {
|
2019-09-23 21:16:52 +00:00
|
|
|
case top
|
|
|
|
case middle
|
|
|
|
case bottom
|
|
|
|
case other(CGFloat)
|
|
|
|
}
|
|
|
|
|
|
|
|
extension Detent {
|
|
|
|
func offset(in view: UIView) -> CGFloat {
|
|
|
|
switch self {
|
|
|
|
case .top:
|
|
|
|
return max(view.safeAreaInsets.top, 50)
|
|
|
|
case .middle:
|
|
|
|
return view.bounds.midY
|
|
|
|
case .bottom:
|
|
|
|
return view.bounds.height - view.safeAreaInsets.bottom - 100//max(view.safeAreaInsets.bottom, 100)
|
|
|
|
case let .other(value):
|
|
|
|
return value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|