Skip to content

Instantly share code, notes, and snippets.

@VAndrJ
Created April 29, 2025 09:07
Show Gist options
  • Save VAndrJ/c6c18d052248debff93abbec08a2bb83 to your computer and use it in GitHub Desktop.
Save VAndrJ/c6c18d052248debff93abbec08a2bb83 to your computer and use it in GitHub Desktop.
MRE to check how TextField and disabled Button works with alert on different iOS versions.
//
// MRE.swift
//
// Created by VAndrJ on 4/29/25.
//
import SwiftUI
struct ContentView: View {
@State private var isAlertPresented = false
@State private var text = ""
@State private var saved = ""
var body: some View {
VStack {
Button("Save file") {
isAlertPresented = true
}
Text("Saved: \(saved)")
}
.alert("Save file", isPresented: $isAlertPresented) {
TextField("File name", text: $text)
Button("Save") {
saved = text
}
.disabled(text.isEmpty)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment