Finish ItemSeriesEpisodeIconView + make geo size globally available
This commit is contained in:
parent
ed05643542
commit
2619848a70
@ -23,6 +23,7 @@
|
|||||||
3D41D1FA2B2CAE0000E58234 /* ItemIconView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D41D1F92B2CAE0000E58234 /* ItemIconView.swift */; };
|
3D41D1FA2B2CAE0000E58234 /* ItemIconView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D41D1F92B2CAE0000E58234 /* ItemIconView.swift */; };
|
||||||
3D4C15722B3CAA670035373E /* DashboardSectionTitleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D4C15712B3CAA670035373E /* DashboardSectionTitleView.swift */; };
|
3D4C15722B3CAA670035373E /* DashboardSectionTitleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D4C15712B3CAA670035373E /* DashboardSectionTitleView.swift */; };
|
||||||
3D58F07E2B4DB19300DB2936 /* TextRatingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D58F07D2B4DB19300DB2936 /* TextRatingView.swift */; };
|
3D58F07E2B4DB19300DB2936 /* TextRatingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D58F07D2B4DB19300DB2936 /* TextRatingView.swift */; };
|
||||||
|
3D6A0DC12B867B4C001FDA40 /* ScreenSize.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D6A0DC02B867B4C001FDA40 /* ScreenSize.swift */; };
|
||||||
3D6A7DB92B7C5D3900A5E31B /* ItemSeasonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D6A7DB82B7C5D3900A5E31B /* ItemSeasonView.swift */; };
|
3D6A7DB92B7C5D3900A5E31B /* ItemSeasonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D6A7DB82B7C5D3900A5E31B /* ItemSeasonView.swift */; };
|
||||||
3D74AE122B7D4EB000C17F2E /* UIScreenWidthExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D74AE112B7D4EB000C17F2E /* UIScreenWidthExtension.swift */; };
|
3D74AE122B7D4EB000C17F2E /* UIScreenWidthExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D74AE112B7D4EB000C17F2E /* UIScreenWidthExtension.swift */; };
|
||||||
3D7709392B29139700199889 /* Pulse in Frameworks */ = {isa = PBXBuildFile; productRef = 3D7709382B29139700199889 /* Pulse */; };
|
3D7709392B29139700199889 /* Pulse in Frameworks */ = {isa = PBXBuildFile; productRef = 3D7709382B29139700199889 /* Pulse */; };
|
||||||
@ -83,6 +84,7 @@
|
|||||||
3D41D1F92B2CAE0000E58234 /* ItemIconView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemIconView.swift; sourceTree = "<group>"; };
|
3D41D1F92B2CAE0000E58234 /* ItemIconView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemIconView.swift; sourceTree = "<group>"; };
|
||||||
3D4C15712B3CAA670035373E /* DashboardSectionTitleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashboardSectionTitleView.swift; sourceTree = "<group>"; };
|
3D4C15712B3CAA670035373E /* DashboardSectionTitleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashboardSectionTitleView.swift; sourceTree = "<group>"; };
|
||||||
3D58F07D2B4DB19300DB2936 /* TextRatingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextRatingView.swift; sourceTree = "<group>"; };
|
3D58F07D2B4DB19300DB2936 /* TextRatingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextRatingView.swift; sourceTree = "<group>"; };
|
||||||
|
3D6A0DC02B867B4C001FDA40 /* ScreenSize.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScreenSize.swift; sourceTree = "<group>"; };
|
||||||
3D6A7DB82B7C5D3900A5E31B /* ItemSeasonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemSeasonView.swift; sourceTree = "<group>"; };
|
3D6A7DB82B7C5D3900A5E31B /* ItemSeasonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemSeasonView.swift; sourceTree = "<group>"; };
|
||||||
3D74AE112B7D4EB000C17F2E /* UIScreenWidthExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIScreenWidthExtension.swift; sourceTree = "<group>"; };
|
3D74AE112B7D4EB000C17F2E /* UIScreenWidthExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIScreenWidthExtension.swift; sourceTree = "<group>"; };
|
||||||
3D8AB2A42B36440D005BD7D0 /* BlurHashDecode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlurHashDecode.swift; sourceTree = "<group>"; };
|
3D8AB2A42B36440D005BD7D0 /* BlurHashDecode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlurHashDecode.swift; sourceTree = "<group>"; };
|
||||||
@ -152,6 +154,7 @@
|
|||||||
3D1015E32B28000E00F5C29A /* AuthStateController.swift */,
|
3D1015E32B28000E00F5C29A /* AuthStateController.swift */,
|
||||||
3DF1ED3D2B282836000AD8EA /* JellyfinClientController.swift */,
|
3DF1ED3D2B282836000AD8EA /* JellyfinClientController.swift */,
|
||||||
3DC6BA2C2B2A422300416B9F /* SettingsController.swift */,
|
3DC6BA2C2B2A422300416B9F /* SettingsController.swift */,
|
||||||
|
3D6A0DC02B867B4C001FDA40 /* ScreenSize.swift */,
|
||||||
);
|
);
|
||||||
path = Controllers;
|
path = Controllers;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -386,6 +389,7 @@
|
|||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
3D6A0DC12B867B4C001FDA40 /* ScreenSize.swift in Sources */,
|
||||||
3D9063CD2B279A310063DD2A /* ContentView.swift in Sources */,
|
3D9063CD2B279A310063DD2A /* ContentView.swift in Sources */,
|
||||||
3D13F96F2B38A32500E91913 /* StickyHeaderView.swift in Sources */,
|
3D13F96F2B38A32500E91913 /* StickyHeaderView.swift in Sources */,
|
||||||
3DF1ED3E2B282836000AD8EA /* JellyfinClientController.swift in Sources */,
|
3DF1ED3E2B282836000AD8EA /* JellyfinClientController.swift in Sources */,
|
||||||
|
12
Jel/Controllers/ScreenSize.swift
Normal file
12
Jel/Controllers/ScreenSize.swift
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
//
|
||||||
|
// ScreenSize.swift
|
||||||
|
// Jel
|
||||||
|
//
|
||||||
|
// Created by zerocool on 2/21/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
class ScreenSize: ObservableObject {
|
||||||
|
@Published var size: CGSize = CGSize(width: 0, height: 0)
|
||||||
|
}
|
@ -16,10 +16,20 @@ struct JelApp: App {
|
|||||||
Version: Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "0.0.0",
|
Version: Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "0.0.0",
|
||||||
Token: ""))
|
Token: ""))
|
||||||
|
|
||||||
|
@StateObject var size: ScreenSize = ScreenSize()
|
||||||
|
|
||||||
var body: some Scene {
|
var body: some Scene {
|
||||||
WindowGroup {
|
WindowGroup {
|
||||||
|
GeometryReader {geo in
|
||||||
ContentView()
|
ContentView()
|
||||||
.environmentObject(jellyfinClientController)
|
.environmentObject(jellyfinClientController)
|
||||||
|
.environmentObject(size)
|
||||||
|
.onChange(of: geo.size) {
|
||||||
|
size.size = geo.size
|
||||||
|
}
|
||||||
|
.onAppear {
|
||||||
|
size.size = geo.size
|
||||||
|
}
|
||||||
.task {
|
.task {
|
||||||
AuthStateController.shared.load()
|
AuthStateController.shared.load()
|
||||||
SettingsController.shared.load()
|
SettingsController.shared.load()
|
||||||
@ -28,4 +38,5 @@ struct JelApp: App {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,7 @@ import JellyfinKit
|
|||||||
|
|
||||||
struct DashboardView: View {
|
struct DashboardView: View {
|
||||||
@State var showingSettingsSheet: Bool = false
|
@State var showingSettingsSheet: Bool = false
|
||||||
@ObservedObject var authState: AuthStateController = AuthStateController.shared
|
|
||||||
@State var refresh: Bool = true
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ScrollView {
|
ScrollView {
|
||||||
@ -25,7 +24,6 @@ struct DashboardView: View {
|
|||||||
.padding([.top, .leading])
|
.padding([.top, .leading])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
.navigationTitle("Home")
|
.navigationTitle("Home")
|
||||||
.toolbar {
|
.toolbar {
|
||||||
ToolbarItem(placement: .topBarTrailing) {
|
ToolbarItem(placement: .topBarTrailing) {
|
||||||
@ -39,9 +37,7 @@ struct DashboardView: View {
|
|||||||
.sheet(isPresented: $showingSettingsSheet) {
|
.sheet(isPresented: $showingSettingsSheet) {
|
||||||
SettingsView(showingSettingsView: $showingSettingsSheet)
|
SettingsView(showingSettingsView: $showingSettingsSheet)
|
||||||
}
|
}
|
||||||
.onChange(of: authState.loggedIn, {
|
}
|
||||||
refresh = !authState.loggedIn
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,23 +12,30 @@ import ExpandableText
|
|||||||
struct ItemSeriesEpisodeIconView: View {
|
struct ItemSeriesEpisodeIconView: View {
|
||||||
var item: BaseItemDto
|
var item: BaseItemDto
|
||||||
|
|
||||||
|
@EnvironmentObject var size: ScreenSize
|
||||||
|
|
||||||
|
var iconWidthMultiplier: CGFloat = 0.35
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
VStack(alignment: .leading) {
|
||||||
HStack(alignment: .top) {
|
HStack(alignment: .top) {
|
||||||
|
ItemIconView(item: item, width: (size.size.width * iconWidthMultiplier), height: (size.size.width * iconWidthMultiplier) / 1.7)
|
||||||
|
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
Text("Episode \(item.indexNumber ?? 0)")
|
Text("Episode \(item.indexNumber ?? 0)")
|
||||||
.foregroundStyle(Color.secondary)
|
.foregroundStyle(Color.secondary)
|
||||||
.font(.callout)
|
.font(.caption)
|
||||||
ItemIconView(item: item, width: UIScreen.screenWidth * 0.5, contentMode: .fill)
|
Text(item.name ?? "---")
|
||||||
.setAspectRatio(item.primaryImageAspectRatio ?? 1.7)
|
|
||||||
}
|
|
||||||
.frame(width: UIScreen.screenWidth * 0.5)
|
|
||||||
|
|
||||||
VStack(alignment: .leading) {
|
|
||||||
Text(item.name ?? "Episode \(item.indexNumber ?? 0)")
|
|
||||||
.font(.callout)
|
|
||||||
.bold()
|
.bold()
|
||||||
|
.lineLimit(nil)
|
||||||
|
|
||||||
Text(item.overview ?? "")
|
Text(item.overview ?? "")
|
||||||
.frame(height: (UIScreen.screenWidth * 0.5) / (item.primaryImageAspectRatio ?? 1.7)) // Calculate optimal amount of lines based on episode image
|
.foregroundStyle(Color.secondary)
|
||||||
|
.font(.callout)
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
.frame(height: (size.size.width * iconWidthMultiplier) / 1.7)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ struct ItemSeriesEpisodesView: View {
|
|||||||
@State var episodeItems: [BaseItemDto] = []
|
@State var episodeItems: [BaseItemDto] = []
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack(alignment: .leading) {
|
||||||
ForEach(episodeItems) {episode in
|
ForEach(episodeItems) {episode in
|
||||||
ItemSeriesEpisodeIconView(item: episode)
|
ItemSeriesEpisodeIconView(item: episode)
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct StickyHeaderView<Content: View>: View {
|
struct StickyHeaderView<Content: View>: View {
|
||||||
|
|
||||||
var minHeight: CGFloat
|
var minHeight: CGFloat
|
||||||
var content: Content
|
var content: Content
|
||||||
|
|
||||||
@ -28,7 +27,7 @@ struct StickyHeaderView<Content: View>: View {
|
|||||||
.frame(width: geo.size.width, height: geo.size.height + geo.frame(in: .global).minY)
|
.frame(width: geo.size.width, height: geo.size.height + geo.frame(in: .global).minY)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.frame(minWidth: UIScreen.current?.bounds.width ?? 200, minHeight: minHeight)
|
.frame(minWidth: UIScreen.screenWidth, minHeight: minHeight)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user