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
// Author: The SwiftUI-Lab | |
// This code is part of the tutorial: https://swiftui-lab.com/swiftui-animations-part4/ | |
import SwiftUI | |
// Sample usage | |
struct ContentView: View { | |
var body: some View { | |
VStack { | |
GifImage(url: URL(string: "https://media.giphy.com/media/YAlhwn67KT76E/giphy.gif?cid=790b7611b26260b2ad23535a70e343e67443ff80ef623844&rid=giphy.gif&ct=g")!) | |
.padding(10) |
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 Triangle: View { | |
let direction: Direction | |
let color: Color | |
init(_ direction: Direction = .down, _ color: Color = .black) { | |
self.direction = direction | |
self.color = color | |
} | |
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
// Author: SwiftUI-Lab (swiftui-lab.com) | |
// Description: A demonstration of a Layout with custom animations | |
// and bi-directional layout values. | |
// blog article: https://swiftui-lab.com/layout-protocol-part-2 | |
import SwiftUI | |
struct ContentView: View { | |
let colors: [Color] = [.yellow, .orange, .red, .purple, .blue, .green] | |
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
// Author: SwiftUI-Lab (swiftui-lab.com) | |
// Description: A demonstration of a layout that interpolates | |
// the result of two other layouts. | |
// blog article: https://swiftui-lab.com/layout-protocol-part-2 | |
import SwiftUI | |
// ------------------------------------------------------------------ | |
// Views | |
// ------------------------------------------------------------------ |
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
// Author: SwiftUI-Lab (swiftui-lab.com) | |
// Description: A demonstration of a wave Layout | |
// blog article: https://swiftui-lab.com/layout-protocol-part-2 | |
import SwiftUI | |
struct ContentView: View { | |
@State var amplitude: CGFloat = 80 | |
@State var phase: Double = 90.0 | |
@State var frequency: Double = 2.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
// Author: SwiftUI-Lab (swiftui-lab.com) | |
// Description: A demonstration of a composed Layout | |
// blog article: https://swiftui-lab.com/layout-protocol-part-2 | |
import SwiftUI | |
struct ContentView: View { | |
let colors: [Color] = [.yellow, .orange, .red, .pink, .purple, .blue, .cyan, .green] |
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
// | |
// Author: The SwiftUI-Lab | |
// The charts in this code are used in the article: https://swiftui-lab.com/swiftui-22-in-numbers | |
// | |
import SwiftUI | |
import Charts | |
@main | |
struct ChartGistApp: App { | |
var body: some Scene { |
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) |
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
// Safely Modifying The View State (SwiftUI) | |
// https://swiftui-lab.com | |
// https://swiftui-lab.com/state-changes | |
import SwiftUI | |
struct CustomView: View { | |
var body: some View { | |
NavigationView { |