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

Use CGFloat, CGPoint, CGRect from Foundation #411

Merged
merged 3 commits into from
Jun 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Sources/TokamakCore/Modifiers/Effects/ClipEffect.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Tokamak contributors
// Copyright 2020-2021 Tokamak contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -15,6 +15,8 @@
// Created by Carson Katri on 06/29/2020.
//

import Foundation

public struct _ClipEffect<ClipShape>: ViewModifier where ClipShape: Shape {
public var shape: ClipShape
public var style: FillStyle
Expand Down
4 changes: 3 additions & 1 deletion Sources/TokamakCore/Modifiers/Effects/GeometryEffect.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Tokamak contributors
// Copyright 2020-2021 Tokamak contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -15,6 +15,8 @@
// Created by Carson Katri on 7/3/20.
//

import Foundation

// FIXME: Make `Animatable`
public protocol GeometryEffect: ViewModifier {
func effectValue(size: CGSize) -> ProjectionTransform
Expand Down
6 changes: 4 additions & 2 deletions Sources/TokamakCore/Modifiers/Effects/RotationEffect.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Tokamak contributors
// Copyright 2020-2021 Tokamak contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -15,6 +15,8 @@
// Created by Carson Katri on 7/3/20.
//

import Foundation

public struct _RotationEffect: GeometryEffect {
public var angle: Angle
public var anchor: UnitPoint
Expand All @@ -25,7 +27,7 @@ public struct _RotationEffect: GeometryEffect {
}

public func effectValue(size: CGSize) -> ProjectionTransform {
.init(CGAffineTransform.identity.rotated(by: angle.radians))
.init(CGAffineTransform.identity.rotated(by: CGFloat(angle.radians)))
}

public func body(content: Content) -> some View {
Expand Down
4 changes: 3 additions & 1 deletion Sources/TokamakCore/Modifiers/FlexFrameLayout.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Tokamak contributors
// Copyright 2020-2021 Tokamak contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import Foundation

public struct _FlexFrameLayout: ViewModifier {
public let minWidth: CGFloat?
public let idealWidth: CGFloat?
Expand Down
4 changes: 3 additions & 1 deletion Sources/TokamakCore/Modifiers/FrameLayout.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Tokamak contributors
// Copyright 2020-2021 Tokamak contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import Foundation

public struct _FrameLayout: ViewModifier {
public let width: CGFloat?
public let height: CGFloat?
Expand Down
4 changes: 3 additions & 1 deletion Sources/TokamakCore/Modifiers/PaddingLayout.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Tokamak contributors
// Copyright 2020-2021 Tokamak contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import Foundation

public struct _PaddingLayout: ViewModifier {
public var edges: Edge.Set
public var insets: EdgeInsets?
Expand Down
16 changes: 16 additions & 0 deletions Sources/TokamakCore/Modifiers/ShadowLayout.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// Copyright 2021 Tokamak contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import Foundation

public struct _ShadowLayout: ViewModifier, EnvironmentReader {
public var color: Color
public var radius: CGFloat
Expand Down
4 changes: 3 additions & 1 deletion Sources/TokamakCore/Modifiers/StyleModifiers.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Tokamak contributors
// Copyright 2020-2021 Tokamak contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -15,6 +15,8 @@
// Created by Carson Katri on 6/29/20.
//

import Foundation

public struct _BackgroundModifier<Background>: ViewModifier, EnvironmentReader
where Background: View
{
Expand Down
4 changes: 3 additions & 1 deletion Sources/TokamakCore/PreviewProvider.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Tokamak contributors
// Copyright 2020-2021 Tokamak contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import Foundation

/// This protocol has no functionality currently, and is only provided for compatibility purposes.
public protocol PreviewProvider {
associatedtype Previews: View
Expand Down
4 changes: 3 additions & 1 deletion Sources/TokamakCore/Shapes/Ellipse.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Tokamak contributors
// Copyright 2020-2021 Tokamak contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -15,6 +15,8 @@
// Created by Carson Katri on 6/29/20.
//

import Foundation

public struct Ellipse: Shape {
public func path(in rect: CGRect) -> Path {
.init(storage: .ellipse(rect), sizing: .flexible)
Expand Down
4 changes: 3 additions & 1 deletion Sources/TokamakCore/Shapes/FixedRoundedRect.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Tokamak contributors
// Copyright 2020-2021 Tokamak contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -15,6 +15,8 @@
// Created by Carson Katri on 7/22/20.
//

import Foundation

public struct FixedRoundedRect: Equatable {
public let rect: CGRect
public let cornerSize: CGSize?
Expand Down
6 changes: 4 additions & 2 deletions Sources/TokamakCore/Shapes/ModifiedShapes.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Tokamak contributors
// Copyright 2020-2021 Tokamak contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -15,6 +15,8 @@
// Created by Carson Katri on 06/28/2020.
//

import Foundation

public struct _StrokedShape<S>: Shape where S: Shape {
@Environment(\.self) public var environment
public var shape: S
Expand Down Expand Up @@ -106,7 +108,7 @@ public struct RotatedShape<Content>: Shape where Content: Shape {
public func path(in rect: CGRect) -> Path {
shape
.path(in: rect)
.applying(.init(rotationAngle: angle.radians))
.applying(.init(rotationAngle: CGFloat(angle.radians)))
}
}

Expand Down
11 changes: 3 additions & 8 deletions Sources/TokamakCore/Shapes/Path.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Tokamak contributors
// Copyright 2020-2021 Tokamak contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -15,13 +15,7 @@
// Created by Carson Katri on 06/28/2020.
//

#if canImport(Darwin)
import Darwin
#elseif canImport(Glibc)
import Glibc
#elseif os(WASI)
import WASILibc
#endif
import Foundation

/// The outline of a 2D shape.
public struct Path: Equatable, LosslessStringConvertible {
Expand Down Expand Up @@ -610,6 +604,7 @@ private func getArc(
clockwise: clockwise
)
} else {
let angle = CGFloat(angle)
let endPoint = CGPoint(
x: (radius * cos(angle)) + center.x,
y: (radius * sin(angle)) + center.y
Expand Down
4 changes: 3 additions & 1 deletion Sources/TokamakCore/Shapes/Rectangle.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2020 Tokamak contributors
// Copyright 2018-2021 Tokamak contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import Foundation

public struct Rectangle: Shape {
public func path(in rect: CGRect) -> Path {
.init(storage: .rect(rect), sizing: .flexible)
Expand Down
4 changes: 3 additions & 1 deletion Sources/TokamakCore/Shapes/Shape.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Tokamak contributors
// Copyright 2020-2021 Tokamak contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -15,6 +15,8 @@
// Created by Carson Katri on 06/28/2020.
//

import Foundation

public protocol Shape: View {
func path(in rect: CGRect) -> Path
}
Expand Down
4 changes: 3 additions & 1 deletion Sources/TokamakCore/Shapes/ShapeModifiers.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Tokamak contributors
// Copyright 2020-2021 Tokamak contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -15,6 +15,8 @@
// Created by Carson Katri on 6/29/20.
//

import Foundation

public extension InsettableShape {
func strokeBorder<S>(
_ content: S,
Expand Down
4 changes: 3 additions & 1 deletion Sources/TokamakCore/Shapes/StrokeStyle.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Tokamak contributors
// Copyright 2020-2021 Tokamak contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -15,6 +15,8 @@
// Created by Carson Katri on 7/22/20.
//

import Foundation

public struct StrokeStyle: Equatable {
public var lineWidth: CGFloat
public var lineCap: CGLineCap
Expand Down
4 changes: 3 additions & 1 deletion Sources/TokamakCore/Shapes/TrimmedPath.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Tokamak contributors
// Copyright 2020-2021 Tokamak contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -15,6 +15,8 @@
// Created by Carson Katri on 7/22/20.
//

import Foundation

public struct TrimmedPath: Equatable {
public let path: Path
public let from: CGFloat
Expand Down
Loading