Skip to content

Commit

Permalink
Rename Color, EdgeInset and Font typealiases to fix namespace conflic…
Browse files Browse the repository at this point in the history
…ts with SwiftUI Types 🚀 (#1055)

* Fix SwiftUI namespace conflict by renaming Color typealias to SFColor and EdgeInsets to SFEdgeInsets.

* Rename Font typealias to SFFont to fix SwiftUI's Font namespace conflict

* Add change log entry.

Co-authored-by: Luciano Almeida <passos.luciano@outlook.com>
  • Loading branch information
MussaCharles and LucianoPAlmeida committed Nov 8, 2022
1 parent 736cfe5 commit b8dfdc6
Show file tree
Hide file tree
Showing 32 changed files with 729 additions and 722 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
The changelog for **SwifterSwift**. Also see the [releases](https://github.com/SwifterSwift/SwifterSwift/releases) on GitHub.

## Upcoming Release
### Breaking Change
- **Color**
- Renamed typealias `Color` typealias to `SFColor` to fix namespace conflicts with swiftUI's `Color` Type. [#1055](https://github.com/SwifterSwift/SwifterSwift/pull/1055) by [MussaCharles](https://github.com/MussaCharles)
- **EdgeInsets**
- Renamed `EdgeInsets` typealias to `SFEdgeInsets` to fix namespace conflicts with swiftUI's `EdgeInsets` Type. [#1055](https://github.com/SwifterSwift/SwifterSwift/pull/1055) by [MussaCharles](https://github.com/MussaCharles)
- **Font**
- Renamed `Font` typealias to `SFFont` to fix namespace conflicts with swiftUI's `Font` Type. [#1055](https://github.com/SwifterSwift/SwifterSwift/pull/1055) by [MussaCharles](https://github.com/MussaCharles)

### Added
- **UIButton**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public extension CAGradientLayer {
/// - startPoint: start point corresponds to the first gradient stop (I.e. [0,0] is the bottom-corner of the layer, [1,1] is the top-right corner).
/// - endPoint: end point corresponds to the last gradient stop
/// - type: The kind of gradient that will be drawn. Currently, the only allowed values are `axial' (the default value), `radial', and `conic'.
convenience init(colors: [Color],
convenience init(colors: [SFColor],
locations: [CGFloat]? = nil,
startPoint: CGPoint = CGPoint(x: 0.5, y: 0),
endPoint: CGPoint = CGPoint(x: 0.5, y: 1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ public extension NSAttributedString {
guard !string.isEmpty else { return self }

let pointSize: CGFloat
if let font = attribute(.font, at: 0, effectiveRange: nil) as? Font {
if let font = attribute(.font, at: 0, effectiveRange: nil) as? SFFont {
pointSize = font.pointSize
} else {
#if os(tvOS) || os(watchOS)
pointSize = Font.preferredFont(forTextStyle: .headline).pointSize
pointSize = SFFont.preferredFont(forTextStyle: .headline).pointSize
#else
pointSize = Font.systemFontSize
pointSize = SFFont.systemFontSize
#endif
}
return applying(attributes: [.font: Font.boldSystemFont(ofSize: pointSize)])
return applying(attributes: [.font: SFFont.boldSystemFont(ofSize: pointSize)])
}
#endif

Expand Down Expand Up @@ -93,7 +93,7 @@ public extension NSAttributedString {
///
/// - Parameter color: text color.
/// - Returns: a NSAttributedString colored with given color.
func colored(with color: Color) -> NSAttributedString {
func colored(with color: SFColor) -> NSAttributedString {
return applying(attributes: [.foregroundColor: color])
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwifterSwift/MapKit/MKMapViewExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public extension MKMapView {
/// - meter: If arrays have a single item, they take the value of meters (Double). The map zooms in at the given meters.
/// - edgePadding: The amount of additional space (measured in screen points) to make visible around the specified rectangle
/// - animated: The animation control takes the Boolean value. Enter the true value for zooming with the animation.
func zoom(to coordinates: [CLLocationCoordinate2D], meter: Double, edgePadding: EdgeInsets, animated: Bool) {
func zoom(to coordinates: [CLLocationCoordinate2D], meter: Double, edgePadding: SFEdgeInsets, animated: Bool) {
guard !coordinates.isEmpty else { return }

if coordinates.count == 1 {
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwifterSwift/SceneKit/SCNBoxExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public extension SCNBox {
/// - length: The length of the box along the z-axis of its local coordinate space.
/// - chamferRadius: The radius of curvature for the edges and corners of the box.
/// - color: The color of the geometry's material.
convenience init(width: CGFloat, height: CGFloat, length: CGFloat, chamferRadius: CGFloat = 0, color: Color) {
convenience init(width: CGFloat, height: CGFloat, length: CGFloat, chamferRadius: CGFloat = 0, color: SFColor) {
self.init(width: width, height: height, length: length, chamferRadius: chamferRadius)
materials = [SCNMaterial(color: color)]
}
Expand All @@ -73,7 +73,7 @@ public extension SCNBox {
/// - sideLength: The width, height, and length of the box in its local coordinate space.
/// - chamferRadius: The radius of curvature for the edges and corners of the box.
/// - color: The color of the geometry's material.
convenience init(sideLength: CGFloat, chamferRadius: CGFloat = 0, color: Color) {
convenience init(sideLength: CGFloat, chamferRadius: CGFloat = 0, color: SFColor) {
self.init(width: sideLength, height: sideLength, length: sideLength, chamferRadius: chamferRadius)
materials = [SCNMaterial(color: color)]
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwifterSwift/SceneKit/SCNCapsuleExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public extension SCNCapsule {
/// - capRadius: The radius both of the capsule’s cylindrical body and of its hemispherical ends.
/// - height: The height of the capsule along the y-axis of its local coordinate space.
/// - material: The material of the geometry.
convenience init(capRadius: CGFloat, height: CGFloat, color: Color) {
convenience init(capRadius: CGFloat, height: CGFloat, color: SFColor) {
self.init(capRadius: capRadius, height: height)
materials = [SCNMaterial(color: color)]
}
Expand All @@ -54,7 +54,7 @@ public extension SCNCapsule {
/// - capDiameter: The diameter both of the capsule’s cylindrical body and of its hemispherical ends.
/// - height: The height of the capsule along the y-axis of its local coordinate space.
/// - material: The material of the geometry.
convenience init(capDiameter: CGFloat, height: CGFloat, color: Color) {
convenience init(capDiameter: CGFloat, height: CGFloat, color: SFColor) {
self.init(capRadius: capDiameter / 2, height: height)
materials = [SCNMaterial(color: color)]
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwifterSwift/SceneKit/SCNConeExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public extension SCNCone {
/// - bottomRadius: The radius of the cone’s base, forming a circle in the x- and z-axis dimensions of its local coordinate space.
/// - height: The height of the cone along the y-axis of its local coordinate space.
/// - color: The color of the geometry's material.
convenience init(topRadius: CGFloat, bottomRadius: CGFloat, height: CGFloat, color: Color) {
convenience init(topRadius: CGFloat, bottomRadius: CGFloat, height: CGFloat, color: SFColor) {
self.init(topRadius: topRadius, bottomRadius: bottomRadius, height: height)
materials = [SCNMaterial(color: color)]
}
Expand All @@ -59,7 +59,7 @@ public extension SCNCone {
/// - bottomDiameter: The diameter of the cone’s base, forming a circle in the x- and z-axis dimensions of its local coordinate space.
/// - height: The height of the cone along the y-axis of its local coordinate space.
/// - color: The color of the geometry's material.
convenience init(topDiameter: CGFloat, bottomDiameter: CGFloat, height: CGFloat, color: Color) {
convenience init(topDiameter: CGFloat, bottomDiameter: CGFloat, height: CGFloat, color: SFColor) {
self.init(topRadius: topDiameter / 2, bottomRadius: bottomDiameter / 2, height: height)
materials = [SCNMaterial(color: color)]
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwifterSwift/SceneKit/SCNCylinderExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public extension SCNCylinder {
/// - radius: The radius of the cylinder’s circular cross section in the x- and z-axis dimensions of its local coordinate space.
/// - height: The height of the cylinder along the y-axis of its local coordinate space.
/// - color: The color of the geometry's material.
convenience init(radius: CGFloat, height: CGFloat, color: Color) {
convenience init(radius: CGFloat, height: CGFloat, color: SFColor) {
self.init(radius: radius, height: height)
materials = [SCNMaterial(color: color)]
}
Expand All @@ -54,7 +54,7 @@ public extension SCNCylinder {
/// - diameter: The diameter of the cylinder’s circular cross section in the x- and z-axis dimensions of its local coordinate space.
/// - height: The height of the cylinder along the y-axis of its local coordinate space.
/// - color: The color of the geometry's material.
convenience init(diameter: CGFloat, height: CGFloat, color: Color) {
convenience init(diameter: CGFloat, height: CGFloat, color: SFColor) {
self.init(radius: diameter / 2, height: height)
materials = [SCNMaterial(color: color)]
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwifterSwift/SceneKit/SCNMaterialExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public extension SCNMaterial {
/// SwifterSwift: Initializes a SCNMaterial with a specific diffuse color.
///
/// - Parameter color: diffuse color.
convenience init(color: Color) {
convenience init(color: SFColor) {
self.init()
diffuse.contents = color
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwifterSwift/SceneKit/SCNPlaneExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public extension SCNPlane {
/// - width: The width of the plane along the x-axis of its local coordinate space.
/// - height: The height of the plane along the y-axis of its local coordinate space.
/// - color: The color of the geometry's material.
convenience init(width: CGFloat, height: CGFloat, color: Color) {
convenience init(width: CGFloat, height: CGFloat, color: SFColor) {
self.init(width: width, height: height)
materials = [SCNMaterial(color: color)]
}
Expand All @@ -50,7 +50,7 @@ public extension SCNPlane {
/// - Parameters:
/// - width: The width and height of the plane along the x-axis and y-axis of its local coordinate space.
/// - color: The color of the geometry's material.
convenience init(width: CGFloat, color: Color) {
convenience init(width: CGFloat, color: SFColor) {
self.init(width: width, height: width)
materials = [SCNMaterial(color: color)]
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwifterSwift/SceneKit/SCNShapeExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public extension SCNShape {
/// - path: The two-dimensional path forming the basis of the shape.
/// - extrusionDepth: The thickness of the extruded shape along the z-axis.
/// - color: The color of the geometry's material.
convenience init(path: UIBezierPath, extrusionDepth: CGFloat, color: Color) {
convenience init(path: UIBezierPath, extrusionDepth: CGFloat, color: SFColor) {
self.init(path: path, extrusionDepth: extrusionDepth)
materials = [SCNMaterial(color: color)]
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwifterSwift/SceneKit/SCNSphereExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public extension SCNSphere {
/// - Parameters:
/// - radius: The radius of the sphere in its local coordinate space.
/// - color: The color of the geometry's material.
convenience init(radius: CGFloat, color: Color) {
convenience init(radius: CGFloat, color: SFColor) {
self.init(radius: radius, material: SCNMaterial(color: color))
}

Expand All @@ -47,7 +47,7 @@ public extension SCNSphere {
/// - Parameters:
/// - diameter: The diameter of the sphere in its local coordinate space.
/// - color: The color of the geometry's material.
convenience init(diameter: CGFloat, color: Color) {
convenience init(diameter: CGFloat, color: SFColor) {
self.init(diameter: diameter, material: SCNMaterial(color: color))
}
}
Expand Down
Loading

0 comments on commit b8dfdc6

Please sign in to comment.