Skip to content

Commit

Permalink
[NT-730] Pledge screen header (#1033)
Browse files Browse the repository at this point in the history
  • Loading branch information
Scollaco authored Jan 17, 2020
1 parent 4aba0cf commit aa73551
Show file tree
Hide file tree
Showing 97 changed files with 185 additions and 778 deletions.
379 changes: 90 additions & 289 deletions Kickstarter-iOS/Views/Controllers/PledgeDescriptionViewController.swift

Large diffs are not rendered by default.

This file was deleted.

27 changes: 0 additions & 27 deletions Kickstarter-iOS/Views/Controllers/PledgeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -480,33 +480,6 @@ extension PledgeViewController: PledgeShippingLocationViewControllerDelegate {
}
}

// MARK: - RewardPledgeTransitionAnimatorDelegate

extension PledgeViewController: RewardPledgeTransitionAnimatorDelegate {
func beginTransition(_ operation: UINavigationController.Operation) {
self.descriptionViewController.beginTransition(operation)
}

func snapshotData(withContainerView view: UIView) -> RewardPledgeTransitionSnapshotData? {
return self.descriptionViewController.snapshotData(withContainerView: view)
}

func destinationFrameData(withContainerView view: UIView) -> RewardPledgeTransitionDestinationFrameData? {
guard let (destination, mask) = self.descriptionViewController
.destinationFrameData(withContainerView: view)
else { return nil }

let offsetDestination = destination
.offsetBy(dx: 0, dy: -self.view.safeAreaInsets.top)

return (offsetDestination, mask)
}

func endTransition(_ operation: UINavigationController.Operation) {
self.descriptionViewController.endTransition(operation)
}
}

// MARK: - PledgeViewControllerMessageDisplaying

extension PledgeViewController: PledgeViewControllerMessageDisplaying {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,9 @@ final class RewardPledgeNavigationController: UINavigationController {
override func viewDidLoad() {
super.viewDidLoad()

_ = self
|> \.delegate .~ self

_ = self.navigationBar
?|> \.barTintColor .~ .ksr_grey_300
?|> \.isTranslucent .~ false
?|> \.shadowImage .~ UIImage()
}
}

extension RewardPledgeNavigationController: UINavigationControllerDelegate {
func navigationController(
_: UINavigationController,
animationControllerFor operation: UINavigationController.Operation,
from fromVC: UIViewController,
to toVC: UIViewController
) -> UIViewControllerAnimatedTransitioning? {
switch (operation, fromVC, toVC) {
case (.push, is RewardPledgeTransitionAnimatorDelegate, is PledgeViewController):
return RewardPledgePushTransitionAnimator()
case (.pop, is PledgeViewController, is RewardPledgeTransitionAnimatorDelegate):
return nil
default:
return nil
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -299,55 +299,6 @@ extension RewardsCollectionViewController: RewardCellDelegate {
}
}

// MARK: - RewardPledgeTransitionAnimatorDelegate

extension RewardsCollectionViewController: RewardPledgeTransitionAnimatorDelegate {
func beginTransition(_: UINavigationController.Operation) {
self.selectedRewardCell()?.alpha = 0
}

func snapshotData(withContainerView view: UIView) -> RewardPledgeTransitionSnapshotData? {
guard
let cell = self.selectedRewardCell(),
let snapshotView = cell.rewardCardContainerView.snapshotView(afterScreenUpdates: false),
let sourceFrame = cell.rewardCardContainerView.superview?
.convert(cell.rewardCardContainerView.frame, to: view)
else { return nil }

return (snapshotView, sourceFrame, snapshotView.bounds)
}

func destinationFrameData(withContainerView _: UIView) -> RewardPledgeTransitionDestinationFrameData? {
guard
let cell = self.selectedRewardCell(),
let frame = cell.rewardCardContainerView.superview?
.convert(cell.rewardCardContainerView.frame, to: self.view)
else { return nil }

return (frame, CGRect(origin: .zero, size: frame.size))
}

func endTransition(_: UINavigationController.Operation) {
self.selectedRewardCell()?.alpha = 1
}

private func selectedRewardCell() -> RewardCell? {
guard
let selectedReward = self.viewModel.outputs.selectedReward(),
let cell = self.cell(for: selectedReward)
else { return nil }

return cell
}

private func cell(for reward: Reward) -> RewardCell? {
return self.collectionView.visibleCells
.compactMap { $0 as? RewardCell }
.filter { cell in cell.currentReward(is: reward) }
.first
}
}

// MARK: Styles

private var collectionViewStyle: CollectionViewStyle = { collectionView -> UICollectionView in
Expand Down
Loading

0 comments on commit aa73551

Please sign in to comment.