Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NO-JIRA Then 의존성을 제거해요 #37

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion KarrotListKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ Pod::Spec.new do |spec|
spec.source_files = 'Sources/**/*.{swift,h,m}'

spec.dependency 'DifferenceKit', '~> 1.0'
spec.dependency 'Then', '~> 3.0'
end
9 changes: 0 additions & 9 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@
"revision": "073b9671ce2b9b5b96398611427a1f929927e428",
"version": "1.3.0"
}
},
{
"package": "Then",
"repositoryURL": "https://github.com/devxoul/Then.git",
"state": {
"branch": null,
"revision": "d41ef523faef0f911369f79c0b96815d9dbb6d7a",
"version": "3.0.0"
}
}
]
},
Expand Down
5 changes: 0 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,12 @@ let package = Package(
url: "https://github.com/ra1028/DifferenceKit.git",
.upToNextMajor(from: "1.0.0")
),
.package(
url: "https://github.com/devxoul/Then.git",
.upToNextMajor(from: "3.0.0")
),
],
targets: [
.target(
name: "KarrotListKit",
dependencies: [
"DifferenceKit",
"Then",
]
),
.testTarget(
Expand Down
10 changes: 6 additions & 4 deletions Sources/KarrotListKit/Adapter/CollectionViewAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ final public class CollectionViewAdapter: NSObject {

var list: List?

private lazy var pullToRefreshControl = UIRefreshControl().then {
$0.tintColor = configuration.refreshControl.tintColor
$0.addTarget(
private lazy var pullToRefreshControl: UIRefreshControl = {
let refreshControl = UIRefreshControl()
refreshControl.tintColor = configuration.refreshControl.tintColor
refreshControl.addTarget(
self,
action: #selector(pullToRefresh),
for: .valueChanged
)
}
return refreshControl
}()

// MARK: - Initializer

Expand Down
53 changes: 28 additions & 25 deletions Sources/KarrotListKit/Layout/HorizontalLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,37 @@ public struct HorizontalLayout: CompositionalLayoutSectionFactory {
heightDimension: .estimated(context.environment.container.contentSize.height)
),
subitems: layoutCellItems(cells: context.section.cells, sizeStorage: context.sizeStorage)
).then {
$0.interItemSpacing = .fixed(spacing)
)
group.interItemSpacing = .fixed(spacing)


let section = NSCollectionLayoutSection(group: group)
if let sectionInsets {
section.contentInsets = sectionInsets
}

return NSCollectionLayoutSection(group: group).then {
if let sectionInsets = sectionInsets {
$0.contentInsets = sectionInsets
}

if let visibleItemsInvalidationHandler {
$0.visibleItemsInvalidationHandler = visibleItemsInvalidationHandler
}

$0.orthogonalScrollingBehavior = scrollingBehavior

$0.boundarySupplementaryItems = [
layoutHeaderItem(section: context.section, sizeStorage: context.sizeStorage)?.then {
if let headerPinToVisibleBounds {
$0.pinToVisibleBounds = headerPinToVisibleBounds
}
},
layoutFooterItem(section: context.section, sizeStorage: context.sizeStorage)?.then {
if let footerPinToVisibleBounds {
$0.pinToVisibleBounds = footerPinToVisibleBounds
}
},
].compactMap { $0 }
if let visibleItemsInvalidationHandler {
section.visibleItemsInvalidationHandler = visibleItemsInvalidationHandler
}

section.orthogonalScrollingBehavior = scrollingBehavior

let headerItem = layoutHeaderItem(section: context.section, sizeStorage: context.sizeStorage)
if let headerPinToVisibleBounds {
headerItem?.pinToVisibleBounds = headerPinToVisibleBounds
}

let footerItem = layoutFooterItem(section: context.section, sizeStorage: context.sizeStorage)
if let footerPinToVisibleBounds {
footerItem?.pinToVisibleBounds = footerPinToVisibleBounds
}

section.boundarySupplementaryItems = [
headerItem,
footerItem,
].compactMap { $0 }

return section
}
}

Expand Down
57 changes: 30 additions & 27 deletions Sources/KarrotListKit/Layout/VerticalGridLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public struct VerticalGridLayout: CompositionalLayoutSectionFactory {

verticalGroupHeight += horizontalGroupHeight.dimension

return NSCollectionLayoutGroup.horizontal(
let layoutGroup = NSCollectionLayoutGroup.horizontal(
layoutSize: .init(
widthDimension: .fractionalWidth(1.0),
heightDimension: horizontalGroupHeight
Expand All @@ -57,9 +57,10 @@ public struct VerticalGridLayout: CompositionalLayoutSectionFactory {
)
),
count: numberOfItemsInRow
).then {
$0.interItemSpacing = .fixed(itemSpacing)
}
)
layoutGroup.interItemSpacing = .fixed(itemSpacing)

return layoutGroup
}

let group = NSCollectionLayoutGroup.vertical(
Expand All @@ -68,32 +69,34 @@ public struct VerticalGridLayout: CompositionalLayoutSectionFactory {
heightDimension: .estimated(verticalGroupHeight)
),
subitems: horizontalGroups
).then {
$0.interItemSpacing = .fixed(lineSpacing)
)
group.interItemSpacing = .fixed(lineSpacing)

let section = NSCollectionLayoutSection(group: group)
if let sectionInsets {
section.contentInsets = sectionInsets
}

if let visibleItemsInvalidationHandler {
section.visibleItemsInvalidationHandler = visibleItemsInvalidationHandler
}

return NSCollectionLayoutSection(group: group).then {
if let sectionInsets = sectionInsets {
$0.contentInsets = sectionInsets
}

if let visibleItemsInvalidationHandler {
$0.visibleItemsInvalidationHandler = visibleItemsInvalidationHandler
}

$0.boundarySupplementaryItems = [
layoutHeaderItem(section: context.section, sizeStorage: context.sizeStorage)?.then {
if let headerPinToVisibleBounds {
$0.pinToVisibleBounds = headerPinToVisibleBounds
}
},
layoutFooterItem(section: context.section, sizeStorage: context.sizeStorage)?.then {
if let footerPinToVisibleBounds {
$0.pinToVisibleBounds = footerPinToVisibleBounds
}
},
].compactMap { $0 }
let headerItem = layoutHeaderItem(section: context.section, sizeStorage: context.sizeStorage)
if let headerPinToVisibleBounds {
headerItem?.pinToVisibleBounds = headerPinToVisibleBounds
}

let footerItem = layoutFooterItem(section: context.section, sizeStorage: context.sizeStorage)
if let footerPinToVisibleBounds {
footerItem?.pinToVisibleBounds = footerPinToVisibleBounds
}

section.boundarySupplementaryItems = [
headerItem,
footerItem,
].compactMap { $0 }

return section
}
}

Expand Down
44 changes: 23 additions & 21 deletions Sources/KarrotListKit/Layout/VerticalLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,34 @@ public struct VerticalLayout: CompositionalLayoutSectionFactory {
heightDimension: .estimated(context.environment.container.contentSize.height)
),
subitems: layoutCellItems(cells: context.section.cells, sizeStorage: context.sizeStorage)
).then {
$0.interItemSpacing = .fixed(spacing)
)
group.interItemSpacing = .fixed(spacing)

let section = NSCollectionLayoutSection(group: group)
if let sectionInsets {
section.contentInsets = sectionInsets
}

return NSCollectionLayoutSection(group: group).then {
if let sectionInsets = sectionInsets {
$0.contentInsets = sectionInsets
}
if let visibleItemsInvalidationHandler {
section.visibleItemsInvalidationHandler = visibleItemsInvalidationHandler
}

if let visibleItemsInvalidationHandler {
$0.visibleItemsInvalidationHandler = visibleItemsInvalidationHandler
}
let headerItem = layoutHeaderItem(section: context.section, sizeStorage: context.sizeStorage)
if let headerPinToVisibleBounds {
headerItem?.pinToVisibleBounds = headerPinToVisibleBounds
}

$0.boundarySupplementaryItems = [
layoutHeaderItem(section: context.section, sizeStorage: context.sizeStorage)?.then {
if let headerPinToVisibleBounds {
$0.pinToVisibleBounds = headerPinToVisibleBounds
}
},
layoutFooterItem(section: context.section, sizeStorage: context.sizeStorage)?.then {
if let footerPinToVisibleBounds {
$0.pinToVisibleBounds = footerPinToVisibleBounds
}
},
].compactMap { $0 }
let footerItem = layoutFooterItem(section: context.section, sizeStorage: context.sizeStorage)
if let footerPinToVisibleBounds {
footerItem?.pinToVisibleBounds = footerPinToVisibleBounds
}

section.boundarySupplementaryItems = [
headerItem,
footerItem,
].compactMap { $0 }

return section
}
}

Expand Down
3 changes: 1 addition & 2 deletions Sources/KarrotListKit/Section.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import UIKit

import DifferenceKit
import Then

/// The `Section` that representing a UICollectionView Section.
///
Expand All @@ -14,7 +13,7 @@ import Then
///
/// - Note: The layout depends on NSCollectionLayoutSection and
/// you must set the layout through the withSectionLayout modifier.
public struct Section: Identifiable, ListingViewEventHandler, Then {
public struct Section: Identifiable, ListingViewEventHandler {

/// The identifier for `Section`
public let id: AnyHashable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ final class UICollectionComponentReusableView: UICollectionReusableView, Compone
onSizeChanged?(size)
}

return attributes.with {
$0.frame.size = size
}
attributes.frame.size = size

return attributes
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public final class UICollectionViewComponentCell: UICollectionViewCell, Componen
onSizeChanged?(size)
}

return attributes.with {
$0.frame.size = size
}
attributes.frame.size = size

return attributes
}
}
Loading
Loading