Skip to content

Instantly share code, notes, and snippets.

View gabrielribeiro's full-sized avatar

Gabriel Ribeiro gabrielribeiro

View GitHub Profile
@SwiftyAlex
SwiftyAlex / squishybuttonthing.swift
Created April 20, 2024 15:20
squishybuttonthing
// Credit to Raffi for the design! https://twitter.com/raffichill/status/1781492309500027206
struct SquishyButtonThing: View {
@State var expanded: Bool = false
var body: some View {
VStack {
Spacer()
VStack {
@kamilogorek
kamilogorek / _screenshot.md
Last active April 26, 2025 16:35
Clutter-free VS Code Setup
image
@zats
zats / readme.md
Created October 12, 2023 03:08
Private SF Symbols

List of all the images in /Library/Developer/CoreSimulator/Volumes/iOS_21A328/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.0.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/SFSymbols.framework/CoreGlyphsPrivate.bundle/Assets.car

NSBundle *const sfSymbolsBundle = [SFSCoreGlyphsBundle private];
_UIAssetManager *const assetManager = [_UIAssetManager assetManagerForBundle:sfSymbolsBundle];
UIImage *const image = [assetManager imageNamed:@"apple.breathe"];
@mdb1
mdb1 / ViewStateExampleView.swift
Created January 8, 2023 14:01
A simple view to demonstrate how to use the ViewStateWrapper
import SwiftUI
/// In this example:
/// * The view model holds and publishes the view state wrapper value.
/// * The view reacts to changes by holding an @StateObject reference to the view model.
/// * The initial loading is an empty screen with a ProgressView in the middle.
/// * Once we have some data, the subsequent loadings will not override the loaded data,
/// and instead, will just display a ProgressView in the toolbar.
struct ViewStateExampleView: View {
@StateObject private var viewModel: ViewModel = .init()
@chockenberry
chockenberry / AttributedString.swift
Created June 1, 2022 21:08
A playground that shows how to use Swift's AttributedString with Markdown
import UIKit
import Foundation
// NOTE: This playground shows how to use Swift's AttributedString with Markdown.
//
// This code was used to display Markdown content in the Tot iOS Widget <https://tot.rocks>
// MARK: - Helpful Links
// NOTE: The following links helped me figure this stuff out.
enum QueryPredicate {
case isEqualTo(_ field: String, _ value: Any)
case isNotEqualTo(_ field: String, _ value: Any)
case isIn(_ field: String, _ values: [Any])
case isNotIn(_ field: String, _ values: [Any])
case arrayContains(_ field: String, _ value: Any)
case arrayContainsAny(_ field: String, _ values: [Any])
import SwiftUI
import Combine
public struct ChangeObserver<V: Equatable>: ViewModifier {
public init(newValue: V, action: @escaping (V) -> Void) {
self.newValue = newValue
self.newAction = action
}
private typealias Action = (V) -> Void
@christianselig
christianselig / zombie-banana.swift
Created March 20, 2021 20:12
Zombie banana uprising
class Banana: NSObject, NSSecureCoding {
let bananaName: String
let userInfo: [String: Any]
static var supportsSecureCoding: Bool = true
init(bananaName: String, userInfo: [String: Any]) {
self.bananaName = bananaName
self.userInfo = userInfo
}
extension Result {
public func `catch`(_ handler: () throws -> Success) -> Result<Success, Error> {
flatMapError { _ in
.init { try handler() }
}
}
public func `catch`(_ handler: (Failure) throws -> Success) -> Result<Success, Error> {
flatMapError { error in
.init { try handler(error) }
import Foundation
import MapKit
final class MapKitService {
// Map the Apple Category to your own category
private let typesToDrink: [MKPointOfInterestCategory] = [.brewery, .cafe, .winery]
private let typesToEat: [MKPointOfInterestCategory] = [.foodMarket, .restaurant]
func retrieve(from: String, completionBlock: @escaping ([Place]) -> Void) {