Skip to content
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

Merged
merged 8 commits into from
Mar 1, 2017
Merged

Add map attribution #181

merged 8 commits into from
Mar 1, 2017

Conversation

sarahsnow1
Copy link
Member

@sarahsnow1 sarahsnow1 commented Feb 24, 2017

  • Adds attribution button to bottom left of map which links to https://mapzen.com/rights/ when clicked
  • Fixes map's view height to consider tab bar
  • Considers the new mapView property to be the main view and adds all other subview to it instead of to the view controller's view
  • Fixes find me button positioning
  • Adds string resource file
  • Adds dimension resource file

img_4447

Closes #87

Dimens.swift Outdated

import UIKit

open class Dimens {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Should this be open or public visibility ? Do you expect people to be subclassing this?
  2. Not that it matters a ton, but you can import Foundation instead of UIKit since you're not using anything UIKit specific.
  3. Not a fan of name abbreviations - lets call this Dimensions or something else.
  4. Can you document the class?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Public would make more sense...they probably wont subclass it, just access the constants
  2. Updated
  3. Renamed to Dimensions
  4. Documented


var application : ApplicationProtocol = UIApplication.shared
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@@ -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
Copy link
Member

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?

Copy link
Member Author

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

//MARK: - private

private func setupTgControllerView() {
tgViewController.view.frame = CGRect(x: 0, y: 0, width: self.view.bounds.width, height: self.view.bounds.height-tabBarHeight)
Copy link
Member

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 a bounds.width in viewDidLoad, which is when this is being called. This is because of constraints. You really only get the right size of that once viewDidLayoutSubviews is finished. So, if you swap to using constraints, you shouldn't have to set the frame.

Copy link
Member Author

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
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. 👍

@@ -0,0 +1,9 @@
/*
Localizable.strings
Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member Author

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

@sarahsnow1 sarahsnow1 force-pushed the 87-attribution branch 3 times, most recently from e42072d to 1afc55c Compare March 1, 2017 21:36
@@ -224,6 +226,7 @@ class MapViewControllerTests: XCTestCase {
}

func testFindMeButtonInitialState() {
controller.viewDidLoad()
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

isa = PBXGroup;
children = (
7D7DAE191E60B00400FFCA6F /* dimens */,
7D7DAE181E60AFFE00FFCA6F /* strings */,
7D7847241E6775EA000D56CA /* Dimensions.swift */,
Copy link
Member

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?

Copy link
Member Author

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

@msmollin msmollin merged commit 8fb18a9 into master Mar 1, 2017
@msmollin msmollin deleted the 87-attribution branch March 1, 2017 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants