-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MAPSIOS-1272] Add support for style transitions to StyleDSL (#2045)
Enables style transitions in the style DSL by creating a TransitionOptions struct
- Loading branch information
1 parent
603ca4f
commit cc38f82
Showing
19 changed files
with
251 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 43 additions & 16 deletions
59
Sources/MapboxMaps/Foundation/Extensions/Core/TransitionOptions.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,58 @@ | ||
import Foundation | ||
extension TransitionOptions { | ||
|
||
/** | ||
* The `TransitionOptions` control timing for the interpolation between a transitionable style | ||
* property's previous value and new value. These can be used to define the style default property | ||
* transition behavior. Also, any transitionable style property may also have its own `-transition` | ||
* property that defines specific transition timing for that specific layer property, overriding | ||
* the global transition values. | ||
*/ | ||
public struct TransitionOptions: Equatable { | ||
/// Initializes `TransitionOptions` with provided `duration`, `delay` and `enablePlacementTransitions` flag. | ||
/// - Parameters: | ||
/// - duration: Time allotted for transitions to complete. | ||
/// - delay: Length of time before the transition begins. | ||
/// - enablePlacementTransitions: Whether the fade in/out symbol placement transition is enabled. | ||
public convenience init(duration: TimeInterval?, | ||
delay: TimeInterval?, | ||
enablePlacementTransitions: Bool?) { | ||
|
||
self.init(__duration: duration.map(NSNumber.init(value:)), | ||
delay: delay.map(NSNumber.init(value:)), | ||
enablePlacementTransitions: enablePlacementTransitions.map(NSNumber.init(value:))) | ||
public init(duration: TimeInterval? = nil, | ||
delay: TimeInterval? = nil, | ||
enablePlacementTransitions: Bool? = nil) { | ||
self.duration = duration | ||
self.delay = delay | ||
self.enablePlacementTransitions = enablePlacementTransitions | ||
} | ||
|
||
/// Time allotted for transitions to complete. Defaults to `0.3` seconds. | ||
public var duration: TimeInterval? { | ||
__duration?.doubleValue | ||
} | ||
public var duration: TimeInterval? | ||
|
||
/// Length of time before a transition begins. Defaults to `0.0` seconds. | ||
public var delay: TimeInterval? { | ||
__delay?.doubleValue | ||
} | ||
public var delay: TimeInterval? | ||
|
||
/// Whether the fade in/out symbol placement transition is enabled. Defaults to `true`. | ||
public var enablePlacementTransitions: Bool? { | ||
__enablePlacementTransitions?.boolValue | ||
public var enablePlacementTransitions: Bool? | ||
|
||
internal init(_ objValue: MapboxCoreMaps.TransitionOptions) { | ||
self.init(duration: objValue.__duration?.doubleValue, | ||
delay: objValue.__delay?.doubleValue, | ||
enablePlacementTransitions: objValue.__enablePlacementTransitions?.boolValue) | ||
} | ||
|
||
internal var coreOptions: MapboxCoreMaps.TransitionOptions { | ||
.init(self) | ||
} | ||
} | ||
|
||
extension MapboxCoreMaps.TransitionOptions { | ||
internal convenience init(_ swiftValue: TransitionOptions) { | ||
self.init(__duration: swiftValue.duration.map(NSNumber.init(value:)), | ||
delay: swiftValue.delay.map(NSNumber.init(value:)), | ||
enablePlacementTransitions: swiftValue.enablePlacementTransitions.map(NSNumber.init(value:))) | ||
} | ||
} | ||
|
||
@_spi(Experimental) | ||
@available(iOS 13.0, *) | ||
extension TransitionOptions: MapStyleContent, PrimitiveMapStyleContent { | ||
func visit(_ node: MapStyleNode) { | ||
node.mount(MountedUniqueProperty(keyPath: \.transition, value: self)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.