idk i changed layout constants
Some checks are pending
Build and Release / Build IPA (push) Waiting to run
Build and Release / Build Mac Catalyst (push) Waiting to run

This commit is contained in:
Francesco 2025-06-01 16:41:11 +02:00
parent afe49abcfa
commit fddf940b95

View file

@ -31,15 +31,12 @@ struct LibraryView: View {
] ]
private var columnsCount: Int { private var columnsCount: Int {
// Stage Manager Detection
if UIDevice.current.userInterfaceIdiom == .pad && horizontalSizeClass == .compact { if UIDevice.current.userInterfaceIdiom == .pad && horizontalSizeClass == .compact {
return verticalSizeClass == .compact ? 3 : 2 return verticalSizeClass == .compact ? 3 : 2
} else if UIDevice.current.userInterfaceIdiom == .pad { } else if UIDevice.current.userInterfaceIdiom == .pad {
// Normal iPad layout
let isLandscape = UIScreen.main.bounds.width > UIScreen.main.bounds.height let isLandscape = UIScreen.main.bounds.width > UIScreen.main.bounds.height
return isLandscape ? mediaColumnsLandscape : mediaColumnsPortrait return isLandscape ? mediaColumnsLandscape : mediaColumnsPortrait
} else { } else {
// iPhone layout
return verticalSizeClass == .compact ? mediaColumnsLandscape : mediaColumnsPortrait return verticalSizeClass == .compact ? mediaColumnsLandscape : mediaColumnsPortrait
} }
} }
@ -202,31 +199,26 @@ struct LibraryView: View {
} }
private func determineColumns() -> Int { private func determineColumns() -> Int {
// Stage Manager Detection
if UIDevice.current.userInterfaceIdiom == .pad && horizontalSizeClass == .compact { if UIDevice.current.userInterfaceIdiom == .pad && horizontalSizeClass == .compact {
return verticalSizeClass == .compact ? 3 : 2 return verticalSizeClass == .compact ? 3 : 2
} else if UIDevice.current.userInterfaceIdiom == .pad { } else if UIDevice.current.userInterfaceIdiom == .pad {
// Normal iPad layout
let isLandscape = UIScreen.main.bounds.width > UIScreen.main.bounds.height let isLandscape = UIScreen.main.bounds.width > UIScreen.main.bounds.height
return isLandscape ? mediaColumnsLandscape : mediaColumnsPortrait return isLandscape ? mediaColumnsLandscape : mediaColumnsPortrait
} else { } else {
// iPhone layout
return verticalSizeClass == .compact ? mediaColumnsLandscape : mediaColumnsPortrait return verticalSizeClass == .compact ? mediaColumnsLandscape : mediaColumnsPortrait
} }
} }
} }
struct ContinueWatchingSection: View { struct ContinueWatchingSection: View {
@Binding @Binding var items: [ContinueWatchingItem]
var items: [ContinueWatchingItem]
var markAsWatched: (ContinueWatchingItem) -> Void var markAsWatched: (ContinueWatchingItem) -> Void
var removeItem: (ContinueWatchingItem) -> Void var removeItem: (ContinueWatchingItem) -> Void
var body: some View { var body: some View {
ScrollView(.horizontal, showsIndicators: false) { ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 12) { HStack(spacing: 12) {
ForEach(Array(items.reversed().prefix(5))) { ForEach(Array(items.reversed().prefix(5))) { item in
item in
ContinueWatchingCell(item: item, markAsWatched: { ContinueWatchingCell(item: item, markAsWatched: {
markAsWatched(item) markAsWatched(item)
}, removeItem: { }, removeItem: {
@ -235,6 +227,7 @@ struct ContinueWatchingSection: View {
} }
} }
.padding(.horizontal, 20) .padding(.horizontal, 20)
.frame(height: 157.03)
} }
} }
} }
@ -295,7 +288,7 @@ struct ContinueWatchingCell: View {
.shimmering() .shimmering()
} }
.resizable() .resizable()
.aspectRatio(contentMode: .fill) .aspectRatio(16/9, contentMode: .fill)
.frame(width: 280, height: 157.03) .frame(width: 280, height: 157.03)
.cornerRadius(10) .cornerRadius(10)
.clipped() .clipped()
@ -392,11 +385,9 @@ struct ContinueWatchingCell: View {
} }
private func updateProgress() { private func updateProgress() {
// grab the true playback times
let lastPlayed = UserDefaults.standard.double(forKey: "lastPlayedTime_\(item.fullUrl)") let lastPlayed = UserDefaults.standard.double(forKey: "lastPlayedTime_\(item.fullUrl)")
let totalTime = UserDefaults.standard.double(forKey: "totalTime_\(item.fullUrl)") let totalTime = UserDefaults.standard.double(forKey: "totalTime_\(item.fullUrl)")
// compute a clean 01 ratio
let ratio: Double let ratio: Double
if totalTime > 0 { if totalTime > 0 {
ratio = min(max(lastPlayed / totalTime, 0), 1) ratio = min(max(lastPlayed / totalTime, 0), 1)
@ -406,10 +397,8 @@ struct ContinueWatchingCell: View {
currentProgress = ratio currentProgress = ratio
if ratio >= 0.9 { if ratio >= 0.9 {
// >90% watched? drop it immediately
removeItem() removeItem()
} else { } else {
// otherwise persist the latest progress
var updated = item var updated = item
updated.progress = ratio updated.progress = ratio
ContinueWatchingManager.shared.save(item: updated) ContinueWatchingManager.shared.save(item: updated)
@ -500,16 +489,14 @@ struct BookmarksGridView: View {
@Binding var selectedBookmark: LibraryItem? @Binding var selectedBookmark: LibraryItem?
@Binding var isDetailActive: Bool @Binding var isDetailActive: Bool
private private var recentBookmarks: [LibraryItem] {
var recentBookmarks: [LibraryItem] {
Array(libraryManager.bookmarks.prefix(5)) Array(libraryManager.bookmarks.prefix(5))
} }
var body: some View { var body: some View {
ScrollView(.horizontal, showsIndicators: false) { ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 12) { HStack(spacing: 12) {
ForEach(recentBookmarks) { ForEach(recentBookmarks) { item in
item in
BookmarkItemView( BookmarkItemView(
item: item, item: item,
selectedBookmark: $selectedBookmark, selectedBookmark: $selectedBookmark,
@ -518,6 +505,7 @@ struct BookmarksGridView: View {
} }
} }
.padding(.horizontal, 20) .padding(.horizontal, 20)
.frame(height: 243)
} }
} }
} }
@ -531,9 +519,7 @@ struct BookmarkItemView: View {
@Binding var isDetailActive: Bool @Binding var isDetailActive: Bool
var body: some View { var body: some View {
if let module = moduleManager.modules.first(where: { if let module = moduleManager.modules.first(where: { $0.id.uuidString == item.moduleId }) {
$0.id.uuidString == item.moduleId
}) {
Button(action: { Button(action: {
selectedBookmark = item selectedBookmark = item
isDetailActive = true isDetailActive = true
@ -587,8 +573,8 @@ struct BookmarkItemView: View {
.shadow(color: .black, radius: 4, x: 0, y: 2) .shadow(color: .black, radius: 4, x: 0, y: 2)
) )
} }
.frame(width: 162)
} }
.frame(width: 162, height: 243)
.clipShape(RoundedRectangle(cornerRadius: 12)) .clipShape(RoundedRectangle(cornerRadius: 12))
} }
.contextMenu { .contextMenu {