Consolidate images and files
This commit is contained in:
45
CHDataManagement/Views/Files/FileToAddView.swift
Normal file
45
CHDataManagement/Views/Files/FileToAddView.swift
Normal file
@ -0,0 +1,45 @@
|
||||
import SwiftUI
|
||||
import SFSafeSymbols
|
||||
|
||||
struct FileToAddView: View {
|
||||
|
||||
@ObservedObject
|
||||
var file: FileToAdd
|
||||
|
||||
let delete: (FileToAdd) -> Void
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading) {
|
||||
HStack {
|
||||
Image(systemSymbol: file.isSelected ? .checkmarkCircleFill : .circle)
|
||||
.resizable()
|
||||
.frame(width: 20, height: 20)
|
||||
.foregroundStyle(.blue)
|
||||
.onTapGesture {
|
||||
file.isSelected.toggle()
|
||||
}
|
||||
Image(systemSymbol: .trashCircleFill)
|
||||
.resizable()
|
||||
.frame(width: 20, height: 20)
|
||||
.foregroundStyle(.red)
|
||||
.onTapGesture {
|
||||
delete(file)
|
||||
}
|
||||
TextField("", text: $file.uniqueId)
|
||||
.textFieldStyle(.roundedBorder)
|
||||
.frame(maxWidth: 200)
|
||||
|
||||
}
|
||||
Text(file.url.path())
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
List {
|
||||
FileToAddView(file: .init(content: .mock, url: URL(fileURLWithPath: "/path/to/file.swift")), delete: { _ in })
|
||||
FileToAddView(file: .init(content: .mock, url: URL(fileURLWithPath: "/path/to/file2.swift")), delete: { _ in })
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user