Skip to content

Instantly share code, notes, and snippets.

View SeanRobinson159's full-sized avatar
🖥️

Sean Robinson SeanRobinson159

🖥️
View GitHub Profile
@alikaragoz
alikaragoz / RubberBandSwitch.swift
Created October 12, 2023 12:20
iOS Control Center Rubber Band Swift
import SwiftUI
struct RubberBandSwitch: View {
enum Const {
static let shapeSize: CGSize = .init(width: 90.0, height: 190.0)
static let cornerRadius: CGFloat = 26.0
}
@State var value = 0.5
@sebjvidal
sebjvidal / SceneDelegate.swift
Created June 27, 2023 18:14
Custom UINavigationBar Height
// MARK: - SceneDelegate
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
let navigationController = UINavigationController(navigationBarClass: NavigationBar.self, toolbarClass: nil)
(navigationController.navigationBar as! NavigationBar).preferredHeight = 88
navigationController.setViewControllers([ViewController()], animated: false)
import SwiftUI
struct SelectedButton: View {
@State var tabButtons = tabs[0]
@Namespace var animation
var body: some View {
VStack {
HStack {
ScrollView(.horizontal, showsIndicators: false) {
@krzyzanowskim
krzyzanowskim / PastelColor.swift
Last active February 10, 2024 10:27
Random pastel colors
struct ContentView: View {
@State var color: Color = .Pastel.random()
var body: some View {
Rectangle()
.foregroundColor(color)
.onTapGesture {
color = .Pastel.random()
}
}
@lattner
lattner / async_swift_proposal.md
Last active February 23, 2024 11:41 — forked from oleganza/async_swift_proposal.md
Concrete proposal for async semantics in Swift

Async/Await for Swift

Introduction

Modern Cocoa development involves a lot of asynchronous programming using closures and completion handlers, but these APIs are hard to use. This gets particularly problematic when many asynchronous operations are used, error handling is required, or control flow between asynchronous calls gets complicated. This proposal describes a language extension to make this a lot more natural and less error prone.

This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.