From 50e7d04458dca135816d44f76eb9063ed8b3f157 Mon Sep 17 00:00:00 2001 From: Aiden Vigue Date: Sat, 22 May 2021 22:33:48 -0400 Subject: [PATCH] Bug fixes Fix issue where library was hardcoded to 6 across when in landscape - now uses device width to calculate Fixes square placeholder images on home screen Smaller blurhash resolution - less CPU time --- JellyfinPlayer/ContentView.swift | 1 - JellyfinPlayer/ContinueWatchingView.swift | 2 -- JellyfinPlayer/LatestMediaView.swift | 5 ++--- JellyfinPlayer/LibraryView.swift | 23 +++++++++++++++++------ JellyfinPlayer/NextUpView.swift | 1 - 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/JellyfinPlayer/ContentView.swift b/JellyfinPlayer/ContentView.swift index 24135c80..2ca7b46f 100644 --- a/JellyfinPlayer/ContentView.swift +++ b/JellyfinPlayer/ContentView.swift @@ -201,7 +201,6 @@ struct ContentView: View { } func startup() { - let size = UIScreen.main.bounds.size if size.width < size.height { orientationInfo.orientation = .portrait; diff --git a/JellyfinPlayer/ContinueWatchingView.swift b/JellyfinPlayer/ContinueWatchingView.swift index 22d8408b..cb565758 100644 --- a/JellyfinPlayer/ContinueWatchingView.swift +++ b/JellyfinPlayer/ContinueWatchingView.swift @@ -122,7 +122,6 @@ struct ContinueWatchingView: View { .placeholder { Image(uiImage: UIImage(blurHash: (item.BlurHash == "" ? "W$H.4}D%bdo#a#xbtpxVW?W?jXWsXVt7Rjf5axWqxbWXnhada{s-" : item.BlurHash), size: CGSize(width: 32, height: 32))!) .resizable() - .scaledToFit() .frame(width: 320, height: 180) .cornerRadius(10) } @@ -153,7 +152,6 @@ struct ContinueWatchingView: View { .placeholder { Image(uiImage: UIImage(blurHash: (item.BlurHash == "" ? "W$H.4}D%bdo#a#xbtpxVW?W?jXWsXVt7Rjf5axWqxbWXnhada{s-" : item.BlurHash), size: CGSize(width: 32, height: 32))!) .resizable() - .scaledToFit() .frame(width: 320, height: 180) .cornerRadius(10) } diff --git a/JellyfinPlayer/LatestMediaView.swift b/JellyfinPlayer/LatestMediaView.swift index d2f1f0f0..07fc6735 100644 --- a/JellyfinPlayer/LatestMediaView.swift +++ b/JellyfinPlayer/LatestMediaView.swift @@ -94,9 +94,8 @@ struct LatestMediaView: View { WebImage(url: URL(string: "\(globalData.server?.baseURI ?? "")/Items/\(item.Id)/Images/\(item.ImageType)?maxWidth=250&quality=85&tag=\(item.Image)")!) .resizable() // Resizable like SwiftUI.Image, you must use this modifier or the view will use the image bitmap size .placeholder { - Image(uiImage: UIImage(blurHash: (item.BlurHash == "" ? "W$H.4}D%bdo#a#xbtpxVW?W?jXWsXVt7Rjf5axWqxbWXnhada{s-" : item.BlurHash), size: CGSize(width: 16, height: 16))!) + Image(uiImage: UIImage(blurHash: (item.BlurHash == "" ? "W$H.4}D%bdo#a#xbtpxVW?W?jXWsXVt7Rjf5axWqxbWXnhada{s-" : item.BlurHash), size: CGSize(width: 32, height: 16))!) .resizable() - .scaledToFit() .frame(width: 100, height: 150) .cornerRadius(10) } @@ -119,6 +118,7 @@ struct LatestMediaView: View { .opacity(0.8) .cornerRadius(10.0) .padding(3), alignment: .topTrailing + ).shadow(radius: 6) } else { Spacer().frame(height:10) @@ -127,7 +127,6 @@ struct LatestMediaView: View { .placeholder { Image(uiImage: UIImage(blurHash: (item.BlurHash == "" ? "W$H.4}D%bdo#a#xbtpxVW?W?jXWsXVt7Rjf5axWqxbWXnhada{s-" : item.BlurHash), size: CGSize(width: 16, height: 16))!) .resizable() - .scaledToFit() .frame(width: 100, height: 150) .cornerRadius(10) } diff --git a/JellyfinPlayer/LibraryView.swift b/JellyfinPlayer/LibraryView.swift index cb98276a..570b9ad5 100644 --- a/JellyfinPlayer/LibraryView.swift +++ b/JellyfinPlayer/LibraryView.swift @@ -76,6 +76,7 @@ struct LibraryView: View { } func loadItems() { + recalcTracks() _isLoading.wrappedValue = true; if(_extraParam.wrappedValue == "") { _url.wrappedValue = "/Users/\(globalData.user?.user_id ?? "")/Items?Limit=\(endIndex)&StartIndex=\(startIndex)&Recursive=true&Fields=PrimaryImageAspectRatio%2CBasicSyncInfo&ImageTypeLimit=1&EnableImageTypes=Primary%2CBackdrop%2CThumb%2CBanner&IncludeItemTypes=Movie,Series\(selected_library_id == "favorites" ? "&Filters=IsFavorite" : "&ParentId=" + selected_library_id)\(filterString)" @@ -160,15 +161,22 @@ struct LibraryView: View { return result } - var tracks: [GridTrack] { - self.isPortrait ? 3 : 6 + func recalcTracks() { + let trkCnt: Int = Int(floor(UIScreen.main.bounds.size.width / 125)); + _tracks.wrappedValue = [] + for _ in (0..