Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: full screen viewer #38

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Sources/Screens/File/FileGrid.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct FileGrid: View, ListItemScrollable {
@ObservedObject private var fileStore: FileStore
@ObservedObject private var workspaceStore: WorkspaceStore
@State private var tappedItem: VOFile.Entity?
@State private var viewerIsPresented: Bool = false

init(fileStore: FileStore, workspaceStore: WorkspaceStore) {
self.fileStore = fileStore
Expand All @@ -36,6 +37,7 @@ struct FileGrid: View, ListItemScrollable {
Button {
if file.snapshot?.status == .ready {
tappedItem = file
viewerIsPresented = true
}
} label: {
FileCell(file, fileStore: fileStore)
Expand All @@ -58,8 +60,10 @@ struct FileGrid: View, ListItemScrollable {
}
}
}
.navigationDestination(item: $tappedItem) {
Viewer($0)
.fullScreenCover(isPresented: $viewerIsPresented) {
if let tappedItem {
Viewer(tappedItem)
}
}
.modifierIfPhone {
$0.padding(.vertical, VOMetrics.spacing)
Expand Down
8 changes: 6 additions & 2 deletions Sources/Screens/File/FileList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct FileList: View, ListItemScrollable {
@ObservedObject private var fileStore: FileStore
@ObservedObject private var workspaceStore: WorkspaceStore
@State private var tappedItem: VOFile.Entity?
@State private var viewerIsPresented: Bool = false

init(fileStore: FileStore, workspaceStore: WorkspaceStore) {
self.fileStore = fileStore
Expand All @@ -29,6 +30,7 @@ struct FileList: View, ListItemScrollable {
Button {
if file.snapshot?.status == .ready {
tappedItem = file
viewerIsPresented = true
}
} label: {
FileRow(file)
Expand All @@ -52,8 +54,10 @@ struct FileList: View, ListItemScrollable {
}
}
.listStyle(.inset)
.navigationDestination(item: $tappedItem) {
Viewer($0)
.fullScreenCover(isPresented: $viewerIsPresented) {
if let tappedItem {
Viewer(tappedItem)
}
}
}
}
Expand Down
37 changes: 21 additions & 16 deletions Sources/Screens/Viewer/Viewer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,36 @@ import SwiftUI
import VoltaserveCore

struct Viewer: View {
@Environment(\.presentationMode) private var presentationMode
@State private var isImmersiveMode: Bool = false
private let file: VOFile.Entity

init(_ file: VOFile.Entity) {
self.file = file
}

var body: some View {
VStack {
ViewerPDF(file)
ViewerImage(file)
ViewerVideo(file)
ViewerAudio(file)
Viewer3D(file)
if UIDevice.current.userInterfaceIdiom == .pad {
NavigationView {
VStack {
ViewerPDF(file)
ViewerImage(file)
ViewerVideo(file)
ViewerAudio(file)
Viewer3D(file)
ViewerMosaic(file)
.edgesIgnoringSafeArea(.bottom)
} else {
ViewerMosaic(file)
.edgesIgnoringSafeArea(.horizontal)
}
}
.navigationBarTitleDisplayMode(.inline)
.navigationTitle(file.name)
.modifierIfPad {
$0.edgesIgnoringSafeArea(.bottom)
.navigationBarTitleDisplayMode(.inline)
.navigationTitle(file.name)
.toolbar {
ToolbarItem(placement: .topBarLeading) {
Button {
presentationMode.wrappedValue.dismiss()
} label: {
Image(systemName: "xmark")
}
}
}
.edgesIgnoringSafeArea(.bottom)
}
}
}