33 lines
917 B
Swift
33 lines
917 B
Swift
import SwiftUI
|
|
|
|
struct NewGroupView: View {
|
|
@Environment(AppModel.self) private var model
|
|
@Environment(\.dismiss) private var dismiss
|
|
@State private var name = ""
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading, spacing: 16) {
|
|
Text("Create new folder")
|
|
.font(.title2.bold())
|
|
|
|
TextField("Folder name", text: $name)
|
|
.textFieldStyle(.roundedBorder)
|
|
|
|
HStack {
|
|
Spacer()
|
|
Button("Cancel") {
|
|
dismiss()
|
|
}
|
|
Button("Create") {
|
|
model.library.createGroup(name: name)
|
|
dismiss()
|
|
}
|
|
.keyboardShortcut(.defaultAction)
|
|
.disabled(name.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty)
|
|
}
|
|
}
|
|
.padding(24)
|
|
.frame(width: 340)
|
|
}
|
|
}
|