my-files-sample/BeReal/Browse/Views/BrowseView.swift

157 lines
5.1 KiB
Swift
Raw Normal View History

//
// BrowseView.swift
// Browse
//
// Created by Javier Cicchelli on 03/12/2022.
// Copyright © 2022 Röck+Cöde. All rights reserved.
//
import SwiftUI
struct BrowseView: View {
var body: some View {
List {
Group {
Group {
FolderItem(name: "Some folder #1 name")
FolderItem(name: "Some folder #2 name")
FolderItem(name: "Some folder #3 name")
FolderItem(name: "Some folder #4 name")
FolderItem(name: "Some folder #5 name")
FolderItem(name: "Some folder #6 name")
FolderItem(name: "Some folder #7 name")
}
Group {
DocumentItem(
name: "Some document #1 name",
lastModified: "3 months ago",
fileSize: "1,23 Mbytes"
)
DocumentItem(
name: "Some document #2 name",
lastModified: "2 years ago",
fileSize: "123 Kbytes"
)
DocumentItem(
name: "Some document #3 name",
lastModified: "13 days ago",
fileSize: "12 bytes"
)
DocumentItem(
name: "Some document #4 name",
lastModified: "13 hours ago",
fileSize: "12,3 Gbytes"
)
DocumentItem(
name: "Some document #5 name",
lastModified: "13 minutes ago",
fileSize: "123 Tbytes"
)
DocumentItem(
name: "Some document #6 name",
lastModified: "13 seconds ago",
fileSize: "123 Tbytes"
)
DocumentItem(
name: "Some document #7 name",
lastModified: "13 nanoseconds ago",
fileSize: "123 Tbytes"
)
}
}
.swipeActions(
edge: .trailing,
allowsFullSwipe: true
) {
Button {
// ...
} label: {
Label {
Text("Delete item")
} icon: {
Image.trash
}
}
.tint(.red)
// TODO: allow download only if item is a file.
Button {
// ...
} label: {
Label {
Text("Download item")
} icon: {
Image.download
}
}
.tint(.orange)
}
}
.listStyle(.inset)
.background(Color.red)
.navigationTitle("Folder name")
.toolbar {
ToolbarItem(placement: .primaryAction) {
Menu {
Button {
// TODO: Implement the creation of a new folder.
} label: {
Label {
Text("Create a new folder")
} icon: {
Image.newFolder
}
}
Button {
// TODO: Implement the upload of a file from the device to the API.
} label: {
Label {
Text("Upload a file")
} icon: {
Image.newFile
}
}
} label: {
Label {
Text("Add file and/or folder")
} icon: {
Image.add
.foregroundColor(.red)
}
}
}
ToolbarItem(placement: .navigationBarTrailing) {
Button {
// TODO: Implement the show of the user profile.
} label: {
Image.profile
.foregroundColor(.red)
}
}
}
}
}
// MARK: - Image+Constants
private extension Image {
static let profile = Image(systemName: "person.crop.circle.fill")
static let add = Image(systemName: "plus.circle.fill")
static let newFolder = Image(systemName: "folder.badge.plus")
static let newFile = Image(systemName: "doc.badge.plus")
static let trash = Image(systemName: "trash")
static let download = Image(systemName: "arrow.down.doc")
}
// MARK: - Previews
struct BrowseView_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
BrowseView()
}
}
}