Skip to content

Instantly share code, notes, and snippets.

View nalexn's full-sized avatar
😈
Designing software the ruthless way

Alexey Naumov nalexn

😈
Designing software the ruthless way
View GitHub Profile
import SwiftUI
import Combine
public struct ChangeObserver<V: Equatable>: ViewModifier {
public init(newValue: V, action: @escaping (V) -> Void) {
self.newValue = newValue
self.newAction = action
}
private typealias Action = (V) -> Void
@tcldr
tcldr / TimingFunction.swift
Last active March 21, 2023 07:24
For when you need the progress along an Apple Animation curve outside of CoreAnimation in a Swift 4.2 interface. Given a cubic Bezier timing curve defined by two control points, (or UIKit's `UICubicTimingParameters`), returns the progress along the curve at any given time. Includes a port of the WebKit implementation of UnitBezier which hopefull…
//
// TimingFunction.swift
//
// Created by tcldr on 04/11/2018.
// https://github.com/tcldr
// Copyright © 2018 tcldr.
//
// Permission is hereby granted, free of charge,
// to any person obtaining a copy of this software and
// associated documentation files (the "Software"), to
@Revolucent
Revolucent / UIView+Rx.swift
Created October 5, 2018 02:53
isFirstResponder observable with RxSwift
import RxCocoa
import RxSwift
import UIKit
extension Reactive where Base: UIView {
var isFirstResponder: Observable<Bool> {
return Observable
.merge(
methodInvoked(#selector(UIView.becomeFirstResponder)),
methodInvoked(#selector(UIView.resignFirstResponder))