Replaced the FileSystemItemable protocol with the FileSystemItem one for the Browse module.
This commit is contained in:
parent
228438454f
commit
13010816e1
@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
struct Document {
|
||||
struct Document: FileSystemItem {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
@ -35,7 +35,3 @@ struct Document {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - FileSystemItemable
|
||||
|
||||
extension Document: FileSystemItemable {}
|
||||
|
@ -6,7 +6,7 @@
|
||||
// Copyright © 2022 Röck+Cöde. All rights reserved.
|
||||
//
|
||||
|
||||
public struct Folder {
|
||||
public struct Folder: FileSystemItem {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
@ -24,11 +24,3 @@ public struct Folder {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - FileSystemItemable
|
||||
|
||||
extension Folder: FileSystemItemable {}
|
||||
|
||||
// MARK: - Equatable
|
||||
|
||||
extension Folder: Equatable {}
|
||||
|
@ -6,11 +6,7 @@
|
||||
// Copyright © 2022 Röck+Cöde. All rights reserved.
|
||||
//
|
||||
|
||||
protocol FileSystemItem {
|
||||
protocol FileSystemItem: Identifiable, Hashable, Equatable {
|
||||
var id: String { get }
|
||||
var name: String { get }
|
||||
}
|
||||
|
||||
// MARK: - Type aliases
|
||||
|
||||
typealias FileSystemItemable = FileSystemItem & Identifiable & Hashable
|
||||
|
@ -22,7 +22,7 @@ struct GetItemsUseCase {
|
||||
id: String,
|
||||
username: String,
|
||||
password: String
|
||||
) async throws -> [any FileSystemItemable] {
|
||||
) async throws -> [any FileSystemItem] {
|
||||
let items = try await apiService.getItems(
|
||||
id: id,
|
||||
credentials: .init(
|
||||
@ -32,7 +32,7 @@ struct GetItemsUseCase {
|
||||
)
|
||||
|
||||
return items
|
||||
.compactMap { item -> any FileSystemItemable in
|
||||
.compactMap { item -> any FileSystemItem in
|
||||
if item.isDirectory {
|
||||
return Folder(
|
||||
id: item.id,
|
||||
|
@ -13,7 +13,7 @@ struct DocumentItem: View {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
let item: FileSystemItem
|
||||
let item: any FileSystemItem
|
||||
let select: ActionClosure
|
||||
let download: ActionClosure
|
||||
let delete: ActionClosure
|
||||
|
@ -13,7 +13,7 @@ struct FolderItem: View {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
let item: FileSystemItem
|
||||
let item: any FileSystemItem
|
||||
let select: ActionClosure
|
||||
let delete: ActionClosure
|
||||
|
||||
|
@ -22,7 +22,7 @@ extension View {
|
||||
}
|
||||
|
||||
func delete(
|
||||
item: Binding<(any FileSystemItemable)?>,
|
||||
item: Binding<(any FileSystemItem)?>,
|
||||
) -> some View {
|
||||
modifier(DeleteItemViewModifier(item: item))
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ struct DeleteItemViewModifier: ViewModifier {
|
||||
|
||||
// MARK: Bindings
|
||||
|
||||
@Binding var item: (any FileSystemItemable)?
|
||||
@Binding var item: (any FileSystemItem)?
|
||||
|
||||
// MARK: Body
|
||||
|
||||
|
@ -19,9 +19,9 @@ public struct BrowseView: View {
|
||||
// MARK: States
|
||||
|
||||
@State private var status: ViewStatus = .loading
|
||||
@State private var items: [any FileSystemItemable] = []
|
||||
@State private var items: [any FileSystemItem] = []
|
||||
@State private var stack: Stack?
|
||||
@State private var itemToDelete: (any FileSystemItemable)?
|
||||
@State private var itemToDelete: (any FileSystemItem)?
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
@ -114,7 +114,7 @@ private extension BrowseView {
|
||||
// MARK: Functions
|
||||
|
||||
@ViewBuilder func makeFolderItem(
|
||||
for item: any FileSystemItemable
|
||||
for item: any FileSystemItem
|
||||
) -> some View {
|
||||
if let folder = item as? Folder {
|
||||
FolderItem(item: item) {
|
||||
@ -139,7 +139,7 @@ private extension BrowseView {
|
||||
}
|
||||
|
||||
@ViewBuilder func makeDocumentItem(
|
||||
for item: any FileSystemItemable
|
||||
for item: any FileSystemItem
|
||||
) -> some View {
|
||||
if let document = item as? Document {
|
||||
DocumentItem(item: item) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user