Skip to content

Instantly share code, notes, and snippets.

View klaas's full-sized avatar
🤠
Howdy!

Klaas klaas

🤠
Howdy!
View GitHub Profile
@groue
groue / ObservableState.swift
Last active May 5, 2025 12:41
WithBindable
// Copyright (C) 2025 Gwendal Roué
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
@mbrandonw
mbrandonw / FB10144005.md
Last active June 11, 2024 07:32
iOS 16 Navigation API feedbacks

How to execute logic when NavigationLink is tapped?

FB10144005

Currently it doesn't seem possible to execute additional logic when a navigation link is tapped with the new NavigationLink(value:) initializer. When the link is tapped it updates path state all the way back at the root NavigationStack to drive navigation, but there are many times where we need to perform logic after the tap and before the drill down.

For example, after tapping a link we may want to pre-emptively load some data to show on the drill down screen. Or we may want to perform some form validation. Or we may want to track some analytics. This does not seem possible with the current link API.

A workaround is to use Buttons instead of NavigationLinks, but then you lose all of the styling and affordances given to links, such as chevrons when used in List.

If the API for NavigationLink cannot be changed to accomodate for this, perhaps a new ButtonStyle could be introduced that allows regular buttons to take on the sty

@brettohland
brettohland / 1.0 FormatStyle in Excruciating Detail.md
Last active April 16, 2025 17:37
FormatStyle in Excruciating Detail
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
-------------------------------------------------------------- ------------------ --------------
------------------------------------------------------------- --- --------- --- ----------
------------------------- --- ---------------------------- --- --------- -- ---------
------------- --------- ---- --------------------------- --- -------- ---------
------------ --------- --- --------------------------- --- ----------- ---- ---
-------- -- --------- --- ---------------------------- ---------- ---
--------- ---------- ----------------------------- ---------- -----
// Author: The SwiftUI-Lab
// This code is part of the tutorial: https://swiftui-lab.com/swiftui-animations-part4/
import SwiftUI
// Sample usage
struct ContentView: View {
var body: some View {
VStack {
GifImage(url: URL(string: "https://media.giphy.com/media/YAlhwn67KT76E/giphy.gif?cid=790b7611b26260b2ad23535a70e343e67443ff80ef623844&rid=giphy.gif&ct=g")!)
.padding(10)
@dippnerd
dippnerd / SwiftUI Multi-Select Picker
Created February 8, 2021 18:55
One way to create a SwiftUI form list of items that lets you select more than one (unlike the stock picker form)
struct MultiSelectPickerView: View {
//the list of all items to read from
@State var sourceItems: [String]
//a binding to the values we want to track
@Binding var selectedItems: [String]
var body: some View {
Form {
List {
@mhoehle
mhoehle / survstat.R
Last active October 7, 2020 17:56
Make an age-stratified plot of the weekly COVID-19 incidence in Germany
#############################################################
# Illustrative script showing how to use SurvStat data
# to make an age-stratified COVID-19 incidence plot for Germany.
#
# Author: Michael Höhle <https://www.math.su.se/~hoehle>
# Date: 2020-10-07
# Code License: MIT (https://en.wikipedia.org/wiki/MIT_License)
#############################################################
# Load packages
@IsaacXen
IsaacXen / README.md
Last active May 10, 2025 14:33
(Almost) Every WWDC videos download links for aria2c.

Disable:

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist

Enable:

sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist

//
//
// NTSolar.swift
//
// Created by Neil Tiffin on 5/8/19.
// Copyright © 2019 Performance Champions, Inc.
// Copyright © 2019 Neil Tiffin.
//
// Released to the public domain by Neil Tiffin, May 2019
// Released to the public domain by Performance Champions, Inc., May 2019