From ee9f3c02f00913e61ecb0f8ab6b2d4aba3a6be8a Mon Sep 17 00:00:00 2001 From: Ethan Pippin Date: Mon, 28 Mar 2022 23:29:24 -0600 Subject: [PATCH 1/2] fix and lint --- Shared/Views/LiveTVChannelItemElement.swift | 2 +- Swiftfin tvOS/Views/LibraryListView.swift | 50 +++++++++---------- .../EpisodesRowView/EpisodesRowView.swift | 3 +- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/Shared/Views/LiveTVChannelItemElement.swift b/Shared/Views/LiveTVChannelItemElement.swift index f36aa1bf..939a0152 100644 --- a/Shared/Views/LiveTVChannelItemElement.swift +++ b/Shared/Views/LiveTVChannelItemElement.swift @@ -120,7 +120,7 @@ struct LiveTVChannelItemElement: View { .stroke(isFocused ? Color.blue : Color.clear, lineWidth: 4)) .cornerRadius(20) .scaleEffect(isFocused ? 1.1 : 1) - .focusable(true) +// .focusable(true) .focused($focused) .onChange(of: focused) { foc in withAnimation(.linear(duration: 0.15)) { diff --git a/Swiftfin tvOS/Views/LibraryListView.swift b/Swiftfin tvOS/Views/LibraryListView.swift index 9001544d..4760e74e 100644 --- a/Swiftfin tvOS/Views/LibraryListView.swift +++ b/Swiftfin tvOS/Views/LibraryListView.swift @@ -38,31 +38,6 @@ struct LibraryListView: View { self.mainCoordinator.root(\.liveTV) } label: { - ZStack { - HStack { - Spacer() - VStack { - Text(library.name ?? "") - .foregroundColor(.white) - .font(.title2) - .fontWeight(.semibold) - } - Spacer() - }.padding(32) - } - .frame(minWidth: 100, maxWidth: .infinity) - .frame(height: 100) - } - .cornerRadius(10) - .shadow(radius: 5) - .padding(.bottom, 5) - } - } else { - Button { - self.libraryListRouter.route(to: \.library, - (viewModel: LibraryViewModel(parentID: library.id), title: library.name ?? "")) - } - label: { ZStack { HStack { Spacer() @@ -81,6 +56,31 @@ struct LibraryListView: View { .cornerRadius(10) .shadow(radius: 5) .padding(.bottom, 5) + } + } else { + Button { + self.libraryListRouter.route(to: \.library, + (viewModel: LibraryViewModel(parentID: library.id), title: library.name ?? "")) + } + label: { + ZStack { + HStack { + Spacer() + VStack { + Text(library.name ?? "") + .foregroundColor(.white) + .font(.title2) + .fontWeight(.semibold) + } + Spacer() + }.padding(32) + } + .frame(minWidth: 100, maxWidth: .infinity) + .frame(height: 100) + } + .cornerRadius(10) + .shadow(radius: 5) + .padding(.bottom, 5) } } } else { diff --git a/Swiftfin/Components/EpisodesRowView/EpisodesRowView.swift b/Swiftfin/Components/EpisodesRowView/EpisodesRowView.swift index 3bcac987..6f6831a8 100644 --- a/Swiftfin/Components/EpisodesRowView/EpisodesRowView.swift +++ b/Swiftfin/Components/EpisodesRowView/EpisodesRowView.swift @@ -29,7 +29,8 @@ struct EpisodesRowView: View where RowManager: EpisodesRowManager { } } else { Menu { - ForEach(Array(viewModel.seasonsEpisodes.keys).sorted(by: { $0.name ?? "" < $1.name ?? "" }), id: \.self) { season in + ForEach(Array(viewModel.seasonsEpisodes.keys).sorted(by: { $0.indexNumber ?? 0 < $1.indexNumber ?? 0 }), + id: \.self) { season in Button { viewModel.select(season: season) } label: { From 8ee1e35e7797e9b6f07b65546e14f0c73aaa8f78 Mon Sep 17 00:00:00 2001 From: Ethan Pippin Date: Tue, 29 Mar 2022 12:41:51 -0600 Subject: [PATCH 2/2] move logic --- Shared/ViewModels/EpisodesRowManager.swift | 4 ++++ Swiftfin/Components/EpisodesRowView/EpisodesRowView.swift | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Shared/ViewModels/EpisodesRowManager.swift b/Shared/ViewModels/EpisodesRowManager.swift index 5bc12889..47bbd2e3 100644 --- a/Shared/ViewModels/EpisodesRowManager.swift +++ b/Shared/ViewModels/EpisodesRowManager.swift @@ -21,6 +21,10 @@ protocol EpisodesRowManager: ViewModel { extension EpisodesRowManager { + var sortedSeasons: [BaseItemDto] { + Array(seasonsEpisodes.keys).sorted(by: { $0.indexNumber ?? 0 < $1.indexNumber ?? 0 }) + } + // Also retrieves the current season episodes if available func retrieveSeasons() { TvShowsAPI.getSeasons(seriesId: item.seriesId ?? "", diff --git a/Swiftfin/Components/EpisodesRowView/EpisodesRowView.swift b/Swiftfin/Components/EpisodesRowView/EpisodesRowView.swift index 6f6831a8..1ba76a1a 100644 --- a/Swiftfin/Components/EpisodesRowView/EpisodesRowView.swift +++ b/Swiftfin/Components/EpisodesRowView/EpisodesRowView.swift @@ -29,7 +29,7 @@ struct EpisodesRowView: View where RowManager: EpisodesRowManager { } } else { Menu { - ForEach(Array(viewModel.seasonsEpisodes.keys).sorted(by: { $0.indexNumber ?? 0 < $1.indexNumber ?? 0 }), + ForEach(viewModel.sortedSeasons, id: \.self) { season in Button { viewModel.select(season: season)