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 { | |
var body: some View { | |
NavigationStack { | |
TabView { | |
List { | |
Text("Content") | |
} | |
} |
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 { | |
var body: some View { | |
VStack { | |
ChildView() | |
ChildView() | |
} | |
.padding() | |
.overlayPreferenceValue(ViewPreferenceKey.self) { $0 } |
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 { | |
@State private var showSheet1 = false | |
@State private var showSheet2 = false | |
@State private var showSheet3 = false | |
var body: some View { | |
VStack { | |
Button("State object created directly") { |
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 { | |
@State private var id = UUID() | |
@State private var isOn = false | |
var body: some View { | |
VStack { | |
// Changing this toggle will cause child views to update colors | |
Toggle("Toggle", isOn: $isOn) |
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 | |
final class SwiftUIView<Content: View>: UIView { | |
private var heightConstraint: NSLayoutConstraint? | |
init(content: Content, onSizeChanged: @escaping (CGSize) -> Void) { | |
super.init(frame: .zero) | |
let sizeReadingContent = content.readSize { [weak self] newSize in |
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 | |
public class TapPanGestureRecognizer: UIGestureRecognizer { | |
private var waitingForSecondTap: Task<Void, Never>? | |
public private(set) var initialLocation: CGPoint = .zero { | |
didSet { | |
currentLocation = initialLocation | |
} | |
} |