Skip to content

Instantly share code, notes, and snippets.

View borisdipner's full-sized avatar
🚀
Up Up Up

B Ꮎ Ꮢ I S⠀D I P N Ξ Ꮢ borisdipner

🚀
Up Up Up
View GitHub Profile
import Foundation
extension Bundle {
func decode<T: Decodable>(_ type: T.Type,
from file: String,
dateDecodingStrategy: JSONDecoder.DateDecodingStrategy = .deferredToDate,
keyDecodingStrategy: JSONDecoder.KeyDecodingStrategy = .useDefaultKeys) -> T {
guard let url = self.url(forResource: file, withExtension: nil) else {
import SwiftUI
struct OnboardingCard: Codable, Identifiable, Equatable {
var id: UUID
var title: String
var subTitle: String
var image: String
}
struct AdaptivePagingScrollView: View {
/// { * * * States * * * }
/// { * * * Functions * * * }
var body: some View {
// 01
GeometryReader { viewGeometry in
HStack(alignment: .center, spacing: itemSpacing) {
struct AdaptivePagingScrollView: View {
/// { * * * States * * * }
// 01
private func countOffset(for pageIndex: Int) -> CGFloat {
let activePageOffset = CGFloat(pageIndex) * (itemWidth + itemPadding)
return leadingOffset - activePageOffset
}
struct AdaptivePagingScrollView: View {
private let items: [AnyView]
private let itemPadding: CGFloat
private let itemSpacing: CGFloat
private let itemWidth: CGFloat
private let itemsAmount: Int
private let contentWidth: CGFloat
private let leadingOffset: CGFloat
class TagsLayout: UICollectionViewFlowLayout {
required override init() {super.init(); common()}
required init?(coder aDecoder: NSCoder) {super.init(coder: aDecoder); common()}
private func common() {
estimatedItemSize = UICollectionViewFlowLayout.automaticSize
minimumLineSpacing = 10
minimumInteritemSpacing = 10
}
//
// CircleView.swift
// ProjectX
//
// Created by Boris Dipner on 01.01.2021.
// Copyright © 2021 Boris Dipner. All rights reserved.
//
import UIKit
//
// MasterViewController.swift
// ProjectXX
//
// Created by Boris Dipner on 11/08/20.
// Copyright © 2020 Boris Dipner. All rights reserved.
//
import UIKit
@borisdipner
borisdipner / UICollectionView + NSFetchedResultsController.swift
Created November 28, 2020 20:35
UICollectionView + NSFetchedResultsController Swift 5
// MARK: NSFetchedResultsController
extension ViewController: NSFetchedResultsControllerDelegate {
var blockOperations: [BlockOperation] = []
func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
switch type {
case .insert:
let insertBlock: () -> Void = { [weak self] in self?.collectionView?.insertItems(at: [newIndexPath!]) }
blockOperations.append(BlockOperation(block: insertBlock))
import UIKit
class WCGraintCircleLayer: CALayer {
override init () {
super.init()
}
convenience init(bounds:CGRect,position:CGPoint,fromColor:UIColor,toColor:UIColor,linewidth:CGFloat,toValue:CGFloat) {
self.init()