Skip to content

Instantly share code, notes, and snippets.

View klaas's full-sized avatar
🤠
Howdy!

Klaas klaas

🤠
Howdy!
View GitHub Profile
@mbrandonw
mbrandonw / FB10144005.md
Last active March 22, 2024 17:05
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 9, 2024 14:22
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 April 16, 2024 15:54
(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
@AliSoftware
AliSoftware / Bindings.swift
Last active April 2, 2024 23:47
Re-implementation of @binding and @State (from SwiftUI) myself to better understand it
/*:
This is a concept re-implementation of the @Binding and @State property wrappers from SwiftUI
The only purpose of this code is to implement those wrappers myself
just to understand how they work internally and why they are needed,
⚠️ This is not supposed to be a reference implementation nor cover all
subtleties of the real Binding and State types.
The only purpose of this playground is to show how re-implementing
them myself has helped me understand the whole thing better