mirror of
https://github.com/yattee/yattee.git
synced 2025-08-05 02:04:07 +00:00
Add recent documents to home on iOS
This commit is contained in:
@@ -7,16 +7,7 @@ struct DocumentsView: View {
|
||||
BrowserPlayerControls {
|
||||
ScrollView(.vertical, showsIndicators: false) {
|
||||
if model.directoryContents.isEmpty {
|
||||
VStack(alignment: .center, spacing: 20) {
|
||||
HStack {
|
||||
Image(systemName: "doc")
|
||||
Text("No documents")
|
||||
}
|
||||
Text("Share files from Finder on a Mac\nor iTunes on Windows")
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.foregroundColor(.secondary)
|
||||
NoDocumentsView()
|
||||
} else {
|
||||
ForEach(model.sortedDirectoryContents, id: \.absoluteString) { url in
|
||||
let video = Video.local(model.replacePrivateVar(url) ?? url)
|
||||
|
22
Shared/Documents/NoDocumentsView.swift
Normal file
22
Shared/Documents/NoDocumentsView.swift
Normal file
@@ -0,0 +1,22 @@
|
||||
import SwiftUI
|
||||
|
||||
struct NoDocumentsView: View {
|
||||
var body: some View {
|
||||
VStack(alignment: .center, spacing: 20) {
|
||||
HStack {
|
||||
Image(systemName: "doc")
|
||||
Text("No documents")
|
||||
}
|
||||
Text("Share files from Finder on a Mac\nor iTunes on Windows")
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
|
||||
struct NoDocumentsView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
NoDocumentsView()
|
||||
}
|
||||
}
|
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