Repository navigation
[ios, macos] Refactor snapshot attribution. - #10525
Conversation
96f62a8 to
cb0bf9d
Compare
cb0bf9d to
42197f0
Compare
|
@1ec5 could you please review this branch. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
It would be simpler to return attributionInfo.title.size directly. CGSize is a struct; a struct is passed by value rather than by reference.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
This line has no effect because the following line always overwrites attributionSize.width.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Gah, sorry, that makes sense. Didn’t see it for some reason.
There was a problem hiding this comment.
-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.
42197f0 to
ae9d793
Compare
|
@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` |
There was a problem hiding this comment.
Providing an example is a good idea. I think it would read better as a sentence, though:
If the
styleproperty is set toMGLAttributionInfoStyleShortand thetitleproperty is set toOpenStreetMap, then this method returnsOSM.
(jazzy will autolink title, since it’s in the same class, so no need to qualify it with MGLAttributionInfo.)
ae9d793 to
f56bb37
Compare
Fixes #10490