Commit b038490c authored by Toby Brennan's avatar Toby Brennan
Browse files

Rework selection API

parent 9a439e3b
Showing with 97 additions and 131 deletions
+97 -131
......@@ -354,7 +354,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "cd BuildTools\nSDKROOT=macosx\n#Temporarily uncomment the following line to update your packages (based on the versions defined in BuildTools/Package.swift)\nswift package update\n\nswift run -c release swiftformat \"$SRCROOT/../\"\n";
shellScript = "cd BuildTools\nSDKROOT=macosx\n#Temporarily uncomment the following line to update your packages (based on the versions defined in BuildTools/Package.swift)\n#swift package update\n\n#swift run -c release swiftformat \"$SRCROOT/../\"\n";
};
/* End PBXShellScriptBuildPhase section */
......
......@@ -7,7 +7,6 @@ import UIKit
struct PhotoGridScreen: View
{
@State var data: [Post] = DataSource.postsForGridSection(1, number: 1000)
@State var highlightedIndexes: Set<Int> = []
@State var selectedIndexes: Set<Int> = []
@Environment(\.editMode) private var editMode
......@@ -23,8 +22,7 @@ struct PhotoGridScreen: View
ASCollectionViewSection(
id: 0,
data: data,
highlightedIndexes: $highlightedIndexes,
selectedIndexes: $selectedIndexes,
selectionMode: isEditing ? .selectMultiple($selectedIndexes) : .none,
onCellEvent: onCellEvent)
{ item, state in
ZStack(alignment: .bottomTrailing)
......@@ -54,8 +52,6 @@ struct PhotoGridScreen: View
editMode: isEditing,
section: section)
.layout(self.layout)
.allowsSelection(self.isEditing)
.allowsMultipleSelection(self.isEditing)
.edgesIgnoringSafeArea(.all)
.navigationBarTitle("Explore", displayMode: .large)
.navigationBarItems(
......
......@@ -8,7 +8,6 @@ import UIKit
struct WaterfallScreen: View
{
@State var data: [[Post]] = (0 ... 10).map { DataSource.postsForWaterfallSection($0, number: 100) }
@State var highlightedIndexes: [SectionID: Set<Int>] = [:]
@State var selectedIndexes: [SectionID: Set<Int>] = [:]
@State var selectedPost: Post? = nil // Post being viewed in the detail view
@State var columnMinSize: CGFloat = 150
......@@ -28,8 +27,10 @@ struct WaterfallScreen: View
ASCollectionViewSection(
id: offset,
data: sectionData,
highlightedIndexes: $highlightedIndexes[offset],
selectedIndexes: $selectedIndexes[offset],
selectionMode: self.isEditing ? .selectMultiple($selectedIndexes[offset]) : .selectSingle
{ selectedIndex in
selectedPost = sectionData[selectedIndex]
},
onCellEvent: onCellEvent)
{ item, state in
GeometryReader
......@@ -97,10 +98,8 @@ struct WaterfallScreen: View
editMode: isEditing,
sections: sections)
.layout(self.layout)
.allowsMultipleSelection(self.isEditing)
.customDelegate(WaterfallScreenLayoutDelegate.init)
.contentInsets(.init(top: 0, left: 10, bottom: 10, right: 10))
.onChange(of: selectedIndexes, perform: onSelectionChange)
.postSheet(item: $selectedPost, onDismiss: { self.selectedIndexes = [:] })
.navigationBarTitle("Waterfall Layout", displayMode: .inline)
.navigationBarItems(
......@@ -144,21 +143,6 @@ struct WaterfallScreen: View
}
}
func onSelectionChange(_ selection: [SectionID: Set<Int>])
{
guard !isEditing else { return }
if let (sectionID, selectedIndexes) = selection.first(where: { !$0.value.isEmpty }),
let selectedIndex = selectedIndexes.first
{
selectedPost = data[sectionID][selectedIndex]
}
else
{
selectedPost = nil
}
}
func onCellEvent(_ event: CellEvent<Post>)
{
switch event
......
......@@ -141,28 +141,13 @@ public extension ASCollectionView
return this
}
/// Set whether the ASCollectionView should allow selection, default is true
func allowsSelection(_ allowsSelection: Bool) -> Self
/// Set whether the ASCollectionView should automatically scroll an active textview/input to avoid the system keyboard. Default is true
func shouldScrollToAvoidKeyboard(_ avoidKeyboard: Bool = true) -> Self
{
var this = self
this.allowsSelection = allowsSelection
this.dodgeKeyboard = avoidKeyboard
return this
}
/// Set whether the ASCollectionView should allow multiple selection, default is false
func allowsMultipleSelection(_ allowsMultipleSelection: Bool) -> Self
{
var this = self
this.allowsMultipleSelection = allowsMultipleSelection
return this
}
/// Set whether the ASCollectionView should automatically scroll an active textview/input to avoid the system keyboard. Default is true
func shouldScrollToAvoidKeyboard(_ avoidKeyboard: Bool = true) -> Self {
var this = self
this.dodgeKeyboard = avoidKeyboard
return this
}
}
// MARK: PUBLIC layout modifier functions
......
......@@ -24,9 +24,8 @@ public extension ASSection
data: DataCollection,
dataID dataIDKeyPath: KeyPath<DataCollection.Element, DataID>,
container: @escaping ((Content, ASCellContext) -> Container),
highlightedIndexes: Binding<Set<Int>>? = nil,
selectionMode: ASSectionSelectionMode = .none,
shouldAllowHighlight: ((_ index: Int) -> Bool)? = nil,
selectedIndexes: Binding<Set<Int>>? = nil,
shouldAllowSelection: ((_ index: Int) -> Bool)? = nil,
shouldAllowDeselection: ((_ index: Int) -> Bool)? = nil,
onCellEvent: OnCellEvent<DataCollection.Element>? = nil,
......@@ -43,9 +42,8 @@ public extension ASSection
dataIDKeyPath: dataIDKeyPath,
container: container,
content: contentBuilder,
highlightedIndexes: highlightedIndexes,
selectionMode: selectionMode,
shouldAllowHighlight: shouldAllowHighlight,
selectedIndexes: selectedIndexes,
shouldAllowSelection: shouldAllowSelection,
shouldAllowDeselection: shouldAllowDeselection,
onCellEvent: onCellEvent,
......@@ -59,9 +57,8 @@ public extension ASSection
id: SectionID,
data: DataCollection,
dataID dataIDKeyPath: KeyPath<DataCollection.Element, DataID>,
highlightedIndexes: Binding<Set<Int>>? = nil,
selectionMode: ASSectionSelectionMode = .none,
shouldAllowHighlight: ((_ index: Int) -> Bool)? = nil,
selectedIndexes: Binding<Set<Int>>? = nil,
shouldAllowSelection: ((_ index: Int) -> Bool)? = nil,
shouldAllowDeselection: ((_ index: Int) -> Bool)? = nil,
onCellEvent: OnCellEvent<DataCollection.Element>? = nil,
......@@ -72,7 +69,7 @@ public extension ASSection
@ViewBuilder contentBuilder: @escaping ((DataCollection.Element, ASCellContext) -> Content))
where DataCollection.Index == Int
{
self.init(id: id, data: data, dataID: dataIDKeyPath, container: { content, _ in content }, highlightedIndexes: highlightedIndexes, shouldAllowHighlight: shouldAllowHighlight, selectedIndexes: selectedIndexes, shouldAllowSelection: shouldAllowSelection, shouldAllowDeselection: shouldAllowDeselection, onCellEvent: onCellEvent, dragDropConfig: dragDropConfig, shouldAllowSwipeToDelete: shouldAllowSwipeToDelete, onSwipeToDelete: onSwipeToDelete, contextMenuProvider: contextMenuProvider, contentBuilder: contentBuilder)
self.init(id: id, data: data, dataID: dataIDKeyPath, container: { content, _ in content }, selectionMode: selectionMode, shouldAllowHighlight: shouldAllowHighlight, shouldAllowSelection: shouldAllowSelection, shouldAllowDeselection: shouldAllowDeselection, onCellEvent: onCellEvent, dragDropConfig: dragDropConfig, shouldAllowSwipeToDelete: shouldAllowSwipeToDelete, onSwipeToDelete: onSwipeToDelete, contextMenuProvider: contextMenuProvider, contentBuilder: contentBuilder)
}
}
......@@ -94,9 +91,8 @@ public extension ASCollectionViewSection
id: SectionID,
data: DataCollection,
container: @escaping ((Content, ASCellContext) -> Container),
highlightedIndexes: Binding<Set<Int>>? = nil,
selectionMode: ASSectionSelectionMode = .none,
shouldAllowHighlight: ((_ index: Int) -> Bool)? = nil,
selectedIndexes: Binding<Set<Int>>? = nil,
shouldAllowSelection: ((_ index: Int) -> Bool)? = nil,
shouldAllowDeselection: ((_ index: Int) -> Bool)? = nil,
onCellEvent: OnCellEvent<DataCollection.Element>? = nil,
......@@ -107,15 +103,14 @@ public extension ASCollectionViewSection
@ViewBuilder contentBuilder: @escaping ((DataCollection.Element, ASCellContext) -> Content))
where DataCollection.Index == Int, DataCollection.Element: Identifiable
{
self.init(id: id, data: data, dataID: \.id, container: container, highlightedIndexes: highlightedIndexes, shouldAllowHighlight: shouldAllowHighlight, selectedIndexes: selectedIndexes, shouldAllowSelection: shouldAllowSelection, shouldAllowDeselection: shouldAllowDeselection, onCellEvent: onCellEvent, dragDropConfig: dragDropConfig, shouldAllowSwipeToDelete: shouldAllowSwipeToDelete, onSwipeToDelete: onSwipeToDelete, contextMenuProvider: contextMenuProvider, contentBuilder: contentBuilder)
self.init(id: id, data: data, dataID: \.id, container: container, selectionMode: selectionMode, shouldAllowHighlight: shouldAllowHighlight, shouldAllowSelection: shouldAllowSelection, shouldAllowDeselection: shouldAllowDeselection, onCellEvent: onCellEvent, dragDropConfig: dragDropConfig, shouldAllowSwipeToDelete: shouldAllowSwipeToDelete, onSwipeToDelete: onSwipeToDelete, contextMenuProvider: contextMenuProvider, contentBuilder: contentBuilder)
}
init<Content: View, DataCollection: RandomAccessCollection>(
id: SectionID,
data: DataCollection,
highlightedIndexes: Binding<Set<Int>>? = nil,
selectionMode: ASSectionSelectionMode = .none,
shouldAllowHighlight: ((_ index: Int) -> Bool)? = nil,
selectedIndexes: Binding<Set<Int>>? = nil,
shouldAllowSelection: ((_ index: Int) -> Bool)? = nil,
shouldAllowDeselection: ((_ index: Int) -> Bool)? = nil,
onCellEvent: OnCellEvent<DataCollection.Element>? = nil,
......@@ -126,7 +121,7 @@ public extension ASCollectionViewSection
@ViewBuilder contentBuilder: @escaping ((DataCollection.Element, ASCellContext) -> Content))
where DataCollection.Index == Int, DataCollection.Element: Identifiable
{
self.init(id: id, data: data, container: { content, _ in content }, highlightedIndexes: highlightedIndexes, shouldAllowHighlight: shouldAllowHighlight, selectedIndexes: selectedIndexes, shouldAllowSelection: shouldAllowSelection, shouldAllowDeselection: shouldAllowDeselection, onCellEvent: onCellEvent, dragDropConfig: dragDropConfig, shouldAllowSwipeToDelete: shouldAllowSwipeToDelete, onSwipeToDelete: onSwipeToDelete, contextMenuProvider: contextMenuProvider, contentBuilder: contentBuilder)
self.init(id: id, data: data, container: { content, _ in content }, selectionMode: selectionMode, shouldAllowHighlight: shouldAllowHighlight, shouldAllowSelection: shouldAllowSelection, shouldAllowDeselection: shouldAllowDeselection, onCellEvent: onCellEvent, dragDropConfig: dragDropConfig, shouldAllowSwipeToDelete: shouldAllowSwipeToDelete, onSwipeToDelete: onSwipeToDelete, contextMenuProvider: contextMenuProvider, contentBuilder: contentBuilder)
}
}
......
......@@ -81,22 +81,6 @@ public extension ASTableView
this.scrollPositionSetter = binding
return this
}
/// Set whether the ASTableView should allow selection, default is true
func allowsSelection(_ allowsSelection: Bool) -> Self
{
var this = self
this.allowsSelection = allowsSelection
return this
}
/// Set whether the ASTableView should allow multiple selection, default is false
func allowsMultipleSelection(_ allowsMultipleSelection: Bool) -> Self
{
var this = self
this.allowsMultipleSelection = allowsMultipleSelection
return this
}
}
// MARK: ASTableView specific header modifiers
......@@ -123,13 +107,6 @@ public extension ASTableViewSection
return self
}
}
func onSelectSingle(_ callback: @escaping ((Int) -> Void)) -> Self
{
var section = self
section.dataSource.onSelectSingle = callback
return section
}
}
@available(iOS 13.0, *)
......
......@@ -40,9 +40,6 @@ public struct ASCollectionView<SectionID: Hashable>: UIViewControllerRepresentab
internal var alwaysBounceVertical: Bool = false
internal var alwaysBounceHorizontal: Bool = false
internal var allowsSelection: Bool = true
internal var allowsMultipleSelection: Bool = false
internal var scrollPositionSetter: Binding<ASCollectionViewScrollPosition?>?
internal var animateOnDataRefresh: Bool = true
......@@ -189,8 +186,8 @@ public struct ASCollectionView<SectionID: Hashable>: UIViewControllerRepresentab
assignIfChanged(collectionView, \.dragInteractionEnabled, newValue: true)
assignIfChanged(collectionView, \.alwaysBounceVertical, newValue: parent.alwaysBounceVertical)
assignIfChanged(collectionView, \.alwaysBounceHorizontal, newValue: parent.alwaysBounceHorizontal)
assignIfChanged(collectionView, \.allowsSelection, newValue: parent.allowsSelection)
assignIfChanged(collectionView, \.allowsMultipleSelection, newValue: parent.allowsMultipleSelection)
assignIfChanged(collectionView, \.allowsSelection, newValue: true)
assignIfChanged(collectionView, \.allowsMultipleSelection, newValue: true)
assignIfChanged(collectionView, \.showsVerticalScrollIndicator, newValue: parent.verticalScrollIndicatorEnabled)
assignIfChanged(collectionView, \.showsHorizontalScrollIndicator, newValue: parent.horizontalScrollIndicatorEnabled)
assignIfChanged(collectionView, \.keyboardDismissMode, newValue: .interactive)
......@@ -685,6 +682,7 @@ public struct ASCollectionView<SectionID: Hashable>: UIViewControllerRepresentab
public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)
{
updateSelection(collectionView)
parent.sections[safe: indexPath.section]?.dataSource.didSelect(indexPath)
}
public func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath)
......@@ -710,7 +708,7 @@ public struct ASCollectionView<SectionID: Hashable>: UIViewControllerRepresentab
{
parent.sections.enumerated().reduce(Set<IndexPath>())
{ (selectedIndexPaths, section) -> Set<IndexPath> in
guard let indexes = section.element.dataSource.getSelectedIndexes() else { return selectedIndexPaths }
guard let indexes = section.element.dataSource.selectedIndicesBinding?.wrappedValue else { return selectedIndexPaths }
let indexPaths = indexes.map { IndexPath(item: $0, section: section.offset) }
return selectedIndexPaths.union(indexPaths)
}
......@@ -738,7 +736,7 @@ public struct ASCollectionView<SectionID: Hashable>: UIViewControllerRepresentab
}
parent.sections.enumerated().forEach
{ offset, section in
section.dataSource.updateSelection(selectionBySection[offset] ?? [])
section.dataSource.updateSelection(with: selectionBySection[offset] ?? [])
}
}
......
......@@ -242,6 +242,7 @@ private class AS_UIHostingController<Content: View>: UIHostingController<Content
disableInteractionsIfNeeded()
}
@available(*, unavailable)
@objc dynamic required init?(coder aDecoder: NSCoder)
{
fatalError("init(coder:) has not been implemented")
......
......@@ -36,18 +36,18 @@ internal protocol ASSectionDataSourceProtocol
func unhighlightIndex(_ index: Int)
func shouldHighlight(_ indexPath: IndexPath) -> Bool
func getSelectedIndexes() -> Set<Int>?
var selectedIndicesBinding: Binding<Set<Int>>? { get }
func isSelected(index: Int) -> Bool
func updateSelection(_ indices: Set<Int>)
func shouldSelect(_ indexPath: IndexPath) -> Bool
func shouldDeselect(_ indexPath: IndexPath) -> Bool
func didSelect(_ indexPath: IndexPath)
func updateSelection(with indices: Set<Int>)
var dragEnabled: Bool { get }
var dropEnabled: Bool { get }
var reorderingEnabled: Bool { get }
mutating func setSelfSizingConfig(config: @escaping SelfSizingConfig)
var onSelectSingle: ((Int) -> Void)? { get set }
}
@available(iOS 13.0, *)
......@@ -66,6 +66,15 @@ protocol ASDataSourceConfigurableSupplementary
func setAsEmpty(supplementaryID: ASSupplementaryCellID?)
}
@available(iOS 13.0, *)
public enum ASSectionSelectionMode
{
case none
case highlighting(Binding<Set<Int>>)
case selectSingle((Int) -> Void)
case selectMultiple(Binding<Set<Int>>)
}
@available(iOS 13.0, *)
internal struct ASSectionDataSource<DataCollection: RandomAccessCollection, DataID, Content, Container>: ASSectionDataSourceProtocol where DataID: Hashable, Content: View, Container: View, DataCollection.Index == Int
{
......@@ -75,13 +84,10 @@ internal struct ASSectionDataSource<DataCollection: RandomAccessCollection, Data
var container: (Content, ASCellContext) -> Container
var content: (DataCollection.Element, ASCellContext) -> Content
var highlightedIndexes: Binding<Set<Int>>?
var selectionMode: ASSectionSelectionMode = .none
var shouldAllowHighlight: ((_ index: Int) -> Bool)?
var selectedIndexes: Binding<Set<Int>>?
var shouldAllowSelection: ((_ index: Int) -> Bool)?
var shouldAllowDeselection: ((_ index: Int) -> Bool)?
var onSelectSingle: ((Int) -> Void)?
var onCellEvent: OnCellEvent<DataCollection.Element>?
var dragDropConfig: ASDragDropConfig<DataCollection.Element>
......@@ -319,17 +325,38 @@ internal struct ASSectionDataSource<DataCollection: RandomAccessCollection, Data
selfSizingConfig?(context)
}
var highlightedIndicesBinding: Binding<Set<Int>>?
{
switch selectionMode
{
case let .highlighting(highlighted):
return highlighted
default:
return nil
}
}
var selectedIndicesBinding: Binding<Set<Int>>?
{
switch selectionMode
{
case let .selectMultiple(selected):
return selected
default:
return nil
}
}
func isHighlighted(index: Int) -> Bool
{
highlightedIndexes?.wrappedValue.contains(index) ?? false
(highlightedIndicesBinding?.wrappedValue.contains(index) ?? false) || (selectedIndicesBinding?.wrappedValue.contains(index) ?? false)
}
func highlightIndex(_ index: Int)
{
DispatchQueue.main.async
{
guard let highlightedIndexes = self.highlightedIndexes?.wrappedValue else { return }
self.highlightedIndexes?.wrappedValue = highlightedIndexes.union([index])
self.highlightedIndicesBinding?.wrappedValue = highlightedIndicesBinding?.wrappedValue.union([index]) ?? []
}
}
......@@ -337,55 +364,61 @@ internal struct ASSectionDataSource<DataCollection: RandomAccessCollection, Data
{
DispatchQueue.main.async
{
guard let highlightedIndexes = self.highlightedIndexes?.wrappedValue else { return }
self.highlightedIndexes?.wrappedValue = highlightedIndexes.subtracting([index])
self.highlightedIndicesBinding?.wrappedValue = highlightedIndicesBinding?.wrappedValue.subtracting([index]) ?? []
}
}
func shouldHighlight(_ indexPath: IndexPath) -> Bool
{
guard data.containsIndex(indexPath.item) else { return isHighlightable }
return shouldAllowHighlight?(indexPath.item) ?? isHighlightable
}
private var isHighlightable: Bool
{
highlightedIndexes != nil || selectedIndexes != nil
}
func getSelectedIndexes() -> Set<Int>?
{
selectedIndexes?.wrappedValue
guard data.containsIndex(indexPath.item) else { return false }
switch selectionMode
{
case .none: return false
case .highlighting:
return shouldAllowHighlight?(indexPath.item) ?? true
case .selectSingle, .selectMultiple:
return shouldSelect(indexPath) && (shouldAllowHighlight?(indexPath.item) ?? true)
}
}
func isSelected(index: Int) -> Bool
{
selectedIndexes?.wrappedValue.contains(index) ?? false
selectedIndicesBinding?.wrappedValue.contains(index) ?? false
}
func updateSelection(_ indices: Set<Int>)
func shouldSelect(_ indexPath: IndexPath) -> Bool
{
DispatchQueue.main.async
guard data.containsIndex(indexPath.item) else { return false }
switch selectionMode
{
self.selectedIndexes?.wrappedValue = Set(indices)
case .none, .highlighting: return false
case .selectSingle, .selectMultiple:
return shouldAllowSelection?(indexPath.item) ?? true
}
}
func shouldSelect(_ indexPath: IndexPath) -> Bool
func shouldDeselect(_ indexPath: IndexPath) -> Bool
{
guard data.containsIndex(indexPath.item) else { return isSelectable }
return shouldAllowSelection?(indexPath.item) ?? isSelectable
guard data.containsIndex(indexPath.item) else { return false }
return shouldAllowDeselection?(indexPath.item) ?? true
}
func shouldDeselect(_ indexPath: IndexPath) -> Bool
func didSelect(_ indexPath: IndexPath)
{
guard data.containsIndex(indexPath.item) else { return isSelectable }
return shouldAllowDeselection?(indexPath.item) ?? isSelectable
switch selectionMode
{
case let .selectSingle(closure):
closure(indexPath.item)
default: break
}
}
private var isSelectable: Bool
func updateSelection(with indices: Set<Int>)
{
selectedIndexes != nil
DispatchQueue.main.async
{
self.selectedIndicesBinding?.wrappedValue = indices
}
}
}
......
......@@ -34,9 +34,6 @@ public struct ASTableView<SectionID: Hashable>: UIViewControllerRepresentable, C
internal var separatorsEnabled: Bool = true
internal var allowsSelection: Bool = true
internal var allowsMultipleSelection: Bool = false
internal var onPullToRefresh: ((_ endRefreshing: @escaping (() -> Void)) -> Void)?
internal var alwaysBounce: Bool = false
......@@ -152,14 +149,13 @@ public struct ASTableView<SectionID: Hashable>: UIViewControllerRepresentable, C
assignIfChanged(tableView, \.showsVerticalScrollIndicator, newValue: parent.scrollIndicatorEnabled)
assignIfChanged(tableView, \.showsHorizontalScrollIndicator, newValue: parent.scrollIndicatorEnabled)
assignIfChanged(tableView, \.keyboardDismissMode, newValue: .interactive)
assignIfChanged(tableView, \.allowsSelection, newValue: parent.allowsSelection)
assignIfChanged(tableView, \.allowsMultipleSelection, newValue: parent.allowsMultipleSelection)
updateTableViewContentInsets(tableView)
assignIfChanged(tableView, \.allowsSelection, newValue: true)
assignIfChanged(tableView, \.allowsMultipleSelectionDuringEditing, newValue: true)
assignIfChanged(tableView, \.allowsMultipleSelection, newValue: true)
assignIfChanged(tableView, \.allowsSelectionDuringEditing, newValue: true)
assignIfChanged(tableView, \.allowsMultipleSelectionDuringEditing, newValue: true)
assignIfChanged(tableView, \.isEditing, newValue: parent.editMode)
}
......@@ -538,6 +534,7 @@ public struct ASTableView<SectionID: Hashable>: UIViewControllerRepresentable, C
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
{
updateSelection(tableView)
parent.sections[safe: indexPath.section]?.dataSource.didSelect(indexPath)
}
public func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath)
......@@ -563,7 +560,7 @@ public struct ASTableView<SectionID: Hashable>: UIViewControllerRepresentable, C
{
parent.sections.enumerated().reduce(Set<IndexPath>())
{ (selectedIndexPaths, section) -> Set<IndexPath> in
guard let indexes = section.element.dataSource.getSelectedIndexes() else { return selectedIndexPaths }
guard let indexes = section.element.dataSource.selectedIndicesBinding?.wrappedValue else { return selectedIndexPaths }
let indexPaths = indexes.map { IndexPath(item: $0, section: section.offset) }
return selectedIndexPaths.union(indexPaths)
}
......@@ -591,7 +588,7 @@ public struct ASTableView<SectionID: Hashable>: UIViewControllerRepresentable, C
}
parent.sections.enumerated().forEach
{ offset, section in
section.dataSource.updateSelection(selectionBySection[offset] ?? [])
section.dataSource.updateSelection(with: selectionBySection[offset] ?? [])
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment