Skip to content

Commit

Permalink
[NT-1295] Add UITableView and data source to ManagePledgeViewControll…
Browse files Browse the repository at this point in the history
…er (#1213)

* [NT-636] "Fix" button on Manage Pledge screen for errored backings (#982)

* Fix button on errored pledges

* Tests

* Formatting

* Screenshot tests

* Rerecording tests

* formatting

* [NT-636] "Fix" button on Manage Pledge screen for errored backings (#982)

* Fix button on errored pledges

* Tests

* Formatting

* Screenshot tests

* Rerecording tests

* formatting

* [NT-635] Update "fix" state of CTA button (#993)

* Added missing strings

* [NT-634] Errored pledges top cell (#991)

* [NT-635] CTA fix button navigation (#1027)

* [NT-973] Fix payment icon error (#1104)

* fix image shown

* commit adds fixIconHidden output and tests this output. Also corrects some tests

* fix test

* snapshot

* renames erroredPledge to isErrored

* swift format

* fixes tests errors

* Revert "fixes tests errors"

This reverts commit 32cea0f.

* uses isErrored

* pr feedback

* [NT-974, NT-637] Navigate to fix pledge screen/ Fix Pledge state (#1109)

* fix image shown

* commit adds fixIconHidden output and tests this output. Also corrects some tests

* fix test

* snapshot

* renames erroredPledge to isErrored

* swift format

* fixes tests errors

* Revert "fixes tests errors"

This reverts commit 32cea0f.

* uses isErrored

* navigating to fix screen

* testing gotofixpledge output

* corrected merge and removed unused constant

* fix payment method copy

* testing pledgeContext

* seift format

* wip

* wip

* pr feedback

* swift format

* pr feedback

* swiftformat

* [NT-214] Fix pledge tracking events (#1128)

* wip- 2/3 events

* tests

* Should fix feature branch (#1141)

* should fix feature branch

* Update Library/ViewModels/PledgeViewModel.swift

pr feedback

Co-Authored-By: jgsamudio <jonathan2457@gmail.com>

* swift format

* Revert "swift format"

This reverts commit 89b6a0d.

* swift format

* Revert "swift format"

This reverts commit eb9261b.

* swift format

Co-authored-by: jgsamudio <jonathan2457@gmail.com>

* [NT-1072] Whitelist fix pledge tracking events for data lake (#1142)

* whitelisted tracking events

* swift format

* fix test

* pr feedback

* [NT-686] add pledge collection date query (#1140)

* wip - collection date feature complete

* tests passing

* swift format

* wip- refactor

* fix tests

* snapshots

* updated copy

* swift format

* pr feedback

* cache formatter

* swift format

* New snapshots

* [NT-1182] Fetch Backing for ManagePledgeViewController from GraphQL (#1174)

* Fetch Backing for ManagePledgeViewController from GraphQL

* Correct test names, use rawValue in GraphSchema

* Remove Argo import

* Put GraphBackingEnvelope back

* Fix snapshot tests

* Record snapshots from commandline

* [NT-1185] Configure CancePledgeViewController with GraphQL Backing (#1176)

* Configure CancePledge with GraphQL backing

* Update tests

* Fix merge error

* Record snapshots from commandline

* [NT-1183, NT-1184] Configure ManagePledgeViewController subviews with GraphQL Backing (#1188)

* Configure ManagePledgeSummaryView with GraphQL Backing

* Fix snapshot tests

* Fix tests

* Make reward optional

* Refactor, ensure all sub-vc's don't depend on Project directly

* Move test

* Put test back

* Remove coalesce

* Alphabetize

* Tuples -> Structs

* Convert to double during deserialization

* Fix tests

* Remove recordMode

* [NT-633] Errored Pledge Deeplink (#1178)

* Errored pledge deeplink

* RefTag tests

* Revert debug code

* Use correct navigation controller

* Present login modal when logged out during errored pledge deeplink

* Present login modal when logged out

* Update visibility modifiers

* Fix failing test

* [NT-650, NT-1135, NT-1052] Add Errored Pledges to badge count (#1193)

* Add errored pledges to badge count and refresh user on fix pledge

* Fix test, updating backings on user update

* Ensure errored backing are cleared, shipping amount is shown in summary

* Add test

* Add retry payment method behaviour

* ManagePledgeView loading state

* Don't un-hide rootStackView if backing fails to load

* Don't hide apple pay button in fix context

* Add pull-to-refresh on error

* [NT-1247] ManagePledgeViewController loading state (#1203)

* Add retry payment method behaviour

* ManagePledgeView loading state

* Don't un-hide rootStackView if backing fails to load

* Don't hide apple pay button in fix context

* Show apple pay button when changing payment method

* Test commit - will revert

* Revert "Test commit - will revert"

This reverts commit 5e196f0.

* Fix layout

* Fix merge error

* Fix project file

* Hide rightBarButtonItem when view is errored

* ignoreValues instead

* Refactor to instantiate ManagePledgeViewModel with params only

* Fix ManagePledgeViewBackingEnvelopeTests

* [NT-1274] Pull to refresh on failure to fetch Project/Backing (#1206)

* Add retry payment method behaviour

* ManagePledgeView loading state

* Don't un-hide rootStackView if backing fails to load

* Don't hide apple pay button in fix context

* Add pull-to-refresh on error

* Fix layout

* Fix merge error

* Hide rightBarButtonItem when view is errored

* ignoreValues instead

* Fix tests

* Fix tests

* Consolidate shared functions, prefer filterMap

* Refactor ManagePledgeViewController to use a table view

* Fix layout issues with card view

* Add data source test

* Fix presentation crash, only show payment method section if a credit card was deserialized

* Allow optional backing param

* Remove logEvents

* Remove logEvents

* [NT-1269, NT-1270] Deprecate BackingViewController (#1212)

* Add retry payment method behaviour

* ManagePledgeView loading state

* Don't un-hide rootStackView if backing fails to load

* Don't hide apple pay button in fix context

* Add pull-to-refresh on error

* Fix layout

* Fix merge error

* Hide rightBarButtonItem when view is errored

* ignoreValues instead

* Refactor to instantiate ManagePledgeViewModel with params only

* Fix ManagePledgeViewBackingEnvelopeTests

* Fix tests

* Fix tests

* Consolidate shared functions, prefer filterMap

* Fix presentation crash, only show payment method section if a credit card was deserialized

* Allow optional backing param

* Remove logEvents

* Remove unused code

* [NT-1223, NT-1296] Reward Add-Ons GraphQL integration (#1216)

* Map add-on data to Reward

* Add quantity to reward title

* Pass quantity through

* Add boolean for isAddOn

* Move ID

* Add tests

* Set timezone in unit test

* Add test for query

* [NT-1298] Manage Pledge Shipping Disclaimer View (#1217)

* Add disclaimer view to manage pledge view

* Remove text color from style

* Update snapshots

* Add snapshots

* Hide pledge disclaimer view when no shipping or user is creator

* Update snapshots

* Fix Library tests

* [NT-1297] Add bonus support (#1218)

* Updates to reward received vc

* Add tests

* Add context-specific string

* Add bonus amount

* Update query

* Fix query

* Fix query

* Configure RewardCardView with context, hide bonus on no reward, fix corner radius

* Fix tests

* Fix snapshot test

* Layout fix

Co-authored-by: Isabel Barrera <isabel@kickstarter.com>
Co-authored-by: Nino Collaco <scollaco@gmail.com>
Co-authored-by: Isabel Barrera <ifbarrera@me.com>
Co-authored-by: christella <cdolm92@gmail.com>
Co-authored-by: jgsamudio <jonathan2457@gmail.com>
  • Loading branch information
6 people authored Jun 12, 2020
1 parent 38f452a commit 05d45d1
Show file tree
Hide file tree
Showing 191 changed files with 2,173 additions and 1,079 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "calendar-icon.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
34 changes: 34 additions & 0 deletions Kickstarter-iOS/DataSources/ManagePledgeDataSource.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import Foundation
import KsApi
import Library
import Prelude
import UIKit

internal final class ManagePledgeDataSource: ValueCellDataSource {
internal enum Section: Int {
case rewards
}

internal func load(project: Project, rewards: [Reward]) {
self.clearValues()

let values = rewards.map { reward -> RewardCardViewData in
(project, reward, .manage)
}

self.set(
values: values,
cellClass: RewardTableViewCell.self,
inSection: Section.rewards.rawValue
)
}

internal override func configureCell(tableCell cell: UITableViewCell, withValue value: Any) {
switch (cell, value) {
case let (cell as RewardTableViewCell, value as RewardCardViewData):
cell.configureWith(value: value)
default:
assertionFailure("Unrecognized combo: \(cell), \(value).")
}
}
}
22 changes: 22 additions & 0 deletions Kickstarter-iOS/DataSources/ManagePledgeDataSourceTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Foundation
@testable import Kickstarter_Framework
@testable import KsApi
@testable import Library
import Prelude
import XCTest

final class ManagePledgeDataSourceTests: TestCase {
let dataSource = ManagePledgeDataSource()
let tableView = UITableView()

func testLoadDataIntoDataSource() {
let rewards = [Reward.template, .template]
let project = Project.template
|> \.rewards .~ rewards

self.dataSource.load(project: project, rewards: rewards)

XCTAssertEqual(1, self.dataSource.numberOfSections(in: self.tableView))
XCTAssertEqual(2, self.dataSource.numberOfItems(in: 0))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Prelude
import UIKit

final class RewardsCollectionViewDataSource: ValueCellDataSource {
func load(_ values: [(Project, Either<Reward, Backing>)]) {
func load(_ values: [RewardCardViewData]) {
self.set(
values: values,
cellClass: RewardCell.self,
Expand All @@ -15,7 +15,7 @@ final class RewardsCollectionViewDataSource: ValueCellDataSource {

override func configureCell(collectionCell cell: UICollectionViewCell, withValue value: Any) {
switch (cell, value) {
case let (cell as RewardCell, value as (Project, Either<Reward, Backing>)):
case let (cell as RewardCell, value as RewardCardViewData):
cell.configureWith(value: value)
default:
assertionFailure("Unrecognized (cell, value) combo.")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@testable import Kickstarter_Framework
@testable import KsApi
import Library
import Prelude
import XCTest

Expand All @@ -12,7 +13,7 @@ final class RewardsCollectionViewDataSourceTests: XCTestCase {

func testLoadRewards() {
let project = Project.cosmicSurgery
let rewardsData = project.rewards.map { (project, Either<Reward, Backing>.left($0)) }
let rewardsData = project.rewards.map { reward -> RewardCardViewData in (project, reward, .pledge) }

self.dataSource.load(rewardsData)

Expand Down
2 changes: 1 addition & 1 deletion Kickstarter-iOS/Views/Cells/RewardCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ final class RewardCell: UICollectionViewCell, ValueCell {
|> scrollViewStyle
}

internal func configureWith(value: (project: Project, reward: Either<Reward, Backing>)) {
internal func configureWith(value: RewardCardViewData) {
self.rewardCardContainerView.configure(with: value)
}

Expand Down
73 changes: 73 additions & 0 deletions Kickstarter-iOS/Views/Cells/RewardTableViewCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import Foundation
import KsApi
import Library
import Prelude
import ReactiveSwift

final class RewardTableViewCell: UITableViewCell, ValueCell {
// MARK: - Properties

private lazy var containerView: UIView = { UIView(frame: .zero) }()
private lazy var rewardCardView: RewardCardView = { RewardCardView(frame: .zero) }()

override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)

self.configureViews()
self.bindViewModel()
}

required init?(coder _: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

// MARK: - Functions

private func configureViews() {
_ = (self.containerView, self.contentView)
|> ksr_addSubviewToParent()
|> ksr_constrainViewToMarginsInParent()

_ = (self.rewardCardView, self.containerView)
|> ksr_addSubviewToParent()
|> ksr_constrainViewToMarginsInParent(priority: UILayoutPriority(rawValue: 999))
}

override func layoutSubviews() {
super.layoutSubviews()

self.separatorInset = .init(leftRight: self.frame.width / 2)
}

override func bindStyles() {
super.bindStyles()

_ = self.contentView
|> contentViewStyle

_ = self.containerView
|> containerViewStyle
}

internal func configureWith(value: RewardCardViewData) {
self.rewardCardView.configure(with: value)

self.contentView.setNeedsLayout()
self.contentView.layoutIfNeeded()
}
}

// MARK: - Styles

private let containerViewStyle: ViewStyle = { (view: UIView) in
view
|> checkoutWhiteBackgroundStyle
|> roundedStyle(cornerRadius: Styles.grid(3))
|> \.layoutMargins .~ .init(all: Styles.grid(3))
}

private let contentViewStyle: ViewStyle = { (view: UIView) in
view
|> checkoutBackgroundStyle
|> \.layoutMargins .~ .init(leftRight: Styles.grid(3))
}
78 changes: 0 additions & 78 deletions Kickstarter-iOS/Views/Controllers/ManagePledgeRewardView.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -228,5 +228,5 @@ private let totalLabelStyle: LabelStyle = { label in
|> \.textColor .~ UIColor.black
|> \.font .~ UIFont.ksr_subhead().bolded
|> \.adjustsFontForContentSizeCategory .~ true
|> \.text %~ { _ in Strings.Total_amount() }
|> \.text %~ { _ in Strings.Total() }
}
Loading

0 comments on commit 05d45d1

Please sign in to comment.