-
Notifications
You must be signed in to change notification settings - Fork 24
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
Add map attribution #181
Add map attribution #181
Conversation
Dimens.swift
Outdated
|
||
import UIKit | ||
|
||
open class Dimens { |
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 be open or public visibility ? Do you expect people to be subclassing this?
- Not that it matters a ton, but you can import Foundation instead of UIKit since you're not using anything UIKit specific.
- Not a fan of name abbreviations - lets call this Dimensions or something else.
- Can you document the class?
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.
- Public would make more sense...they probably wont subclass it, just access the constants
- Updated
- Renamed to Dimensions
- Documented
src/MapViewController.swift
Outdated
|
||
var application : ApplicationProtocol = UIApplication.shared |
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.
Probably could be a let
constant.
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.
Updated
src/MapViewController.swift
Outdated
@@ -446,6 +451,9 @@ open class MapViewController: UIViewController, LocationManagerDelegate { | |||
findMeButton.setBackgroundImage(UIImage(named: "ic_find_me_pressed"), for: [.selected]) | |||
findMeButton.backgroundColor = UIColor.white | |||
findMeButton.autoresizingMask = [.flexibleTopMargin, .flexibleLeftMargin] | |||
let viewRect = mapView.bounds |
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 won't work correctly. The createFindMeButton()
function is called in the initializer of the VC. Referencing the view at this stage in the lifecycle will force view generation to happen outside of the proper lifecycle events.
What are you attempting to solve by moving this around?
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 was focused on removing it from viewWillAppear
since it doesnt need to be added every time the view appears but youre right, this isn't the place to add it. I've moved calling of this method from the initializer into viewDidLoad
src/MapViewController.swift
Outdated
//MARK: - private | ||
|
||
private func setupTgControllerView() { | ||
tgViewController.view.frame = CGRect(x: 0, y: 0, width: self.view.bounds.width, height: self.view.bounds.height-tabBarHeight) |
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.
Couple issues:
-
The reason you're needing to subtract the height here is because you're not using constraints. The view should adopt the size of its superview. So what I would do here is try here is to use the Autresizing Mask to keep it simple. Something like
.autoresizingMask = [.flexibleTopMargin, .flexibleLeftMargin, .flexibleRightMargin, .flexibleBottomMargin]
should do what you want. -
The next issue is
self.view
doesn't always have abounds.width
in viewDidLoad, which is when this is being called. This is because of constraints. You really only get the right size of that onceviewDidLayoutSubviews
is finished. So, if you swap to using constraints, you shouldn't have to set the frame.
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 view's height doesn't adjust for the tab bar so I do need to adjust for it. I've updated setting of the tgViewController
to use constraints.
attributionBtn.titleLabel?.font = UIFont.systemFont(ofSize: 14) | ||
attributionBtn.addTarget(self, action: #selector(openMapzenTerms), for: .touchUpInside) | ||
attributionBtn.sizeToFit() | ||
attributionBtn.translatesAutoresizingMaskIntoConstraints = false |
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 should automatically get set to false when you add new constraints.
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.
Thats when constraints are set in IB:
If you want to use Auto Layout to dynamically calculate the size and position of your view, you must set this property to false, and then provide a non ambiguous, nonconflicting set of constraints for the view.
By default, the property is set to true for any view you programmatically create. If you add views in Interface Builder, the system automatically sets this property to false.
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.
Got it. 👍
Localizable.strings
Outdated
@@ -0,0 +1,9 @@ | |||
/* | |||
Localizable.strings |
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.
Did you check to make sure this gets imported when pulled in via cocoapods?
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 I didnt, will do that now
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.
Remove the strings file and will properly handle this in a follow up PR. Ticket here: #187
e42072d
to
1afc55c
Compare
@@ -224,6 +226,7 @@ class MapViewControllerTests: XCTestCase { | |||
} | |||
|
|||
func testFindMeButtonInitialState() { | |||
controller.viewDidLoad() |
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.
Mmmmm we should open the scope of setupFindMeButton()
to Internal
so we can test it. That'll still accomplish keeping it private from implementing devs.
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.
Updated
ios-sdk.xcodeproj/project.pbxproj
Outdated
isa = PBXGroup; | ||
children = ( | ||
7D7DAE191E60B00400FFCA6F /* dimens */, | ||
7D7DAE181E60AFFE00FFCA6F /* strings */, | ||
7D7847241E6775EA000D56CA /* Dimensions.swift */, |
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.
Did this get moved into src
on disk?
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.
Yes. Its now in src/dimensions/Dimensions.swift
I'm thinking we might want to move our controllers, managers, extensions into separate folders in later PR too
a4c47f2
to
6ee219f
Compare
https://mapzen.com/rights/
when clickedmapView
property to be the main view and adds all other subview to it instead of to the view controller's viewCloses #87