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
// The SwiftUI Lab: https://swiftui-lab.com | |
// Article: Inspecting the View Tree – Part 1 | |
// https://swiftui-lab.com/communicating-with-the-view-tree-part-1/ | |
import SwiftUI | |
struct EasyExample : View { | |
@State private var activeIdx: Int = 0 | |
var body: some 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
// The SwiftUI Lab: https://swiftui-lab.com | |
// Article: Inspecting the View Tree – Part 1 | |
// https://swiftui-lab.com/communicating-with-the-view-tree-part-1/ | |
import SwiftUI | |
struct MyTextPreferenceKey: PreferenceKey { | |
typealias Value = [MyTextPreferenceData] | |
static var defaultValue: [MyTextPreferenceData] = [] |
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
// The SwiftUI Lab: https://swiftui-lab.com | |
// Article: Inspecting the View Tree – Part 2 | |
// https://swiftui-lab.com/communicating-with-the-view-tree-part-2/ | |
import SwiftUI | |
struct MyTextPreferenceData { | |
let viewIdx: Int | |
let bounds: Anchor<CGRect> | |
} |
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
// The SwiftUI Lab: https://swiftui-lab.com | |
// Article: Inspecting the View Tree – Part 2 | |
// https://swiftui-lab.com/communicating-with-the-view-tree-part-2/ | |
import SwiftUI | |
struct MyTextPreferenceData { | |
let viewIdx: Int | |
var topLeading: Anchor<CGPoint>? = nil | |
var bottomTrailing: Anchor<CGPoint>? = nil |
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
// The SwiftUI Lab: https://swiftui-lab.com | |
// Article: Inspecting the View Tree – Part 3 | |
// https://swiftui-lab.com/communicating-with-the-view-tree-part-3/ | |
import SwiftUI | |
enum MyViewType: Equatable { | |
case formContainer // main container | |
case fieldContainer // contains a text label + text field | |
case field(Int) // text field (with an associated value that indicates the character count in the field) |
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
// The SwiftUI Lab: https://swiftui-lab.com | |
import SwiftUI | |
struct ContentView: View { | |
var body: some View { | |
Text("hello world!") | |
.padding(20) | |
.addBorder(Color.blue, width: 3.0, cornerRadius: 80) | |
} | |
} |
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 { | |
@State private var flag = false | |
var body: some View { | |
GeometryReader { proxy in | |
ZStack(alignment: .topLeading) { | |
// Draw the Infinity Shape | |
InfinityShape().stroke(Color.purple, style: StrokeStyle(lineWidth: 5, lineCap: .round, lineJoin: .miter, miterLimit: 0, dash: [7, 7], dashPhase: 0)) | |
.foregroundColor(.blue) |
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
// Authoer: The SwiftUI Lab | |
// Full article: https://swiftui-lab.com/scrollview-pull-to-refresh/ | |
import SwiftUI | |
struct RefreshableScrollView<Content: View>: View { | |
@State private var previousScrollOffset: CGFloat = 0 | |
@State private var scrollOffset: CGFloat = 0 | |
@State private var frozen: Bool = false | |
@State private var rotation: Angle = .degrees(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
// Authoer: The SwiftUI Lab | |
// Full article: https://swiftui-lab.com/scrollview-pull-to-refresh/ | |
import SwiftUI | |
import Combine | |
struct Dog: Identifiable { | |
let id = UUID() | |
let name:String | |
let picture: 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
// Authoer: The SwiftUI Lab | |
// Full article: https://swiftui-lab.com/scrollview-pull-to-refresh/ | |
import SwiftUI | |
struct ContentView: View { | |
@ObservedObject var model = MyModel() | |
@State private var alternate: Bool = true | |
let array = Array<String>(repeating: "Hello", count: 100) |
OlderNewer