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