This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// SUImagePickerView.swift | |
// SUImagePickerView | |
// | |
// Created by Karthick Selvaraj on 02/05/20. | |
// Copyright © 2020 Karthick Selvaraj. All rights reserved. | |
// | |
import SwiftUI | |
import UIKit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ContentView.swift | |
// SUImagePickerView | |
// | |
// Created by Karthick Selvaraj on 02/05/20. | |
// Copyright © 2020 Karthick Selvaraj. All rights reserved. | |
// | |
import SwiftUI | |
struct ContentView: View { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// recommended | |
@State private var name: String = "" | |
// Not recommended. But it will work though. | |
@State var name: String = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class MenuData: ObservableObject { | |
@Published var menu: [MenuSection] = [] // Will make an announcement when an item is added or remove from this menu array | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Environment(\.horizontalSizeClass) var horizontalSizeClass | |
@Environment(\.managedObjectContext) var managedObjectContext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
} | |
OlderNewer