Skip to content

Instantly share code, notes, and snippets.

View esnssr's full-sized avatar

Eslam Nasser esnssr

View GitHub Profile
import SwiftUI
enum Experiment: String, CaseIterable, Identifiable {
case form
case concentricRect
case uniformConcentricRect
case containerRelative
case containerRelativeWithContainerShape
case containerCornerInsets
struct TabBar: View {
@State private var selectedTab: Tab = .overview
@Namespace private var ns
enum Tab {
case overview, data, graphs, settings
}
var body: some View {
@juliensagot
juliensagot / VariableBlurView.swift
Last active September 22, 2025 06:52
SwiftUI variable blur view
import Foundation
import SwiftUI
import UIKit
extension UIBlurEffect {
public static func variableBlurEffect(radius: Double, imageMask: UIImage) -> UIBlurEffect? {
let methodType = (@convention(c) (AnyClass, Selector, Double, UIImage) -> UIBlurEffect).self
let selectorName = ["imageMask:", "effectWithVariableBlurRadius:"].reversed().joined()
let selector = NSSelectorFromString(selectorName)
// A URLSession extension that fetches data from a URL and decodes to some Decodable type.
// Usage: let user = try await URLSession.shared.decode(UserData.self, from: someURL)
// Note: this requires Swift 5.5.
extension URLSession {
func decode<T: Decodable>(
_ type: T.Type = T.self,
from url: URL,
keyDecodingStrategy: JSONDecoder.KeyDecodingStrategy = .useDefaultKeys,
dataDecodingStrategy: JSONDecoder.DataDecodingStrategy = .deferredToData,
dateDecodingStrategy: JSONDecoder.DateDecodingStrategy = .deferredToDate