Skip to content

Commit

Permalink
Fix build warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Ye committed Dec 16, 2023
1 parent 1255f73 commit dea3ffd
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 4 deletions.
7 changes: 5 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ let openSwiftUITarget = Target.target(
],
swiftSettings: [
.enableExperimentalFeature("AccessLevelOnImport"),
.define("OPENSWIFTUI_SUPPRESS_DEPRECATED_WARNINGS")
],
linkerSettings: [
.unsafeFlags(
Expand All @@ -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(
Expand Down
60 changes: 60 additions & 0 deletions Sources/OpenSwiftUI/Views/Controls/Slider/Slider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<V>(
value: Binding<V>,
in bounds: ClosedRange<V> = 0 ... 1,
Expand All @@ -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,
Expand All @@ -146,6 +160,7 @@ extension Slider {
maximumValueLabel: maximumValueLabel(),
label: label
)
#endif

Check warning on line 163 in Sources/OpenSwiftUI/Views/Controls/Slider/Slider.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUI/Views/Controls/Slider/Slider.swift#L141-L163

Added lines #L141 - L163 were not covered by tests
}

/// Creates a slider to select a value from a given range, subject to a
Expand All @@ -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<V>(
value: Binding<V>,
in bounds: ClosedRange<V>,
Expand All @@ -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,
Expand All @@ -188,6 +217,7 @@ extension Slider {
maximumValueLabel: maximumValueLabel(),
label: label
)
#endif

Check warning on line 220 in Sources/OpenSwiftUI/Views/Controls/Slider/Slider.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUI/Views/Controls/Slider/Slider.swift#L197-L220

Added lines #L197 - L220 were not covered by tests
}
}

Expand All @@ -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<V>(
value: Binding<V>,
in bounds: ClosedRange<V> = 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

Check warning on line 271 in Sources/OpenSwiftUI/Views/Controls/Slider/Slider.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUI/Views/Controls/Slider/Slider.swift#L251-L271

Added lines #L251 - L271 were not covered by tests
}

/// Creates a slider to select a value from a given range, subject to a
Expand All @@ -245,21 +290,36 @@ 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<V>(
value: Binding<V>,
in bounds: ClosedRange<V>,
step: V.Stride = 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: step,
onEditingChanged: onEditingChanged,
minimumValueLabel: EmptyView(),
maximumValueLabel: EmptyView(),
customMinMaxValueLabels: false,
label: label()
)
#else
self.init(
value: value,
in: bounds,
step: step,
onEditingChanged: onEditingChanged,
label: label
)
#endif

Check warning on line 322 in Sources/OpenSwiftUI/Views/Controls/Slider/Slider.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUI/Views/Controls/Slider/Slider.swift#L301-L322

Added lines #L301 - L322 were not covered by tests
}
}

Expand Down
10 changes: 8 additions & 2 deletions Sources/OpenSwiftUI/Views/View/internal/ViewAlias.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ protocol ViewAlias: PrimitiveView {
}

extension View {
func viewAlias<Alias: ViewAlias, Source: View>(_ alias: Alias.Type, _ source: () -> Source) -> some View {
func viewAlias<Alias: ViewAlias, Source: View>(
_ alias: Alias.Type,
_ source: () -> Source
) -> some View {
modifier(StaticSourceWriter<Alias, Source>(source: source()))

Check warning on line 19 in Sources/OpenSwiftUI/Views/View/internal/ViewAlias.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUI/Views/View/internal/ViewAlias.swift#L18-L19

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

func viewAlias<Alias: ViewAlias, Source: View>(_ alias: Alias.Type, _ source: () -> Source?) -> some View {
func viewAlias<Alias: ViewAlias, Source: View>(
_ alias: Alias.Type,
_ source: () -> Source?
) -> some View {
modifier(OptionalSourceWriter<Alias, Source>(source: source()))

Check warning on line 26 in Sources/OpenSwiftUI/Views/View/internal/ViewAlias.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUI/Views/View/internal/ViewAlias.swift#L25-L26

Added lines #L25 - L26 were not covered by tests
}
}
Expand Down

0 comments on commit dea3ffd

Please sign in to comment.