-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NT-205] Manage pledge reward section (#868)
- Loading branch information
Showing
36 changed files
with
353 additions
and
124 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
Kickstarter-iOS/Views/Controllers/ManagePledgeRewardView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import KsApi | ||
import Library | ||
import Prelude | ||
import UIKit | ||
|
||
final class ManagePledgeRewardView: UIView { | ||
// MARK: - Properties | ||
|
||
private lazy var rewardView: RewardCardView = { | ||
RewardCardView(frame: .zero) | ||
}() | ||
|
||
private lazy var rootStackView: UIStackView = { UIStackView(frame: .zero) }() | ||
private lazy var titleLabel: UILabel = { UILabel(frame: .zero) }() | ||
|
||
// MARK: - Life cycle | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
|
||
self.configureViews() | ||
self.bindStyles() | ||
} | ||
|
||
required init?(coder _: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
// MARK: - Configuration | ||
|
||
public func configure(with value: (Project, Either<Reward, Backing>)) { | ||
self.rewardView.configure(with: value, context: .pledgeView) | ||
} | ||
|
||
private func configureViews() { | ||
_ = ([self.titleLabel, self.rewardView], self.rootStackView) | ||
|> ksr_addArrangedSubviewsToStackView() | ||
|
||
_ = (self.rootStackView, self) | ||
|> ksr_addSubviewToParent() | ||
|> ksr_constrainViewToEdgesInParent() | ||
} | ||
|
||
// MARK: - Styles | ||
|
||
override func bindStyles() { | ||
super.bindStyles() | ||
|
||
_ = self.rewardView | ||
|> checkoutBackgroundStyle | ||
|
||
_ = self.rootStackView | ||
|> checkoutCardStackViewStyle | ||
|
||
_ = self.titleLabel | ||
|> titleLabelStyle | ||
} | ||
} | ||
|
||
// MARK: - Styles | ||
|
||
private let titleLabelStyle: LabelStyle = { label in | ||
label | ||
|> checkoutTitleLabelStyle | ||
|> \.text %~ { _ in Strings.Selected_reward() } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
Kickstarter-iOS/Views/Controllers/ManagePledgeViewControllerTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
@testable import Kickstarter_Framework | ||
@testable import KsApi | ||
@testable import Library | ||
import Prelude | ||
import UIKit | ||
|
||
final class ManagePledgeViewControllerTests: TestCase { | ||
override func setUp() { | ||
super.setUp() | ||
|
||
AppEnvironment.pushEnvironment(mainBundle: Bundle.framework) | ||
UIView.setAnimationsEnabled(false) | ||
} | ||
|
||
override func tearDown() { | ||
AppEnvironment.popEnvironment() | ||
UIView.setAnimationsEnabled(true) | ||
|
||
super.tearDown() | ||
} | ||
|
||
func testView() { | ||
combos(Language.allLanguages, [Device.phone4_7inch, Device.pad]).forEach { language, device in | ||
withEnvironment(language: language) { | ||
let reward = Reward.template | ||
|> Reward.lens.shipping.enabled .~ true | ||
let backing = Backing.template | ||
|> Backing.lens.reward .~ reward | ||
let backedProject = Project.cosmicSurgery | ||
|> Project.lens.personalization.backing .~ backing | ||
|
||
let controller = ManagePledgeViewController.instantiate() | ||
controller.configureWith(project: backedProject, reward: Reward.template) | ||
let (parent, _) = traitControllers(device: device, orientation: .portrait, child: controller) | ||
parent.view.frame.size.height = 1_200 | ||
|
||
self.scheduler.run() | ||
|
||
FBSnapshotVerifyView(parent.view, identifier: "lang_\(language)_device_\(device)") | ||
} | ||
} | ||
} | ||
} |
19 changes: 0 additions & 19 deletions
19
Kickstarter-iOS/Views/Controllers/ManageViewPledgeViewControllerTests.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.