Skip to content

Commit 4263d85

Browse files
committed
Merge branch 'release/1.4.0'
2 parents 0dea6e1 + 22ec633 commit 4263d85

File tree

6 files changed

+38
-37
lines changed

6 files changed

+38
-37
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.1
1+
// swift-tools-version:5.3
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription

ScrollStackController.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "ScrollStackController"
3-
s.version = "1.3.3"
3+
s.version = "1.4.0"
44
s.summary = "Create complex scrollable layout using UIViewController and simplify your code"
55
s.homepage = "https://github.com/malcommac/ScrollStackController"
66
s.license = { :type => "MIT", :file => "LICENSE" }
@@ -10,5 +10,5 @@ Pod::Spec.new do |s|
1010
s.source = { :git => "https://github.com/malcommac/ScrollStackController.git", :tag => s.version.to_s }
1111
s.frameworks = "Foundation", "UIKit"
1212
s.source_files = 'Sources/**/*.swift'
13-
s.swift_versions = ['5.0', '5.1']
13+
s.swift_versions = ['5.0', '5.1', '5.3']
1414
end

ScrollStackControllerDemo/ViewController.swift

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ class ViewController: UIViewController, ScrollStackControllerDelegate {
5050
pricingVC = PricingVC.create(delegate: self)
5151
notesVC = NotesVC.create(delegate: self)
5252

53+
/*stackView.isSeparatorHidden = false
54+
stackView.separatorColor = .red
55+
stackView.separatorThickness = 3
56+
stackView.autoHideLastRowSeparator = true
57+
*/
58+
5359
/*
5460
Plain UIView example
5561
let plainView = UIView(frame: .zero)
@@ -58,13 +64,16 @@ class ViewController: UIViewController, ScrollStackControllerDelegate {
5864
stackView.addRow(view: plainView)
5965
*/
6066

61-
stackView.addRows(controllers: [welcomeVC, notesVC, tagsVC, galleryVC, pricingVC], animated: false)
67+
stackView.addRows(controllers: [welcomeVC, notesVC/*, tagsVC, galleryVC, pricingVC*/], animated: false)
6268
}
6369

6470
@IBAction public func addNewRow() {
65-
let galleryVC = GalleryVC.create()
66-
stackView.scrollToTop()
67-
stackView.addRow(controller: galleryVC, at: .top, animated: true)
71+
stackView.addRows(controllers: [tagsVC, galleryVC, pricingVC], animated: false)
72+
73+
74+
// let galleryVC = GalleryVC.create()
75+
// stackView.scrollToTop()
76+
// stackView.addRow(controller: galleryVC, at: .top, animated: true)
6877
}
6978

7079
@IBAction public func hideOrShowRandomRow() {

Sources/ScrollStackController/ScrollStack.swift

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ open class ScrollStack: UIScrollView, UIScrollViewDelegate {
180180
/// Hide automatically the last separator.
181181
open var autoHideLastRowSeparator = false {
182182
didSet {
183-
updateRowSeparatorVisibility(lastRow)
183+
updateRowsSeparatorVisibility()
184184
}
185185
}
186186

@@ -803,9 +803,7 @@ open class ScrollStack: UIScrollView, UIScrollViewDelegate {
803803
guard let row = row else {
804804
return nil
805805
}
806-
807-
let previousRow = rowBeforeRow(row)
808-
806+
809807
// Animate visibility
810808
let removedController = row.controller
811809
animateCellVisibility(row, animated: animated, hide: true, completion: { [weak self] in
@@ -817,7 +815,7 @@ open class ScrollStack: UIScrollView, UIScrollViewDelegate {
817815

818816
// When removing a cell the cell above is the only cell whose separator visibility
819817
// will be affected, so we need to update its visibility.
820-
self.updateRowSeparatorVisibility(previousRow)
818+
self.updateRowsSeparatorVisibility()
821819

822820
// Remove from the status
823821
self.prevVisibilityState.removeValue(forKey: row)
@@ -883,31 +881,17 @@ open class ScrollStack: UIScrollView, UIScrollViewDelegate {
883881
}
884882

885883
private func postInsertRow(_ row: ScrollStackRow, animated: Bool, completion: (() -> Void)? = nil) {
886-
// Setup separator visibility for the new cell
887-
updateRowSeparatorVisibility(row)
888-
889-
// A cell can affect the visibility of the cell before it, e.g. if
890-
// `automaticallyHidesLastSeparator` is true and a new cell is added as the last cell, so update
891-
// the previous cell's separator visibility as well.
892-
updateRowSeparatorVisibility(rowBeforeRow(row))
893-
894-
// Animate visibility
895-
animateCellVisibility(row, animated: animated, hide: false, completion: completion)
884+
updateRowsSeparatorVisibility() // update visibility of the separators
885+
animateCellVisibility(row, animated: animated, hide: false, completion: completion) // Animate visibility of the cell
896886
}
897887

898888
/// Update the separator visibility.
899889
///
900890
/// - Parameter row: row target.
901-
private func updateRowSeparatorVisibility(_ row: ScrollStackRow?) {
902-
guard let row = row, row === stackView.arrangedSubviews.last else {
903-
return
904-
}
905-
906-
row.isSeparatorHidden = hideSeparators
907-
908-
let isLast = (row === rows.last)
909-
if isLast && autoHideLastRowSeparator {
910-
row.isSeparatorHidden = true
891+
private func updateRowsSeparatorVisibility() {
892+
let rows = stackView.arrangedSubviews as? [ScrollStackRow] ?? []
893+
for (idx, row) in rows.enumerated() {
894+
row.separatorView.isHidden = (idx == rows.last?.index ? true : row.isSeparatorHidden)
911895
}
912896
}
913897

Sources/ScrollStackController/ScrollStackRow.swift

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,15 @@ open class ScrollStackRow: UIView, UIGestureRecognizerDelegate {
127127
}
128128

129129
open var isSeparatorHidden: Bool {
130-
get {
131-
return separatorView.isHidden
132-
}
133-
set {
134-
separatorView.isHidden = newValue
130+
didSet {
131+
separatorView.isHidden = isSeparatorHidden
135132
}
133+
// get {
134+
// return separatorView.isHidden
135+
// }
136+
// set {
137+
// separatorView.isHidden = newValue
138+
// }
136139
}
137140

138141
// MARK: Private Properties
@@ -179,6 +182,7 @@ open class ScrollStackRow: UIView, UIGestureRecognizerDelegate {
179182
self.controller = nil
180183
self.contentView = view
181184
self.rowPadding = stackView.rowPadding
185+
self.isSeparatorHidden = stackView.isSeparatorHidden
182186

183187
super.init(frame: .zero)
184188

@@ -190,6 +194,8 @@ open class ScrollStackRow: UIView, UIGestureRecognizerDelegate {
190194
self.controller = controller
191195
self.contentView = controller.view
192196
self.rowPadding = stackView.rowPadding
197+
self.isSeparatorHidden = stackView.isSeparatorHidden
198+
193199
super.init(frame: .zero)
194200

195201
setupPostInit()
@@ -237,6 +243,8 @@ open class ScrollStackRow: UIView, UIGestureRecognizerDelegate {
237243
didUpdateSeparatorAxis()
238244

239245
applyParentStackAttributes()
246+
247+
separatorView.isHidden = isSeparatorHidden
240248
}
241249

242250
private func applyParentStackAttributes() {

0 commit comments

Comments
 (0)