-
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.
③ [Currency selection] Add table view header (#570)
* Add SelectCurrencyViewController * Fix tests * Add tableview header * Update snapshots * Added ViewController tests * Removed recordMode line from test * Simplify layout code for header * Remove SettingsCurrencyCell * Fix snapshot tests * Remove CaseIterable conformance on SettingsAccountCellType * Use reuseIdentifier local constant * Update pragma * Update tableview instantiation * Implicit returns in lazy vars * Fix alignment * ① [Currency selection] Remove currency picker (#568) * Remove currency picker * swiftlint * Remove redundant enum case * Remove reference * Remove local var, improve function name * Set label colour * Update snapshots * Fix project file * Correctly size header/footer views * Make the tests pass (#585) * Run snapshot tests on all devices * Remove duplicate extension, use keypath setter * Fix autolayout warnings
- Loading branch information
1 parent
4ca636e
commit 2c0552b
Showing
34 changed files
with
207 additions
and
49 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
Kickstarter-iOS/Assets.xcassets/icons/icon--currency-header.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,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "icon--currency-header.pdf" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Binary file added
BIN
+18 KB
...tarter-iOS/Assets.xcassets/icons/icon--currency-header.imageset/icon--currency-header.pdf
Binary file not shown.
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
31 changes: 31 additions & 0 deletions
31
Kickstarter-iOS/Views/Controllers/SelectCurrencyViewControllerTests.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,31 @@ | ||
import Library | ||
import Prelude | ||
import Result | ||
import XCTest | ||
@testable import Kickstarter_Framework | ||
@testable import KsApi | ||
|
||
internal final class SelectCurrencyViewControllerTests: TestCase { | ||
override func setUp() { | ||
super.setUp() | ||
UIView.setAnimationsEnabled(false) | ||
} | ||
|
||
override func tearDown() { | ||
UIView.setAnimationsEnabled(true) | ||
super.tearDown() | ||
} | ||
|
||
func testView() { | ||
combos(Language.allLanguages, Device.allCases) | ||
.forEach { language, device in | ||
withEnvironment(language: language) { | ||
let vc = SelectCurrencyViewController.instantiate() | ||
vc.configure(with: .USD) | ||
let (parent, _) = traitControllers(device: device, orientation: .portrait, child: vc) | ||
|
||
FBSnapshotVerifyView(parent.view, identifier: "lang_\(language)_device_\(device)") | ||
} | ||
} | ||
} | ||
} |
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,62 @@ | ||
import Library | ||
import Prelude | ||
import Prelude_UIKit | ||
import UIKit | ||
|
||
final class SelectCurrencyTableViewHeader: UIView { | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
|
||
self.addSubview(self.headerStackView) | ||
self.headerStackView.constrainEdges(to: self) | ||
} | ||
|
||
required init?(coder aDecoder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
override func bindStyles() { | ||
super.bindStyles() | ||
|
||
_ = self.headerImageView | ||
|> \.contentMode .~ .scaleAspectFill | ||
|
||
_ = self.headerStackView | ||
|> \.axis .~ .vertical | ||
|> \.alignment .~ .center | ||
|> \.spacing .~ Styles.grid(2) | ||
|> \.layoutMargins .~ .init( | ||
top: Styles.grid(4), left: Styles.grid(2), bottom: Styles.grid(2), right: Styles.grid(2) | ||
) | ||
|> \.isLayoutMarginsRelativeArrangement .~ true | ||
|
||
_ = self.headerLabel | ||
|> settingsDescriptionLabelStyle | ||
|> \.textColor .~ .ksr_text_dark_grey_500 | ||
|> \.backgroundColor .~ .ksr_grey_200 | ||
} | ||
|
||
// MARK: Accessors | ||
|
||
public var text: String? { | ||
didSet { | ||
_ = self.headerLabel |> \.text .~ text | ||
} | ||
} | ||
|
||
// MARK: Subviews | ||
|
||
private lazy var headerStackView: UIStackView = { | ||
return UIStackView(arrangedSubviews: [ | ||
self.headerImageView, | ||
self.headerLabel | ||
]) | ||
}() | ||
|
||
private lazy var headerImageView: UIImageView = { | ||
UIImageView(image: image(named: "icon--currency-header", inBundle: Bundle.framework)) | ||
}() | ||
|
||
private lazy var headerLabel: UILabel = { UILabel(frame: .zero) }() | ||
} |
Oops, something went wrong.