diff options
Diffstat (limited to 'Jel')
-rw-r--r-- | Jel/Controllers/ScreenSize.swift | 12 | ||||
-rw-r--r-- | Jel/JelApp.swift | 27 | ||||
-rw-r--r-- | Jel/Views/Dashboard/DashboardView.swift | 28 | ||||
-rw-r--r-- | Jel/Views/Item/Series/ItemSeriesEpisodeIconView.swift | 39 | ||||
-rw-r--r-- | Jel/Views/Item/Series/ItemSeriesEpisodesView.swift | 2 | ||||
-rw-r--r-- | Jel/Views/Utility/StickyHeaderView.swift | 3 |
6 files changed, 68 insertions, 43 deletions
diff --git a/Jel/Controllers/ScreenSize.swift b/Jel/Controllers/ScreenSize.swift new file mode 100644 index 0000000..972d395 --- /dev/null +++ b/Jel/Controllers/ScreenSize.swift @@ -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) +} diff --git a/Jel/JelApp.swift b/Jel/JelApp.swift index 5dce28d..234c130 100644 --- a/Jel/JelApp.swift +++ b/Jel/JelApp.swift @@ -16,16 +16,27 @@ struct JelApp: App { Version: Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "0.0.0", Token: "")) + @StateObject var size: ScreenSize = ScreenSize() + var body: some Scene { WindowGroup { - ContentView() - .environmentObject(jellyfinClientController) - .task { - AuthStateController.shared.load() - SettingsController.shared.load() - jellyfinClientController.setUrl(url: AuthStateController.shared.serverUrl) - jellyfinClientController.setToken(token: AuthStateController.shared.authToken ?? "") - } + GeometryReader {geo in + ContentView() + .environmentObject(jellyfinClientController) + .environmentObject(size) + .onChange(of: geo.size) { + size.size = geo.size + } + .onAppear { + size.size = geo.size + } + .task { + AuthStateController.shared.load() + SettingsController.shared.load() + jellyfinClientController.setUrl(url: AuthStateController.shared.serverUrl) + jellyfinClientController.setToken(token: AuthStateController.shared.authToken ?? "") + } + } } } } diff --git a/Jel/Views/Dashboard/DashboardView.swift b/Jel/Views/Dashboard/DashboardView.swift index 931a884..508d002 100644 --- a/Jel/Views/Dashboard/DashboardView.swift +++ b/Jel/Views/Dashboard/DashboardView.swift @@ -10,8 +10,7 @@ import JellyfinKit struct DashboardView: View { @State var showingSettingsSheet: Bool = false - @ObservedObject var authState: AuthStateController = AuthStateController.shared - @State var refresh: Bool = true + var body: some View { ScrollView { @@ -25,23 +24,20 @@ struct DashboardView: View { .padding([.top, .leading]) } } - } - .navigationTitle("Home") - .toolbar { - ToolbarItem(placement: .topBarTrailing) { - Button { - showingSettingsSheet.toggle() - } label: { - Label("Settings", systemImage: "gear") + .navigationTitle("Home") + .toolbar { + ToolbarItem(placement: .topBarTrailing) { + Button { + showingSettingsSheet.toggle() + } label: { + Label("Settings", systemImage: "gear") + } } } + .sheet(isPresented: $showingSettingsSheet) { + SettingsView(showingSettingsView: $showingSettingsSheet) + } } - .sheet(isPresented: $showingSettingsSheet) { - SettingsView(showingSettingsView: $showingSettingsSheet) - } - .onChange(of: authState.loggedIn, { - refresh = !authState.loggedIn - }) } } diff --git a/Jel/Views/Item/Series/ItemSeriesEpisodeIconView.swift b/Jel/Views/Item/Series/ItemSeriesEpisodeIconView.swift index fea8997..9217bea 100644 --- a/Jel/Views/Item/Series/ItemSeriesEpisodeIconView.swift +++ b/Jel/Views/Item/Series/ItemSeriesEpisodeIconView.swift @@ -12,23 +12,30 @@ import ExpandableText struct ItemSeriesEpisodeIconView: View { var item: BaseItemDto + @EnvironmentObject var size: ScreenSize + + var iconWidthMultiplier: CGFloat = 0.35 + var body: some View { - HStack(alignment: .top) { - VStack(alignment: .leading) { - Text("Episode \(item.indexNumber ?? 0)") - .foregroundStyle(Color.secondary) - .font(.callout) - ItemIconView(item: item, width: UIScreen.screenWidth * 0.5, contentMode: .fill) - .setAspectRatio(item.primaryImageAspectRatio ?? 1.7) - } - .frame(width: UIScreen.screenWidth * 0.5) - - VStack(alignment: .leading) { - Text(item.name ?? "Episode \(item.indexNumber ?? 0)") - .font(.callout) - .bold() - Text(item.overview ?? "") - .frame(height: (UIScreen.screenWidth * 0.5) / (item.primaryImageAspectRatio ?? 1.7)) // Calculate optimal amount of lines based on episode image + VStack(alignment: .leading) { + HStack(alignment: .top) { + ItemIconView(item: item, width: (size.size.width * iconWidthMultiplier), height: (size.size.width * iconWidthMultiplier) / 1.7) + + VStack(alignment: .leading) { + Text("Episode \(item.indexNumber ?? 0)") + .foregroundStyle(Color.secondary) + .font(.caption) + Text(item.name ?? "---") + .bold() + .lineLimit(nil) + + Text(item.overview ?? "") + .foregroundStyle(Color.secondary) + .font(.callout) + + Spacer() + } + .frame(height: (size.size.width * iconWidthMultiplier) / 1.7) } } } diff --git a/Jel/Views/Item/Series/ItemSeriesEpisodesView.swift b/Jel/Views/Item/Series/ItemSeriesEpisodesView.swift index 2588515..17d5c9b 100644 --- a/Jel/Views/Item/Series/ItemSeriesEpisodesView.swift +++ b/Jel/Views/Item/Series/ItemSeriesEpisodesView.swift @@ -17,7 +17,7 @@ struct ItemSeriesEpisodesView: View { @State var episodeItems: [BaseItemDto] = [] var body: some View { - VStack { + VStack(alignment: .leading) { ForEach(episodeItems) {episode in ItemSeriesEpisodeIconView(item: episode) } diff --git a/Jel/Views/Utility/StickyHeaderView.swift b/Jel/Views/Utility/StickyHeaderView.swift index b3bfd02..decc867 100644 --- a/Jel/Views/Utility/StickyHeaderView.swift +++ b/Jel/Views/Utility/StickyHeaderView.swift @@ -8,7 +8,6 @@ import SwiftUI struct StickyHeaderView<Content: View>: View { - var minHeight: CGFloat 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(minWidth: UIScreen.current?.bounds.width ?? 200, minHeight: minHeight) + .frame(minWidth: UIScreen.screenWidth, minHeight: minHeight) } } |