File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,8 +3,18 @@ import Combine
33
44final class KFSFileManager : ObservableObject {
55 static let shared = KFSFileManager ( )
6+ struct FileEntry : Identifiable , Hashable {
7+ let id : String
8+ let name : String
9+ let isDir : Bool
10+ init ( name: String , isDir: Bool ) {
11+ self . id = name
12+ self . name = name
13+ self . isDir = isDir
14+ }
15+ }
616 @Published var currentPath : String = " / "
7- @Published var entries : [ ( name : String , isDir : Bool ) ] = [ ]
17+ @Published var entries : [ FileEntry ] = [ ]
818 @Published var lastError : String ? = nil
919 @Published var status : String = " idle "
1020
@@ -17,7 +27,7 @@ final class KFSFileManager: ObservableObject {
1727 if let list = laramgr. shared. kfslistdir ( path: p) {
1828 DispatchQueue . main. async {
1929 self . currentPath = p
20- self . entries = list
30+ self . entries = list. map { FileEntry ( name : $0 . name , isDir : $0 . isDir ) }
2131 self . status = " listed "
2232 }
2333 } else {
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ struct FileManagerView: View {
2020 }
2121 } . padding ( )
2222
23- List ( kfs. entries, id : \ . ( name ) ) { entry in
23+ List ( kfs. entries) { entry in
2424 HStack {
2525 if entry. isDir { Image ( systemName: " folder " ) }
2626 else { Image ( systemName: " doc.text " ) }
You can’t perform that action at this time.
0 commit comments