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