swiftui.gallery
swiftui.gallery copied to clipboard
FormView
import SwiftUI
struct ContentView: View {
static let cities = ["New York", "London", "New Delhi", "Singapore", "Sydney"]
@State private var citySelected = 0 //0 represents the first item being the default selection
@State private var addOwnCity = false
@State private var ownCity = ""
var body: some View {
NavigationView {
Section {
Form {
Picker(selection: $citySelected, label: Text("Choose a city:")) {
ForEach(0 ..< Self.cities.count) {
Text(Self.cities[$0])
}
}
Toggle(isOn: $addOwnCity.animation()) {
Text("Do you want to add your own city?")
}
if addOwnCity {
TextField("Enter your own city" ,text: $ownCity)
}
}
}.navigationBarTitle(Text("Form example"), displayMode: .inline)
}
}
}
I've added the code and the first image -- I need to rethink how I organize the gallery so that we can show multiple images for each view. Thank you!
I love the repo! It is simple and effective! Will continue to contribute whatever I learn as and when time permits!