Skip to content

Commit 902f13a

Browse files
committed
updated
1 parent cf1f566 commit 902f13a

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

Sources/AdvancedCollectionTableView-iOS/CollectionView/DataSource/UICollectionViewDiffableDataSource+.swift

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ extension UICollectionViewDiffableDataSource {
7070

7171
When using this property, ``emptyContentConfiguration`` is set to `nil`.
7272

73-
- Note: The empty view is only used, when you apply your snapshots using ``UIKit/UICollectionViewDiffableDataSource/apply(_:_:completion:)``.
73+
- Important: The empty view is only used, when you apply your snapshots using ``UIKit/UICollectionViewDiffableDataSource/apply(_:_:completion:)``.
7474
\
7575
\
76-
You have to provide a snapshot and an apply option (either `.animated`, `nonAnimated` or `usingReloadedData`). For example:
76+
You have to provide a snapshot and an apply option (either `.animated`, `.nonAnimated` or `.usingReloadedData`). For example:
7777
\
7878
\
7979
```dataSource.apply(snapshot, .animated)```
@@ -82,13 +82,12 @@ extension UICollectionViewDiffableDataSource {
8282
get { getAssociatedValue(key: "emptyView", object: self, initialValue: nil) }
8383
set {
8484
guard emptyView != newValue else { return }
85+
emptyView?.removeFromSuperview()
86+
set(associatedValue: newValue, key: "emptyView", object: self)
8587
if newValue != nil {
8688
emptyContentConfiguration = nil
87-
} else {
88-
emptyView?.removeFromSuperview()
89+
updateEmptyView()
8990
}
90-
set(associatedValue: newValue, key: "emptyView", object: self)
91-
updateEmptyView()
9291
}
9392
}
9493

@@ -97,31 +96,30 @@ extension UICollectionViewDiffableDataSource {
9796

9897
When using this property, ``emptyView`` is set to `nil`.
9998

100-
- Note: The empty content configuration is only used, when you apply your snapshots using ``UIKit/UICollectionViewDiffableDataSource/apply(_:_:completion:)``.
99+
- Important: The empty content configuration is only used, when you apply your snapshots using ``UIKit/UICollectionViewDiffableDataSource/apply(_:_:completion:)``.
101100
\
102101
\
103-
You have to provide a snapshot and an apply option (either `.animated`, `nonAnimated` or `usingReloadedData`). For example:
102+
You have to provide a snapshot and an apply option (either `.animated`, `.nonAnimated` or `.usingReloadedData`). For example:
104103
\
105104
\
106105
```dataSource.apply(snapshot, .animated)```
107106
*/
108107
public var emptyContentConfiguration: UIContentConfiguration? {
109108
get { getAssociatedValue(key: "emptyContentConfiguration", object: self, initialValue: nil) }
110109
set {
110+
set(associatedValue: newValue, key: "emptyContentConfiguration", object: self)
111111
if let configuration = newValue {
112-
emptyView?.removeFromSuperview()
113112
emptyView = nil
114113
if let emptyContentView = self.emptyContentView {
115114
emptyContentView.contentConfiguration = configuration
116115
} else {
117116
emptyContentView = .init(configuration: configuration)
118117
}
118+
updateEmptyView()
119119
} else {
120120
emptyContentView?.removeFromSuperview()
121121
emptyContentView = nil
122122
}
123-
set(associatedValue: newValue, key: "emptyContentConfiguration", object: self)
124-
updateEmptyView()
125123
}
126124
}
127125

Sources/AdvancedCollectionTableView-iOS/TableView/DataSource/TableViewDiffableDataSource.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ class TableViewDiffableDataSource<SectionIdentifierType, ItemIdentifierType> : U
4747
oldValue?.removeFromSuperview()
4848
if emptyView != nil {
4949
emptyContentConfiguration = nil
50+
updateEmptyView()
5051
}
51-
updateEmptyView()
5252
}
5353
}
5454

@@ -60,18 +60,17 @@ class TableViewDiffableDataSource<SectionIdentifierType, ItemIdentifierType> : U
6060
open var emptyContentConfiguration: UIContentConfiguration? = nil {
6161
didSet {
6262
if let configuration = emptyContentConfiguration {
63-
emptyView?.removeFromSuperview()
6463
emptyView = nil
6564
if let emptyContentView = self.emptyContentView {
6665
emptyContentView.contentConfiguration = configuration
6766
} else {
6867
emptyContentView = .init(configuration: configuration)
6968
}
69+
updateEmptyView()
7070
} else {
7171
emptyContentView?.removeFromSuperview()
7272
emptyContentView = nil
7373
}
74-
updateEmptyView()
7574
}
7675
}
7776

0 commit comments

Comments
 (0)