Skip to content

Instantly share code, notes, and snippets.

View jeffbailey's full-sized avatar

Jeff Bailey jeffbailey

View GitHub Profile
@UnderscoreDavidSmith
UnderscoreDavidSmith / Sparkle.swift
Created December 20, 2022 16:00
Sparkle Effect in SwiftUI
@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)
import SwiftUI
struct DetailView: View {
@Binding var showDetail: Bool
var body: some View {
List {
NavigationLink("detail", isActive: $showDetail) {
Text("Detail")
}
@jordibruin
jordibruin / ReviewTabView.swift
Created October 14, 2020 23:23
Simple App Store Review showcase in SwiftUI
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()
@SatoTakeshiX
SatoTakeshiX / convert.swift
Last active June 6, 2024 12:25
Take capture a view by SwiftUI
//
// ContentView.swift
// TryGeometryReader
//
// Created by satoutakeshi on 2019/12/07.
// Copyright © 2019 satoutakeshi. Licensed under MIT.
//
import SwiftUI
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")
}
//
// ContentView.swift
// AnimationTimingCurve
//
// Created by Chris Eidhof on 25.09.19.
// Copyright © 2019 Chris Eidhof. All rights reserved.
//
import SwiftUI
@simonliotier
simonliotier / SwiftUI+CustomFonts+DynamicType.swift
Last active December 11, 2019 14:27
Example of how to get Dynamic Type with custom fonts in SwiftUI
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
}
@trevphil
trevphil / KalmanFilter.swift
Created June 3, 2019 13:24
Kalman Filter for CLLocation
import Foundation
import CoreLocation
extension CLLocation {
// Alias for `horizontalAccuracy` (more readable)
var uncertainty: Double {
return horizontalAccuracy
}
}
@yogeshmanghnani
yogeshmanghnani / GradientWrapperView.swift
Last active February 24, 2019 12:59
Gradients in iOS using Swift
import UIKit
class GradientWrapperView: UIView {
private let gradientLayer: CAGradientLayer = {
let layer = CAGradientLayer()
layer.borderColor = UIColor.black.cgColor
layer.borderWidth = CGFloat(0.5)
return layer
}()
import Foundation
import UIKit
struct ViewStyle<T> {
let style: (T) -> Void
}
let filled = ViewStyle<UIButton> {
$0.setTitleColor(.white, for: .normal)
$0.backgroundColor = .red