swiftui.gallery icon indicating copy to clipboard operation
swiftui.gallery copied to clipboard

FormView

Open pavan288 opened this issue 6 years ago • 2 comments

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)
        }
    }
}
Screenshot 2019-10-07 at 3 03 41 PM Screenshot 2019-10-07 at 3 04 13 PM

pavan288 avatar Oct 07 '19 09:10 pavan288

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!

zainhoda avatar Oct 07 '19 15:10 zainhoda

I love the repo! It is simple and effective! Will continue to contribute whatever I learn as and when time permits!

pavan288 avatar Oct 07 '19 17:10 pavan288