61
damus/Components/TextFieldAlert.swift
Normal file
61
damus/Components/TextFieldAlert.swift
Normal file
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// TextFieldAlert.swift
|
||||
// damus
|
||||
//
|
||||
// Created by William Casarin on 2022-06-09.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct TextFieldAlert<Presenting>: View where Presenting: View {
|
||||
@Binding var isShowing: Bool
|
||||
@Binding var text: String
|
||||
let presenting: Presenting
|
||||
let title: String
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { (deviceSize: GeometryProxy) in
|
||||
ZStack {
|
||||
self.presenting
|
||||
.disabled(isShowing)
|
||||
VStack {
|
||||
Text(self.title)
|
||||
TextField("Relay", text: self.$text)
|
||||
Divider()
|
||||
HStack {
|
||||
Button(action: {
|
||||
withAnimation {
|
||||
self.isShowing.toggle()
|
||||
}
|
||||
}) {
|
||||
Text("Dismiss")
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
.background(Color.white)
|
||||
.frame(
|
||||
width: deviceSize.size.width*0.7,
|
||||
height: deviceSize.size.height*0.7
|
||||
)
|
||||
.shadow(radius: 1)
|
||||
.opacity(self.isShowing ? 1 : 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
extension View {
|
||||
|
||||
func textFieldAlert(isShowing: Binding<Bool>,
|
||||
text: Binding<String>,
|
||||
title: String) -> some View {
|
||||
TextFieldAlert(isShowing: isShowing,
|
||||
text: text,
|
||||
presenting: self,
|
||||
title: title)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user