Skip to content

Commit 8152fa2

Browse files
authored
Merge pull request #14 from SwiftPackageRepository/feature/tvOS-Support
Added tvOS support
2 parents 54b5dae + 7625d35 commit 8152fa2

File tree

47 files changed

+1168
-42
lines changed

Some content is hidden

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

47 files changed

+1168
-42
lines changed

Examples/GKMatchMaker/GKMatchMaker.xcodeproj/project.pbxproj

Lines changed: 198 additions & 5 deletions
Large diffs are not rendered by default.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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>com.apple.security.app-sandbox</key>
6+
<true/>
7+
<key>com.apple.security.files.user-selected.read-only</key>
8+
<true/>
9+
<key>com.apple.security.network.client</key>
10+
<true/>
11+
<key>com.apple.security.network.server</key>
12+
<true/>
13+
</dict>
14+
</plist>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
},
6+
"properties" : {
7+
"canvasSize" : {
8+
"width" : 1280,
9+
"height" : 768
10+
}
11+
},
12+
"layers" : [
13+
{
14+
"filename" : "GameKitUILogo.imagestacklayer"
15+
},
16+
{
17+
"filename" : "GameKitUILogo1.imagestacklayer"
18+
}
19+
]
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"layers" : [
3+
{
4+
"filename" : "GameKitUILogo.imagestacklayer"
5+
},
6+
{
7+
"filename" : "GameKitUILogo1.imagestacklayer"
8+
}
9+
],
10+
"properties" : {
11+
"canvasSize" : {
12+
"width" : 400,
13+
"height" : 240
14+
}
15+
},
16+
"info" : {
17+
"version" : 1,
18+
"author" : "xcode"
19+
}
20+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"assets" : [
3+
{
4+
"role" : "primary-app-icon",
5+
"idiom" : "tv",
6+
"filename" : "App Icon - App Store.imagestack",
7+
"size" : "1280x768"
8+
},
9+
{
10+
"role" : "primary-app-icon",
11+
"filename" : "App Icon.imagestack",
12+
"idiom" : "tv",
13+
"size" : "400x240"
14+
},
15+
{
16+
"filename" : "Top Shelf Image.imageset",
17+
"idiom" : "tv",
18+
"size" : "1920x720",
19+
"role" : "top-shelf-image"
20+
},
21+
{
22+
"idiom" : "tv",
23+
"role" : "top-shelf-image-wide",
24+
"filename" : "Top Shelf Image Wide.imageset",
25+
"size" : "2320x720"
26+
}
27+
],
28+
"info" : {
29+
"version" : 1,
30+
"author" : "xcode"
31+
}
32+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"images" : [
3+
{
4+
"scale" : "1x",
5+
"idiom" : "tv"
6+
},
7+
{
8+
"scale" : "2x",
9+
"idiom" : "tv"
10+
}
11+
],
12+
"info" : {
13+
"version" : 1,
14+
"author" : "xcode"
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"images" : [
3+
{
4+
"scale" : "1x",
5+
"idiom" : "tv"
6+
},
7+
{
8+
"scale" : "2x",
9+
"idiom" : "tv"
10+
}
11+
],
12+
"info" : {
13+
"version" : 1,
14+
"author" : "xcode"
15+
}
16+
}

Examples/GKMatchMaker/Shared/Modifiers/PrimaryButtonStyle.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ struct PrimaryButtonStyle: ButtonStyle {
3636
.cornerRadius(32)
3737
}
3838
}
39+

Examples/GKMatchMaker/Shared/ViewModels/Authentication/AuthenticationViewModel.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,27 @@
2626

2727
import Foundation
2828
import Combine
29+
import GameKit
30+
import GameKitUI
2931

3032
class AuthenticationViewModel: ObservableObject {
3133

3234
@Published public var showModal = false
3335
@Published public var showAlert = false
36+
@Published public var isAuthenticated = false
3437
@Published public var alertTitle: String = ""
3538
@Published public var alertMessage: String = ""
3639
@Published public var currentState: String = "Loading GameKit..."
37-
38-
public init() {
40+
@Published public var player: GKPlayer? {
41+
didSet {
42+
self.isAuthenticated = self.player != nil
43+
}
3944
}
4045

4146
public func load() {
47+
if self.isAuthenticated {
48+
return
49+
}
4250
self.showAuthenticationModal()
4351
}
4452

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,17 @@ struct AuthenticationView: View {
3838
Text(self.viewModel.currentState)
3939
.font(.body)
4040
.padding(8)
41-
Button() {
42-
self.viewModel.showAuthenticationModal()
43-
} label: {
44-
Text("Login")
41+
if self.viewModel.isAuthenticated,
42+
let player = self.viewModel.player {
43+
PlayerView(viewModel: PlayerViewModel(player))
44+
} else {
45+
Button() {
46+
self.viewModel.showAuthenticationModal()
47+
} label: {
48+
Text("Login")
49+
}
50+
.buttonStyle(PrimaryButtonStyle())
4551
}
46-
.buttonStyle(PrimaryButtonStyle())
4752
}
4853
.navigationTitle(Text("GameKit Authentication"))
4954
}
@@ -57,7 +62,8 @@ struct AuthenticationView: View {
5762
self.viewModel.currentState = error.localizedDescription
5863
} authenticated: { (player) in
5964
self.viewModel.showModal = false
60-
self.viewModel.currentState = "Hello \(player.displayName)"
65+
self.viewModel.player = player
66+
self.viewModel.currentState = "Authenticated"
6167
}
6268
.frame(width: 640, height: 480)
6369
}

0 commit comments

Comments
 (0)