Skip to content
2 changes: 1 addition & 1 deletion Sources/OpenSwiftUI/View/Control/Slider/Slider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@
}

func set(base: inout Value, newValue: Double) {
base = clamp(Value(newValue), min: 0, max: 1)
base = Value(newValue).clamp(min: 0, max: 1)

Check warning on line 653 in Sources/OpenSwiftUI/View/Control/Slider/Slider.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUI/View/Control/Slider/Slider.swift#L653

Added line #L653 was not covered by tests
}
}

Expand Down
35 changes: 0 additions & 35 deletions Sources/OpenSwiftUICore/Animation/TODO/Animatable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
// Audited for iOS 15.5
// Status: Blocked by Graph

public import Foundation

// MARK: - Animatable

/// A type that describes how to animate a property of a view.
Expand Down Expand Up @@ -49,36 +47,3 @@ extension Animatable where AnimatableData == EmptyAnimatableData {
// TODO
}
}

// MARK: - Animatable + CoreGraphics

extension CGPoint: Animatable {
public var animatableData: AnimatablePair<CGFloat, CGFloat> {
@inlinable
get { .init(x, y) }
@inlinable
set { (x, y) = newValue[] }
}
}

extension CGSize: Animatable {
public var animatableData: AnimatablePair<CGFloat, CGFloat> {
@inlinable
get { .init(width, height) }
@inlinable
set { (width, height) = newValue[] }
}
}

extension CGRect: Animatable {
public var animatableData: AnimatablePair<CGPoint.AnimatableData, CGSize.AnimatableData> {
@inlinable
get {
.init(origin.animatableData, size.animatableData)
}
@inlinable
set {
(origin.animatableData, size.animatableData) = newValue[]
}
}
}
24 changes: 15 additions & 9 deletions Sources/OpenSwiftUICore/Data/Codable/CodableProxy.swift
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
//
// CodableProxy.swift
// OpenSwiftUI
// OpenSwiftUICore
//
// Audited for iOS 15.5
// Status: Complete
// Audited for iOS 18.0
// Status: WIP

protocol CodableProxy: Codable {
associatedtype Base
var base: Base { get }
}

protocol CodableByProxy {
package protocol CodableByProxy {
associatedtype CodingProxy: Codable
var codingProxy: CodingProxy { get }

static func unwrap(codingProxy: CodingProxy) -> Self
}

package protocol CodableProxy: Codable {
associatedtype Base
var base: Base { get }
}

extension CodableByProxy where Self == CodingProxy.Base, CodingProxy: CodableProxy {
package static func unwrap(codingProxy: CodingProxy) -> Self {
codingProxy.base

Check warning on line 22 in Sources/OpenSwiftUICore/Data/Codable/CodableProxy.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Data/Codable/CodableProxy.swift#L21-L22

Added lines #L21 - L22 were not covered by tests
}
}
4 changes: 2 additions & 2 deletions Sources/OpenSwiftUICore/Data/Update.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
//
// Audited for iOS 18.0
// Status: Blocked by Signpost
// ID: EA173074DA35FA471DC70643259B7E74 (RELEASE_2021)
// ID: 61534957AEEC2EDC447ABDC13B4D426F (RELEASE_2024)
// ID: EA173074DA35FA471DC70643259B7E74 (SwiftUI)
// ID: 61534957AEEC2EDC447ABDC13B4D426F (SwiftUICore)

import OpenSwiftUI_SPI
import OpenGraphShims
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//
// CGAffineTransform+Extension.swift
// OpenSwiftUICore
//
// Audited for iOS 18.0
// Status: Complete

#if canImport(Darwin)

package import CoreGraphics

extension CGAffineTransform {
package init(rotation: Angle) {
let sin = sin(rotation.radians)
let cos = cos(rotation.radians)
self.init(a: cos, b: sin, c: -sin, d: cos, tx: 0, ty: 0)

Check warning on line 16 in Sources/OpenSwiftUICore/Extension/CGAffineTransform+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGAffineTransform+Extension.swift#L13-L16

Added lines #L13 - L16 were not covered by tests
}

package var isTranslation: Bool {
return a == 1 && b == 0 && c == 0 && d == 1

Check warning on line 20 in Sources/OpenSwiftUICore/Extension/CGAffineTransform+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGAffineTransform+Extension.swift#L19-L20

Added lines #L19 - L20 were not covered by tests
}

package var isRectilinear: Bool {
return (b == 0 && c == 0) || (a == 0 && d == 0)

Check warning on line 24 in Sources/OpenSwiftUICore/Extension/CGAffineTransform+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGAffineTransform+Extension.swift#L23-L24

Added lines #L23 - L24 were not covered by tests
}

package var isUniform: Bool {
guard isRectilinear else {
return false

Check warning on line 29 in Sources/OpenSwiftUICore/Extension/CGAffineTransform+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGAffineTransform+Extension.swift#L27-L29

Added lines #L27 - L29 were not covered by tests
}
return a == d && b == c

Check warning on line 31 in Sources/OpenSwiftUICore/Extension/CGAffineTransform+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGAffineTransform+Extension.swift#L31

Added line #L31 was not covered by tests
}

package func rotated(by angle: Angle) -> CGAffineTransform {
CGAffineTransform(rotation: angle).concatenating(self)

Check warning on line 35 in Sources/OpenSwiftUICore/Extension/CGAffineTransform+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGAffineTransform+Extension.swift#L34-L35

Added lines #L34 - L35 were not covered by tests
}

package var scale: CGFloat {
let m = a * a + b * b
let n = c * c + d * d

if m == 1.0 && n == 1.0 {
return 1.0
} else {
return (sqrt(m) + sqrt(n)) / 2

Check warning on line 45 in Sources/OpenSwiftUICore/Extension/CGAffineTransform+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGAffineTransform+Extension.swift#L38-L45

Added lines #L38 - L45 were not covered by tests
}
}
}

extension CGAffineTransform: ProtobufMessage {
package func encode(to encoder: inout ProtobufEncoder) throws {
encoder.cgFloatField(1, a, defaultValue: 1)
encoder.cgFloatField(2, b, defaultValue: 0)
encoder.cgFloatField(3, c, defaultValue: 0)
encoder.cgFloatField(4, d, defaultValue: 1)
encoder.cgFloatField(5, tx, defaultValue: 0)
encoder.cgFloatField(6, ty, defaultValue: 0)
}

package init(from decoder: inout ProtobufDecoder) throws {
var transform = CGAffineTransform.identity
while let field = try decoder.nextField() {
switch field.tag {
case 1: transform.a = try decoder.cgFloatField(field)
case 2: transform.b = try decoder.cgFloatField(field)
case 3: transform.c = try decoder.cgFloatField(field)
case 4: transform.d = try decoder.cgFloatField(field)
case 5: transform.tx = try decoder.cgFloatField(field)
case 6: transform.ty = try decoder.cgFloatField(field)
default: try decoder.skipField(field)
}
}
self = transform
}
}

#endif
151 changes: 151 additions & 0 deletions Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
//
// CGPoint+Extension.swift
// OpenSwiftUICore
//
// Audited for iOS 18.0
// Status: Complete

public import Foundation

@_spi(ForOpenSwiftUIOnly) public typealias PlatformPoint = CGPoint

extension CGPoint {
@inlinable
package static var infinity: CGPoint {
.init(x: CGFloat.infinity, y: CGFloat.infinity)

Check warning on line 15 in Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift#L14-L15

Added lines #L14 - L15 were not covered by tests
}

@inlinable
package init(_ size: CGSize) {
self.init(x: size.width, y: size.height)

Check warning on line 20 in Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift#L19-L20

Added lines #L19 - L20 were not covered by tests
}

@inlinable
package var isFinite: Bool {
x.isFinite && y.isFinite

Check warning on line 25 in Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift#L24-L25

Added lines #L24 - L25 were not covered by tests
}

@inlinable
package func offsetBy(dx: CGFloat, dy: CGFloat) -> CGPoint {
CGPoint(x: x + dx, y: y + dy)

Check warning on line 30 in Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift#L29-L30

Added lines #L29 - L30 were not covered by tests
}

@inlinable
package func offsetBy(dx: CGFloat) -> CGPoint {
offsetBy(dx: dx, dy: 0)

Check warning on line 35 in Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift#L34-L35

Added lines #L34 - L35 were not covered by tests
}

@inlinable
package func offsetBy(dy: CGFloat) -> CGPoint {
offsetBy(dx: 0, dy: dy)

Check warning on line 40 in Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift#L39-L40

Added lines #L39 - L40 were not covered by tests
}

@inlinable
package func offset(by offset: CGSize) -> CGPoint {
offsetBy(dx: offset.width, dy: offset.height)

Check warning on line 45 in Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift#L44-L45

Added lines #L44 - L45 were not covered by tests
}

@inlinable
package func scaledBy(x: CGFloat, y: CGFloat) -> CGPoint {
CGPoint(x: self.x * x, y: self.y * y)

Check warning on line 50 in Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift#L49-L50

Added lines #L49 - L50 were not covered by tests
}

@inlinable
package func scaledBy(x: CGFloat) -> CGPoint {
scaledBy(x: x, y: 1)

Check warning on line 55 in Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift#L54-L55

Added lines #L54 - L55 were not covered by tests
}

@inlinable
package func scaledBy(y: CGFloat) -> CGPoint {
scaledBy(x: 1, y: y)

Check warning on line 60 in Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift#L59-L60

Added lines #L59 - L60 were not covered by tests
}

@inlinable
package func scaled(by scale: CGFloat) -> CGPoint {
scaledBy(x: scale, y: scale)

Check warning on line 65 in Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift#L64-L65

Added lines #L64 - L65 were not covered by tests
}

@inlinable
package var isNaN: Bool {
x.isNaN || y.isNaN

Check warning on line 70 in Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift#L69-L70

Added lines #L69 - L70 were not covered by tests
}

@inlinable
package var flushingNaNs: CGPoint {
CGPoint(x: !x.isNaN ? x : 0, y: !y.isNaN ? y : 0)

Check warning on line 75 in Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift#L74-L75

Added lines #L74 - L75 were not covered by tests
}

@inlinable
package func approximates(_ other: CGPoint, epsilon: CGFloat) -> Bool {
x.approximates(other.x, epsilon: epsilon)
&& y.approximates(other.y, epsilon: epsilon)

Check warning on line 81 in Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift#L79-L81

Added lines #L79 - L81 were not covered by tests
}

@inlinable
package mutating func clamp(size: CGSize) {
x.clamp(to: 0...size.width)
y.clamp(to: 0...size.height)

Check warning on line 87 in Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift#L85-L87

Added lines #L85 - L87 were not covered by tests
}

@inlinable
package func clamped(size: CGSize) -> CGPoint {
var point = self
point.clamp(size: size)
return point

Check warning on line 94 in Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift#L91-L94

Added lines #L91 - L94 were not covered by tests
}

@inlinable
package mutating func clamp(rect: CGRect) {
x.clamp(to: rect.x...rect.size.width)
y.clamp(to: rect.y...rect.size.height)

Check warning on line 100 in Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift#L98-L100

Added lines #L98 - L100 were not covered by tests
}

@inlinable
package func clamped(rect: CGRect) -> CGPoint {
var point = self
point.clamp(rect: rect)
return point

Check warning on line 107 in Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift#L104-L107

Added lines #L104 - L107 were not covered by tests
}
}

extension CGPoint {
@inlinable
package subscript(d: Axis) -> CGFloat {
get { d == .horizontal ? x : y }
set { if d == .horizontal { x = newValue } else { y = newValue } }

Check warning on line 115 in Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift#L114-L115

Added lines #L114 - L115 were not covered by tests
}

@inlinable
package init(_ l1: CGFloat, in first: Axis, by l2: CGFloat) {
self = first == .horizontal ? CGPoint(x: l1, y: l2) : CGPoint(x: l2, y: l1)

Check warning on line 120 in Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift#L119-L120

Added lines #L119 - L120 were not covered by tests
}
}

extension CGPoint: Animatable {
public var animatableData: AnimatablePair<CGFloat, CGFloat> {
@inlinable
get { .init(x, y) }

Check warning on line 127 in Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift#L127

Added line #L127 was not covered by tests
@inlinable
set { (x, y) = (newValue.first, newValue.second) }

Check warning on line 129 in Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift#L129

Added line #L129 was not covered by tests
}
}

extension CGPoint: ProtobufMessage {
package func encode(to encoder: inout ProtobufEncoder) {
encoder.cgFloatField(1, x)
encoder.cgFloatField(2, y)

Check warning on line 136 in Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift#L134-L136

Added lines #L134 - L136 were not covered by tests
}

package init(from decoder: inout ProtobufDecoder) throws {
var x: CGFloat = .zero
var y: CGFloat = .zero
while let field = try decoder.nextField() {
switch field.tag {
case 1: x = try decoder.cgFloatField(field)
case 2: y = try decoder.cgFloatField(field)
default: try decoder.skipField(field)

Check warning on line 146 in Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift#L139-L146

Added lines #L139 - L146 were not covered by tests
}
}
self.init(x: x, y: y)

Check warning on line 149 in Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift#L149

Added line #L149 was not covered by tests
}
}
Loading
Loading