Skip to content

Instantly share code, notes, and snippets.

var body: some View {
NavigationView {
List($colors){ $color in
Text(color.name)
}
.refreshable {
self.colors.append(Colors(name: "Newly added"))
}
.navigationTitle("Colors List")
import SwiftUI
struct Colors : Identifiable{
var id = UUID()
var name : String
}
struct SearchingLists: View {
@State private var searchQuery: String = ""
@State private var colors: [Colors] = [Colors(name: "blue"),
struct Colors : Identifiable{
var id = UUID()
var name : String
}
struct SearchingLists: View {
@State private var searchQuery: String = ""
@State private var colors: [Colors] = [Colors(name: "Blue"),Colors(name: "Red"),Colors(name: "Green")]
var body: some View {
Form{
TextField("Email", text: $field1)
SecureField("Password", text: $field2)
TextField("Name", text: $field3)
.submitScope(false) //setting true won't submit the values
}
.onSubmit {
print(field1)
enum CurrentField{
case field1
case field2
}
struct TextFieldFocus: View {
@State var field1 = ""
@State var field2 = ""
VStack{
Button("Plain", role: .none, action: {})
.buttonStyle(PlainButtonStyle())
Button("Automatic", role: .none, action: {})
.buttonStyle(.automatic)
Button("Log out", role: .cancel, action: {})
.buttonStyle(BorderedButtonStyle())
struct VLabelStyle: LabelStyle {
func makeBody(configuration: Configuration) -> some View {
VStack {
configuration.icon
configuration.title
}
}
}
@main
struct MyWidgetBundle: WidgetBundle {
@WidgetBundleBuilder
var body: some Widget {
AnotherJokesWidget()
JokesWidget()
}
}
struct JokesEntry: TimelineEntry {
public let date: Date
public let joke : String
}
@main
struct ProjectName: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}