61 lines
1.6 KiB
Swift
61 lines
1.6 KiB
Swift
|
|
//
|
||
|
|
// 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()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|