Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

[ios, macos] Refactor snapshot attribution. - #10525

Merged
fabian-guerra merged 1 commit into
release-aguafrom
fabian-refactor-10490
Dec 4, 2017
Merged

fabian-guerra merged 1 commit into
release-aguafrom
fabian-refactor-10490

Conversation

@fabian-guerra

@fabian-guerra fabian-guerra commented Nov 21, 2017 •

Copy link
Copy Markdown
Contributor

Fixes #10490

  • Add clear documentation.

@fabian-guerra fabian-guerra self-assigned this Nov 21, 2017
@kkaefer kkaefer added iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS labels Nov 24, 2017
@fabian-guerra
fabian-guerra requested a review from 1ec5 November 29, 2017 02:08
@lilykaiser lilykaiser added this to the ios-v3.7.1 milestone Nov 29, 2017
@fabian-guerra

Copy link
Copy Markdown
Contributor Author

@1ec5 could you please review this branch.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does there need to be this method that returns a copy of the entire attribution info? It seems like the attribution info style only affects the title, so it would be sufficient to put in a method -titleWithStyle:. -sizeWithStyle: would be unnecessary too, since it would be trivial to get the size of the attributed string title.

@1ec5 1ec5 Dec 1, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be simpler to return attributionInfo.title.size directly. CGSize is a struct; a struct is passed by value rather than by reference.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: misleading indentation.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It’s poor form for a getter method such as this to have a side effect. Can you think of a way to infer the default logo height from the return value of this method?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If client code happens to call this method only once with MGLAttributionInfoStyleMedium, _defaultLogoHeight never gets set. The caller in this case does call this method with MGLAttributionInfoStyleLong beforehand, but this getter method has to assume it can be called only once with any valid value of style.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This line has no effect because the following line always overwrites attributionSize.width.

@fabian-guerra fabian-guerra Dec 1, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It has an effect. In the following line:
attributionSize.width = attributionSize.width + 10 + attributionBackgroundSize.width + 10;

If has a logo adds its size and carry the value to sum the attribution text size.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Gah, sorry, that makes sense. Didn’t see it for some reason.

@1ec5 1ec5 Dec 1, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

-styleFromValue: doesn’t appear to do anything except return the passed-in value, so this line would have no effect. If the compiler is warning about passing an NSUInteger into -attributionSizeWithLogoStyle:sourceAttributionStyle:, then cast styleValue to an MGLAttributionInfoStyle, because we know it’s going to be a valid value.

@fabian-guerra

Copy link
Copy Markdown
Contributor Author

@1ec5 when you have time could you please take a look again.


Example: If `style` = `MGLAttributionInfoStyleShort` and
`MGLAttributionInfo.title` = `OpenStreetMap` then it will format
`MGLAttributionInfo.title` = `OSM`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Providing an example is a good idea. I think it would read better as a sentence, though:

If the style property is set to MGLAttributionInfoStyleShort and the title property is set to OpenStreetMap, then this method returns OSM.

(jazzy will autolink title, since it’s in the same class, so no need to qualify it with MGLAttributionInfo.)

@fabian-guerra
fabian-guerra merged commit 784b71a into release-agua Dec 4, 2017
@fabian-guerra
fabian-guerra deleted the fabian-refactor-10490 branch December 4, 2017 22:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants