This file contains hidden or 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 User: Identifiable { | |
| var id = "Ryan" | |
| } | |
| struct BindingAlertAndSheet: View { | |
| // MARK: - Properties | |
| @State private var isShowingAlert = false | |
| @State private var selectedUser: User? = nil |
This file contains hidden or 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 User: Identifiable { | |
| var id = "Ryan" | |
| } | |
| struct OptionalAlertAndSheet: View { | |
| // MARK: - Properties | |
| @State private var selectedUser: User? = nil | |
This file contains hidden or 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 SplitSideViews: View { | |
| // MARK: - Properties | |
| // MARK: - Body | |
| var body: some View { | |
| NavigationView { | |
| NavigationLink(destination: Text("New secondary")) { | |
| Text("Hello, World!") | |
| } //: NavLink | |
| .navigationTitle("Primary") |
This file contains hidden or 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 CoverFlowScrollView: View { | |
| // MARK: - Properties | |
| let colors: [Color] = [.red, .green, .blue, .orange, .pink, .purple, .yellow] | |
| // MARK: - Body | |
| var body: some View { | |
| VStack { | |
| Spacer() | |
| GeometryReader { fullView in | |
| ScrollView(.horizontal, showsIndicators: false) { | |
| HStack { |
This file contains hidden or 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 ScrollViewDNAEffect: View { | |
| // MARK: - Properties | |
| let colors: [Color] = [.red, .green, .blue, .orange, .pink, .purple, .yellow] | |
| // MARK: - Body | |
| var body: some View { | |
| GeometryReader { fullView in | |
| ScrollView(.vertical) { | |
| ForEach(0..<50) { index in | |
| GeometryReader { geo in | |
| Text("Row #\(index)") |
This file contains hidden or 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 Card: Codable { | |
| let prompt: String | |
| var answer: String | |
| } | |
| struct EditCards: View { | |
| // MARK: - Properties | |
| @Environment(\.presentationMode) var presentationMode | |
| @State private var cards = [Card]() |
This file contains hidden or 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 NotifiedBackground: View { | |
| var body: some View { | |
| /* | |
| UIApplication.significantTimeChangeNotification is called when the user changes their clock or when daylight savings time changes. | |
| UIResponder.keyboardDidShowNotification is called when the keyboard is shown. | |
| */ | |
| // Text("Hello, World!") | |
| // .onReceive(NotificationCenter.default.publisher(for: UIApplication.willResignActiveNotification)) { _ in |
This file contains hidden or 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 TriggerTimer: View { | |
| // MARK: - Properties | |
| // MARK: - Timer | |
| /* | |
| 1. timer to fire every 1sec | |
| 2. timer should run on the main thread | |
| 3. timer should run on the common run loop. (Run loops lets iOS handle running code while the user is actively doing something, such as scrolling in a list.) |
This file contains hidden or 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 CoreHaptics | |
| import SwiftUI | |
| struct VibrationsCoreHaptics: View { | |
| // MARK: - Properties | |
| @State private var engine: CHHapticEngine? | |
| var body: some View { | |
| Text("Tap here") | |
| .onAppear(perform: prepareHaptics) | |
| .onTapGesture(perform: complexSuccess) |
This file contains hidden or 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 GestureDrag: View { | |
| // MARK: - Properties | |
| @State private var offset = CGSize.zero | |
| @State private var isDragging = false | |
| // MARK: - body | |
| var body: some View { | |
| let dragGesture = DragGesture() |