Skip to content

Commit dbf8781

Browse files
committed
tvOS should build now
1 parent 6d75ef3 commit dbf8781

File tree

3 files changed

+47
-29
lines changed

3 files changed

+47
-29
lines changed

Luna/Player/PlayerViewController.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,17 @@ final class PlayerViewController: UIViewController {
192192
b.backgroundColor = UIColor(white: 0.2, alpha: 0.55)
193193
b.layer.cornerRadius = 18
194194
b.layer.cornerCurve = .continuous
195+
#if os(tvOS)
196+
if #available(tvOS 15.0, *) {
197+
var config = UIButton.Configuration.plain()
198+
config.contentInsets = NSDirectionalEdgeInsets(top: 8, leading: 12, bottom: 8, trailing: 12)
199+
b.configuration = config
200+
} else {
201+
b.contentEdgeInsets = UIEdgeInsets(top: 8, left: 12, bottom: 8, right: 12)
202+
}
203+
#else
195204
b.contentEdgeInsets = UIEdgeInsets(top: 8, left: 12, bottom: 8, right: 12)
205+
#endif
196206
b.alpha = 0.0
197207
b.isHidden = true
198208
return b

Luna/Tracking/Sync/ProgressSyncManager.swift

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,34 @@ final class ProgressSyncManager: NSObject, ObservableObject {
254254
Logger.shared.log("AniList login successful", type: "Sync")
255255
}
256256

257+
private func runAuthSession(url: URL) async throws -> URL {
258+
try await withCheckedThrowingContinuation { continuation in
259+
authSession = ASWebAuthenticationSession(url: url, callbackURLScheme: callbackScheme) { callbackURL, error in
260+
if let callbackURL {
261+
continuation.resume(returning: callbackURL)
262+
return
263+
}
264+
265+
if let error {
266+
continuation.resume(throwing: error)
267+
return
268+
}
269+
270+
continuation.resume(throwing: SyncError.authorizationFailed("Authentication was cancelled"))
271+
}
272+
273+
authSession?.presentationContextProvider = self
274+
authSession?.prefersEphemeralWebBrowserSession = false
275+
if authSession?.start() != true {
276+
continuation.resume(throwing: SyncError.authorizationFailed("Unable to start authentication"))
277+
}
278+
}
279+
}
280+
#else
281+
func loginTrakt() async throws { throw SyncError.unsupportedPlatform }
282+
func loginAniList() async throws { throw SyncError.unsupportedPlatform }
283+
#endif
284+
257285
private func refreshTraktUsername() async {
258286
do {
259287
let token = try await validToken(for: .trakt)
@@ -317,34 +345,6 @@ final class ProgressSyncManager: NSObject, ObservableObject {
317345
}
318346
}
319347

320-
private func runAuthSession(url: URL) async throws -> URL {
321-
try await withCheckedThrowingContinuation { continuation in
322-
authSession = ASWebAuthenticationSession(url: url, callbackURLScheme: callbackScheme) { callbackURL, error in
323-
if let callbackURL {
324-
continuation.resume(returning: callbackURL)
325-
return
326-
}
327-
328-
if let error {
329-
continuation.resume(throwing: error)
330-
return
331-
}
332-
333-
continuation.resume(throwing: SyncError.authorizationFailed("Authentication was cancelled"))
334-
}
335-
336-
authSession?.presentationContextProvider = self
337-
authSession?.prefersEphemeralWebBrowserSession = false
338-
if authSession?.start() != true {
339-
continuation.resume(throwing: SyncError.authorizationFailed("Unable to start authentication"))
340-
}
341-
}
342-
}
343-
#else
344-
func loginTrakt() async throws { throw SyncError.unsupportedPlatform }
345-
func loginAniList() async throws { throw SyncError.unsupportedPlatform }
346-
#endif
347-
348348
func pushMovieProgress(tmdbId: Int, title: String, progress: Double) {
349349
Task {
350350
await pushToProviders(movieId: tmdbId, title: title, progress: progress)

Luna/Views/SettingsView.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ struct SettingsView: View {
1111
@AppStorage("tmdbLanguage") private var selectedLanguage = "en-US"
1212
@StateObject private var algorithmManager = AlgorithmManager.shared
1313
@AppStorage("showKanzen") private var showKanzen: Bool = false
14+
15+
private var appVersion: String {
16+
Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "1.0"
17+
}
18+
19+
private var buildNumber: String {
20+
Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String ?? "1"
21+
}
1422

1523
let languages = [
1624
("en-US", "English (US)"),
@@ -50,7 +58,7 @@ struct SettingsView: View {
5058
.shadow(radius: 10)
5159

5260
VStack(spacing: 15) {
53-
Text("Version \(Bundle.main.appVersion) (\(Bundle.main.buildNumber))")
61+
Text("Version \(appVersion) (\(buildNumber))")
5462
.font(.footnote)
5563
.fontWeight(.regular)
5664
.foregroundColor(.secondary)

0 commit comments

Comments
 (0)