Skip to content

Commit

Permalink
1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
nathantannar4 committed Jul 31, 2024
1 parent 855b631 commit eb872a6
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ extension View {

@frozen
public struct AccessibilityShowsLargeContentViewModifierIfAvailable: VersionedViewModifier {

@inlinable
public init() { }

@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public func v3Body(content: Content) -> some View {
content
Expand All @@ -41,12 +45,15 @@ public struct AccessibilityLargeContentViewModifierIfAvailable<Label: View>: Ver
}

extension View {
@inlinable
public func accessibilityShowsLargeContentViewerIfAvailable() -> some View {
modifier(AccessibilityShowsLargeContentViewModifierIfAvailable())
}

@inlinable
public func accessibilityLargeContentViewerIfAvailable<Label: View>(@ViewBuilder label: () -> Label) -> some View {
public func accessibilityLargeContentViewerIfAvailable<Label: View>(
@ViewBuilder label: () -> Label
) -> some View {
modifier(AccessibilityLargeContentViewModifierIfAvailable(label: label))
}
}
Expand Down
20 changes: 17 additions & 3 deletions Sources/Turbocharger/Sources/ViewModifier/AlignmentOffset.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import SwiftUI

/// A modifier that scales the edge alignment guides by an offset
@frozen
public struct AlignmentGuideAdjustmentModifier: ViewModifier {

public var anchor: UnitPoint
public var offset: CGPoint

@inlinable
public init(anchor: UnitPoint, offset: CGPoint) {
self.anchor = anchor
self.offset = offset
Expand All @@ -27,17 +29,29 @@ public struct AlignmentGuideAdjustmentModifier: ViewModifier {
extension View {

/// A modifier that scales the edge alignment guides by an offset
public func alignmentGuideAdjustment(anchor: UnitPoint) -> some View {
@inlinable
public func alignmentGuideAdjustment(
anchor: UnitPoint
) -> some View {
modifier(AlignmentGuideAdjustmentModifier(anchor: anchor, offset: .zero))
}

/// A modifier that scales the edge alignment guides by an offset
public func alignmentGuideAdjustment(x: CGFloat, y: CGFloat) -> some View {
@inlinable
public func alignmentGuideAdjustment(
x: CGFloat,
y: CGFloat
) -> some View {
modifier(AlignmentGuideAdjustmentModifier(anchor: .zero, offset: CGPoint(x: x, y: y)))
}

/// A modifier that scales the edge alignment guides by an offset
public func alignmentGuideAdjustment(anchor: UnitPoint, x: CGFloat, y: CGFloat) -> some View {
@inlinable
public func alignmentGuideAdjustment(
anchor: UnitPoint,
x: CGFloat,
y: CGFloat
) -> some View {
modifier(AlignmentGuideAdjustmentModifier(anchor: anchor, offset: CGPoint(x: x, y: y)))
}
}
3 changes: 3 additions & 0 deletions Sources/Turbocharger/Sources/ViewModifier/Badge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import SwiftUI

/// A modifier that adds a view as a badge
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
@frozen
public struct BadgeModifier<Label: View>: ViewModifier {

public var alignment: Alignment
Expand All @@ -14,6 +15,7 @@ public struct BadgeModifier<Label: View>: ViewModifier {
public var inset: CGFloat
public var label: Label

@inlinable
public init(
alignment: Alignment,
anchor: UnitPoint = UnitPoint(x: 0.25, y: 0.25),
Expand All @@ -28,6 +30,7 @@ public struct BadgeModifier<Label: View>: ViewModifier {
self.inset = inset
}

@inlinable
public init(
alignment: Alignment,
anchor: UnitPoint = UnitPoint(x: 0.25, y: 0.25),
Expand Down
7 changes: 2 additions & 5 deletions Sources/Turbocharger/Sources/ViewModifier/Hidden.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ import SwiftUI
@frozen
public struct HiddenModifier: ViewModifier {

@usableFromInline
var isHidden: Bool

@usableFromInline
var transition: AnyTransition
public var isHidden: Bool
public var transition: AnyTransition

@inlinable
public init(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ public struct OnAppearAndChangeModifier<
Value: Equatable
>: VersionedViewModifier {

@usableFromInline
var value: Value

@usableFromInline
var action: (Value) -> Void
public var value: Value
public var action: (Value) -> Void

@inlinable
public init(value: Value, action: @escaping (Value) -> Void) {
Expand Down
8 changes: 7 additions & 1 deletion Sources/Turbocharger/Sources/ViewModifier/SafeArea.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,32 @@ public struct SafeAreaPaddingModifier: ViewModifier {
}
}

@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS, introduced: 14.0, deprecated: 100000.0, message: "Please use the built in safeAreaPadding modifier")
@available(macOS, introduced: 11.0, deprecated: 100000.0, message: "Please use the built in safeAreaPadding modifier")
@available(tvOS, introduced: 14.0, deprecated: 100000.0, message: "Please use the built in safeAreaPadding modifier")
@available(watchOS, introduced: 7.0, deprecated: 100000.0, message: "Please use the built in safeAreaPadding modifier")
extension View {

/// A modifier that adds additional safe area padding
/// to the edges of a view.
@inlinable
@_disfavoredOverload
public func safeAreaPadding(_ edgeInsets: EdgeInsets) -> some View {
modifier(SafeAreaPaddingModifier(edgeInsets))
}

/// A modifier that adds additional safe area padding
/// to the edges of a view.
@inlinable
@_disfavoredOverload
public func safeAreaPadding(_ length: CGFloat = 16) -> some View {
modifier(SafeAreaPaddingModifier(length))
}

/// A modifier that adds additional safe area padding
/// to the edges of a view.
@inlinable
@_disfavoredOverload
public func safeAreaPadding(_ edges: Edge.Set, _ length: CGFloat = 16) -> some View {
modifier(SafeAreaPaddingModifier(edges, length))
}
Expand Down
30 changes: 21 additions & 9 deletions Sources/Turbocharger/Sources/ViewModifier/ScaledFrame.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import SwiftUI
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
@frozen
public struct ScaledFrameModifier: ViewModifier {
var width: CGFloat?
var height: CGFloat?
var alignment: Alignment

public var width: CGFloat?
public var height: CGFloat?
public var alignment: Alignment
@ScaledMetric var scale: CGFloat

public init(
Expand All @@ -36,11 +37,12 @@ public struct ScaledFrameModifier: ViewModifier {
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
@frozen
public struct ScaledFlexFrameModifier: ViewModifier {
var minWidth: CGFloat?
var maxWidth: CGFloat?
var minHeight: CGFloat?
var maxHeight: CGFloat?
var alignment: Alignment

public var minWidth: CGFloat?
public var maxWidth: CGFloat?
public var minHeight: CGFloat?
public var maxHeight: CGFloat?
public var alignment: Alignment
@ScaledMetric var scale: CGFloat

public init(
Expand Down Expand Up @@ -72,10 +74,18 @@ public struct ScaledFlexFrameModifier: ViewModifier {

@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension View {
public func frame(_ size: CGFloat?, relativeTo textStyle: Font.TextStyle) -> some View {

@inlinable
@_disfavoredOverload
public func frame(
_ size: CGFloat?,
relativeTo textStyle: Font.TextStyle
) -> some View {
frame(width: size, height: size, alignment: .center, relativeTo: textStyle)
}

@inlinable
@_disfavoredOverload
public func frame(
width: CGFloat? = nil,
height: CGFloat? = nil,
Expand All @@ -92,6 +102,8 @@ extension View {
)
}

@inlinable
@_disfavoredOverload
public func frame(
minWidth: CGFloat? = nil,
maxWidth: CGFloat? = nil,
Expand Down

0 comments on commit eb872a6

Please sign in to comment.