Skip to content

Commit 2b7a69b

Browse files
authored
Update examples and fix deprecation warning (pointfreeco#153)
* Update examples and fix deprecation warning * wip * wip
1 parent ec3b0f9 commit 2b7a69b

File tree

5 files changed

+151
-152
lines changed

5 files changed

+151
-152
lines changed

Examples/CaseStudies/01-Alerts.swift

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,18 @@ struct OptionalAlerts: View {
2121
}
2222
.disabled(self.model.isLoading)
2323
}
24-
.alert(
25-
title: { Text("Fact about \($0.number)") },
26-
unwrapping: self.$model.fact,
27-
actions: {
28-
Button("Get another fact about \($0.number)") {
29-
Task { await self.model.numberFactButtonTapped() }
30-
}
31-
Button("Close", role: .cancel) {
32-
self.model.fact = nil
33-
}
34-
},
35-
message: { Text($0.description) }
36-
)
24+
.alert(item: self.$model.fact) {
25+
Text("Fact about \($0.number)")
26+
} actions: {
27+
Button("Get another fact about \($0.number)") {
28+
Task { await self.model.numberFactButtonTapped() }
29+
}
30+
Button("Close", role: .cancel) {
31+
self.model.fact = nil
32+
}
33+
} message: {
34+
Text($0.description)
35+
}
3736
.navigationTitle("Alerts")
3837
}
3938
}

Examples/CaseStudies/02-ConfirmationDialogs.swift

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,15 @@ struct OptionalConfirmationDialogs: View {
2020
}
2121
}
2222
.disabled(self.model.isLoading)
23-
.confirmationDialog(
24-
title: { Text("Fact about \($0.number)") },
25-
titleVisibility: .visible,
26-
unwrapping: self.$model.fact,
27-
actions: {
28-
Button("Get another fact about \($0.number)") {
29-
Task { await self.model.numberFactButtonTapped() }
30-
}
31-
},
32-
message: { Text($0.description) }
33-
)
23+
.confirmationDialog(item: self.$model.fact, titleVisibility: .visible) {
24+
Text("Fact about \($0.number)")
25+
} actions: {
26+
Button("Get another fact about \($0.number)") {
27+
Task { await self.model.numberFactButtonTapped() }
28+
}
29+
} message: {
30+
Text($0.description)
31+
}
3432
}
3533
.navigationTitle("Dialogs")
3634
}

Sources/SwiftUINavigation/Internal/Deprecations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
}
1818

1919
@available(
20-
*, deprecated, renamed: "confirmationDialog(item:textVisibility:title:actions:message:)"
20+
*, deprecated, renamed: "confirmationDialog(item:titleVisibility:title:actions:message:)"
2121
)
2222
public func confirmationDialog<Value, A: View, M: View>(
2323
title: (Value) -> Text,

SwiftUINavigation.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 119 additions & 121 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tests/SwiftUINavigationTests/BindingTests.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,19 @@
3535
}
3636

3737
func testDestinationCannotReplaceOtherDestination() throws {
38-
@Binding var destination: Status?
39-
_destination = Binding(initialValue: .inStock(quantity: 1))
38+
#if os(iOS) || os(macOS)
39+
try XCTSkipIf(ProcessInfo.processInfo.environment["CI"] != nil)
4040

41-
let inStock = try XCTUnwrap($destination.inStock)
41+
@Binding var destination: Status?
42+
_destination = Binding(initialValue: .inStock(quantity: 1))
4243

43-
destination = .outOfStock(isOnBackOrder: true)
44+
let inStock = try XCTUnwrap($destination.inStock)
4445

45-
inStock.wrappedValue = 42
46-
XCTAssertEqual(destination, .outOfStock(isOnBackOrder: true))
46+
destination = .outOfStock(isOnBackOrder: true)
47+
48+
inStock.wrappedValue = 42
49+
XCTAssertEqual(destination, .outOfStock(isOnBackOrder: true))
50+
#endif
4751
}
4852
}
4953

0 commit comments

Comments
 (0)