mirror of
https://github.com/yattee/yattee.git
synced 2025-08-09 20:24:06 +00:00
Add recent documents to home on iOS
This commit is contained in:
36
Shared/Documents/RecentDocumentsView.swift
Normal file
36
Shared/Documents/RecentDocumentsView.swift
Normal file
@@ -0,0 +1,36 @@
|
||||
import Defaults
|
||||
import SwiftUI
|
||||
|
||||
struct RecentDocumentsView: View {
|
||||
var limit = 3
|
||||
let model = DocumentsModel.shared
|
||||
|
||||
var body: some View {
|
||||
LazyVStack {
|
||||
if recentDocuments.isEmpty {
|
||||
NoDocumentsView()
|
||||
} else {
|
||||
ForEach(recentDocuments, id: \.absoluteString) { url in
|
||||
let video = Video.local(model.replacePrivateVar(url) ?? url)
|
||||
PlayerQueueRow(
|
||||
item: PlayerQueueItem(video)
|
||||
)
|
||||
.contextMenu {
|
||||
VideoContextMenuView(video: video)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 15)
|
||||
}
|
||||
|
||||
var recentDocuments: [URL] {
|
||||
model.recentDocuments(limit)
|
||||
}
|
||||
}
|
||||
|
||||
struct RecentDocumentsView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
RecentDocumentsView()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user