更新pod

This commit is contained in:
DDIsFriend
2023-12-26 17:57:08 +08:00
parent 5746a6ed72
commit 67ffe41748
9 changed files with 7753 additions and 7775 deletions

View File

@@ -11,12 +11,18 @@ open class DDUIPanGestureRecognizer : UIPanGestureRecognizer {
case bottom,top
}
public enum ExpandLevel {
case min,`default`,max
}
public struct PanGesValue {
public var from : PanGestureFromType = .bottom
public var minDisplayHeight : CGFloat = 0
public var maxDisplayHeight : CGFloat = 0
public var criticalValue : CGFloat?
public var isExpanded : Bool = false
public var from : PanGestureFromType = .bottom ///
public var minDisplayHeight : CGFloat = 0 ///
public var defaultDisplayHeight : CGFloat = 0 ///
public var maxDisplayHeight : CGFloat = 0 ///
public var criticalValue : CGFloat? ///
public var expandLevel : ExpandLevel = .min ///
internal var translationY : CGFloat = 0
internal var currentY : CGFloat = 0
}
@@ -37,32 +43,7 @@ open class DDUIPanGestureRecognizer : UIPanGestureRecognizer {
}
@objc fileprivate func panGesAction(ges: DDUIPanGestureRecognizer) {
guard let superView = ges.view?.superview else {
assert(false,"父类都没有,拖什么拖")
return
}
let superViewFrame = superView.frame
let viewFrame = ges.view?.frame ?? .zero
let superViewH = superViewFrame.size.height
let viewH = viewFrame.size.height
switch ges.panGesValue.from {
case .bottom:
/// viewyviewviewysuperViewyminYdeltaH
var minY = superViewH - ges.panGesValue.maxDisplayHeight
let deltaH = superViewH - viewH
if deltaH > minY {
minY = deltaH
}
/// viewy
var maxY = superViewH - ges.panGesValue.minDisplayHeight
if deltaH > maxY {
maxY = deltaH
}
var currentY : CGFloat = 0.0
getBaseValue(duration: 0.1) { viewFrame, minY, defaultY, maxY, currentY in
switch ges.state {
case .began:
currentY = viewFrame.origin.y
@@ -74,17 +55,6 @@ open class DDUIPanGestureRecognizer : UIPanGestureRecognizer {
ges.panGesValue.translationY = translationPoint.y
currentY = (viewFrame.origin.y) + deltaY
/// y
if currentY < minY {
return
}
/// y
if currentY > maxY {
return
}
break
case .ended:
///
@@ -93,12 +63,8 @@ open class DDUIPanGestureRecognizer : UIPanGestureRecognizer {
if ges.panGesValue.currentY < criticalY {
currentY = minY
///
ges.panGesValue.isExpanded = true
}else{
currentY = maxY
///
ges.panGesValue.isExpanded = false
}
ges.panGesValue.translationY = 0
break
@@ -106,17 +72,86 @@ open class DDUIPanGestureRecognizer : UIPanGestureRecognizer {
currentY = viewFrame.origin.y
break
}
ges.panGesValue.currentY = currentY
}
}
func getBaseValue(duration: TimeInterval,baseValueHandler: (_ viewFrame: CGRect, _ minY: CGFloat, _ defaultY: CGFloat, _ maxY: CGFloat,_ currentY: inout CGFloat) -> Void) {
guard let superView = view?.superview else {
assert(false,"父类都没有,拖什么拖")
return
}
UIView.animate(withDuration: 0.1, animations: {
ges.view?.frame = CGRectMake(viewFrame.origin.x, currentY, viewFrame.size.width, viewFrame.size.height)
let superViewFrame = superView.frame
let viewFrame = view?.frame ?? .zero
let superViewH = superViewFrame.size.height
let viewH = viewFrame.size.height
switch panGesValue.from {
case .bottom:
/// viewyviewviewysuperViewyminYdeltaH
var minY = superViewH - panGesValue.maxDisplayHeight
let deltaH = superViewH - viewH
if deltaH > minY {
minY = deltaH
}
/// viewy
var maxY = superViewH - panGesValue.minDisplayHeight
if deltaH > maxY {
maxY = deltaH
}
/// y
var defaultY = superViewH - panGesValue.defaultDisplayHeight
if deltaH > defaultY {
defaultY = deltaH
}
var currentY : CGFloat = 0.0
///
baseValueHandler(viewFrame,minY,defaultY,maxY,&currentY)
/// y
if currentY < minY {
return
}
/// y
if currentY > maxY {
return
}
panGesValue.currentY = currentY
if panGesValue.currentY == minY {
panGesValue.expandLevel = .max
}else if panGesValue.currentY == maxY {
panGesValue.expandLevel = .min
}else if panGesValue.currentY == defaultY {
panGesValue.expandLevel = .default
}
UIView.animate(withDuration: duration, animations: {[weak self] in
self?.view?.frame = CGRectMake(viewFrame.origin.x, currentY, viewFrame.size.width, viewFrame.size.height)
})
break
default:
default:
break
}
}
}
}
public func expand(_ expand: ExpandLevel) {
getBaseValue(duration: 0.25) { viewFrame, minY, defaultY, maxY, currentY in
if expand == .max {
currentY = minY
}else if expand == .min {
currentY = maxY
}else if expand == .default {
currentY = defaultY
}
}
}
}
extension UIView {