Create BearWave macOS radio-first app
This commit is contained in:
36
Sources/BearWaveCore/Views/ManualStationView.swift
Normal file
36
Sources/BearWaveCore/Views/ManualStationView.swift
Normal file
@@ -0,0 +1,36 @@
|
||||
import SwiftUI
|
||||
|
||||
struct ManualStationView: View {
|
||||
@Environment(AppModel.self) private var model
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@State private var name = ""
|
||||
@State private var url = ""
|
||||
@State private var country = ""
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 16) {
|
||||
Text("Add station manually")
|
||||
.font(.title2.bold())
|
||||
|
||||
TextField("Name", text: $name)
|
||||
TextField("Stream URL (http/https)", text: $url)
|
||||
TextField("Country (optional)", text: $country)
|
||||
|
||||
HStack {
|
||||
Spacer()
|
||||
Button("Cancel") {
|
||||
dismiss()
|
||||
}
|
||||
Button("Add") {
|
||||
model.library.addManualStation(name: name, url: url, country: country)
|
||||
dismiss()
|
||||
}
|
||||
.keyboardShortcut(.defaultAction)
|
||||
.disabled(name.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty || URL(string: url) == nil)
|
||||
}
|
||||
}
|
||||
.textFieldStyle(.roundedBorder)
|
||||
.padding(24)
|
||||
.frame(width: 430)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user