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
@available(iOS 15.0, *) | |
struct TwinkleView:View { | |
private func position(in proxy: GeometryProxy, sparkle:Sparkle) -> CGPoint { | |
let radius = min(proxy.size.width, proxy.size.height) / 2.0 | |
let drawnRadius = (radius - 5) * sparkle.position.x | |
let angle = Double.pi * 2.0 * sparkle.position.y | |
let x = proxy.size.width * 0.5 + drawnRadius * cos(angle) | |
let y = proxy.size.height * 0.5 + drawnRadius * sin(angle) |
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 ReviewTabView: View { | |
var reviews: [Review] = [ | |
Review(title: "Great app", reviewer: "Maartje Derks", text: "This app really makes my life so much easier. Can't wait to use it."), | |
Review(title: "Great app", reviewer: "Maartje Derks", text: "This app really makes my life so much easier. Can't wait to use it."), | |
Review(title: "Great app", reviewer: "Maartje Derks", text: "This app really makes my life so much easier. Can't wait to use it."), | |
Review(title: "Great app", reviewer: "Maartje Derks", text: "This app really makes my life so much easier. Can't wait to use it."), | |
] | |
@State var selectedIndex = 0 | |
@State var timer = Timer.publish(every: 4, on: .main, in: .common).autoconnect() |
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 | |
// TryGeometryReader | |
// | |
// Created by satoutakeshi on 2019/12/07. | |
// Copyright © 2019 satoutakeshi. Licensed under MIT. | |
// | |
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
public class RootViewController<Content: View>: UIHostingController<Content> { | |
public init(view: Content, rootViewManager: RootViewManager) { | |
super.init(rootView: view) | |
rootViewManager.rootViewController = self | |
} | |
@objc required dynamic init?(coder aDecoder: NSCoder) { | |
fatalError("init(coder:) has not been implemented") | |
} |
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 | |
// AnimationTimingCurve | |
// | |
// Created by Chris Eidhof on 25.09.19. | |
// Copyright © 2019 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 SwiftUI | |
/// Example of how to get Dynamic Type with custom fonts in SwiftUI. | |
struct ContentView: View { | |
var body: some View { | |
VStack(spacing: 20) { | |
Text("A large title").customFont(.largeTitle) // "Optima-ExtraBlack", 28 | |
Text("A body").customFont(.body) // "Kailasa", 16 | |
Text("A caption").customFont(.caption2) // "IowanOldStyle-Italic", 11 | |
} |
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 Foundation | |
import CoreLocation | |
extension CLLocation { | |
// Alias for `horizontalAccuracy` (more readable) | |
var uncertainty: Double { | |
return horizontalAccuracy | |
} | |
} |
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 UIKit | |
class GradientWrapperView: UIView { | |
private let gradientLayer: CAGradientLayer = { | |
let layer = CAGradientLayer() | |
layer.borderColor = UIColor.black.cgColor | |
layer.borderWidth = CGFloat(0.5) | |
return layer | |
}() |
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 Foundation | |
import UIKit | |
struct ViewStyle<T> { | |
let style: (T) -> Void | |
} | |
let filled = ViewStyle<UIButton> { | |
$0.setTitleColor(.white, for: .normal) | |
$0.backgroundColor = .red |
NewerOlder