struct ModalPopups: View {
? ? @State private var showingModal = false
? ? var body: some View {
? ? ? ? ZStack {
? ? ? ? ? ? VStack(spacing: 20) {
? ? ? ? ? ? ? ? Text("Popup對話框之彈出").font(.largeTitle)
? ? ? ? ? ? ? ? Text("介紹").font(.title).foregroundColor(.gray)
? ? ? ? ? ? ? ? Text("您可以使用ZStack和State變量創(chuàng)建自己的模式彈出窗口蟀架。")
? ? ? ? ? ? ? ? ? ? .frame(maxWidth: .infinity)
? ? ? ? ? ? ? ? ? ? .padding().font(.title).layoutPriority(1)
? ? ? ? ? ? ? ? ? ? .background(Color.orange).foregroundColor(Color.white)
? ? ? ? ? ? ? ? Button(action: {
? ? ? ? ? ? ? ? ? ? self.showingModal = true
? ? ? ? ? ? ? ? }) {
? ? ? ? ? ? ? ? ? ? Text("顯示彈出alert")
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? Spacer()
? ? ? ? ? ? }
? ? ? ? ? ? if $showingModal.wrappedValue {
? ? ? ? ? ? ? ? ZStack {
? ? ? ? ? ? ? ? ? ? Color.black.opacity(0.8)
? ? ? ? ? ? ? ? ? ? ? ? .edgesIgnoringSafeArea(.vertical)
? ? ? ? ? ? ? ? ? ? VStack(spacing: 20) {
? ? ? ? ? ? ? ? ? ? ? ? Text("標題")
? ? ? ? ? ? ? ? ? ? ? ? ? ? .bold()
? ? ? ? ? ? ? ? ? ? ? ? ? ? .padding()
? ? ? ? ? ? ? ? ? ? ? ? ? ? .frame(maxWidth: .infinity)
? ? ? ? ? ? ? ? ? ? ? ? ? ? .background(Color.orange)
? ? ? ? ? ? ? ? ? ? ? ? ? ? .foregroundColor(Color.blue)
? ? ? ? ? ? ? ? ? ? ? ? Text("這里是詳情啊")
? ? ? ? ? ? ? ? ? ? ? ? ? ? .foregroundColor(Color.blue)
? ? ? ? ? ? ? ? ? ? ? ? ? ? .padding()
//? ? ? ? ? ? ? ? ? ? ? ? Spacer()
? ? ? ? ? ? ? ? ? ? ? ? Button(action: {
? ? ? ? ? ? ? ? ? ? ? ? ? ? self.showingModal = false
? ? ? ? ? ? ? ? ? ? ? ? }) {
? ? ? ? ? ? ? ? ? ? ? ? ? ? Text("關閉")
? ? ? ? ? ? ? ? ? ? ? ? }.padding()
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? .frame(width: 300)
? ? ? ? ? ? ? ? ? ? .background(Color.white)
? ? ? ? ? ? ? ? ? ? .cornerRadius(20).shadow(radius: 20)
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }
? ? }
}