-
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.
- Loading branch information
1 parent
d4de842
commit c8df8f8
Showing
75 changed files
with
1,136 additions
and
41 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
Kickstarter-iOS/Assets.xcassets/icons/credit cards/Contents.json
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,6 @@ | ||
{ | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
Kickstarter-iOS/Assets.xcassets/icons/credit cards/icon--amex.imageset/Contents.json
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,15 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "icon--amex.pdf" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
}, | ||
"properties" : { | ||
"template-rendering-intent" : "original" | ||
} | ||
} |
Binary file added
BIN
+8.26 KB
Kickstarter-iOS/Assets.xcassets/icons/credit cards/icon--amex.imageset/icon--amex.pdf
Binary file not shown.
15 changes: 15 additions & 0 deletions
15
Kickstarter-iOS/Assets.xcassets/icons/credit cards/icon--diners.imageset/Contents.json
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,15 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "icon--diners.pdf" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
}, | ||
"properties" : { | ||
"template-rendering-intent" : "original" | ||
} | ||
} |
Binary file added
BIN
+9.69 KB
Kickstarter-iOS/Assets.xcassets/icons/credit cards/icon--diners.imageset/icon--diners.pdf
Binary file not shown.
15 changes: 15 additions & 0 deletions
15
Kickstarter-iOS/Assets.xcassets/icons/credit cards/icon--discover.imageset/Contents.json
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,15 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "icon--discover.pdf" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
}, | ||
"properties" : { | ||
"template-rendering-intent" : "original" | ||
} | ||
} |
Binary file added
BIN
+7.64 KB
...starter-iOS/Assets.xcassets/icons/credit cards/icon--discover.imageset/icon--discover.pdf
Binary file not shown.
15 changes: 15 additions & 0 deletions
15
Kickstarter-iOS/Assets.xcassets/icons/credit cards/icon--generic.imageset/Contents.json
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,15 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "icon--generic.pdf" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
}, | ||
"properties" : { | ||
"template-rendering-intent" : "original" | ||
} | ||
} |
Binary file added
BIN
+5.98 KB
Kickstarter-iOS/Assets.xcassets/icons/credit cards/icon--generic.imageset/icon--generic.pdf
Binary file not shown.
15 changes: 15 additions & 0 deletions
15
Kickstarter-iOS/Assets.xcassets/icons/credit cards/icon--jcb.imageset/Contents.json
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,15 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "icon--jcb.pdf" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
}, | ||
"properties" : { | ||
"template-rendering-intent" : "original" | ||
} | ||
} |
Binary file added
BIN
+50.1 KB
Kickstarter-iOS/Assets.xcassets/icons/credit cards/icon--jcb.imageset/icon--jcb.pdf
Binary file not shown.
15 changes: 15 additions & 0 deletions
15
Kickstarter-iOS/Assets.xcassets/icons/credit cards/icon--mastercard.imageset/Contents.json
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,15 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "icon--mastercard.pdf" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
}, | ||
"properties" : { | ||
"template-rendering-intent" : "original" | ||
} | ||
} |
Binary file added
BIN
+8.76 KB
...ter-iOS/Assets.xcassets/icons/credit cards/icon--mastercard.imageset/icon--mastercard.pdf
Binary file not shown.
15 changes: 15 additions & 0 deletions
15
Kickstarter-iOS/Assets.xcassets/icons/credit cards/icon--visa.imageset/Contents.json
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,15 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "icon--visa.pdf" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
}, | ||
"properties" : { | ||
"template-rendering-intent" : "original" | ||
} | ||
} |
Binary file added
BIN
+6.5 KB
Kickstarter-iOS/Assets.xcassets/icons/credit cards/icon--visa.imageset/icon--visa.pdf
Binary file not shown.
22 changes: 22 additions & 0 deletions
22
Kickstarter-iOS/DataSources/PaymentMethodsDataSource.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,22 @@ | ||
import KsApi | ||
import Library | ||
import UIKit | ||
|
||
final class PaymentMethodsDataSource: ValueCellDataSource { | ||
|
||
func load(creditCards: [GraphUserCreditCard.CreditCard]) { | ||
|
||
self.set(values: creditCards, | ||
cellClass: CreditCardCell.self, | ||
inSection: 0) | ||
} | ||
|
||
override func configureCell(tableCell cell: UITableViewCell, withValue value: Any) { | ||
switch (cell, value) { | ||
case let (cell as CreditCardCell, value as GraphUserCreditCard.CreditCard): | ||
cell.configureWith(value: value) | ||
default: | ||
assertionFailure("Unrecognized (cell, viewModel) combo.") | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
Kickstarter-iOS/DataSources/PaymentMethodsDataSourceTests.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,21 @@ | ||
import XCTest | ||
@testable import Kickstarter_Framework | ||
@testable import Library | ||
@testable import KsApi | ||
import Prelude | ||
|
||
internal final class PaymentMethodsDataSourceTests: XCTestCase { | ||
|
||
let dataSource = PaymentMethodsDataSource() | ||
let tableView = UITableView(frame: .zero) | ||
|
||
func testDataSource() { | ||
|
||
let cards = GraphUserCreditCard.template.storedCards.nodes | ||
self.dataSource.load(creditCards: cards) | ||
|
||
XCTAssertEqual(7, self.dataSource.tableView(self.tableView, numberOfRowsInSection: 0)) | ||
|
||
XCTAssertEqual("CreditCardCell", self.dataSource.reusableId(item: 0, section: 0)) | ||
} | ||
} |
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
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
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,50 @@ | ||
import KsApi | ||
import Library | ||
import Prelude | ||
import ReactiveSwift | ||
import UIKit | ||
|
||
internal final class CreditCardCell: UITableViewCell, ValueCell { | ||
|
||
private let viewModel: CreditCardCellViewModelType = CreditCardCellViewModel() | ||
|
||
@IBOutlet fileprivate weak var cardImageView: UIImageView! | ||
@IBOutlet fileprivate weak var cardNumberLabel: UILabel! | ||
@IBOutlet fileprivate weak var expirationDateLabel: UILabel! | ||
@IBOutlet fileprivate weak var separatorView: UIView! | ||
|
||
public func configureWith(value card: GraphUserCreditCard.CreditCard) { | ||
self.viewModel.inputs.configureWith(creditCard: card) | ||
} | ||
|
||
override func bindStyles() { | ||
super.bindStyles() | ||
|
||
_ = self.cardImageView | ||
|> \.contentMode .~ .scaleAspectFit | ||
|
||
_ = self.cardNumberLabel | ||
|> settingsTitleLabelStyle | ||
|
||
_ = self.expirationDateLabel | ||
|> settingsDescriptionLabelStyle | ||
|
||
_ = self.separatorView | ||
|> separatorStyle | ||
} | ||
|
||
override func bindViewModel() { | ||
super.bindViewModel() | ||
|
||
self.cardNumberLabel.rac.text = self.viewModel.outputs.cardNumberText | ||
self.expirationDateLabel.rac.text = self.viewModel.outputs.expirationDateText | ||
|
||
self.viewModel.outputs.cardImage | ||
.observeForUI() | ||
.observeValues { [weak self] image in | ||
guard let _self = self else { return } | ||
_ = _self.cardImageView | ||
?|> \.image .~ image | ||
} | ||
} | ||
} |
107 changes: 107 additions & 0 deletions
107
Kickstarter-iOS/Views/Controllers/PaymentMethodsViewController.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,107 @@ | ||
import KsApi | ||
import Library | ||
import Prelude | ||
import UIKit | ||
|
||
internal final class PaymentMethodsViewController: UIViewController { | ||
|
||
private let dataSource = PaymentMethodsDataSource() | ||
private let viewModel: PaymentMethodsViewModelType = PaymentMethodsViewModel() | ||
|
||
@IBOutlet private weak var headerLabel: UILabel! | ||
@IBOutlet private weak var tableView: UITableView! | ||
|
||
public static func instantiate() -> PaymentMethodsViewController { | ||
return Storyboard.Settings.instantiate(PaymentMethodsViewController.self) | ||
} | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
self.tableView.dataSource = self.dataSource | ||
self.tableView.delegate = self | ||
self.tableView.register(nib: .CreditCardCell) | ||
self.tableView.registerHeaderFooter(nib: .PaymentMethodsFooterView) | ||
|
||
self.viewModel.inputs.viewDidLoad() | ||
self.navigationItem.rightBarButtonItem = UIBarButtonItem( | ||
title: Strings.discovery_favorite_categories_buttons_edit(), | ||
style: .plain, | ||
target: self, | ||
action: nil | ||
) | ||
} | ||
|
||
override func bindStyles() { | ||
super.bindStyles() | ||
|
||
_ = self | ||
|> settingsViewControllerStyle | ||
|> UIViewController.lens.title %~ { _ in | ||
Strings.Payment_methods() | ||
} | ||
|
||
_ = self.headerLabel | ||
|> settingsDescriptionLabelStyle | ||
|> \.text %~ { _ in | ||
Strings.Any_payment_methods_you_saved_to_Kickstarter() | ||
} | ||
|
||
_ = self.tableView | ||
|> \.backgroundColor .~ .clear | ||
|> \.estimatedRowHeight .~ Styles.grid(13) | ||
|> \.allowsSelection .~ false | ||
|> \.separatorStyle .~ .none | ||
} | ||
|
||
override func bindViewModel() { | ||
super.bindViewModel() | ||
|
||
self.viewModel.outputs.paymentMethods | ||
.observeForUI() | ||
.observeValues { [weak self] result in | ||
self?.dataSource.load(creditCards: result) | ||
self?.tableView.reloadData() | ||
} | ||
|
||
self.viewModel.outputs.goToAddCardScreen | ||
.observeForUI() | ||
.observeValues { [weak self] in | ||
self?.goToAddCardScreen() | ||
} | ||
} | ||
|
||
private func goToAddCardScreen() { | ||
let vc = AddNewCardViewController.instantiate() | ||
let nav = UINavigationController(rootViewController: vc) | ||
nav.modalPresentationStyle = .formSheet | ||
|
||
self.present(nav, animated: true, completion: nil) | ||
} | ||
} | ||
|
||
extension PaymentMethodsViewController: UITableViewDelegate { | ||
|
||
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { | ||
return 0.1 | ||
} | ||
|
||
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { | ||
return Styles.grid(13) | ||
} | ||
|
||
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? { | ||
let footer = tableView.dequeueReusableHeaderFooterView( | ||
withIdentifier: Nib.PaymentMethodsFooterView.rawValue | ||
) as? PaymentMethodsFooterView | ||
footer?.delegate = self | ||
return footer | ||
} | ||
} | ||
|
||
extension PaymentMethodsViewController: PaymentMethodsFooterViewDelegate { | ||
|
||
internal func paymentMethodsFooterViewDidTapAddNewCardButton(_ footerView: PaymentMethodsFooterView) { | ||
self.viewModel.inputs.paymentMethodsFooterViewDidTapAddNewCardButton() | ||
} | ||
} |
Oops, something went wrong.