|
4 | 4 |
|
5 | 5 | // TODO |
6 | 6 |
|
| 7 | +public import OpenCoreGraphicsShims |
| 8 | +package import OpenRenderBoxShims |
| 9 | + |
7 | 10 | @available(OpenSwiftUI_v4_0, *) |
8 | 11 | public struct ContentTransition: Equatable, Sendable { |
9 | 12 | package enum Storage: Equatable, @unchecked Sendable { |
@@ -72,8 +75,199 @@ public struct ContentTransition: Equatable, Sendable { |
72 | 75 |
|
73 | 76 | // TODO: NumericTextConfiguration |
74 | 77 |
|
| 78 | + @_spi(Private) |
| 79 | + public struct EffectType: Equatable, Sendable { |
| 80 | + package enum Arg: Equatable, Sendable { |
| 81 | + case none |
| 82 | + case float(Float) |
| 83 | + case int(UInt32) |
| 84 | + } |
| 85 | + |
| 86 | + package var type: ORBTransitionEffectType |
| 87 | + package var arg0: ContentTransition.EffectType.Arg, arg1: ContentTransition.EffectType.Arg |
| 88 | + |
| 89 | + package init( |
| 90 | + type: ORBTransitionEffectType, |
| 91 | + arg0: ContentTransition.EffectType.Arg = .none, |
| 92 | + arg1: ContentTransition.EffectType.Arg = .none |
| 93 | + ) { |
| 94 | + self.type = type |
| 95 | + self.arg0 = arg0 |
| 96 | + self.arg1 = arg1 |
| 97 | + } |
| 98 | + |
| 99 | + public static var opacity: ContentTransition.EffectType { |
| 100 | + self.init(type: .opacity, arg0: .none, arg1: .none) |
| 101 | + } |
| 102 | + |
| 103 | + @available(*, deprecated, message: "use opacity variable") |
| 104 | + public static func opacity(_ opacity: Double = 0) -> ContentTransition.EffectType { |
| 105 | + self.init(type: .opacity, arg0: .none, arg1: .none) |
| 106 | + } |
| 107 | + |
| 108 | + public static func blur(radius: CGFloat) -> ContentTransition.EffectType { |
| 109 | + self.init(type: .blur, arg0: .float(Float(radius)), arg1: .none) |
| 110 | + } |
| 111 | + |
| 112 | + @available(OpenSwiftUI_v6_0, *) |
| 113 | + public static func relativeBlur(scale: CGSize) -> ContentTransition.EffectType { |
| 114 | + self.init(type: .relativeBlur, arg0: .float(Float(scale.width)), arg1: .float(Float(scale.height))) |
| 115 | + } |
| 116 | + |
| 117 | + public static func scale(_ scale: CGFloat = 0) -> ContentTransition.EffectType { |
| 118 | + self.init(type: .scale, arg0: .float(Float(scale)), arg1: .none) |
| 119 | + } |
| 120 | + |
| 121 | + public static func translation(_ size: CGSize) -> ContentTransition.EffectType { |
| 122 | + self.init(type: .translationSize, arg0: .float(Float(size.width)), arg1: .float(Float(size.height))) |
| 123 | + } |
| 124 | + |
| 125 | + @available(OpenSwiftUI_v6_0, *) |
| 126 | + public static func translation(scale: CGSize) -> ContentTransition.EffectType { |
| 127 | + self.init(type: .translationScale, arg0: .float(Float(scale.width)), arg1: .float(Float(scale.height))) |
| 128 | + } |
| 129 | + |
| 130 | + public static var matchMove: ContentTransition.EffectType { |
| 131 | + self.init(type: .matchMove, arg0: .none, arg1: .none) |
| 132 | + } |
| 133 | + } |
| 134 | + |
| 135 | + @_spi(Private) |
| 136 | + @available(OpenSwiftUI_v6_0, *) |
| 137 | + public enum SequenceDirection: Hashable, Sendable { |
| 138 | + case leading, trailing, up, down |
| 139 | + case forwards, backwards |
| 140 | + } |
| 141 | + |
| 142 | + @_spi(Private) |
| 143 | + public struct Effect: Equatable, Sendable { |
| 144 | + package var type: ContentTransition.EffectType |
| 145 | + package var begin: Float |
| 146 | + package var duration: Float |
| 147 | + package var events: ORBTransitionEvents |
| 148 | + package var flags: ORBTransitionEffectFlags |
| 149 | + |
| 150 | + package init( |
| 151 | + type: ContentTransition.EffectType, |
| 152 | + begin: Float = 0, |
| 153 | + duration: Float = 1, |
| 154 | + events: ORBTransitionEvents = .addRemove, |
| 155 | + flags: ORBTransitionEffectFlags = .init() |
| 156 | + ) { |
| 157 | + self.type = type |
| 158 | + self.begin = begin |
| 159 | + self.duration = duration |
| 160 | + self.events = events |
| 161 | + self.flags = flags |
| 162 | + } |
| 163 | + |
| 164 | + public init( |
| 165 | + _ type: ContentTransition.EffectType, |
| 166 | + timeline: ClosedRange<Float> = 0 ... 1, |
| 167 | + appliesOnInsertion: Bool = true, |
| 168 | + appliesOnRemoval: Bool = true |
| 169 | + ) { |
| 170 | + self.type = type |
| 171 | + self.begin = timeline.lowerBound |
| 172 | + self.duration = timeline.upperBound - timeline.lowerBound |
| 173 | + self.events = [ |
| 174 | + appliesOnInsertion ? .add : [], |
| 175 | + appliesOnRemoval ? .remove : [], |
| 176 | + ] |
| 177 | + self.flags = [] |
| 178 | + } |
| 179 | + |
| 180 | + @available(OpenSwiftUI_v6_0, *) |
| 181 | + public static func sequence( |
| 182 | + direction: ContentTransition.SequenceDirection, |
| 183 | + delay: Double, |
| 184 | + maxAllowedDurationMultiple: Double = .infinity, |
| 185 | + appliesOnInsertion: Bool = true, |
| 186 | + appliesOnRemoval: Bool = true |
| 187 | + ) -> ContentTransition.Effect { |
| 188 | + _openSwiftUIUnimplementedFailure() |
| 189 | + } |
| 190 | + |
| 191 | + @available(OpenSwiftUI_v6_0, *) |
| 192 | + public func removeInverts(_ state: Bool) -> ContentTransition.Effect { |
| 193 | + _openSwiftUIUnimplementedFailure() |
| 194 | + } |
| 195 | + } |
| 196 | + |
| 197 | + @_spi(Private) |
| 198 | + public struct Method: Equatable, Sendable { |
| 199 | + package var method: ORBTransitionMethod |
| 200 | + |
| 201 | + package init(method: ORBTransitionMethod) { |
| 202 | + self.method = method |
| 203 | + } |
| 204 | + |
| 205 | + public static let diff: ContentTransition.Method = .init(method: .diff) |
| 206 | + |
| 207 | + public static let forwards: ContentTransition.Method = .init(method: .forwards) |
| 208 | + |
| 209 | + public static let backwards: ContentTransition.Method = .init(method: .backwards) |
| 210 | + |
| 211 | + public static let prefix: ContentTransition.Method = .init(method: .prefix) |
| 212 | + |
| 213 | + public static let suffix: ContentTransition.Method = .init(method: .suffix) |
| 214 | + |
| 215 | + public static let prefixAndSuffix: ContentTransition.Method = .init(method: .prefixAndSuffix) |
| 216 | + |
| 217 | + public static let binary: ContentTransition.Method = .init(method: .binary) |
| 218 | + |
| 219 | + public static let none: ContentTransition.Method = .init(method: .none) |
| 220 | + |
| 221 | + public static func == (a: ContentTransition.Method, b: ContentTransition.Method) -> Bool { |
| 222 | + a.method == b.method |
| 223 | + } |
| 224 | + } |
| 225 | + |
75 | 226 | // TODO |
76 | | - package enum Effect {} |
| 227 | + package struct State {} |
| 228 | +} |
| 229 | + |
| 230 | +// FIXME: ORB |
| 231 | + |
| 232 | +package enum ORBTransitionMethod: Int { |
| 233 | + case empty |
| 234 | + case diff |
| 235 | + case forwards |
| 236 | + case backwards |
| 237 | + case prefix |
| 238 | + case suffix |
| 239 | + case binary |
| 240 | + case none |
| 241 | + case prefixAndSuffix |
| 242 | +} |
| 243 | + |
| 244 | +// ProtobufEnum |
| 245 | +package struct ORBTransitionEvents: OptionSet { |
| 246 | + package let rawValue: UInt32 |
| 247 | + |
| 248 | + package init(rawValue: UInt32) { |
| 249 | + self.rawValue = rawValue |
| 250 | + } |
| 251 | + |
| 252 | + public static let add: ORBTransitionEvents = .init(rawValue: 1) |
| 253 | + public static let remove: ORBTransitionEvents = .init(rawValue: 2) |
| 254 | + public static let addRemove: ORBTransitionEvents = .init(rawValue: 3) |
| 255 | +} |
| 256 | + |
| 257 | +package struct ORBTransitionEffectFlags: OptionSet { |
| 258 | + package let rawValue: UInt32 |
| 259 | + |
| 260 | + package init(rawValue: UInt32) { |
| 261 | + self.rawValue = rawValue |
| 262 | + } |
| 263 | +} |
77 | 264 |
|
78 | | - package enum State {} |
| 265 | +package enum ORBTransitionEffectType: UInt32, Equatable { |
| 266 | + case opacity = 1 |
| 267 | + case scale = 2 |
| 268 | + case translationSize = 3 |
| 269 | + case blur = 4 |
| 270 | + case matchMove = 5 |
| 271 | + case translationScale = 15 |
| 272 | + case relativeBlur = 16 |
79 | 273 | } |
0 commit comments