-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NT-312] Pledge amount invalid input color #849
Conversation
import UIKit | ||
|
||
extension UITraitCollection { | ||
static let allCases: [UITraitCollection] = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a test helper for allowing us testing large text better.
@@ -112,15 +112,13 @@ private let labelStyle: LabelStyle = { (label: UILabel) in | |||
|> \.font .~ UIFont.ksr_body() | |||
|> \.adjustsFontForContentSizeCategory .~ true | |||
|> \.textAlignment .~ NSTextAlignment.right | |||
|> \.textColor .~ UIColor.ksr_green_500 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are now set using VM's outputs
|> \.translatesAutoresizingMaskIntoConstraints .~ false | ||
}() | ||
|
||
private lazy var horizontalSpacer: UIView = { UIView(frame: .zero) }() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No real need for auto layout anymore...we're using spacing (where we have previously used auto layout)...this should be simpler and more readable.
@@ -40,16 +36,14 @@ final class PledgeAmountViewController: UIViewController { | |||
|> ksr_addSubviewToParent() | |||
|> ksr_constrainViewToEdgesInParent() | |||
|
|||
_ = ([self.titleLabel, self.adaptableStackView], self.rootStackView) | |||
_ = ([self.titleLabel, self.adaptableStackView, UIView(frame: .zero)], self.rootStackView) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sure that the vertical stack view will always align its subviews vertically to the top
|> ksr_addArrangedSubviewsToStackView() | ||
|
||
self.amountInputView.textField.delegate = self | ||
|
||
self.spacer.widthAnchor.constraint(greaterThanOrEqualToConstant: Styles.grid(3)).isActive = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have previously used this width as the minimum space between the stepper and the input field (otherwise when the text field grows it would almost touch the stepper)...now this is done using spacing
on the stack view which should be much simpler and easier to reason about.
import Prelude | ||
import UIKit | ||
|
||
final class PledgeAmountViewControllerTests: TestCase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I felt like it was a perfect opportunity to add testing...not only can we test large text but also invalid input values, currency symbol, stepper increment/decrement button etc.
} | ||
} | ||
|
||
func testView_WithShippingLocation() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Rename to something more meaningful
self.stepperMaxValue = minAndMax.signal | ||
.map(second) | ||
self.stepperMinValue = minValue.mapConst(0) | ||
self.stepperMaxValue = minValue.mapConst(Double.greatestFiniteMagnitude) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made a decision to use 0...Double.max but we can chose something else as well (I'm open to discussing this).
The reason we're able to do 0...Double.max is because we want to allow the user to actually decrement/increment bellow/above pledge's min/max value...in that case we simply change the input text to red to indicate this out of bounds state.
Generated by 🚫 Danger |
Cartfile.resolved
Outdated
@@ -4,7 +4,7 @@ github "Alamofire/AlamofireImage" "c41f8b0acfbb3180fe045df73596e4332c338633" | |||
github "ReactiveCocoa/ReactiveSwift" "6.0.0" | |||
github "facebook/facebook-objc-sdk" "v5.0.2" | |||
github "kickstarter/Kickstarter-Prelude" "d03f8831dcec9ad157db4f1c5f769ec17e1a3766" | |||
github "kickstarter/Kickstarter-ReactiveExtensions" "aa994f0921dca1965ae537fe77c2edc798eef230" | |||
github "kickstarter/Kickstarter-ReactiveExtensions" "99c3013e22fd6d4ea29d9d4c7a4a7b10bf80a99c" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's weird that it builds on Circle and not on my machine. I wonder what's the real problem here. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hash in this file should match the one in the Cartfile
.
) | ||
|
||
self.textFieldIsFirstResponder = self.doneButtonTappedProperty.signal | ||
.mapConst(false) | ||
|
||
self.textFieldTextColor = textColor | ||
.wrapInOptional() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately it seemed necessary to pass textColor
as an optional to a UITextField
(which is how it's also defined in UIKit)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cartfile.resolved
Outdated
@@ -4,7 +4,7 @@ github "Alamofire/AlamofireImage" "c41f8b0acfbb3180fe045df73596e4332c338633" | |||
github "ReactiveCocoa/ReactiveSwift" "6.0.0" | |||
github "facebook/facebook-objc-sdk" "v5.0.2" | |||
github "kickstarter/Kickstarter-Prelude" "d03f8831dcec9ad157db4f1c5f769ec17e1a3766" | |||
github "kickstarter/Kickstarter-ReactiveExtensions" "aa994f0921dca1965ae537fe77c2edc798eef230" | |||
github "kickstarter/Kickstarter-ReactiveExtensions" "99c3013e22fd6d4ea29d9d4c7a4a7b10bf80a99c" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hash in this file should match the one in the Cartfile
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
legit!
📲 What
🤔 Why
Some UX improvements to amount input
🛠 How
See inline comments
👀 See
✅ Acceptance criteria
TextField input
0
disables the decrement button of the stepperDouble max
disables the increment button of the stepper (this will be harder to test so it might be sufficient to review snapshots and integration tests)Stepper input
0
disables the decrement button of the stepperDouble max
disables the increment button of the stepper (this will be harder to test so it might be sufficient to review snapshots and integration tests)It's possible that the last criteria will be better tested when we remove decimal support in some of the upcoming work.
⏰ TODO