-
Notifications
You must be signed in to change notification settings - Fork 310
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
Adding generic shield support to instruction banner. #1417
Conversation
import Foundation | ||
import UIKit | ||
|
||
class GenericRouteShield: StylableView { |
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.
Should this class be public, so that developers can customize the colors or roundedness?
} else if let genericShieldString = attributedString(forGenericShield: component, dataSource: dataSource) { | ||
build(component, [joinString, genericShieldString]) | ||
} else { | ||
fallthrough |
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 is a clever use of a switch statement, but do you think the fallthroughs inside conditionals make the code flow a little more difficult to keep track of?
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.
@1ec5 It's certainly a complex switch, but I'd make the case that it's a heck of a lot easier to follow than the mess of if
statements before it.
I like to think that the fallthrough
statements enforce the idea that everything falls-back to text.
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.
Would it make sense to factor this switch out into it's own function? This is function is getting boarder-line large.
690494f
to
b2b96ca
Compare
This is looking great! |
f637ffb
to
b2b96ca
Compare
Posterity: determined that test failures are not due to machine. Bisected work on this branch to find root-cause of test issues. First bad commit found to be |
5fba7a6
to
5a1f541
Compare
…sing components are shields
…xpecting to see a green light.
…cted, and that they are replaced by actual images as we receive them. This exposes a bug where we're having cache key issues for generic shields, as the cache is storing the generated generic attachment image as the loaded attachment image's key-value. Also: Tightening up the timeout values now that things are looking pretty stable.
…are always represented by generic cache keys.
66a364a
to
218f133
Compare
…ity to tune tolerance per-test.
view.frame.size = size | ||
FBSnapshotVerifyView(view, tolerance: 0.01) | ||
FBSnapshotVerifyView(view, suffixes: ["_64"], tolerance: tolerance) |
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 looks suspect.
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 suffixes: ["_64"]
? That just tells the snapshot framework that we only have reference images in the ReferenceImages_64
folder, so it doesn't try to look in the ReferenceImages_32
folder as a fallback. (Default Behavior)
This basically removes unneeded (since we don't do 32-bit testing) noise from the output log.
import Foundation | ||
import UIKit | ||
|
||
public class GenericRouteShield: StylableView { |
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.
Add documentation for this public class.
import Foundation | ||
import UIKit | ||
|
||
public class GenericRouteShield: StylableView { |
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.
Will this class also suffer from #1392 until a hashKey is exposed?
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.
Good point. We should also be hashing off the foregroundColor
of the GenericRouteShield
.
return nil | ||
} | ||
} | ||
|
||
var genericCacheKey: String { | ||
return "generic-" + (text ?? "nil") |
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.
Are there cases we could end up with different shields that have the same cache key, ie generic-
because text is nil?
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.
A good test case might be, two different steps where the number is given but no text associated with it? Maybe it can't happen but worth checking out.
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.
@bsudekum The InstructionPresenter
doesn't try to render Generic Shields with no text, as they would be an empty box. Even so, this code works because one empty box is equal to another.
return "\(imageURL.absoluteString)-\(VisualInstructionComponent.scale)" | ||
case .delimiter: | ||
default: |
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 might make more sense to keep .delimiter
here and remove default so as new cases are added, the compiler will yell at us to handle them.
GenericRouteShield.appearance().backgroundColor = .clear | ||
GenericRouteShield.appearance().borderWidth = 1.0 | ||
GenericRouteShield.appearance().cornerRadius = 5.0 | ||
GenericRouteShield.appearance().foregroundColor = .black |
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.
How does this look for the night style?
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.
Pretty good, all we end up having to do is needing to change the foregroundColor
: Line
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.
Oh i missed that, 👍
… applied style. Also doing this to exit components, as it was not quite done correctly.
Adding support for generic shields. Implements #1190. This also has the neat side-effect of rendering normal shields as generic ones until their images load.
To-Do:
public
-ationGenericRouteShield
GenericRouteShield
based upon it's foreground color / textVisualInstructionComponent
extension/cc @mapbox/navigation-ios