Skip to content

Commit 148d454

Browse files
committed
#8 multiplatform macos support
1 parent 2a1d363 commit 148d454

6 files changed

Lines changed: 58 additions & 22 deletions

File tree

Examples/GKMatchMaker/GKMatchMaker.xcodeproj/project.pbxproj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
151CAAD125E39928002A7FDC /* Config.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 151CAAD025E39928002A7FDC /* Config.xcconfig */; };
1717
151CAAD225E39928002A7FDC /* Config.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 151CAAD025E39928002A7FDC /* Config.xcconfig */; };
1818
151CAAD725E399D6002A7FDC /* GameKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 151CAAD625E399D6002A7FDC /* GameKit.framework */; };
19+
151F91ED25E42EC60015DD88 /* PrimaryButtonModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 151F91EC25E42EC60015DD88 /* PrimaryButtonModifier.swift */; };
20+
151F91EE25E42EC60015DD88 /* PrimaryButtonModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 151F91EC25E42EC60015DD88 /* PrimaryButtonModifier.swift */; };
1921
15A6F7D725E39B7D00FE5387 /* GameKitUI in Frameworks */ = {isa = PBXBuildFile; productRef = 15A6F7D625E39B7D00FE5387 /* GameKitUI */; };
2022
15A6F7D925E39B8300FE5387 /* GameKitUI in Frameworks */ = {isa = PBXBuildFile; productRef = 15A6F7D825E39B8300FE5387 /* GameKitUI */; };
2123
15A6F7DB25E39B8F00FE5387 /* GameKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15A6F7DA25E39B8F00FE5387 /* GameKit.framework */; };
@@ -39,6 +41,7 @@
3941
151CAAD025E39928002A7FDC /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
4042
151CAAD625E399D6002A7FDC /* GameKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/System/Library/Frameworks/GameKit.framework; sourceTree = DEVELOPER_DIR; };
4143
151CAAD825E399DF002A7FDC /* GameKitUI.swift */ = {isa = PBXFileReference; lastKnownFileType = folder; name = GameKitUI.swift; path = ../..; sourceTree = "<group>"; };
44+
151F91EC25E42EC60015DD88 /* PrimaryButtonModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrimaryButtonModifier.swift; sourceTree = "<group>"; };
4245
15A6F7DA25E39B8F00FE5387 /* GameKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameKit.framework; path = System/Library/Frameworks/GameKit.framework; sourceTree = SDKROOT; };
4346
15A6F7DF25E39BC100FE5387 /* ContentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
4447
15A6F7F025E39E0500FE5387 /* MatchMakingViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatchMakingViewModel.swift; sourceTree = "<group>"; };
@@ -84,6 +87,7 @@
8487
isa = PBXGroup;
8588
children = (
8689
1507A0BC25E410CA006DDBFC /* GKMatchMakerApp.swift */,
90+
151F91E825E42DE30015DD88 /* Modifiers */,
8791
15A6F7E025E39BC100FE5387 /* ViewModels */,
8892
15A6F7DE25E39BC100FE5387 /* Views */,
8993
151CAA8D25E39837002A7FDC /* Assets.xcassets */,
@@ -126,6 +130,14 @@
126130
name = Frameworks;
127131
sourceTree = "<group>";
128132
};
133+
151F91E825E42DE30015DD88 /* Modifiers */ = {
134+
isa = PBXGroup;
135+
children = (
136+
151F91EC25E42EC60015DD88 /* PrimaryButtonModifier.swift */,
137+
);
138+
path = Modifiers;
139+
sourceTree = "<group>";
140+
};
129141
15A6F7DE25E39BC100FE5387 /* Views */ = {
130142
isa = PBXGroup;
131143
children = (
@@ -284,6 +296,7 @@
284296
1507A0C625E419E5006DDBFC /* SinglePlayerView.swift in Sources */,
285297
15A6F7F625E39E5300FE5387 /* MatchMakingView.swift in Sources */,
286298
15A6F7E225E39BC100FE5387 /* ContentView.swift in Sources */,
299+
151F91ED25E42EC60015DD88 /* PrimaryButtonModifier.swift in Sources */,
287300
1507A0BD25E410CA006DDBFC /* GKMatchMakerApp.swift in Sources */,
288301
15A6F7F125E39E0500FE5387 /* MatchMakingViewModel.swift in Sources */,
289302
);
@@ -296,6 +309,7 @@
296309
1507A0C725E419E5006DDBFC /* SinglePlayerView.swift in Sources */,
297310
15A6F7F725E39E5300FE5387 /* MatchMakingView.swift in Sources */,
298311
15A6F7E325E39BC100FE5387 /* ContentView.swift in Sources */,
312+
151F91EE25E42EC60015DD88 /* PrimaryButtonModifier.swift in Sources */,
299313
1507A0BE25E410CA006DDBFC /* GKMatchMakerApp.swift in Sources */,
300314
15A6F7F225E39E0500FE5387 /* MatchMakingViewModel.swift in Sources */,
301315
);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
///
2+
/// PrimaryButtonModifier.swift
3+
/// GKMatchMaker
4+
///
5+
/// Created by Sascha Müllner on 22.02.21.
6+
///
7+
8+
import SwiftUI
9+
10+
struct PrimaryButtonModifier: ViewModifier {
11+
func body(content: Content) -> some View {
12+
return content
13+
.font(.title)
14+
.padding(40)
15+
.background(Color("ButtonColor"))
16+
.cornerRadius(40)
17+
.foregroundColor(Color("ButtonTextColor"))
18+
}
19+
}
20+
21+
extension Text {
22+
func primaryButtonStyle() -> some View {
23+
self.modifier(PrimaryButtonModifier())
24+
}
25+
}

Examples/GKMatchMaker/Shared/ViewModels/MultiPlayer/MatchMakingViewModel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
///
2-
/// MatchMakingViewModel.swift
3-
/// MatchMaking
2+
/// GKMatchMakerViewModel.swift
3+
/// GKMatchMaker
44
///
55
/// Created by Sascha Müllner on 24.11.20.
66

Examples/GKMatchMaker/Shared/Views/ContentView.swift

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,30 @@
11
///
22
/// ContentView.swift
3-
/// MatchMaking
3+
/// GKMatchMaker
44
///
55
/// Created by Sascha Müllner on 24.11.20.
66

77
import SwiftUI
8+
89
struct ContentView: View {
910
var body: some View {
1011
NavigationView {
1112
ZStack {
12-
Color("BackgroundColor").ignoresSafeArea()
13+
Color("BackgroundColor").edgesIgnoringSafeArea(.all)
1314
VStack(alignment: .center, spacing: 32) {
1415
NavigationLink(destination: SinglePlayerView()) {
1516
Text("Single Player")
16-
.fontWeight(.bold)
17-
.font(.title)
18-
.padding(40)
19-
.background(Color("ButtonColor"))
20-
.cornerRadius(40)
21-
.foregroundColor(Color("ButtonTextColor"))
17+
.primaryButtonStyle()
2218
}
2319
NavigationLink(destination: MatchMakingView()) {
2420
Text("Multi Player")
25-
.fontWeight(.bold)
26-
.font(.title)
27-
.padding(40)
28-
.background(Color("ButtonColor"))
29-
.cornerRadius(40)
30-
.foregroundColor(Color("ButtonTextColor"))
31-
21+
.primaryButtonStyle()
3222
}
3323
}
3424
}
35-
.navigationViewStyle(StackNavigationViewStyle())
3625
.navigationBarTitle(Text("Match Making"))
3726
}
27+
.navigationViewStyle(StackNavigationViewStyle())
3828
}
3929
}
4030

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
///
2-
/// MatchMakingView.swift
3-
/// MatchMaking
2+
/// GKMatchMakerView.swift
3+
/// GKMatchMaker
44
///
55
/// Created by Sascha Müllner on 24.11.20.
66

@@ -19,10 +19,16 @@ struct MatchMakingView: View {
1919
Text(self.viewModel.currentState)
2020
.font(.body)
2121
.padding(8)
22+
Button() {
23+
self.viewModel.showAuthenticationModal()
24+
} label: {
25+
Text("Authenticate")
26+
.primaryButtonStyle()
27+
}
28+
2229
}
30+
.navigationBarTitle(Text("GameKit Matchmaker"))
2331
}
24-
.navigationViewStyle(StackNavigationViewStyle())
25-
.navigationBarTitle(Text("GameKit Matchmaker"))
2632
.onAppear() {
2733
self.viewModel.load()
2834
}

Examples/GKMatchMaker/Shared/Views/SinglePlayer/SinglePlayerView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ struct SinglePlayerView: View {
1616
.font(.body)
1717
.padding(8)
1818
}
19+
.navigationBarTitle(Text("Single Player"))
1920
}
2021
}
2122
}

0 commit comments

Comments
 (0)