Skip to content

Instantly share code, notes, and snippets.

@PhanithNY
PhanithNY / ShadowCutoutView.swift
Created April 2, 2025 06:30 — forked from AlexChekel1337/ShadowCutoutView.swift
A view that combines shadow, corner radius, and translucent background into one view
class ShadowCutoutView: UIView {
var contentView: UIView? {
didSet {
oldValue?.removeFromSuperview()
guard let contentView else {
return
}
contentView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
@PhanithNY
PhanithNY / PreviewProviderModifier.swift
Created December 1, 2021 05:45 — forked from davidsteppenbeck/PreviewProviderModifier.swift
A SwiftUI view modifier for simple preview providers.
#if DEBUG
import SwiftUI
struct PreviewProviderModifier: ViewModifier {
/// Whether or not a basic light mode preview is included in the group.
var includeLightMode: Bool
/// Whether or not a basic dark mode preview is included in the group.
var includeDarkMode: Bool
extension Result {
public func `catch`(_ handler: () throws -> Success) -> Result<Success, Error> {
flatMapError { _ in
.init { try handler() }
}
}
public func `catch`(_ handler: (Failure) throws -> Success) -> Result<Success, Error> {
flatMapError { error in
.init { try handler(error) }
@PhanithNY
PhanithNY / ColorableNavigationController.swift
Created February 14, 2019 05:57 — forked from Sorix/ColorableNavigationController.swift
Colourable UINavigationController that supports different colors for navigation bars among different view controllers
//
// ColorableNavigationController.swift
//
// Created by Vasily Ulianov on 26.10.16.
//
import UIKit
/// Navigation bar colors for `ColorableNavigationController`, called on `push` & `pop` actions
public protocol NavigationBarColorable: class {
var navigationTintColor: UIColor? { get }