Renamed the FileSystemItemIdentifiable protocol as FileSystemItemable for the Browse module.
This commit is contained in:
parent
34f7813a5c
commit
d357c1a069
@ -36,6 +36,6 @@ struct Document {
|
||||
|
||||
}
|
||||
|
||||
// MARK: - FileSystemIdIdentifiable
|
||||
// MARK: - FileSystemItemable
|
||||
|
||||
extension Document: FileSystemItemIdentifiable {}
|
||||
extension Document: FileSystemItemable {}
|
||||
|
@ -25,9 +25,9 @@ public struct Folder {
|
||||
|
||||
}
|
||||
|
||||
// MARK: - FileSystemIdIdentifiable
|
||||
// MARK: - FileSystemItemable
|
||||
|
||||
extension Folder: FileSystemItemIdentifiable {}
|
||||
extension Folder: FileSystemItemable {}
|
||||
|
||||
// MARK: - Equatable
|
||||
|
||||
|
@ -13,4 +13,4 @@ protocol FileSystemItem {
|
||||
|
||||
// MARK: - Type aliases
|
||||
|
||||
typealias FileSystemItemIdentifiable = FileSystemItem & Identifiable & Hashable
|
||||
typealias FileSystemItemable = FileSystemItem & Identifiable & Hashable
|
||||
|
@ -13,9 +13,9 @@ import Foundation
|
||||
|
||||
struct GetDataUseCase {
|
||||
|
||||
// MARK: Dependencies
|
||||
// MARK: Properties
|
||||
|
||||
@Dependency(\.apiService) private var apiService
|
||||
let apiService: APIService
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
@ -34,3 +34,13 @@ struct GetDataUseCase {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Initialisers
|
||||
|
||||
extension GetDataUseCase {
|
||||
init() {
|
||||
@Dependency(\.apiService) var apiService
|
||||
|
||||
self.init(apiService: apiService)
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,9 @@ import Dependencies
|
||||
|
||||
struct GetItemsUseCase {
|
||||
|
||||
// MARK: Dependencies
|
||||
// MARK: Properties
|
||||
|
||||
@Dependency(\.apiService) private var apiService
|
||||
let apiService: APIService
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
@ -22,7 +22,7 @@ struct GetItemsUseCase {
|
||||
id: String,
|
||||
username: String,
|
||||
password: String
|
||||
) async throws -> [any FileSystemItemIdentifiable] {
|
||||
) async throws -> [any FileSystemItemable] {
|
||||
let items = try await apiService.getItems(
|
||||
id: id,
|
||||
credentials: .init(
|
||||
@ -32,7 +32,7 @@ struct GetItemsUseCase {
|
||||
)
|
||||
|
||||
return items
|
||||
.compactMap { item -> any FileSystemItemIdentifiable in
|
||||
.compactMap { item -> any FileSystemItemable in
|
||||
if item.isDirectory {
|
||||
return Folder(
|
||||
id: item.id,
|
||||
@ -51,3 +51,13 @@ struct GetItemsUseCase {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Initialisers
|
||||
|
||||
extension GetItemsUseCase {
|
||||
init() {
|
||||
@Dependency(\.apiService) var apiService
|
||||
|
||||
self.init(apiService: apiService)
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ extension View {
|
||||
}
|
||||
|
||||
func delete(
|
||||
item: Binding<(any FileSystemItemIdentifiable)?>
|
||||
item: Binding<(any FileSystemItemable)?>,
|
||||
) -> some View {
|
||||
modifier(DeleteItemViewModifier(item: item))
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ struct DeleteItemViewModifier: ViewModifier {
|
||||
|
||||
// MARK: Bindings
|
||||
|
||||
@Binding var item: (any FileSystemItemIdentifiable)?
|
||||
@Binding var item: (any FileSystemItemable)?
|
||||
|
||||
// MARK: Body
|
||||
|
||||
|
@ -19,9 +19,9 @@ public struct BrowseView: View {
|
||||
// MARK: States
|
||||
|
||||
@State private var status: ViewStatus = .loading
|
||||
@State private var items: [any FileSystemItemIdentifiable] = []
|
||||
@State private var items: [any FileSystemItemable] = []
|
||||
@State private var stack: Stack?
|
||||
@State private var itemToDelete: (any FileSystemItemIdentifiable)?
|
||||
@State private var itemToDelete: (any FileSystemItemable)?
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
@ -32,7 +32,7 @@ public struct BrowseView: View {
|
||||
private let login: ActionClosure
|
||||
|
||||
private let getItems: GetItemsUseCase = .init()
|
||||
|
||||
|
||||
// MARK: Initialisers
|
||||
|
||||
public init(
|
||||
@ -114,7 +114,7 @@ private extension BrowseView {
|
||||
// MARK: Functions
|
||||
|
||||
@ViewBuilder func makeFolderItem(
|
||||
for item: any FileSystemItemIdentifiable
|
||||
for item: any FileSystemItemable
|
||||
) -> some View {
|
||||
if let folder = item as? Folder {
|
||||
FolderItem(item: item) {
|
||||
@ -139,7 +139,7 @@ private extension BrowseView {
|
||||
}
|
||||
|
||||
@ViewBuilder func makeDocumentItem(
|
||||
for item: any FileSystemItemIdentifiable
|
||||
for item: any FileSystemItemable
|
||||
) -> some View {
|
||||
if let document = item as? Document {
|
||||
DocumentItem(item: item) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user