Skip to content

Commit

Permalink
Merge pull request #25 from traderepublic/develop
Browse files Browse the repository at this point in the history
Release 0.8
  • Loading branch information
Niclas Kristek authored Oct 22, 2020
2 parents f6dae13 + 954fb69 commit 0721d29
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ extension ListCollectionViewAdapter: UICollectionViewDataSource {
assertionFailure("Could not find the specified section")
return UICollectionViewCell()
}
let sectionIndexPath = SectionIndexPath(externalRepresentation: indexPath,
internalRepresentation: indexPath.item)
let sectionIndexPath = SectionIndexPath(indexInCollectionView: indexPath,
indexInSectionController: indexPath.item)
return sections[indexPath.section].controller.dataSource.cellForItem(at: sectionIndexPath)
}

Expand All @@ -32,8 +32,8 @@ extension ListCollectionViewAdapter: UICollectionViewDataSource {
assertionFailure("Could not find the specified section")
return UICollectionReusableView()
}
let sectionIndexPath = SectionIndexPath(externalRepresentation: indexPath,
internalRepresentation: indexPath.item)
let sectionIndexPath = SectionIndexPath(indexInCollectionView: indexPath,
indexInSectionController: indexPath.item)

let sectionController = sections[indexPath.section]

Expand All @@ -56,8 +56,8 @@ extension ListCollectionViewAdapter: UICollectionViewDataSource {
assertionFailure("Could not find the specified section")
return false
}
let sectionIndexPath = SectionIndexPath(externalRepresentation: indexPath,
internalRepresentation: indexPath.item)
let sectionIndexPath = SectionIndexPath(indexInCollectionView: indexPath,
indexInSectionController: indexPath.item)
return sections[indexPath.section].controller.dataSource.canMoveItem(at: sectionIndexPath)
}

Expand All @@ -73,10 +73,10 @@ extension ListCollectionViewAdapter: UICollectionViewDataSource {
guard moveInsideSection || allowReorderingBetweenDifferentSections else {
return
}
let sourceSectionIndexPath = SectionIndexPath(externalRepresentation: sourceIndexPath,
internalRepresentation: sourceIndexPath.item)
let destinationSectionIndexPath = SectionIndexPath(externalRepresentation: destinationIndexPath,
internalRepresentation: destinationIndexPath.item)
let sourceSectionIndexPath = SectionIndexPath(indexInCollectionView: sourceIndexPath,
indexInSectionController: sourceIndexPath.item)
let destinationSectionIndexPath = SectionIndexPath(indexInCollectionView: destinationIndexPath,
indexInSectionController: destinationIndexPath.item)
sections[sourceIndexPath.section].controller.dataSource.moveItem(at: sourceSectionIndexPath,
to: destinationSectionIndexPath)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ extension ListCollectionViewAdapter: UICollectionViewDelegate {
open func collectionView(_ collectionView: UICollectionView,
shouldHighlightItemAt indexPath: IndexPath) -> Bool {
guard indexPath.isSectionIndexValid(for: sections) else { return true }
let sectionIndexPath = SectionIndexPath(externalRepresentation: indexPath,
internalRepresentation: indexPath.item)
let sectionIndexPath = SectionIndexPath(indexInCollectionView: indexPath,
indexInSectionController: indexPath.item)
return sections[indexPath.section].controller.delegate?.shouldHighlightItem(at: sectionIndexPath) ?? true
}

open func collectionView(_ collectionView: UICollectionView,
didHighlightItemAt indexPath: IndexPath) {
guard indexPath.isSectionIndexValid(for: sections) else { return }
let sectionIndexPath = SectionIndexPath(externalRepresentation: indexPath,
internalRepresentation: indexPath.item)
let sectionIndexPath = SectionIndexPath(indexInCollectionView: indexPath,
indexInSectionController: indexPath.item)
sections[indexPath.section].controller.delegate?.didHighlightItem(at: sectionIndexPath)
}

open func collectionView(_ collectionView: UICollectionView,
didUnhighlightItemAt indexPath: IndexPath) {
guard indexPath.isSectionIndexValid(for: sections) else { return }
let sectionIndexPath = SectionIndexPath(externalRepresentation: indexPath,
internalRepresentation: indexPath.item)
let sectionIndexPath = SectionIndexPath(indexInCollectionView: indexPath,
indexInSectionController: indexPath.item)
sections[indexPath.section].controller.delegate?.didUnhighlightItem(at: sectionIndexPath)
}

Expand All @@ -32,32 +32,32 @@ extension ListCollectionViewAdapter: UICollectionViewDelegate {
open func collectionView(_ collectionView: UICollectionView,
shouldSelectItemAt indexPath: IndexPath) -> Bool {
guard indexPath.isSectionIndexValid(for: sections) else { return true }
let sectionIndexPath = SectionIndexPath(externalRepresentation: indexPath,
internalRepresentation: indexPath.item)
let sectionIndexPath = SectionIndexPath(indexInCollectionView: indexPath,
indexInSectionController: indexPath.item)
return sections[indexPath.section].controller.delegate?.shouldSelectItem(at: sectionIndexPath) ?? true
}

open func collectionView(_ collectionView: UICollectionView,
shouldDeselectItemAt indexPath: IndexPath) -> Bool {
guard indexPath.isSectionIndexValid(for: sections) else { return true }
let sectionIndexPath = SectionIndexPath(externalRepresentation: indexPath,
internalRepresentation: indexPath.item)
let sectionIndexPath = SectionIndexPath(indexInCollectionView: indexPath,
indexInSectionController: indexPath.item)
return sections[indexPath.section].controller.delegate?.shouldDeselectItem(at: sectionIndexPath) ?? true
}

open func collectionView(_ collectionView: UICollectionView,
didSelectItemAt indexPath: IndexPath) {
guard indexPath.isSectionIndexValid(for: sections) else { return }
let sectionIndexPath = SectionIndexPath(externalRepresentation: indexPath,
internalRepresentation: indexPath.item)
let sectionIndexPath = SectionIndexPath(indexInCollectionView: indexPath,
indexInSectionController: indexPath.item)
sections[indexPath.section].controller.delegate?.didSelectItem(at: sectionIndexPath)
}

open func collectionView(_ collectionView: UICollectionView,
didDeselectItemAt indexPath: IndexPath) {
guard indexPath.isSectionIndexValid(for: sections) else { return }
let sectionIndexPath = SectionIndexPath(externalRepresentation: indexPath,
internalRepresentation: indexPath.item)
let sectionIndexPath = SectionIndexPath(indexInCollectionView: indexPath,
indexInSectionController: indexPath.item)
sections[indexPath.section].controller.delegate?.didDeselectItem(at: sectionIndexPath)
}

Expand All @@ -67,8 +67,8 @@ extension ListCollectionViewAdapter: UICollectionViewDelegate {
willDisplay cell: UICollectionViewCell,
forItemAt indexPath: IndexPath) {
guard indexPath.isSectionIndexValid(for: sections) else { return }
let sectionIndexPath = SectionIndexPath(externalRepresentation: indexPath,
internalRepresentation: indexPath.item)
let sectionIndexPath = SectionIndexPath(indexInCollectionView: indexPath,
indexInSectionController: indexPath.item)
sections[indexPath.section].controller.delegate?.willDisplay(cell: cell, at: sectionIndexPath)
}

Expand All @@ -77,8 +77,8 @@ extension ListCollectionViewAdapter: UICollectionViewDelegate {
forElementKind elementKind: String,
at indexPath: IndexPath) {
guard indexPath.isSectionIndexValid(for: sections) else { return }
let sectionIndexPath = SectionIndexPath(externalRepresentation: indexPath,
internalRepresentation: indexPath.item)
let sectionIndexPath = SectionIndexPath(indexInCollectionView: indexPath,
indexInSectionController: indexPath.item)
let delegate = sections[indexPath.section].controller.delegate
switch elementKind {
case UICollectionView.elementKindSectionHeader:
Expand All @@ -94,8 +94,8 @@ extension ListCollectionViewAdapter: UICollectionViewDelegate {
didEndDisplaying cell: UICollectionViewCell,
forItemAt indexPath: IndexPath) {
guard indexPath.isSectionIndexValid(for: sections) else { return }
let sectionIndexPath = SectionIndexPath(externalRepresentation: indexPath,
internalRepresentation: indexPath.item)
let sectionIndexPath = SectionIndexPath(indexInCollectionView: indexPath,
indexInSectionController: indexPath.item)
sections[indexPath.section].controller.delegate?.didEndDisplaying(cell: cell, at: sectionIndexPath)
}

Expand All @@ -104,8 +104,8 @@ extension ListCollectionViewAdapter: UICollectionViewDelegate {
forElementOfKind elementKind: String,
at indexPath: IndexPath) {
guard indexPath.isSectionIndexValid(for: sections) else { return }
let sectionIndexPath = SectionIndexPath(externalRepresentation: indexPath,
internalRepresentation: indexPath.item)
let sectionIndexPath = SectionIndexPath(indexInCollectionView: indexPath,
indexInSectionController: indexPath.item)
let delegate = sections[indexPath.section].controller.delegate
switch elementKind {
case UICollectionView.elementKindSectionHeader:
Expand All @@ -123,8 +123,8 @@ extension ListCollectionViewAdapter: UICollectionViewDelegate {
open func collectionView(_ collectionView: UICollectionView,
shouldShowMenuForItemAt indexPath: IndexPath) -> Bool {
guard indexPath.isSectionIndexValid(for: sections) else { return false }
let sectionIndexPath = SectionIndexPath(externalRepresentation: indexPath,
internalRepresentation: indexPath.item)
let sectionIndexPath = SectionIndexPath(indexInCollectionView: indexPath,
indexInSectionController: indexPath.item)
return sections[indexPath.section].controller.delegate?.shouldShowMenuForItem(at: sectionIndexPath) ?? false
}

Expand All @@ -134,8 +134,8 @@ extension ListCollectionViewAdapter: UICollectionViewDelegate {
forItemAt indexPath: IndexPath,
withSender sender: Any?) -> Bool {
guard indexPath.isSectionIndexValid(for: sections) else { return false }
let sectionIndexPath = SectionIndexPath(externalRepresentation: indexPath,
internalRepresentation: indexPath.item)
let sectionIndexPath = SectionIndexPath(indexInCollectionView: indexPath,
indexInSectionController: indexPath.item)
return sections[indexPath.section].controller.delegate?.canPerform(action: action,
forItemAt: sectionIndexPath,
withSender: sender) ?? false
Expand All @@ -147,8 +147,8 @@ extension ListCollectionViewAdapter: UICollectionViewDelegate {
forItemAt indexPath: IndexPath,
withSender sender: Any?) {
guard indexPath.isSectionIndexValid(for: sections) else { return }
let sectionIndexPath = SectionIndexPath(externalRepresentation: indexPath,
internalRepresentation: indexPath.item)
let sectionIndexPath = SectionIndexPath(indexInCollectionView: indexPath,
indexInSectionController: indexPath.item)
sections[indexPath.section].controller.delegate?.perform(action: action,
forItemAt: sectionIndexPath,
withSender: sender)
Expand All @@ -170,8 +170,8 @@ extension ListCollectionViewAdapter: UICollectionViewDelegate {
guard indexPath.isSectionIndexValid(for: sections) else {
return self.collectionView(collectionView, shouldSelectItemAt: indexPath)
}
let sectionIndexPath = SectionIndexPath(externalRepresentation: indexPath,
internalRepresentation: indexPath.item)
let sectionIndexPath = SectionIndexPath(indexInCollectionView: indexPath,
indexInSectionController: indexPath.item)
return sections[indexPath.section].controller.delegate?.canFocusItem(at: sectionIndexPath)
?? self.collectionView(collectionView, shouldSelectItemAt: indexPath)
}
Expand Down Expand Up @@ -208,8 +208,8 @@ extension ListCollectionViewAdapter: UICollectionViewDelegate {
shouldSpringLoadItemAt indexPath: IndexPath,
with context: UISpringLoadedInteractionContext) -> Bool {
guard indexPath.isSectionIndexValid(for: sections) else { return true }
let sectionIndexPath = SectionIndexPath(externalRepresentation: indexPath,
internalRepresentation: indexPath.item)
let sectionIndexPath = SectionIndexPath(indexInCollectionView: indexPath,
indexInSectionController: indexPath.item)
return sections[indexPath.section].controller.delegate?.shouldSpringLoadItem(at: sectionIndexPath,
with: context) ?? true
}
Expand All @@ -220,8 +220,8 @@ extension ListCollectionViewAdapter: UICollectionViewDelegate {
open func collectionView(_ collectionView: UICollectionView,
shouldBeginMultipleSelectionInteractionAt indexPath: IndexPath) -> Bool {
guard indexPath.isSectionIndexValid(for: sections) else { return false }
let sectionIndexPath = SectionIndexPath(externalRepresentation: indexPath,
internalRepresentation: indexPath.item)
let sectionIndexPath = SectionIndexPath(indexInCollectionView: indexPath,
indexInSectionController: indexPath.item)
return sections[indexPath.section].controller.delegate?
.shouldBeginMultipleSelectionInteraction(at: sectionIndexPath) ?? false
}
Expand All @@ -230,8 +230,8 @@ extension ListCollectionViewAdapter: UICollectionViewDelegate {
open func collectionView(_ collectionView: UICollectionView,
didBeginMultipleSelectionInteractionAt indexPath: IndexPath) {
guard indexPath.isSectionIndexValid(for: sections) else { return }
let sectionIndexPath = SectionIndexPath(externalRepresentation: indexPath,
internalRepresentation: indexPath.item)
let sectionIndexPath = SectionIndexPath(indexInCollectionView: indexPath,
indexInSectionController: indexPath.item)
sections[indexPath.section].controller.delegate?.didBeginMultipleSelectionInteraction(at: sectionIndexPath)
}

Expand All @@ -244,8 +244,8 @@ extension ListCollectionViewAdapter: UICollectionViewDelegate {
contextMenuConfigurationForItemAt indexPath: IndexPath,
point: CGPoint) -> UIContextMenuConfiguration? {
guard indexPath.isSectionIndexValid(for: sections) else { return nil }
let sectionIndexPath = SectionIndexPath(externalRepresentation: indexPath,
internalRepresentation: indexPath.item)
let sectionIndexPath = SectionIndexPath(indexInCollectionView: indexPath,
indexInSectionController: indexPath.item)
return sections[indexPath.section].controller.delegate?.contextMenuConfigurationForItem(at: sectionIndexPath,
point: point)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ extension ListCollectionViewAdapter: UICollectionViewDragDelegate {
let dragDelegate = sections[indexPath.section].controller.dragDelegate
else { return [] }
session.localContext = sections[indexPath.section].controller
let sectionIndexPath = SectionIndexPath(externalRepresentation: indexPath,
internalRepresentation: indexPath.item)
let sectionIndexPath = SectionIndexPath(indexInCollectionView: indexPath,
indexInSectionController: indexPath.item)
return dragDelegate.dragItems(forBeginning: session, at: sectionIndexPath)
}

Expand All @@ -24,8 +24,8 @@ extension ListCollectionViewAdapter: UICollectionViewDragDelegate {
session.localContext as? SectionController === sections[indexPath.section].controller,
let dragDelegate = sections[indexPath.section].controller.dragDelegate
else { return [] }
let sectionIndexPath = SectionIndexPath(externalRepresentation: indexPath,
internalRepresentation: indexPath.item)
let sectionIndexPath = SectionIndexPath(indexInCollectionView: indexPath,
indexInSectionController: indexPath.item)
return dragDelegate.dragItems(forAddingTo: session, at: sectionIndexPath, point: point)
}

Expand All @@ -35,8 +35,8 @@ extension ListCollectionViewAdapter: UICollectionViewDragDelegate {
indexPath.isSectionIndexValid(for: sections),
let dragDelegate = sections[indexPath.section].controller.dragDelegate
else { return nil }
let sectionIndexPath = SectionIndexPath(externalRepresentation: indexPath,
internalRepresentation: indexPath.item)
let sectionIndexPath = SectionIndexPath(indexInCollectionView: indexPath,
indexInSectionController: indexPath.item)
return dragDelegate.dragPreviewParametersForItem(at: sectionIndexPath)
}

Expand Down
Loading

0 comments on commit 0721d29

Please sign in to comment.