buttons moved to relay config view to be outside of form
This commit is contained in:
@@ -8,72 +8,41 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct AddRelayView: View {
|
struct AddRelayView: View {
|
||||||
@Binding var show_add_relay: Bool
|
|
||||||
@Binding var relay: String
|
@Binding var relay: String
|
||||||
|
|
||||||
let action: (String?) -> Void
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(alignment: .leading) {
|
ZStack(alignment: .leading) {
|
||||||
Form {
|
HStack{
|
||||||
Section(NSLocalizedString("Add Relay", comment: "Label for section for adding a relay server.")) {
|
TextField(NSLocalizedString("wss://some.relay.com", comment: "Placeholder example for relay server address."), text: $relay)
|
||||||
ZStack(alignment: .leading) {
|
.padding(2)
|
||||||
HStack{
|
.padding(.leading, 25)
|
||||||
TextField(NSLocalizedString("wss://some.relay.com", comment: "Placeholder example for relay server address."), text: $relay)
|
.autocorrectionDisabled(true)
|
||||||
.padding(2)
|
.textInputAutocapitalization(.never)
|
||||||
.padding(.leading, 25)
|
|
||||||
.autocorrectionDisabled(true)
|
Label("", systemImage: "xmark.circle.fill")
|
||||||
.textInputAutocapitalization(.never)
|
.foregroundColor(.accentColor)
|
||||||
|
.padding(.trailing, -25.0)
|
||||||
Label("", systemImage: "xmark.circle.fill")
|
.opacity((relay == "") ? 0.0 : 1.0)
|
||||||
.foregroundColor(.blue)
|
.onTapGesture {
|
||||||
.padding(.trailing, -25.0)
|
self.relay = ""
|
||||||
.opacity((relay == "") ? 0.0 : 1.0)
|
|
||||||
.onTapGesture {
|
|
||||||
self.relay = ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Label("", systemImage: "doc.on.clipboard")
|
|
||||||
.padding(.leading, -10)
|
|
||||||
.onTapGesture {
|
|
||||||
if let pastedrelay = UIPasteboard.general.string {
|
|
||||||
self.relay = pastedrelay
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VStack {
|
Label("", systemImage: "doc.on.clipboard")
|
||||||
HStack {
|
.padding(.leading, -10)
|
||||||
Button(NSLocalizedString("Cancel", comment: "Button to cancel out of view adding user inputted relay.")) {
|
.onTapGesture {
|
||||||
show_add_relay = false
|
if let pastedrelay = UIPasteboard.general.string {
|
||||||
action(nil)
|
self.relay = pastedrelay
|
||||||
}
|
|
||||||
.contentShape(Rectangle())
|
|
||||||
|
|
||||||
Spacer()
|
|
||||||
|
|
||||||
Button(NSLocalizedString("Add", comment: "Button to confirm adding user inputted relay.")) {
|
|
||||||
show_add_relay = false
|
|
||||||
action(relay)
|
|
||||||
relay = ""
|
|
||||||
}
|
|
||||||
.buttonStyle(.borderedProminent)
|
|
||||||
.contentShape(Rectangle())
|
|
||||||
}
|
}
|
||||||
.padding()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AddRelayView_Previews: PreviewProvider {
|
struct AddRelayView_Previews: PreviewProvider {
|
||||||
@State static var show: Bool = true
|
|
||||||
@State static var relay: String = ""
|
@State static var relay: String = ""
|
||||||
|
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
AddRelayView(show_add_relay: $show, relay: $relay, action: {_ in })
|
AddRelayView(relay: $relay)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user