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 | |
// OverlayTest | |
// | |
// Created by Chris Eidhof on 26.09.22. | |
// | |
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
import SwiftUI | |
struct Light: View { | |
var body: some View { | |
Circle() | |
.overlay(rings) | |
.overlay( | |
Circle() | |
.fill(gradient) | |
.alignmentGuide(VerticalAlignment.center, computeValue: { $0.height/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
import SwiftUI | |
struct MyValue: _ViewTraitKey { | |
static var defaultValue: Int = 0 | |
} | |
extension View { | |
func myValue(_ value: Int) -> some View { | |
_trait(MyValue.self, value) | |
} |
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 | |
// Shared | |
// | |
// Created by Chris Eidhof on 05.05.22. | |
// | |
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
// | |
// ContentView.swift | |
// Shared | |
// | |
// Created by Chris Eidhof on 16.04.22. | |
// | |
import SwiftUI | |
struct Jump: AnimatableModifier { |
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 | |
let url = URL(string: "https://www.objc.io/images/books/thinking-in-swiftui/thinking-in-swiftui-hero-original_216a663.png")! | |
struct ContentView: View { | |
var image: some View { | |
AsyncImage(url: url, content: { image in | |
image | |
.resizable() | |
.aspectRatio( contentMode: .fit) |
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
/* | |
Make sure to compile this with the following flags: | |
-Xfrontend -warn-concurrency -Xfrontend -enable-actor-data-race-checks | |
*/ | |
extension AsyncIteratorProtocol { | |
func newAndNext() async throws -> (Self, Element)? { |
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 AsyncZippedSequence<L, R>: AsyncSequence where L: AsyncSequence, R: AsyncSequence { | |
typealias Element = (L.Element, R.Element) | |
var l: L | |
var r: R | |
func makeAsyncIterator() -> AsyncZippedIterator<L.Element, R.Element> { | |
AsyncZippedIterator(l, r) | |
} | |
} |