Files
QueueCube/ios/QueueCube/Views/EditItemView.swift

61 lines
1.6 KiB
Swift
Raw Normal View History

2025-06-20 18:50:06 -07:00
//
// EditItemView.swift
// QueueCube
//
// Created by James Magahern on 6/20/25.
//
import SwiftUI
@Observable
class EditItemViewModel
{
var mediaURL: String = ""
var title: String = ""
var onDone: (EditItemViewModel) -> Void = { _ in }
var onCancel: (EditItemViewModel) -> Void = { _ in }
}
struct EditItemView: View
{
@Binding var model: EditItemViewModel
var body: some View {
NavigationStack {
Form {
Section(.url) {
TextField(.url, text: $model.mediaURL)
.foregroundStyle(.secondary)
.disabled(true) // editing URL not yet supported by server
.contextMenu {
Button(.copyURL) {
UIPasteboard.general.string = model.mediaURL
}
}
}
Section(.title) {
TextField(.title, text: $model.title)
}
}
.navigationTitle(.editItem)
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItemGroup(placement: .topBarLeading) {
Button(.cancel, role: .cancel) {
model.onCancel(model)
}
}
ToolbarItemGroup(placement: .topBarTrailing) {
Button(.done, role: .destructive) {
model.onDone(model)
}
.bold()
}
}
}
}
}