Skip to content

Instantly share code, notes, and snippets.

View karthironald's full-sized avatar
👨‍💻
Learning.

Karthick Selvaraj karthironald

👨‍💻
Learning.
  • @mallow technologies private limited
  • Karur
View GitHub Profile
import SwiftUI
struct ContentView: View {
let products = ["iPhone", "iPad", "iMac", "MacBook", "Watch", "AppleTv"]
@State private var shouldShowSlider = false
@State private var size: CGFloat = 20.0
var body: some View {
NavigationView {
//
// SUImagePickerView.swift
// SUImagePickerView
//
// Created by Karthick Selvaraj on 02/05/20.
// Copyright © 2020 Karthick Selvaraj. All rights reserved.
//
import SwiftUI
import UIKit
//
// ContentView.swift
// SUImagePickerView
//
// Created by Karthick Selvaraj on 02/05/20.
// Copyright © 2020 Karthick Selvaraj. All rights reserved.
//
import SwiftUI
struct ContentView: View {
// recommended
@State private var name: String = ""
// Not recommended. But it will work though.
@State var name: String = ""
final class MenuData: ObservableObject {
@Published var menu: [MenuSection] = [] // Will make an announcement when an item is added or remove from this menu array
}
struct ContentView: View {
@ObservedObject var menuData: MenuData = MenuData() // Listener added to receive data changed announcements to refresh the List inside body.
var body: some View {
List(menuData.menu) { menu in
Text(menu.name)
final class MenuData: ObservableObject {
@Published var menu: [MenuSection] = [] // Will make an announcement when an item is added or remove from this menu array
}
class Order: ObservableObject {
@Published var items = [MenuItem]()
}
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
var order = Order()
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
...
@Environment(\.horizontalSizeClass) var horizontalSizeClass
@Environment(\.managedObjectContext) var managedObjectContext
struct WorkoutsList: View {
@Environment(\.managedObjectContext) var managedObjectContext
@FetchRequest(entity: Workout.entity(), sortDescriptors: [NSSortDescriptor(keyPath: \Workout.createdAt, ascending: true)]) var workouts: FetchedResults<Workout>
var body: some View {
NavigationView {
List(workouts, id: \.self) { workout in
Text(workout.name)
}
struct ContentView: View {
static let names = ["name1", "name2", "name3", "name4", "name5", "name6"]
var body: some View {
List(ContentView.names, id: \.self) { name in
Text(name)
}
}