|
@@ -63,14 +63,16 @@ open class KSMediaPickerView: UIView {
|
|
|
|
|
|
override public init(frame: CGRect) {
|
|
|
super.init(frame: frame)
|
|
|
+ let view1 = UIView(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: kNavBarTotalHeight))
|
|
|
+ view1.backgroundColor = UIColor.white
|
|
|
backgroundColor = .ks_white
|
|
|
layer.addSublayer(_blackBackgroundLayer)
|
|
|
-
|
|
|
addSubview(collectionView)
|
|
|
+ addSubview(view1)
|
|
|
addSubview(previewView)
|
|
|
addSubview(albumTableView)
|
|
|
- albumNavigationView.nextButton.isEnabled = false
|
|
|
addSubview(albumNavigationView)
|
|
|
+ albumNavigationView.nextButton.isEnabled = false
|
|
|
|
|
|
collectionView.handlePanCallback = {[weak self] (pan) in
|
|
|
self?._collectionView(did: pan)
|
|
@@ -103,8 +105,7 @@ open class KSMediaPickerView: UIView {
|
|
|
var viewH = safeBottomMargin+48.0
|
|
|
var viewX = floatZore
|
|
|
var viewY = windowHeight-viewH
|
|
|
- _toolBarSafeAreaView.frame = CGRect(x: viewX, y: viewY, width: viewW, height: viewH)
|
|
|
-
|
|
|
+
|
|
|
let margin = CGFloat(3.0)
|
|
|
let columnCount = UInt(4)
|
|
|
let itemW = floor((windowWidth-margin*CGFloat(columnCount-1))/CGFloat(columnCount))
|
|
@@ -138,12 +139,11 @@ open class KSMediaPickerView: UIView {
|
|
|
viewH = previewViewFrameMaxY+20.0
|
|
|
_previewGestureCorrespondingArea = CGRect(x: viewX, y: viewY, width: viewW, height: viewH)
|
|
|
|
|
|
- let toolBarSafeAreaViewHeight = _toolBarSafeAreaView.bounds.size.height
|
|
|
|
|
|
viewX = floatZore
|
|
|
viewY = floatZore
|
|
|
viewW = windowWidth
|
|
|
- viewH = windowHeight-toolBarSafeAreaViewHeight
|
|
|
+ viewH = windowHeight-kTabBarTotalHeight
|
|
|
|
|
|
if jumpType == .publishEdit {
|
|
|
let frame = CGRect(x: viewX, y: viewY, width: viewW, height: viewH + kTabBarTotalHeight)
|
|
@@ -191,39 +191,45 @@ open class KSMediaPickerView: UIView {
|
|
|
break
|
|
|
case .changed:
|
|
|
// FIXME: preview视图收起展示逻辑
|
|
|
-// guard let baseY = _baseY else {
|
|
|
-// return
|
|
|
-// }
|
|
|
-// let location = pan.location(in: self)
|
|
|
-// let locationY = location.y
|
|
|
-// _isScrollDown = locationY > _panBeginLocationY
|
|
|
-// _isInGestureCorrespondingArea = _previewGestureCorrespondingArea != nil && _previewGestureCorrespondingArea!.contains(location)
|
|
|
-// if _isInGestureCorrespondingArea {
|
|
|
-// var previewFrame = previewView.frame
|
|
|
-// var y = locationY-previewFrame.size.height
|
|
|
-// if y >= baseY {
|
|
|
-// y = baseY
|
|
|
-// }
|
|
|
-// previewFrame.origin.y = y
|
|
|
-// previewView.frame = previewFrame
|
|
|
-//
|
|
|
-// _previewGestureCorrespondingArea!.size.height = previewFrame.maxY+20.0
|
|
|
-// }
|
|
|
-// _panBeginLocationY = locationY
|
|
|
- break
|
|
|
- case .cancelled, .ended, .failed:
|
|
|
- guard _isInGestureCorrespondingArea, let baseY = _baseY else {
|
|
|
+ guard let baseY = _baseY else {
|
|
|
return
|
|
|
}
|
|
|
+ let location = pan.location(in: self)
|
|
|
+ let locationY = location.y
|
|
|
+ _isScrollDown = locationY > _panBeginLocationY
|
|
|
+ _isInGestureCorrespondingArea = _previewGestureCorrespondingArea != nil && _previewGestureCorrespondingArea!.contains(location)
|
|
|
+ if _isInGestureCorrespondingArea {
|
|
|
+ var previewFrame = previewView.frame
|
|
|
+ var y = locationY-previewFrame.size.height
|
|
|
+ if y >= baseY {
|
|
|
+ y = baseY
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ previewFrame.origin.y = y
|
|
|
+ previewView.frame = previewFrame
|
|
|
+
|
|
|
+ _previewGestureCorrespondingArea!.size.height = previewFrame.maxY+20.0
|
|
|
+ }
|
|
|
+ _panBeginLocationY = locationY
|
|
|
+ break
|
|
|
+ case .cancelled, .ended, .failed:
|
|
|
+ let baseY = _baseY
|
|
|
+// guard _isInGestureCorrespondingArea, let baseY = _baseY else {
|
|
|
+// if albumNavigationView.isHidden {
|
|
|
+// _isRetract = false
|
|
|
+// }
|
|
|
+// return
|
|
|
+// }
|
|
|
var previewFrame = previewView.frame
|
|
|
let maxY = previewFrame.maxY
|
|
|
- let boundary = (previewFrame.size.height+baseY)*(_isScrollDown ? 0.2 : 0.8)
|
|
|
+ let boundary = (previewFrame.size.height+baseY!)*(_isScrollDown ? 0.2 : 0.8)
|
|
|
if maxY < boundary {
|
|
|
_isRetract = true
|
|
|
- previewFrame.origin.y = baseY-previewFrame.size.height
|
|
|
+ previewFrame.origin.y = baseY!-previewFrame.size.height
|
|
|
} else {
|
|
|
_isRetract = false
|
|
|
- previewFrame.origin.y = baseY
|
|
|
+ previewFrame.origin.y = baseY!
|
|
|
}
|
|
|
|
|
|
let height = previewFrame.maxY
|
|
@@ -237,6 +243,7 @@ open class KSMediaPickerView: UIView {
|
|
|
UIView.animate(withDuration: 0.2, animations: {[weak self, weak previewView] in
|
|
|
previewView?.frame = previewFrame
|
|
|
guard let k_topPoint = topPoint else {
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
self?.collectionView.contentOffset = k_topPoint
|
|
@@ -262,6 +269,7 @@ open class KSMediaPickerView: UIView {
|
|
|
previewView.frame = previewFrame
|
|
|
|
|
|
_previewGestureCorrespondingArea!.size.height = previewFrame.maxY+20.0
|
|
|
+ collectionViewScrollToTop()
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -278,7 +286,8 @@ open class KSMediaPickerView: UIView {
|
|
|
} else if _isRetract {
|
|
|
_isRetract = false
|
|
|
previewFrame.origin.y = baseY
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else {
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -311,7 +320,7 @@ open class KSMediaPickerView: UIView {
|
|
|
let point = CGPoint(x: 0.0, y: -collectionView.contentInset.top)
|
|
|
if !point.equalTo(collectionView.contentOffset) {
|
|
|
collectionView.setContentOffset(point, animated: false)
|
|
|
- showPreview(false)
|
|
|
+ showPreview(true)
|
|
|
}
|
|
|
}
|
|
|
|