Skip to content

Commit 54b5dae

Browse files
authored
Merge pull request #13 from SwiftPackageRepository/macOS-support-#11
macOS Support
2 parents f0e50f5 + e27dca6 commit 54b5dae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1381
-64
lines changed

Examples/GKMatchMaker/GKMatchMaker.xcodeproj/project.pbxproj

Lines changed: 68 additions & 28 deletions
Large diffs are not rendered by default.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>PreviewsEnabled</key>
6+
<false/>
7+
</dict>
8+
</plist>

Examples/GKMatchMaker/Shared/GKMatchMakerApp.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ struct GKMatchMakerApp: App {
3434
public var body: some Scene {
3535
WindowGroup {
3636
ZStack {
37+
Color("BackgroundColor").ignoresSafeArea()
3738
ContentView()
3839
.alert(isPresented: self.$viewModel.showAlert) {
3940
Alert(title: Text(self.viewModel.alertTitle),

Examples/GKMatchMaker/Shared/Modifiers/PrimaryButtonModifier.swift renamed to Examples/GKMatchMaker/Shared/Modifiers/PrimaryButtonStyle.swift

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,13 @@
2626

2727
import SwiftUI
2828

29-
struct PrimaryButtonModifier: ViewModifier {
30-
func body(content: Content) -> some View {
31-
return content
29+
struct PrimaryButtonStyle: ButtonStyle {
30+
func makeBody(configuration: Self.Configuration) -> some View {
31+
configuration.label
3232
.font(.title)
3333
.padding(32)
34-
.background(Color("ButtonColor"))
34+
.foregroundColor(configuration.isPressed ? Color("ButtonColor") : Color("ButtonTextColor"))
35+
.background(configuration.isPressed ? Color("ButtonTextColor") : Color("ButtonColor"))
3536
.cornerRadius(32)
36-
.foregroundColor(Color("ButtonTextColor"))
37-
}
38-
}
39-
40-
extension Text {
41-
func primaryButtonStyle() -> some View {
42-
self.modifier(PrimaryButtonModifier())
4337
}
4438
}

Examples/GKMatchMaker/Shared/ViewModels/GKMatchMakerAppModel.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class GKMatchMakerAppModel: ObservableObject {
5656

5757
public init() {
5858
self.subscribe()
59+
/*
5960
NotificationCenter.default.addObserver(forName: nil, object: nil, queue: nil) { notification in
6061
os_log("Notification found with:\r\n name:%{public}@\r\nobject:%{public}\r\nuserInfo: %{public})",
6162
log: .default,
@@ -65,6 +66,7 @@ class GKMatchMakerAppModel: ObservableObject {
6566
String(describing: notification.userInfo)
6667
)
6768
}
69+
*/
6870
}
6971

7072
deinit {

Examples/GKMatchMaker/Shared/Views/Authentication/AuthenticationView.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ struct AuthenticationView: View {
4242
self.viewModel.showAuthenticationModal()
4343
} label: {
4444
Text("Login")
45-
.primaryButtonStyle()
4645
}
46+
.buttonStyle(PrimaryButtonStyle())
4747
}
48-
.navigationBarTitle(Text("GameKit Authentication"))
48+
.navigationTitle(Text("GameKit Authentication"))
4949
}
5050
.onAppear() {
5151
self.viewModel.load()
@@ -59,6 +59,7 @@ struct AuthenticationView: View {
5959
self.viewModel.showModal = false
6060
self.viewModel.currentState = "Hello \(player.displayName)"
6161
}
62+
.frame(width: 640, height: 480)
6263
}
6364
.alert(isPresented: self.$viewModel.showAlert) {
6465
Alert(title: Text(self.viewModel.alertTitle),

Examples/GKMatchMaker/Shared/Views/MultiPlayer/MatchMakingView.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ struct MatchMakingView: View {
4141
self.viewModel.showMatchMakerModal()
4242
} label: {
4343
Text("Create Match")
44-
.primaryButtonStyle()
4544
}
45+
.buttonStyle(PrimaryButtonStyle())
4646
}
47-
.navigationBarTitle(Text("GameKit Matchmaker"))
47+
.navigationTitle(Text("GameKit Matchmaker"))
4848
}
4949
.onAppear() {
5050
self.viewModel.load()
@@ -64,6 +64,7 @@ struct MatchMakingView: View {
6464
} started: { (match) in
6565
self.viewModel.showModal = false
6666
}
67+
.frame(width: 640, height: 480)
6768
}
6869
.alert(isPresented: self.$viewModel.showAlert) {
6970
Alert(title: Text(self.viewModel.alertTitle),

Examples/GKMatchMaker/Shared/Views/MultiPlayer/MatchView.swift

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,20 @@ struct MatchView: View {
5151
}
5252
}
5353
}
54-
.navigationBarTitle(Text("GameKit Match"), displayMode: .inline)
55-
.navigationBarItems(trailing:
56-
Button(action: {
57-
GKMatchManager.shared.cancel()
58-
}) {
59-
HStack(alignment: .center) {
60-
Image(systemName: "xmark.circle").imageScale(.large)
61-
Text("Cancel")
54+
.navigationTitle(Text("GameKit Match"))
55+
.toolbar {
56+
ToolbarItemGroup {
57+
Button(action: {
58+
GKMatchManager.shared.cancel()
59+
}) {
60+
HStack(alignment: .center) {
61+
Image(systemName: "xmark.circle").imageScale(.large)
62+
Text("Cancel")
63+
}
6264
}
6365
}
64-
)
66+
}
6567
}
66-
.navigationViewStyle(StackNavigationViewStyle())
6768
}
6869
}
6970

Examples/GKMatchMaker/Shared/Views/ContentView.swift renamed to Examples/GKMatchMaker/iOS/Views/ContentView.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ struct ContentView: View {
4444
}
4545
}
4646
}
47-
.navigationBarTitle(Text("GameKit"))
47+
.navigationTitle(Text("GameKit"))
4848
}
49-
.navigationViewStyle(StackNavigationViewStyle())
5049
}
5150
}
5251

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
///
2+
/// MIT License
3+
///
4+
/// Copyright (c) 2020 Sascha Müllner
5+
///
6+
/// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
/// of this software and associated documentation files (the "Software"), to deal
8+
/// in the Software without restriction, including without limitation the rights
9+
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
/// copies of the Software, and to permit persons to whom the Software is
11+
/// furnished to do so, subject to the following conditions:
12+
///
13+
/// The above copyright notice and this permission notice shall be included in all
14+
/// copies or substantial portions of the Software.
15+
///
16+
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
/// SOFTWARE.
23+
///
24+
/// Created by Sascha Müllner on 03.04.21.
25+
26+
import SwiftUI
27+
import GameKit
28+
import GameKitUI
29+
30+
struct ContentView: View {
31+
32+
var body: some View {
33+
SidebarView()
34+
.frame(minWidth: 800, maxWidth: .infinity, minHeight: 600, maxHeight: .infinity)
35+
}
36+
}
37+
38+
struct ContentView_Previews: PreviewProvider {
39+
static var previews: some View {
40+
ContentView()
41+
}
42+
}

0 commit comments

Comments
 (0)