Skip to content

Instantly share code, notes, and snippets.

View RobertKoval's full-sized avatar
🏠
Working from home

Robert Koval RobertKoval

🏠
Working from home
  • Kyiv, Ukraine
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

@vinhnx
vinhnx / uicollectionview+centerPaging.md
Created June 9, 2017 09:24
Centered Paging with Preview Cells on UICollectionView

Centered Paging with Preview Cells on UICollectionView

The proposed offset is where the collection view would stop without our intervention. We peek into this area by finding its centre as proposedContentOffsetCenterX and examine our currently visible cells to see which one’s centre is closer to the centre of that area.

import UIKit
 
class CenterCellCollectionViewFlowLayout: UICollectionViewFlowLayout {
    
    var mostRecentOffset : CGPoint = CGPoint()
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active May 27, 2024 03:13
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example