Skip to content

Commit

Permalink
Merge pull request #111 from VAndrJ/develop
Browse files Browse the repository at this point in the history
Swift 6 errors fixes.
  • Loading branch information
VAndrJ authored Sep 7, 2024
2 parents 89fab00 + 6217149 commit 3df649b
Show file tree
Hide file tree
Showing 25 changed files with 385 additions and 132 deletions.
22 changes: 11 additions & 11 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ PODS:
- Texture/Video (3.2.0):
- Texture/Core
- VANavigator (2.0.2)
- VATextureKit (2.2.1):
- VATextureKit (2.3.0):
- Texture (~> 3.2.0)
- VATextureKitSpec (= 2.2.1)
- VATextureKitCombine (2.2.1)
- VATextureKitRx (2.2.1):
- VATextureKitSpec (= 2.3.0)
- VATextureKitCombine (2.3.0)
- VATextureKitRx (2.3.0):
- Differentiator (~> 5.0.0)
- RxCocoa (~> 6.5.0)
- RxSwift (~> 6.5.0)
- Texture (~> 3.2.0)
- VATextureKit (= 2.2.1)
- VATextureKitSpec (= 2.2.1)
- VATextureKitSpec (2.2.1):
- VATextureKit (= 2.3.0)
- VATextureKitSpec (= 2.3.0)
- VATextureKitSpec (2.3.0):
- Texture (~> 3.2.0)

DEPENDENCIES:
Expand Down Expand Up @@ -109,10 +109,10 @@ SPEC CHECKSUMS:
Swiftional: 8eadd8011de7ef752768ce8ed8bf6ff03c95f74c
Texture: 61e86ea2ee124f545be40293b54b5b8986006da2
VANavigator: 0a02a9fb322c4bf25147deaea1bce0475a3b835d
VATextureKit: a434aa5ee968bac04ec66c2b37bbdecf516ddf68
VATextureKitCombine: 8fb8d87c73075f1041c10d7a0a3139c6fc156cfc
VATextureKitRx: 8cc6d264c75d66dc8fdb271e19e602e855778be7
VATextureKitSpec: 46188f698da9b18bf6d1c0cb4c4dd60213443a98
VATextureKit: b5f352b79ed7f9907dcbbcc614d1eaa4f344d4d8
VATextureKitCombine: 902be44c1c7d00beeaf9da820c10387d32ee411f
VATextureKitRx: dad947d5f6bb65662f82246e909cd69d3a6908e6
VATextureKitSpec: f135db116736886ed36d9bdbacf07321f733137b

PODFILE CHECKSUM: 3d7fafaca1f450dcfe13429c6dd34801506b139f

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class VAContainerButtonNodeSnapshotTests: XCTestCase {
}

func test_node_insets() {
let sut = VAContainerButtonNode(child: childNode, insets: UIEdgeInsets(all: 16))
let sut = VAContainerButtonNode(child: childNode, insets: .init(all: 16))
sut.backgroundColor = .orange

assertNodeSnapshot(matching: sut, size: .auto)
Expand Down
8 changes: 4 additions & 4 deletions Example/VATextureKit/Navigator/AppNavigator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ class AppScreenFactory: NavigatorScreenFactory {
return VAViewController(node: LinkTextScreenNode())
case _ as CountingTextNodeNavigationIdentity:
return VAViewController(node: CountingTextNodeController())
case _ as DynamicHeightGridListNavigationIdentity:
return VAViewController(node: DynamicHeightGridListScreenNode())
// case _ as DynamicHeightGridListNavigationIdentity:
// return VAViewController(node: DynamicHeightGridListScreenNode())
case _ as ShimmersNavigationIdentity:
return VAViewController(node: ShimmersScreenNode())
case _ as SpecBasedGridListNavigationIdentity:
Expand All @@ -125,8 +125,8 @@ class AppScreenFactory: NavigatorScreenFactory {
return MainNodeController(navigator: navigator)
case _ as EmitterLayerAnimationNavigationIdentity:
return VAViewController(node: EmitterLayerAnimationScreenNode())
case _ as SelfSizingListNavigationIdentity:
return VAViewController(node: SelfSizingListContainerScreenNode())
// case _ as SelfSizingListNavigationIdentity:
// return VAViewController(node: SelfSizingListContainerScreenNode())
case _ as UIViewSizedContainerNavigationIdentity:
return VAViewController(node: UIViewSizedContainerScreenNode())
case _ as UIViewContainerNavigationIdentity:
Expand Down
27 changes: 18 additions & 9 deletions Example/VATextureKit/Nodes/PagerIndicatorNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,32 @@ import RxSwift
import RxCocoa

final class PagerIndicatorNode<Item: Equatable & IdentifiableType>: VASizedViewWrapperNode<UIPageControl>, @unchecked Sendable {
private let bag = DisposeBag()
private weak var pagerNode: VAPagerNode<Item>?
private var bag = DisposeBag()
private weak var pagerNode: VAPagerNode<Item>? {
didSet {
ensureOnMainActor {
bag = DisposeBag()
bind()
}
}
}

convenience init(pagerNode: VAPagerNode<Item>) {
convenience init(pagerNode: @MainActor @escaping () -> VAPagerNode<Item>) {
self.init(childGetter: { UIPageControl() }, sizing: .viewSize)

self.pagerNode = pagerNode
ensureOnMainActor {
self.pagerNode = pagerNode()
}
}

override func viewDidLoad() {
super.viewDidLoad()

child.addTarget(
self,
action: #selector(onChange(_:)),
for: .valueChanged
)
bind()
}

Expand All @@ -34,11 +48,6 @@ final class PagerIndicatorNode<Item: Equatable & IdentifiableType>: VASizedViewW

@MainActor
private func bind() {
child.addTarget(
self,
action: #selector(onChange(_:)),
for: .valueChanged
)
pagerNode?.indexObs
.map { Int($0 + 0.5) }
.debounce(.milliseconds(100), scheduler: MainScheduler.asyncInstance)
Expand Down
18 changes: 10 additions & 8 deletions Example/VATextureKit/Screens/Components/PagerScreenNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,20 @@ extension PagerScreenNode {
}

final class PagerScreenNode: ScreenNode, @unchecked Sendable {
private lazy var pagerNode = VAPagerNode(data: .init(
itemsObs: viewModel.pagerItemsObs,
cellGetter: mapToCell(viewModel:),
isCircular: true
))
private lazy var pagerNode = VAMainActorWrapperNode { [viewModel] in
VAPagerNode(data: .init(
itemsObs: viewModel.pagerItemsObs,
cellGetter: mapToCell(viewModel:),
isCircular: true
))
}
private lazy var previousButtonNode = HapticButtonNode(title: "Previous")
.minConstrained(size: .init(same: 44))
private lazy var nextButtonNode = HapticButtonNode(title: "Next")
.minConstrained(size: .init(same: 44))
private lazy var randomizeButtonNode = HapticButtonNode(title: "Randomize")
.minConstrained(size: .init(same: 44))
private lazy var pagerIndicatorNode = PagerIndicatorNode(pagerNode: pagerNode)
private lazy var pagerIndicatorNode = PagerIndicatorNode(pagerNode: { [pagerNode] in pagerNode.child })
private let viewModel: PagerScreenNodeViewModel

init(viewModel: PagerScreenNodeViewModel) {
Expand Down Expand Up @@ -67,8 +69,8 @@ final class PagerScreenNode: ScreenNode, @unchecked Sendable {
}

override func bind() {
previousButtonNode.onTap = self ?> { $0.pagerNode.previous() }
nextButtonNode.onTap = self ?> { $0.pagerNode.next() }
previousButtonNode.onTap = self ?> { $0.pagerNode.child.previous() }
nextButtonNode.onTap = self ?> { $0.pagerNode.child.next() }
randomizeButtonNode.onTap = self ?>> { $0.viewModel.generateRandomPagerItems }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@ import VATextureKitRx
struct SlidingTabBarNavigationIdentity: DefaultNavigationIdentity {}

final class SlidingTabBarScreenNode: ScreenNode, @unchecked Sendable {
private lazy var pagerNode = VAPagerNode(context: .init(
items: (0...5).map { PagerCardCellNodeViewModel(title: "Title \($0)", description: "Description \($0)") },
cellGetter: mapToCell(viewModel:)
))
private lazy var pagerNode = VAMainActorWrapperNode {
VAPagerNode(context: .init(
items: (0...5).map { PagerCardCellNodeViewModel(title: "Title \($0)", description: "Description \($0)") },
cellGetter: mapToCell(viewModel:)
))
}
private lazy var topTabBarNode = VASlidingTabBarNode(context: .init(
data: (0...5).map { "Title".repeating($0) },
spacing: 16,
contentInset: .init(horizontal: 16),
indicatorInset: 8,
color: { $0.systemPurple },
item: { data, onSelect in VASlidingTabTextNode(data: data, onSelect: onSelect) },
indexObs: pagerNode.indexObs,
onSelect: { [weak pagerNode] in pagerNode?.scroll(to: $0) }
indexObs: { [pagerNode] in pagerNode.child.indexObs },
onSelect: { [weak pagerNode] in pagerNode?.child.scroll(to: $0) }
))
private lazy var floatingTabBarNode = VASlidingTabBarNode(context: .init(
data: (0...5).map { "Title".repeating($0) },
Expand All @@ -32,8 +34,8 @@ final class SlidingTabBarScreenNode: ScreenNode, @unchecked Sendable {
indicatorInset: 8,
color: { $0.systemBlue },
item: { data, onSelect in VASlidingTabTextNode(data: data, onSelect: onSelect) },
indexObs: pagerNode.indexObs,
onSelect: { [weak pagerNode] in pagerNode?.scroll(to: $0) }
indexObs: { [pagerNode] in pagerNode.child.indexObs },
onSelect: { [weak pagerNode] in pagerNode?.child.scroll(to: $0) }
)).apply {
$0.cornerCurve = .continuous
$0.borderWidth = 1
Expand Down Expand Up @@ -80,8 +82,8 @@ final class SlidingTabBarScreenNode: ScreenNode, @unchecked Sendable {
}

override func bind() {
previousButtonNode.onTap = self ?> { $0.pagerNode.previous() }
nextButtonNode.onTap = self ?> { $0.pagerNode.next() }
previousButtonNode.onTap = self ?> { $0.pagerNode.child.previous() }
nextButtonNode.onTap = self ?> { $0.pagerNode.child.next() }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ final class VASlidingTabTextNode: DisplayNode, VASlidingTab, @unchecked Sendable
let buttonNode = VAButtonNode()

private let maskLayer = CAShapeLayer()
private let onSelect: @MainActor () -> Void
private let onSelect: @MainActor @Sendable () -> Void

required init(data: String, onSelect: @MainActor @escaping () -> Void) {
required init(data: String, onSelect: @MainActor @escaping @Sendable() -> Void) {
self.onSelect = onSelect
self.titleNode = VATextNode(text: data)
self.topTitleNode = VATextNode(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ final class ColumnLayoutScreenNode: ScrollScreenNode, @unchecked Sendable {
)

init() {
super.init(context: .init(contentInset: UIEdgeInsets(vertical: 24)))
super.init(context: .init(contentInset: .init(vertical: 24)))
}

override func scrollLayoutSpecThatFits(constrainedSize: ASSizeRange) -> ASLayoutSpec {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ final class RowLayoutScreenNode: ScrollScreenNode, @unchecked Sendable {
)

init() {
super.init(context: .init(contentInset: UIEdgeInsets(vertical: 24)))
super.init(context: .init(contentInset: .init(vertical: 24)))
}

override func scrollLayoutSpecThatFits(constrainedSize: ASSizeRange) -> ASLayoutSpec {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,44 @@ extension CollectionListHeaderFooterScreenNode {
}

final class CollectionListHeaderFooterScreenNode: ScreenNode, @unchecked Sendable {
private lazy var leftListNode = VAListNode(
context: .init(
listDataObs: viewModel.listDataObs,
cellGetter: mapToCell(viewModel:),
headerGetter: { $0.model.headerViewModel.flatMap(mapToCell(viewModel:)) },
footerGetter: { $0.model.footerViewModel.flatMap(mapToCell(viewModel:)) },
moveItem: viewModel.moveItem(source:destination:)
),
layoutData: .init(
layout: .default(parameters: .init(
minimumLineSpacing: 8,
sectionHeadersPinToVisibleBounds: true,
sectionFootersPinToVisibleBounds: true
))
private lazy var leftListNode = VAMainActorWrapperNode { [viewModel] in
VAListNode(
context: .init(
listDataObs: viewModel.listDataObs,
cellGetter: mapToCell(viewModel:),
headerGetter: { $0.model.headerViewModel.flatMap(mapToCell(viewModel:)) },
footerGetter: { $0.model.footerViewModel.flatMap(mapToCell(viewModel:)) },
moveItem: viewModel.moveItem(source:destination:)
),
layoutData: .init(
layout: .default(parameters: .init(
minimumLineSpacing: 8,
sectionHeadersPinToVisibleBounds: true,
sectionFootersPinToVisibleBounds: true
))
)
)
).flex(basisPercent: 50)
private lazy var rightListNode = VAListNode(
context: .init(
listDataObs: viewModel.listDataObs,
cellGetter: mapToCell(viewModel:),
headerGetter: { $0.model.headerViewModel.flatMap(mapToCell(viewModel:)) },
footerGetter: { $0.model.footerViewModel.flatMap(mapToCell(viewModel:)) },
moveItem: viewModel.moveItem(source:destination:)
),
layoutData: .init(
sizing: .vertical(columns: 2, ratio: 1),
layout: .default(parameters: .init(
minimumLineSpacing: 8,
minimumInteritemSpacing: 8,
sectionHeadersPinToVisibleBounds: true,
sectionFootersPinToVisibleBounds: true
))
}.flex(basisPercent: 50)
private lazy var rightListNode = VAMainActorWrapperNode { [viewModel] in
VAListNode(
context: .init(
listDataObs: viewModel.listDataObs,
cellGetter: mapToCell(viewModel:),
headerGetter: { $0.model.headerViewModel.flatMap(mapToCell(viewModel:)) },
footerGetter: { $0.model.footerViewModel.flatMap(mapToCell(viewModel:)) },
moveItem: viewModel.moveItem(source:destination:)
),
layoutData: .init(
sizing: .vertical(columns: 2, ratio: 1),
layout: .default(parameters: .init(
minimumLineSpacing: 8,
minimumInteritemSpacing: 8,
sectionHeadersPinToVisibleBounds: true,
sectionFootersPinToVisibleBounds: true
))
)
)
).flex(basisPercent: 50)
}.flex(basisPercent: 50)

let viewModel: CollectionListHeaderFooterViewModel

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2023 Volodymyr Andriienko. All rights reserved.
//

/*
import VATextureKitRx

struct DynamicHeightGridListNavigationIdentity: DefaultNavigationIdentity {}
Expand Down Expand Up @@ -41,3 +42,4 @@ final class DynamicHeightGridListScreenNode: ScreenNode, @unchecked Sendable {
listNode.backgroundColor = theme.systemBackground
}
}
*/
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2023 Volodymyr Andriienko. All rights reserved.
//

/*
import VATextureKitRx

struct SelfSizingListNavigationIdentity: DefaultNavigationIdentity {}
Expand Down Expand Up @@ -135,3 +136,4 @@ private class _ExampleCardCellNodeViewModel: CellViewModel {
self.title = title
}
}
*/
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,27 @@ import RxCocoa
struct SpecBasedGridListNavigationIdentity: DefaultNavigationIdentity {}

final class SpecBasedGridListScreenNode: ScreenNode, @unchecked Sendable {
private lazy var listNode = VAListNode(
data: .init(
listDataObs: listDataObs,
cellGetter: TagCellNode.init(viewModel:)
),
layoutData: .init(
contentInset: UIEdgeInsets(all: 16),
layout: .delegate(VASpecGridListLayoutDelegate(info: .init(
scrollableDirection: .vertical,
itemsConfiguration: .init(
spacing: 8,
main: .center,
alignContent: .center,
line: 8
),
sectionsConfiguration: .init(cross: .stretch)
)))
private lazy var listNode = VAMainActorWrapperNode { [listDataObs] in
VAListNode(
data: .init(
listDataObs: listDataObs,
cellGetter: TagCellNode.init(viewModel:)
),
layoutData: .init(
contentInset: .init(all: 16),
layout: .delegate(VASpecGridListLayoutDelegate(info: .init(
scrollableDirection: .vertical,
itemsConfiguration: .init(
spacing: 8,
main: .center,
alignContent: .center,
line: 8
),
sectionsConfiguration: .init(cross: .stretch)
)))
)
)
)
}

@Obs.Relay(value: [])
private var listDataObs: Observable<[TagCellNodeViewModel]>
Expand Down
Loading

0 comments on commit 3df649b

Please sign in to comment.