Skip to content

Instantly share code, notes, and snippets.


Dariusz Rybicki darrarski

View GitHub Profile
darrarski / CustomIntensityVisualEffectView.swift
Last active May 12, 2022
UIVisualEffectView subclass that allows to customise effect intensity
View CustomIntensityVisualEffectView.swift
import UIKit
final class CustomIntensityVisualEffectView: UIVisualEffectView {
/// Create visual effect view with given effect and its intensity
/// - Parameters:
/// - effect: visual effect, eg UIBlurEffect(style: .dark)
/// - intensity: custom intensity from 0.0 (no effect) to 1.0 (full effect) using linear scale
init(effect: UIVisualEffect, intensity: CGFloat) {
theEffect = effect
darrarski / TimeZones.js
Last active Apr 16, 2022 — forked from fcrespo82/TimeZones.js
Scriptable time zones widget
View TimeZones.js
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: cyan; icon-glyph: clock;
// list of time zones:
let configs = [
{name: "Warsaw", timzeZone: "Europe/Berlin", bgColor: new Color("BF0D3E",1)},
{name: "Recife", timeZone: "America/Recife", bgColor: new Color("009639",1)},
{name: "Los Angeles", timeZone: "America/Los_Angeles", bgColor: new Color("3878d1",1)}
darrarski / FormattedTextField.swift
Last active Apr 6, 2022
SwiftUI FormattedTextField - TextField with custom display/edit formatters
View FormattedTextField.swift
import SwiftUI
public struct FormattedTextField<Formatter: TextFieldFormatter>: View {
public init(_ title: String,
value: Binding<Formatter.Value>,
formatter: Formatter) {
self.title = title
self.value = value
self.formatter = formatter
darrarski / SwiftUI_InterfaceOrientationObservingViewModifier.swift
Created Feb 18, 2022
SwiftUI view modifier that performs action whenever UIInterfaceOrientation reported by UIViewController changes
View SwiftUI_InterfaceOrientationObservingViewModifier.swift
import SwiftUI
struct InterfaceOrientationObservingViewModifier: ViewModifier {
let onChange: (UIInterfaceOrientation) -> Void
func body(content: Content) -> some View {
content.background(InterfaceOrientationObservingView(onChange: onChange))
darrarski / SwiftUI_DeviceOrientationObservingViewModifier.swift
Created Feb 18, 2022
SwiftUI view modifier that performs action whenever accelerometer-based UIDeviceOrientation changes
View SwiftUI_DeviceOrientationObservingViewModifier.swift
import CoreMotion
import SwiftUI
struct DeviceOrientationObservingViewModifier: ViewModifier {
let onChange: (UIDeviceOrientation) -> Void
func body(content: Content) -> some View {
content.background(DeviceOrientationObservingView(onChange: onChange))
darrarski / SwiftUI_LazyVGrid_ContextMenu_Delete.swift
Created Feb 11, 2022
SwiftUI workaround for broken animation when deleting collection item with context menu.
View SwiftUI_LazyVGrid_ContextMenu_Delete.swift
import SwiftUI
struct Item: Equatable, Identifiable {
var id = UUID()
var color: Color
struct ContentView: View {
@State var items = Array(repeating: [, .green, .blue], count: 10)
.flatMap { $0 }
darrarski / FetchedResultsPublisher.swift
Last active Feb 7, 2022
View FetchedResultsPublisher.swift
import Combine
import CoreData
public final class FetchedResultsPublisher
: Publisher
ResultType: NSFetchRequestResult
darrarski / App.swift
Created Apr 7, 2021
Lazy navigation in SwiftUI - animations issue
View App.swift
// Based on "Lazy navigation in SwiftUI" blogpost by Majid Jabrayilov
// Blogpost url:
// This gist shows an issue with using conditional NavigationLinks.
// When using StackNavigationViewStyle push animations are not present.
import SwiftUI
struct LazyNavApp: App {
var body: some Scene {
darrarski / SwiftUI_BottomBarViewModifier.swift
Created Jan 16, 2022
SwiftUI extension that adds bottom bar (like toolbar tor tabbar) to the provided view.
View SwiftUI_BottomBarViewModifier.swift
import SwiftUI
extension View {
func bottomBar<Bar: View>(
ignoresKeyboard: Bool = true,
frameChangeAnimation: Animation? = .default,
@ViewBuilder bar: @escaping () -> Bar
) -> some View {
ignoresKeyboard: ignoresKeyboard,
darrarski / SwiftUI_GeometryReaderViewModifier.swift
Last active Jan 16, 2022
SwiftUI extension that attaches geometry reader to a view and notifies whenever provided geometry changes.
View SwiftUI_GeometryReaderViewModifier.swift
import SwiftUI
extension View {
func geometryReader<Geometry: Codable>(
geometry: @escaping (GeometryProxy) -> Geometry,
onChange: @escaping (Geometry) -> Void
) -> some View {
geometry: geometry,
onChange: onChange