File size: 1,489 Bytes
ce0d62c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
prompt,output
Create a SwiftUI view with a button that changes text on tap,"import SwiftUI

struct ContentView: View {
    @State private var text = ""Hello, World!""

    var body: some View {
        VStack {
            Text(text)
                .font(.largeTitle)
            Button(""Tap me"") {
                text = ""Button Tapped!""
            }
            .padding()
        }
    }
}"
Create a SwiftUI view with a TextField and a Text showing its value,"import SwiftUI

struct ContentView: View {
    @State private var name = """"

    var body: some View {
        VStack {
            TextField(""Enter your name"", text: $name)
                .textFieldStyle(RoundedBorderTextFieldStyle())
                .padding()
            Text(""Hello, \(name)!"")
                .font(.title)
        }
        .padding()
    }
}"
Create a SwiftUI List with 5 items,"import SwiftUI

struct ContentView: View {
    let items = [""Item 1"", ""Item 2"", ""Item 3"", ""Item 4"", ""Item 5""]

    var body: some View {
        List(items, id: \ .self) { item in
            Text(item)
        }
    }
}"
Create a SwiftUI view with a toggle switch,"import SwiftUI

struct ContentView: View {
    @State private var isOn = false

    var body: some View {
        VStack {
            Toggle(""Enable Feature"", isOn: $isOn)
                .padding()
            Text(isOn ? ""Feature is ON"" : ""Feature is OFF"")
                .font(.title)
        }
        .padding()
    }
}"