Skip to content

Instantly share code, notes, and snippets.

struct OverflowLayout: Layout {
var spacing = CGFloat(10)
func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize {
let containerWidth = proposal.replacingUnspecifiedDimensions().width
let sizes = subviews.map { $0.sizeThatFits(.unspecified) }
return layout(sizes: sizes, containerWidth: containerWidth).size
}
func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) {
@niw
niw / LICENSE
Last active May 14, 2023 15:35
macOS Big Sur Icon Template for Affinity Photo
macOS Big Sur Icon Template for Affinity Photo (c) by Yoshimasa Niwa
macOS Big Sur Icon Template for Affinity Photo is licensed under a
Creative Commons Attribution 4.0 International License.
You should have received a copy of the license along with this
work. If not, see <http://creativecommons.org/licenses/by/4.0/>.
@jfuellert
jfuellert / ScrollableView.swift
Last active March 29, 2024 08:40
A scrollable SwiftUI view, UIScrollView wrapper. ScrollableView lets you read and write content offsets for scrollview in SwiftUI, with and without animations.
import SwiftUI
struct ScrollableView<Content: View>: UIViewControllerRepresentable, Equatable {
// MARK: - Coordinator
final class Coordinator: NSObject, UIScrollViewDelegate {
// MARK: - Properties
private let scrollView: UIScrollView
var offset: Binding<CGPoint>
@hollance
hollance / Barfdown.markdown
Last active March 25, 2023 18:16
A markdown-ish parser written in Swift 2.0

Barfdown: a Markdown-ish Parser Written in Swift

Goals for this project:

  • Parse a simplified version of Markdown that is good enough for writing my blog posts.
  • Be reasonably efficient. This means the parser shouldn't copy substrings around if not necessary. This is done by storing all the elements as indexes into the original text.
  • Be small and therefore be easy to understand.
  • No regular expressions. They are the lazy person's solution to parsing. ;-)

This is just a toy project for me to experiment with writing parsers in Swift. Because why not?