Skip to content

Commit be0e624

Browse files
Documentation and formatting updates.
1 parent 171fb1a commit be0e624

3 files changed

Lines changed: 9 additions & 25 deletions

File tree

Demo/Sources/Demos/Demo Screens/AutoScrollingViewController3.swift

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import BlueprintUI
1414
import BlueprintUICommonControls
1515

1616

17-
final class AutoScrollingViewController3 : UIViewController
18-
{
17+
final class AutoScrollingViewController3 : UIViewController {
18+
1919
let list = ListView()
2020

2121
lazy var insertButton: UIBarButtonItem = {
@@ -48,21 +48,16 @@ final class AutoScrollingViewController3 : UIViewController
4848

4949
override func viewDidLoad() {
5050
super.viewDidLoad()
51-
5251
updateItems()
5352
}
5453

5554
private func updateItems() {
56-
57-
self.list.configure { list in
55+
list.configure { list in
5856
list.appearance = .demoAppearance
5957
list.layout = .demoLayout
60-
6158
list.behavior.verticalLayoutGravity = .bottom
62-
6359
list.animation = .fast
64-
65-
list += Section("items", items: self.items)
60+
list += Section("items", items: items)
6661

6762
list.autoScrollAction = .scrollTo(
6863
.item(seekToIdentifier),

ListableUI/Sources/ListView/ListView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,16 +1286,16 @@ public final class ListView : UIView
12861286
if behavior.verticalLayoutGravity == .bottom {
12871287
/// Perform a layout to adjust the `contentSize` of the collection view before
12881288
/// scrolling. This avoids an issue where:
1289-
/// - the list is first appearing with a `bottom` `VerticalLayoutGravity` and a
1290-
/// `scrollToItem(onInsertOf:)` `AutoScrollAction`.
1289+
/// - the list is first appearing with `VerticalLayoutGravity.bottom` and
1290+
/// `AutoScrollAction.scrollToItem(onInsertOf:)` behaviors
12911291
/// - the initial set of items in the list trigger the `scrollToItem(onInsertOf:)`
12921292
/// - the resulting scroll position isn't at the bottom of the list
12931293
///
12941294
/// Without calling `layoutIfNeeded`, the above scenario will reset the scroll position
12951295
/// to the bottom, discarding this scroll update. This is because the system will
12961296
/// asynchronously update the underlying `contentSize` as part of the initial layout,
12971297
/// moments after this method is executed. The list's `contentSize` is overridden to
1298-
/// keep the offset anchored to the bottom when using `bottom` `VerticalLayoutGravity`.
1298+
/// keep the offset anchored to the bottom when using `VerticalLayoutGravity.bottom`.
12991299
collectionView.layoutIfNeeded()
13001300
}
13011301

ListableUI/Tests/ListView/ListViewTests.swift

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -616,9 +616,7 @@ class ListViewTests: XCTestCase
616616
var didPerform : [ListScrollPositionInfo] = []
617617

618618
var content = ListProperties.default { list in
619-
620619
list.animatesChanges = false
621-
622620
list.sections = (1...50).map { sectionID in
623621
Section(sectionID) {
624622
for itemNumber in 1...20 {
@@ -628,7 +626,6 @@ class ListViewTests: XCTestCase
628626
}
629627

630628
let ID = TestContent.identifier(with: "A")
631-
632629
list.autoScrollAction = .scrollTo(
633630
.item(ID),
634631
onInsertOf: ID,
@@ -694,7 +691,6 @@ class ListViewTests: XCTestCase
694691
var didPerform : [ListScrollPositionInfo] = []
695692

696693
var content = ListProperties.default { list in
697-
698694
list.animatesChanges = false
699695
list.behavior.verticalLayoutGravity = .bottom
700696
list.sections = (1...50).map { sectionID in
@@ -706,7 +702,6 @@ class ListViewTests: XCTestCase
706702
}
707703

708704
let ID = TestContent.identifier(with: "A")
709-
710705
list.autoScrollAction = .scrollTo(
711706
.item(ID),
712707
onInsertOf: ID,
@@ -782,7 +777,6 @@ class ListViewTests: XCTestCase
782777
var didPerform : [ListScrollPositionInfo] = []
783778

784779
var content = ListProperties.default { list in
785-
786780
list.sections = (1...50).map { sectionID in
787781
Section(sectionID) {
788782
for itemID in 1...20 {
@@ -792,7 +786,6 @@ class ListViewTests: XCTestCase
792786
}
793787

794788
let ID = TestContent.identifier(with: "A")
795-
796789
list.autoScrollAction = .pin(
797790
.item(ID),
798791
position: .init(position: .bottom),
@@ -806,26 +799,22 @@ class ListViewTests: XCTestCase
806799

807800
show(vc: vc) { vc in
808801
vc.list.configure(with: content)
809-
810802
waitFor { vc.list.updateQueue.isEmpty }
811-
812803
XCTAssertEqual(didPerform.count, 0)
813804

814805
vc.list.configure(with: content)
815-
816806
waitFor { vc.list.updateQueue.isEmpty }
817-
818807
XCTAssertEqual(didPerform.count, 0)
819808

820809
content.content += Section("new") {
821810
TestContent(content: "A")
822811
}
823812

824813
vc.list.configure(with: content)
825-
826814
waitFor { vc.list.updateQueue.isEmpty }
827-
828815
XCTAssertEqual(didPerform.count, 1)
816+
817+
// TODO: Assert that the visible items are correct when using `pin(...)`.
829818
}
830819
}
831820
}

0 commit comments

Comments
 (0)