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
extension View { | |
func vertical(_ key: VerticalAlignment, relative: CGFloat) -> some View { | |
self.alignmentGuide(key, computeValue: { $0.height * relative }) | |
} | |
func overlay<V: View>(alignment: Alignment, relative: UnitPoint = .center, _ other: V) -> some View { | |
self | |
.alignmentGuide(alignment.horizontal, computeValue: { $0.width * relative.x }) | |
.alignmentGuide(alignment.vertical, computeValue: { $0.height * relative.y }) | |
.overlay(other, alignment: alignment) |
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 | |
// Clocks | |
// | |
// Created by Chris Eidhof on 21.02.20. | |
// Copyright © 2020 objc.io. All rights reserved. | |
// | |
import SwiftUI |
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 | |
// QuickCheckTests | |
// | |
// Created by Chris Eidhof on 20.02.20. | |
// Copyright © 2020 objc.io. All rights reserved. | |
// | |
import SwiftUI |
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 | |
// RunningPaceCalculator | |
// | |
// Created by Chris Eidhof on 19.02.20. | |
// Copyright © 2020 Chris Eidhof. All rights reserved. | |
// | |
import SwiftUI |
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 MyView: View { | |
@State var text: String = "hello" | |
var body: some View { | |
TextField("title", text: $text) | |
} | |
} | |
struct ContentView: View { | |
@State var toggled: Bool = false | |
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
import SwiftUI | |
extension View { | |
func assert(size: CGSize) -> some View { | |
self.overlay(GeometryReader { proxy in | |
Group { | |
if size == proxy.size { | |
Color.clear | |
} else { | |
Color.red.opacity(0.5) |
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 | |
// Store | |
// | |
// Created by Chris Eidhof on 05.02.20. | |
// Copyright © 2020 Chris Eidhof. All rights reserved. | |
// | |
import SwiftUI |
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 SwiftSyntax | |
import SwiftSemantics | |
import Foundation | |
let source = try! String(contentsOf: URL(fileURLWithPath: "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.2.sdk/System/Library/Frameworks/SwiftUI.framework/Modules/SwiftUI.swiftmodule/arm64e.swiftinterface")) | |
var collector = DeclarationCollector() | |
let tree = try SyntaxParser.parse(source: source) | |
tree.walk(&collector) |
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 Ticks: ObservableObject { | |
@Published var seconds: Int = 58 | |
func start() { | |
Timer.scheduledTimer(withTimeInterval: 1, repeats: true, block: { [unowned self] _ in | |
withAnimation(.easeInOut) { self.seconds += 1 } | |
if self.seconds == 60 { | |
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + .milliseconds(350)) { |
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 | |
// OrView | |
// | |
// Created by Chris Eidhof on 07.11.19. | |
// Copyright © 2019 Chris Eidhof. All rights reserved. | |
// | |
import SwiftUI |