2022-12-03 07:23:38 +01:00
|
|
|
//
|
|
|
|
// 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 {
|
2022-12-03 08:19:48 +01:00
|
|
|
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"
|
|
|
|
)
|
|
|
|
}
|
2022-12-03 07:23:38 +01:00
|
|
|
}
|
2022-12-03 08:19:48 +01:00
|
|
|
.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)
|
2022-12-03 07:23:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
.listStyle(.inset)
|
|
|
|
.background(Color.red)
|
|
|
|
.navigationTitle("Folder name")
|
2022-12-03 07:41:17 +01:00
|
|
|
.toolbar {
|
|
|
|
ToolbarItem(placement: .primaryAction) {
|
2022-12-03 08:36:15 +01:00
|
|
|
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) {
|
2022-12-03 07:41:17 +01:00
|
|
|
Button {
|
2022-12-03 08:36:15 +01:00
|
|
|
// TODO: Implement the show of the user profile.
|
2022-12-03 07:41:17 +01:00
|
|
|
} label: {
|
|
|
|
Image.profile
|
|
|
|
.foregroundColor(.red)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-12-03 07:23:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-03 07:41:17 +01:00
|
|
|
// MARK: - Image+Constants
|
|
|
|
|
|
|
|
private extension Image {
|
|
|
|
static let profile = Image(systemName: "person.crop.circle.fill")
|
2022-12-03 08:36:15 +01:00
|
|
|
static let add = Image(systemName: "plus.circle.fill")
|
|
|
|
static let newFolder = Image(systemName: "folder.badge.plus")
|
|
|
|
static let newFile = Image(systemName: "doc.badge.plus")
|
2022-12-03 08:19:48 +01:00
|
|
|
static let trash = Image(systemName: "trash")
|
|
|
|
static let download = Image(systemName: "arrow.down.doc")
|
2022-12-03 07:41:17 +01:00
|
|
|
}
|
|
|
|
|
2022-12-03 07:23:38 +01:00
|
|
|
// MARK: - Previews
|
|
|
|
|
|
|
|
struct BrowseView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
NavigationView {
|
|
|
|
BrowseView()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|