diff --git a/Package.swift b/Package.swift index ddcf154..61b6186 100644 --- a/Package.swift +++ b/Package.swift @@ -20,6 +20,7 @@ let openSwiftUITarget = Target.target( ], swiftSettings: [ .enableExperimentalFeature("AccessLevelOnImport"), + .define("OPENSWIFTUI_SUPPRESS_DEPRECATED_WARNINGS") ], linkerSettings: [ .unsafeFlags( @@ -36,13 +37,15 @@ let openSwiftUITestTarget = Target.testTarget( name: "OpenSwiftUITests", dependencies: [ "OpenSwiftUI", - ] + ], + exclude: ["README.md"] ) let openSwiftUICompatibilityTestTarget = Target.testTarget( name: "OpenSwiftUICompatibilityTests", dependencies: [ "OpenSwiftUI", - ] + ], + exclude: ["README.md"] ) let package = Package( diff --git a/Sources/OpenSwiftUI/Views/Controls/Slider/Slider.swift b/Sources/OpenSwiftUI/Views/Controls/Slider/Slider.swift index f18bfd3..0f2e1ba 100644 --- a/Sources/OpenSwiftUI/Views/Controls/Slider/Slider.swift +++ b/Sources/OpenSwiftUI/Views/Controls/Slider/Slider.swift @@ -129,7 +129,9 @@ extension Slider { /// The slider calls `onEditingChanged` when editing begins and ends. For /// example, on iOS, editing begins when the user starts to drag the thumb /// along the slider's track. + #if !OPENSWIFTUI_SUPPRESS_DEPRECATED_WARNINGS @_alwaysEmitIntoClient + #endif public init( value: Binding, in bounds: ClosedRange = 0 ... 1, @@ -138,6 +140,18 @@ extension Slider { @ViewBuilder maximumValueLabel: () -> ValueLabel, onEditingChanged: @escaping (Bool) -> Void = { _ in } ) where V: BinaryFloatingPoint, V.Stride: BinaryFloatingPoint { + #if OPENSWIFTUI_SUPPRESS_DEPRECATED_WARNINGS + self.init( + value: value, + in: bounds, + step: nil, + onEditingChanged: onEditingChanged, + minimumValueLabel: minimumValueLabel(), + maximumValueLabel: maximumValueLabel(), + customMinMaxValueLabels: true, + label: label() + ) + #else self.init( value: value, in: bounds, @@ -146,6 +160,7 @@ extension Slider { maximumValueLabel: maximumValueLabel(), label: label ) + #endif } /// Creates a slider to select a value from a given range, subject to a @@ -169,7 +184,9 @@ extension Slider { /// The slider calls `onEditingChanged` when editing begins and ends. For /// example, on iOS, editing begins when the user starts to drag the thumb /// along the slider's track. + #if !OPENSWIFTUI_SUPPRESS_DEPRECATED_WARNINGS @_alwaysEmitIntoClient + #endif public init( value: Binding, in bounds: ClosedRange, @@ -179,6 +196,18 @@ extension Slider { @ViewBuilder maximumValueLabel: () -> ValueLabel, onEditingChanged: @escaping (Bool) -> Void = { _ in } ) where V: BinaryFloatingPoint, V.Stride: BinaryFloatingPoint { + #if OPENSWIFTUI_SUPPRESS_DEPRECATED_WARNINGS + self.init( + value: value, + in: bounds, + step: step, + onEditingChanged: onEditingChanged, + minimumValueLabel: minimumValueLabel(), + maximumValueLabel: maximumValueLabel(), + customMinMaxValueLabels: true, + label: label() + ) + #else self.init( value: value, in: bounds, @@ -188,6 +217,7 @@ extension Slider { maximumValueLabel: maximumValueLabel(), label: label ) + #endif } } @@ -211,19 +241,34 @@ extension Slider where ValueLabel == EmptyView { /// The slider calls `onEditingChanged` when editing begins and ends. For /// example, on iOS, editing begins when the user starts to drag the thumb /// along the slider's track. + #if !OPENSWIFTUI_SUPPRESS_DEPRECATED_WARNINGS @_alwaysEmitIntoClient + #endif public init( value: Binding, in bounds: ClosedRange = 0 ... 1, @ViewBuilder label: () -> Label, onEditingChanged: @escaping (Bool) -> Void = { _ in } ) where V: BinaryFloatingPoint, V.Stride: BinaryFloatingPoint { + #if OPENSWIFTUI_SUPPRESS_DEPRECATED_WARNINGS + self.init( + value: value, + in: bounds, + step: nil, + onEditingChanged: onEditingChanged, + minimumValueLabel: EmptyView(), + maximumValueLabel: EmptyView(), + customMinMaxValueLabels: false, + label: label() + ) + #else self.init( value: value, in: bounds, onEditingChanged: onEditingChanged, label: label ) + #endif } /// Creates a slider to select a value from a given range, subject to a @@ -245,7 +290,9 @@ extension Slider where ValueLabel == EmptyView { /// The slider calls `onEditingChanged` when editing begins and ends. For /// example, on iOS, editing begins when the user starts to drag the thumb /// along the slider's track. + #if !OPENSWIFTUI_SUPPRESS_DEPRECATED_WARNINGS @_alwaysEmitIntoClient + #endif public init( value: Binding, in bounds: ClosedRange, @@ -253,6 +300,18 @@ extension Slider where ValueLabel == EmptyView { @ViewBuilder label: () -> Label, onEditingChanged: @escaping (Bool) -> Void = { _ in } ) where V: BinaryFloatingPoint, V.Stride: BinaryFloatingPoint { + #if OPENSWIFTUI_SUPPRESS_DEPRECATED_WARNINGS + self.init( + value: value, + in: bounds, + step: step, + onEditingChanged: onEditingChanged, + minimumValueLabel: EmptyView(), + maximumValueLabel: EmptyView(), + customMinMaxValueLabels: false, + label: label() + ) + #else self.init( value: value, in: bounds, @@ -260,6 +319,7 @@ extension Slider where ValueLabel == EmptyView { onEditingChanged: onEditingChanged, label: label ) + #endif } } diff --git a/Sources/OpenSwiftUI/Views/View/internal/ViewAlias.swift b/Sources/OpenSwiftUI/Views/View/internal/ViewAlias.swift index 4009af2..2d0d10e 100644 --- a/Sources/OpenSwiftUI/Views/View/internal/ViewAlias.swift +++ b/Sources/OpenSwiftUI/Views/View/internal/ViewAlias.swift @@ -12,11 +12,17 @@ protocol ViewAlias: PrimitiveView { } extension View { - func viewAlias(_ alias: Alias.Type, _ source: () -> Source) -> some View { + func viewAlias( + _ alias: Alias.Type, + _ source: () -> Source + ) -> some View { modifier(StaticSourceWriter(source: source())) } - func viewAlias(_ alias: Alias.Type, _ source: () -> Source?) -> some View { + func viewAlias( + _ alias: Alias.Type, + _ source: () -> Source? + ) -> some View { modifier(OptionalSourceWriter(source: source())) } }