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
This commit is contained in:
Aiden Vigue 2021-05-22 22:33:48 -04:00
parent b1d5c141a7
commit 50e7d04458
5 changed files with 19 additions and 13 deletions

View File

@ -201,7 +201,6 @@ struct ContentView: View {
}
func startup() {
let size = UIScreen.main.bounds.size
if size.width < size.height {
orientationInfo.orientation = .portrait;

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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..<trkCnt)
{
_tracks.wrappedValue.append(GridTrack.fr(1))
}
}
@State private var tracks: [GridTrack] = []
var body: some View {
if(prefill_id != "") {
LoadingView(isShowing: $isLoading) {
GeometryReader { geometry in
Grid(tracks: self.tracks, spacing: GridSpacing(horizontal: 0, vertical: 20)) {
Grid(tracks: _tracks.wrappedValue, spacing: GridSpacing(horizontal: 0, vertical: 20)) {
ForEach(items, id: \.Id) { item in
NavigationLink(destination: ItemView(item: item )) {
VStack(alignment: .leading) {
@ -239,10 +247,13 @@ struct LibraryView: View {
}
}
Spacer()
}.gridSpan(column: self.isPortrait ? 3 : 6)
}.gridSpan(column: _tracks.wrappedValue.count)
}
Spacer().frame(height: 2).gridSpan(column: self.isPortrait ? 3 : 6)
Spacer().frame(height: 2).gridSpan(column: _tracks.wrappedValue.count)
}.gridContentMode(.scroll)
.onChange(of: isPortrait) { _ in
recalcTracks()
}
}
}
.overrideViewPreference(.unspecified)
@ -266,7 +277,7 @@ struct LibraryView: View {
Image(systemName: "line.horizontal.3.decrease")
}
}
}.popover( isPresented: self.$showFiltersPopover, arrowEdge: .bottom) { LibraryFilterView(library: selected_library_id, output: $filterString, close: $showFiltersPopover).environmentObject(self.globalData) }
}.fullScreenCover( isPresented: self.$showFiltersPopover) { LibraryFilterView(library: selected_library_id, output: $filterString, close: $showFiltersPopover).environmentObject(self.globalData) }
} else {
List(library_ids, id:\.self) { id in
if(id != "genres") {

View File

@ -84,7 +84,6 @@ struct NextUpView: 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)
}