From 8f79ecbc771d88dbd2e462a88c994cfbacff2087 Mon Sep 17 00:00:00 2001 From: Ethan Pippin Date: Fri, 15 Oct 2021 00:14:53 -0600 Subject: [PATCH] Start on ServerListView --- .../Views/ServerListView.swift | 71 +++++++++---------- JellyfinPlayer.xcodeproj/project.pbxproj | 17 ----- .../xcshareddata/swiftpm/Package.resolved | 9 --- Shared/Singleton/SessionManager.swift | 5 -- Shared/SwiftfinStore/SwiftfinStore.swift | 10 +++ 5 files changed, 43 insertions(+), 69 deletions(-) diff --git a/JellyfinPlayer tvOS/Views/ServerListView.swift b/JellyfinPlayer tvOS/Views/ServerListView.swift index f98734ef..b6be5412 100644 --- a/JellyfinPlayer tvOS/Views/ServerListView.swift +++ b/JellyfinPlayer tvOS/Views/ServerListView.swift @@ -23,34 +23,26 @@ struct ServerListView: View { Button { serverListRouter.route(to: \.userList, server) } label: { - ZStack(alignment: Alignment.leading) { - Rectangle() - .foregroundColor(Color.secondarySystemFill) - .frame(height: 100) - .cornerRadius(10) + HStack { + Image(systemName: "server.rack") + .font(.system(size: 72)) + .foregroundColor(.primary) - HStack { - Image(systemName: "server.rack") - .font(.system(size: 36)) + VStack(alignment: .leading, spacing: 5) { + Text(server.name) + .font(.title2) .foregroundColor(.primary) - VStack(alignment: .leading, spacing: 5) { - Text(server.name) - .font(.title2) - .foregroundColor(.primary) - - Text(server.uri) - .font(.footnote) - .disabled(true) - .foregroundColor(.secondary) - - Text(viewModel.userTextFor(server: server)) - .font(.footnote) - .foregroundColor(.primary) - } - }.padding([.leading]) + Text(server.uri) + .font(.footnote) + .disabled(true) + .foregroundColor(.secondary) + + Text(viewModel.userTextFor(server: server)) + .font(.footnote) + .foregroundColor(.primary) + } } - .padding() } .contextMenu { Button(role: .destructive) { @@ -62,32 +54,25 @@ struct ServerListView: View { } } } + .padding(.top, 100) } @ViewBuilder private var noServerView: some View { VStack { Text("Connect to a Jellyfin server to get started") - .frame(minWidth: 50, maxWidth: 240) + .frame(minWidth: 50, maxWidth: 500) .multilineTextAlignment(.center) + .font(.callout) Button { serverListRouter.route(to: \.connectToServer) } label: { - ZStack { - Rectangle() - .foregroundColor(Color.jellyfinPurple) - .frame(maxWidth: 500, maxHeight: 50) - .frame(height: 50) - .cornerRadius(10) - .padding([.leading, .trailing], 30) - .padding([.top, .bottom], 20) - - Text("Connect") - .foregroundColor(Color.white) - .bold() - } + Text("Connect") + .bold() + .font(.callout) } + .padding(.top, 40) } } @@ -98,6 +83,7 @@ struct ServerListView: View { .offset(y: -50) } else { listView + .frame(width: 3000) } } @@ -131,6 +117,7 @@ struct ServerListView: View { var body: some View { innerBody + .frame(width: 1500) .navigationTitle("Servers") .toolbar { ToolbarItemGroup(placement: .navigationBarTrailing) { @@ -142,3 +129,11 @@ struct ServerListView: View { } } } + +struct ContentView_Previews: PreviewProvider { + static var previews: some View { + NavigationView { + ServerListView(viewModel: ServerListViewModel()) + } + } +} diff --git a/JellyfinPlayer.xcodeproj/project.pbxproj b/JellyfinPlayer.xcodeproj/project.pbxproj index dd88b7f9..aefe7266 100644 --- a/JellyfinPlayer.xcodeproj/project.pbxproj +++ b/JellyfinPlayer.xcodeproj/project.pbxproj @@ -37,7 +37,6 @@ 5321753E2671DE9C005491E6 /* Typings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 535870AC2669D8DD00D05A09 /* Typings.swift */; }; 532175402671EE4F005491E6 /* LibraryFilterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53E4E646263F6CF100F67C6B /* LibraryFilterView.swift */; }; 53272532268BF09D0035FBF1 /* MediaViewActionButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53272531268BF09D0035FBF1 /* MediaViewActionButton.swift */; }; - 53272535268BF9710035FBF1 /* SwiftUIFocusGuide in Frameworks */ = {isa = PBXBuildFile; productRef = 53272534268BF9710035FBF1 /* SwiftUIFocusGuide */; }; 53272537268C1DBB0035FBF1 /* SeasonItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53272536268C1DBB0035FBF1 /* SeasonItemView.swift */; }; 53272539268C20100035FBF1 /* EpisodeItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53272538268C20100035FBF1 /* EpisodeItemView.swift */; }; 532E68CF267D9F6B007B9F13 /* VideoPlayerCastDeviceSelector.swift in Sources */ = {isa = PBXBuildFile; fileRef = 532E68CE267D9F6B007B9F13 /* VideoPlayerCastDeviceSelector.swift */; }; @@ -583,7 +582,6 @@ 53A431BF266B0FFE0016769F /* JellyfinAPI in Frameworks */, 535870912669D7A800D05A09 /* Introspect in Frameworks */, 6261A0E026A0AB710072EF1C /* CombineExt in Frameworks */, - 53272535268BF9710035FBF1 /* SwiftUIFocusGuide in Frameworks */, 536D3D84267BEA550004248C /* ParallaxView in Frameworks */, 53ABFDDC267972BF00886593 /* TVServices.framework in Frameworks */, E13DD3CD27164CA7009D4DAF /* CoreStore in Frameworks */, @@ -1304,7 +1302,6 @@ 53A431BE266B0FFE0016769F /* JellyfinAPI */, 53ABFDEC26799D7700886593 /* ActivityIndicator */, 536D3D83267BEA550004248C /* ParallaxView */, - 53272534268BF9710035FBF1 /* SwiftUIFocusGuide */, 53649AAE269CFAF600A2D8B7 /* Puppy */, 6261A0DF26A0AB710072EF1C /* CombineExt */, 6220D0C826D63F3700B8E046 /* Stinsen */, @@ -1428,7 +1425,6 @@ 625CB5782678C4A400530A6E /* XCRemoteSwiftPackageReference "ActivityIndicator" */, 536D3D82267BEA550004248C /* XCRemoteSwiftPackageReference "ParallaxView" */, 53EC6E23267EB10F006DD26A /* XCRemoteSwiftPackageReference "SwiftyJSON" */, - 53272533268BF9710035FBF1 /* XCRemoteSwiftPackageReference "SwiftUIFocusGuide" */, 53649AAB269CFAEA00A2D8B7 /* XCRemoteSwiftPackageReference "Puppy" */, 6260FFF726A09754003FA968 /* XCRemoteSwiftPackageReference "CombineExt" */, 62C29E9A26D0FE4100C1D2E7 /* XCRemoteSwiftPackageReference "stinsen" */, @@ -2370,14 +2366,6 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ - 53272533268BF9710035FBF1 /* XCRemoteSwiftPackageReference "SwiftUIFocusGuide" */ = { - isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/rmnblm/SwiftUIFocusGuide"; - requirement = { - kind = upToNextMajorVersion; - minimumVersion = 0.1.0; - }; - }; 5335256F265EA0A0006CCA86 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/siteline/SwiftUI-Introspect"; @@ -2469,11 +2457,6 @@ /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ - 53272534268BF9710035FBF1 /* SwiftUIFocusGuide */ = { - isa = XCSwiftPackageProductDependency; - package = 53272533268BF9710035FBF1 /* XCRemoteSwiftPackageReference "SwiftUIFocusGuide" */; - productName = SwiftUIFocusGuide; - }; 53352570265EA0A0006CCA86 /* Introspect */ = { isa = XCSwiftPackageProductDependency; package = 5335256F265EA0A0006CCA86 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */; diff --git a/JellyfinPlayer.xcworkspace/xcshareddata/swiftpm/Package.resolved b/JellyfinPlayer.xcworkspace/xcshareddata/swiftpm/Package.resolved index 8893bce9..bfb7d2f1 100644 --- a/JellyfinPlayer.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/JellyfinPlayer.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -136,15 +136,6 @@ "version": "0.1.3" } }, - { - "package": "SwiftUIFocusGuide", - "repositoryURL": "https://github.com/rmnblm/SwiftUIFocusGuide", - "state": { - "branch": null, - "revision": "fb8eefaccb2954efedc19a5539241f370baa4a10", - "version": "0.1.0" - } - }, { "package": "SwiftyJSON", "repositoryURL": "https://github.com/SwiftyJSON/SwiftyJSON", diff --git a/Shared/Singleton/SessionManager.swift b/Shared/Singleton/SessionManager.swift index ab19967d..95039408 100644 --- a/Shared/Singleton/SessionManager.swift +++ b/Shared/Singleton/SessionManager.swift @@ -15,11 +15,6 @@ import Foundation import JellyfinAPI import UIKit -#if os(tvOS) -import TVServices -import SwiftUIFocusGuide -#endif - typealias CurrentLogin = (server: SwiftfinStore.State.Server, user: SwiftfinStore.State.User) // MARK: NewSessionManager diff --git a/Shared/SwiftfinStore/SwiftfinStore.swift b/Shared/SwiftfinStore/SwiftfinStore.swift index 1b6a4809..66967aac 100644 --- a/Shared/SwiftfinStore/SwiftfinStore.swift +++ b/Shared/SwiftfinStore/SwiftfinStore.swift @@ -13,6 +13,7 @@ import Defaults enum SwiftfinStore { + // MARK: State // Safe, copyable representations of their underlying CoreStoredObject's // Relationships are represented by the related object's IDs or value enum State { @@ -33,6 +34,10 @@ enum SwiftfinStore { self.version = version self.userIDs = usersIDs } + + static var sample: Server { + return Server(uri: "https://www.notaurl.com", name: "Johnny's Tree", id: "123abc", os: "macOS", version: "1.1.1", usersIDs: ["1", "2"]) + } } struct User { @@ -47,9 +52,14 @@ enum SwiftfinStore { self.serverID = serverID self.accessToken = accessToken } + + static var sample: User { + return User(username: "JohnnyAppleseed", id: "123abc", serverID: "123abc", accessToken: "open-sesame") + } } } + // MARK: Models enum Models { final class StoredServer: CoreStoreObject {