Skip to content

Instantly share code, notes, and snippets.

View carson-katri's full-sized avatar

Carson Katri carson-katri

View GitHub Profile
struct CardHeading: View {
@State private var touchZoom: Bool = false
var body: some View {
VStack(spacing: 0) {
Image("banner")
.resizable()
.aspectRatio(contentMode: ContentMode.fill)
.frame(minWidth: 0, maxWidth: .infinity, maxHeight: 400)
.clipped()
import SwiftUI
import Combine
import PlaygroundSupport
struct SpringSolver {
let ƛ: CGFloat
let w0: CGFloat
let wd: CGFloat
/// Initial velocity
let v0: CGFloat
@carson-katri
carson-katri / View+badge.swift
Created January 21, 2021 16:21
Adds an `overlay` to a `View` that aligns the middle of the overlay with the edge of the parent, like a badge.
extension View {
func badge<Badge: View>(_ badge: Badge, alignment: Alignment = .topTrailing) -> some View {
overlay(
badge
.alignmentGuide(.leading, computeValue: splitDimension(\.width))
.alignmentGuide(HorizontalAlignment.center, computeValue: splitDimension(\.width))
.alignmentGuide(.trailing, computeValue: splitDimension(\.width))
.alignmentGuide(.top, computeValue: splitDimension(\.height))
.alignmentGuide(VerticalAlignment.center, computeValue: splitDimension(\.height))
.alignmentGuide(.bottom, computeValue: splitDimension(\.height)),