Skip to content

Commit

Permalink
Fix macOS compilation errors (related to SwiftUI focus code which is …
Browse files Browse the repository at this point in the history
…unavailable on our min macOS version)
  • Loading branch information
stackotter committed Apr 15, 2024
1 parent efb2356 commit 63c9484
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 24 deletions.
20 changes: 1 addition & 19 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -172,24 +172,6 @@
"version": null
}
},
{
"package": "Swift Grammar",
"repositoryURL": "https://github.com/tayloraswift/swift-grammar",
"state": {
"branch": null,
"revision": "163ce5d4d88db7d94f2f4ca1cabcb2ae65af8af7",
"version": "0.3.3"
}
},
{
"package": "swift-hash",
"repositoryURL": "https://github.com/tayloraswift/swift-hash",
"state": {
"branch": null,
"revision": "c7ba0cde5eb63042c2196b02b65a770101c1ac11",
"version": "0.5.0"
}
},
{
"package": "SwiftImage",
"repositoryURL": "https://github.com/stackotter/swift-image.git",
Expand Down Expand Up @@ -258,7 +240,7 @@
"repositoryURL": "https://github.com/stackotter/swift-png",
"state": {
"branch": null,
"revision": "dee856ec2cad5a91060ace4729db7e6d747572b3",
"revision": "b68a5662ef9887c8f375854720b3621f772bf8c5",
"version": null
}
},
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ targets.append(.executableTarget(
name: "DeltaClient",
dependencies: [
"DynamicShim",
// .product(name: "SwordRPC", package: "SwordRPC", condition: .when(platforms: [.macOS])),
.product(name: "SwordRPC", package: "SwordRPC", condition: .when(platforms: [.macOS])),
.product(name: "ArgumentParser", package: "swift-argument-parser")
],
path: "Sources/Client"
Expand Down
15 changes: 12 additions & 3 deletions Sources/Client/Views/Play/InGameMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct InGameMenu: View {
@Binding var presented: Bool
@State var state: InGameMenuState = .menu

#if os(tvOS)
@FocusState var focusState: FocusElements?

func moveFocus(_ direction: MoveCommandDirection) {
Expand All @@ -37,6 +38,7 @@ struct InGameMenu: View {
case settings
case disconnect
}
#endif

init(presented: Binding<Bool>) {
_presented = presented
Expand All @@ -52,23 +54,28 @@ struct InGameMenu: View {
Button("Back to game") {
presented = false
}
#if !os(tvOS)
.keyboardShortcut(.escape, modifiers: [])
#endif
#if os(tvOS)
.focused($focusState, equals: .backToGame)
.buttonStyle(PrimaryButtonStyle())
#else
.keyboardShortcut(.escape, modifiers: [])
#endif

Button("Settings") {
state = .settings
}
#if os(tvOS)
.focused($focusState, equals: .settings)
.buttonStyle(SecondaryButtonStyle())
#endif

Button("Disconnect") {
appState.update(to: .serverList)
}
#if os(tvOS)
.focused($focusState, equals: .disconnect)
.buttonStyle(SecondaryButtonStyle())
#endif
}
#if !os(tvOS)
.frame(width: 200)
Expand All @@ -81,10 +88,12 @@ struct InGameMenu: View {
}
.frame(width: geometry.size.width, height: geometry.size.height)
.background(Color.black.opacity(0.702), alignment: .center)
#if os(tvOS)
.onAppear {
focusState = .backToGame
}
.focusSection()
#endif
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ let package = Package(
.package(url: "https://github.com/fourplusone/swift-package-zlib", from: "1.2.11"),
.package(url: "https://github.com/stackotter/swift-image.git", branch: "master"),
.package(url: "https://github.com/OpenCombine/OpenCombine.git", from: "0.13.0"),
.package(url: "https://github.com/stackotter/swift-png", revision: "dee856ec2cad5a91060ace4729db7e6d747572b3"),
.package(url: "https://github.com/stackotter/swift-png", revision: "b68a5662ef9887c8f375854720b3621f772bf8c5"),
.package(url: "https://github.com/stackotter/ASN1Parser", branch: "main"),
.package(url: "https://github.com/krzyzanowskim/CryptoSwift", from: "1.6.0"),
.package(url: "https://github.com/Kitura/SwiftyRequest.git", from: "3.1.0"),
Expand Down

0 comments on commit 63c9484

Please sign in to comment.