Skip to content

Instantly share code, notes, and snippets.

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

advienncurtiz

🏠
Working from home
View GitHub Profile
@hasanalisiseci
hasanalisiseci / HalfSheetWithUIKitForSwiftUI.swift
Created December 23, 2023 11:02
Half Sheet with UIKit for SwiftUI
//
// HalfSheetWithUIKitForSwiftUI.swift
// TestAppForNewThinks
//
// Created by Hasan Ali Şişeci on 23.12.2023.
//
import SwiftUI
extension View {
@globulus
globulus / SwipeActions.swift
Last active August 21, 2023 00:02
Add custom row swipe actions to a SwiftUI List
// Full recipe at https://swiftuirecipes.com/blog/swiftui-list-custom-row-swipe-actions-all-versions
import SwiftUI
// Button in swipe action, renders text or image and can have background color
struct SwipeActionButton: View, Identifiable {
static let width: CGFloat = 70
let id = UUID()
let text: Text?
// Author: SwiftUI-Lab (www.swiftui-lab.com)
// Description: This code is part of the "Advanced SwiftUI Animations - Part 5"
// Article: https://swiftui-lab.com/swiftui-animations-part5/
import SwiftUI
struct ContentView: View {
var body: some View {
DigitalRain()
}
// Author: SwiftUI-Lab (www.swiftui-lab.com)
// Description: This code is part of the "Advanced SwiftUI Animations - Part 5"
// Article: https://swiftui-lab.com/swiftui-animations-part5/
import SwiftUI
struct ContentView: View {
var body: some View {
ClockView()
.background(.gray)
@globulus
globulus / HTMLText.swift
Created May 27, 2021 07:08
SwiftUI Text with HTML via NSAttributedString
// full recipe at https://swiftuirecipes.com/blog/swiftui-text-with-html-via-nsattributedstring
extension Text {
init(html htmlString: String,
raw: Bool = false,
size: CGFloat? = nil,
fontFamily: String = "-apple-system") {
let fullHTML: String
if raw {
fullHTML = htmlString
} else {
import SwiftUI
let buttonWidth: CGFloat = 60
enum CellButtons: Identifiable {
case edit
case delete
case save
case info
@jamesrochabrun
jamesrochabrun / GenericList.swift
Created July 23, 2020 00:34
GenericList using Swift UI.
// 1
struct GenericList<Element, RowContent: View>: View where Element: Identifiable {
// 2
private let items: [Element]
private let rowContent: (Element) -> RowContent
// 3
public init(_ items: [Element], @ViewBuilder rowContent: @escaping (Element) -> RowContent) {
self.items = items
@swiftui-lab
swiftui-lab / squared-triangle.swift
Created July 10, 2020 04:47
A shape of a triangle inside a rectangle
struct Triangle: View {
let direction: Direction
let color: Color
init(_ direction: Direction = .down, _ color: Color = .black) {
self.direction = direction
self.color = color
}
var body: some View {
// Safely Modifying The View State (SwiftUI)
// https://swiftui-lab.com
// https://swiftui-lab.com/state-changes
import SwiftUI
struct CustomView: View {
var body: some View {
NavigationView {
@cbess
cbess / DispatchQueueDelay.swift
Last active December 6, 2022 09:39
Swift DispatchQueue throttle and debounce class (thread-safe)
//
// DispatchQueueDelay.swift
//
// Created by C. Bess on 9/17/19.
// MIT - Soli Deo gloria - perfectGod.com
//
// refs:
// - https://gist.github.com/fjcaetano/ff3e994c4edb4991ab8280f34994beb4
// - https://www.craftappco.com/blog/2018/5/30/simple-throttling-in-swift