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

Color redesign & annotations fixes #650

Merged
merged 4 commits into from
Sep 7, 2021
Merged

Color redesign & annotations fixes #650

merged 4 commits into from
Sep 7, 2021

Conversation

macdrevx
Copy link
Contributor

@macdrevx macdrevx commented Sep 6, 2021

Pull request checklist:

  • Briefly describe the changes in this PR.
  • Write tests for all new functionality. If tests were not written, please explain why.
  • Document any changes to public APIs.
  • Apply changelog label ('breaking change', 'bug 🪲', 'build', 'docs', 'feature 🍏', 'performance ⚡', 'testing 💯') or use the label 'skip changelog'
  • Update the changelog
  • Update the migration guide, API Docs, Markdown files - Readme, Developing, etc

Summary of changes

Breaking Changes

  • Renamed ColorRepresentable to StyleColor
  • Removed the argument label from StyleColor's UIColor initializer
  • Renamed ColorRepresentable.rgbaDescription to StyleColor.rgbaString.
  • Changed StyleColor's Encodable implementation to always encode an rgba color string instead of encoding an rgba expression
  • Updated the extension on UIColor that adds ExpressionArgumentConvertible to return an rgba color string instead of an rgba expression.
  • Style properties on annotation managers are now synced to the layer each display link just like their annotations. Use syncSourceAndLayerIfNeeded() (formerly named syncAnnotationsIfNeeded()) to force the sync to happen earlier.
  • The layerType argument to Style._layerPropertyDefaultValue(for:property:) is now of type LayerType instead of String
  • Expression decoding will now fail if the operator is missing
  • PointAnnotationManager.textVariableAnchor is now of type [TextAnchor]? instead of [String]?
  • PointAnnotationManager.textWritingMode is now of type [TextWritingMode]? instead of [String]?

Bug Fixes

  • Updated annotations to use rgbaString and init(rgbaString:) when serializing and deserializing StyleColors (Fixes Polylines and polygons are always black #636)
  • Annotation managers now properly restore the default values of any annotation or common style properties that are reset to nil.
  • Fixed Expression decoding when second array element could be an operator

Additions

Other Changes

  • StyleColor now stores its data as component-wise Doubles instead of as an expression.
  • Added an internal, failable, expression-based initializer to StyleColor
  • Added an internal, failable, rgba-string-based initializer to StyleColor
  • Updated the codebase to use type inference with UIColor when possible
  • Moved the extension on UIColor that adds ExpressionArgumentConvertible conformance to ExpressionArgumentBuilder.swift
  • Update annotation managers to store common layer styles in a dictionary similarly to how annotations store their styles. This provides better handling of nil since the value parameter of StyleManager.setStyleLayerPropertyForLayerId(_:property:value:) is marked nonnull in Objective-C. The previous implementation silenced a warning about this by casting the optional to Any.
  • Updated style and annotation templates to consistently include a trailing newline
  • Made generated test classes final
  • Allow linter to run on generated code, and fix lint
  • Added integration tests for syncing each annotation and annotation manager property to the layer
  • Added Random.swift test helpers

@macdrevx macdrevx added bug 🪲 Something is broken! breaking change ⚠️ If your pull request introduces a breaking change and updates are required when version is published labels Sep 6, 2021
- Renamed ColorRepresentable to StyleColor
- Removed the argument label from its UIColor initializer
- Updated the codebase to use type inference with UIColor when possible
- Moved the extension on UIColor that adds ExpressionArgumentConvertible
  conformance to ExpressionArgumentBuilder.swift, and updated it to
  return an rgba color string instead of an rgba expression.
- StyleColor now stores its data as component-wise Doubles instead of as
  an expression.
- Added a public, failable, component-wise initializer to StyleColor
- Added an internal, failable, expression-based initializer to
  StyleColor
- Added an internal, failable, rgba-string-based initializer to
  StyleColor
- Renamed ColorRepresentable.rgbaDescription to StyleColor.rgbaString.
- Updated StyleColor's Decodable support to be able to handle rgba color
  strings as well as rgba expressions
- Changed StyleColor's Encodable implementation to always encode an rgba
  color string instead of encoding an rgba expression
- Update annotations to use `rgbaString` and `init(rgbaString:)` when
  serializing and deserializing `StyleColor`s
- Update annotation managers to store common layer styles in a
  dictionary similarly to how annotations store their styles. This
  provides better handling of `nil` since the `value` parameter of
  `StyleManager.setStyleLayerPropertyForLayerId(_:property:value:)` is
  marked nonnull in Objective-C. The previous implementation silenced a
  warning about this by casting the optional to Any.
- Common layer properties are now synced to the layer each display link
  just like annotations. Use `syncSourceAndLayerIfNeeded()` (formerly
  named `syncAnnotationsIfNeeded()` to force the sync to happen earlier.
- Updated style and annotation templates to consistently include a
  trailing newline
- Made generated test classes final
- The `layerType` argument to
  `Style._layerPropertyDefaultValue(for:property:)` is now of type
  `LayerType` instead of `String`
- Annotation managers now properly restore the default values of any
  annotation or common style properties that are reset to nil.
- Made Expression.Operator conform to CaseIterable for testing purposes
- fixed lint in generated code
- updated some types to take [TextAnchor] instead of [String]
- updated some types to take [TextWritingMode] instead of [String]
- updated PointAnnotationManager.textFont implementation to match other common properties
- removed stale todo about turf and QueriedFeature
- Made generated enums conform to CaseIterable
- added integration tests for common properties
- added Random.swift test helpers
- Add workarounds for text-field and line-gradient
- Fix Expression decoding when second array element could be an operator
- Make Expression decoding fail if operator is missing
- Add integration tests for all annotation properties

Fixes #636
@nishant-karajgikar
Copy link
Contributor

Could we run device tests on this PR?

@macdrevx
Copy link
Contributor Author

macdrevx commented Sep 7, 2021

Disable line gradient

@macdrevx macdrevx merged commit 81a435c into main Sep 7, 2021
@macdrevx macdrevx deleted the ah/color-representable branch September 7, 2021 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change ⚠️ If your pull request introduces a breaking change and updates are required when version is published bug 🪲 Something is broken!
Projects
None yet
2 participants