Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
LePips committed Nov 30, 2023
1 parent f30803a commit 67c2549
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 281 deletions.
4 changes: 0 additions & 4 deletions Swiftfin.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,6 @@
E17FB55B28C1266400311DFE /* GenresHStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = E17FB55A28C1266400311DFE /* GenresHStack.swift */; };
E18295E429CAC6F100F91ED0 /* BasicNavigationCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = E154967D296CCB6C00C4EF88 /* BasicNavigationCoordinator.swift */; };
E18443CB2A037773002DDDC8 /* UDPBroadcast in Frameworks */ = {isa = PBXBuildFile; productRef = E18443CA2A037773002DDDC8 /* UDPBroadcast */; };
E1856DD22AF85C8A007FDDBC /* PagingCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1856DD12AF85C8A007FDDBC /* PagingCollectionView.swift */; };
E1856DEE2AFA007A007FDDBC /* UICollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1856DED2AFA007A007FDDBC /* UICollectionView.swift */; };
E185920628CDAA6400326F80 /* CastAndCrewHStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = E185920528CDAA6400326F80 /* CastAndCrewHStack.swift */; };
E185920828CDAAA200326F80 /* SimilarItemsHStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = E185920728CDAAA200326F80 /* SimilarItemsHStack.swift */; };
Expand Down Expand Up @@ -1090,7 +1089,6 @@
E17FB55628C1256400311DFE /* CastAndCrewHStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CastAndCrewHStack.swift; sourceTree = "<group>"; };
E17FB55828C125E900311DFE /* StudiosHStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudiosHStack.swift; sourceTree = "<group>"; };
E17FB55A28C1266400311DFE /* GenresHStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GenresHStack.swift; sourceTree = "<group>"; };
E1856DD12AF85C8A007FDDBC /* PagingCollectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PagingCollectionView.swift; sourceTree = "<group>"; };
E1856DED2AFA007A007FDDBC /* UICollectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UICollectionView.swift; sourceTree = "<group>"; };
E185920528CDAA6400326F80 /* CastAndCrewHStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CastAndCrewHStack.swift; sourceTree = "<group>"; };
E185920728CDAAA200326F80 /* SimilarItemsHStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimilarItemsHStack.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1821,7 +1819,6 @@
E13F05EF28BC9016003499D2 /* LibraryItemRow.swift */,
E1D3044328D1991900587289 /* LibraryViewTypeToggle.swift */,
E111D8F728D03BF900400001 /* PagingLibraryView.swift */,
E1856DD12AF85C8A007FDDBC /* PagingCollectionView.swift */,
E18E01A5288746AF0022598C /* PillHStack.swift */,
E16AA60728A364A6009A983C /* PosterButton.swift */,
E1CCF13028AC07EC006CAC9E /* PosterHStack.swift */,
Expand Down Expand Up @@ -3442,7 +3439,6 @@
E1FCD08826C35A0D007C8DCF /* NetworkError.swift in Sources */,
E175AFF3299AC117004DCF52 /* DebugSettingsView.swift in Sources */,
E12CC1BB28D11E1000678D5D /* RecentlyAddedViewModel.swift in Sources */,
E1856DD22AF85C8A007FDDBC /* PagingCollectionView.swift in Sources */,
E17FB55228C119D400311DFE /* Displayable.swift in Sources */,
E13DD3E527177D15009D4DAF /* ServerListView.swift in Sources */,
E113132B28BDB4B500930F75 /* NavBarDrawerView.swift in Sources */,
Expand Down
2 changes: 2 additions & 0 deletions Swiftfin/Components/LibraryItemRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import JellyfinAPI
import SwiftUI

// TODO: manual dividers

struct LibraryItemRow: View {

@EnvironmentObject
Expand Down
227 changes: 0 additions & 227 deletions Swiftfin/Components/PagingCollectionView.swift

This file was deleted.

61 changes: 32 additions & 29 deletions Swiftfin/Components/PagingLibraryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ import Defaults
import JellyfinAPI
import SwiftUI

// TODO: pad vs phone layouts
// TODO: find better way to init layout
// - is onAppear good enough since right now it will always open up in loading state?
// - that should change if/when better caching is implemented
// TODO: on pad: list layout columns (up to 3?)?

struct PagingLibraryView: View {

@Default(.Customization.Library.gridPosterType)
Expand All @@ -28,41 +34,48 @@ struct PagingLibraryView: View {
private var onSelect: (BaseItemDto) -> Void

var body: some View {
// PagingCollectionView(items: $viewModel.items, viewType: $libraryViewType) { item in
// switch libraryViewType {
// case .grid:
// PosterButton(item: item, type: libraryGridPosterType)
// .onSelect {
// onSelect(item)
// }
// case .list:
// LibraryItemRow(item: item)
// .padding(.vertical, 5)
// }
// }
// .ignoresSafeArea()

CollectionVGrid(
$viewModel.items,
layout: $layout
) { item in
switch libraryViewType {
case .grid:
PosterButton(item: item, type: libraryGridPosterType)
.content { item in
if item.showTitle {
PosterButton.TitleContentView(item: item)
.reservingSpaceLineLimit(1)
}
}
.onSelect {
onSelect(item)
}
case .list:
LibraryItemRow(item: item)
.onSelect {
onSelect(item)
}
.padding(5)
}
}
.ignoresSafeArea()
.onAppear {
switch (libraryViewType, libraryGridPosterType) {
case (.grid, .portrait):
layout = .columns(3)
case (.grid, .landscape):
layout = .columns(2)
case (.list, _):
layout = .columns(1, insets: .init(constant: 0), itemSpacing: 0, lineSpacing: 0)
}
}
.onChange(of: libraryViewType) { newValue in
switch newValue {
case .grid:
layout = .minWidth(100)
case .list:
switch (newValue, libraryGridPosterType) {
case (.grid, .portrait):
layout = .columns(3)
case (.grid, .landscape):
layout = .columns(2)
case (.list, _):
layout = .columns(1, insets: .init(constant: 0), itemSpacing: 0, lineSpacing: 0)
}
}
Expand All @@ -72,19 +85,9 @@ struct PagingLibraryView: View {
extension PagingLibraryView {

init(viewModel: PagingLibraryViewModel) {

let layout: CollectionVGridLayout

switch Defaults[.Customization.Library.viewType] {
case .grid:
layout = .minWidth(120)
case .list:
layout = .columns(1, insets: .init(constant: 0), itemSpacing: 0, lineSpacing: 0)
}

self.init(
viewModel: viewModel,
layout: layout,
layout: .columns(3),
onSelect: { _ in }
)
}
Expand Down
1 change: 1 addition & 0 deletions Swiftfin/Components/PosterButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Defaults
import JellyfinAPI
import SwiftUI

// TODO: just establish rules for default content line limits for design
// TODO: builder methods shouldn't take the item

struct PosterButton<Item: Poster>: View {
Expand Down
Loading

0 comments on commit 67c2549

Please sign in to comment.