Skip to content

Instantly share code, notes, and snippets.

View VAndrJ's full-sized avatar

VAndrJ VAndrJ

  • Ukraine
View GitHub Profile
@VAndrJ
VAndrJ / ComposeView.swift
Created March 3, 2018 09:10 — forked from ahbou/ComposeView.swift
iPhone X InputAccessoryView Fix
//
// ComposeView.swift
import UIKit
class ComposeView: UIView {
// ........
// Other layout code and methods
// ........
@VAndrJ
VAndrJ / FixedSafeAreaLayoutConstraint.swift
Created July 18, 2018 12:32 — forked from filletofish/FixedSafeAreaLayoutConstraint.swift
Constraint that can be updated with safe area but only once
import UIKit
/// Work around problem described here: https://stackoverflow.com/questions/47223680/safe-area-changes-in-parent-vc-when-presenting-modally-vc-in-landscape
/// When presenting screen with another orientation safe area changes on first screen
/// that affects constraints and all layout that depends on safe area.
/// To avoid this bug one should use UCFixedSafeAreaLayoutConstraint that can be updated with safe
/// area inset using `updateAllFixedSafeAreaConstraints(newSafeAreaInsets:)` in UIViewController
///
///
///
@VAndrJ
VAndrJ / NetworkEndpoint.swift
Last active December 4, 2018 14:02
Piece of network module written for Medinternet project.
//
// NetworkEndpoint.swift
// Medinternet
//
// Created by VAndrJ on 6/10/18.
// Copyright © 2018 VAndrJ. All rights reserved.
//
import Foundation
struct TypedIdentifier<T>: Equatable, Codable, ExpressibleByIntegerLiteral, CustomStringConvertible, RawRepresentable {
let rawValue: Int
var description: String {
return "\(rawValue)"
}
init?(rawValue: Int) {
self.rawValue = rawValue
}
//
// ArcView.m
// UIBezierPathExampleForLI
//
// Created by Volodymyr Andriienko on 2/23/19.
// Copyright © 2019 VAndrJ. All rights reserved.
//
#import "ArcView.h"
@VAndrJ
VAndrJ / iOSLogMacros.m
Created August 8, 2019 07:33 — forked from heavenlyfodder/iOSLogMacros.m
Objective-C macros to aid in iOS app debug logging
// mmcneely: From http://stackoverflow.com/questions/969130/nslog-tips-and-tricks
// - DLog prints output to the console, but only if the DEBUG symbol is defined
// - ALog prints output to the console no matter what
// - ULog pops up window on the device (or simulator)
#ifdef DEBUG
# define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
# define DLog(...)
#endif
@VAndrJ
VAndrJ / UINavigationBar+LargeTitleView.swift
Created December 6, 2019 20:36
Extension to find UINavigationBar's large title view.
//
// UINavigationBar+LargeTitleView.swift
// DesignInspirations
//
// Created by VAndrJ on 06.12.2019.
// Copyright © 2019 VAndrJ. All rights reserved.
//
public extension UINavigationBar {
var largeTitleView: UIView? {
@VAndrJ
VAndrJ / UIViewControllerSwiftUIRepresentable.swift
Created January 11, 2021 13:19
Simple extension for Previews of UIView and UIViewController.
#if DEBUG
#if canImport(SwiftUI)
import UIKit
import SwiftUI
@available (iOS 13.0, *)
struct UIViewControllerSwiftUIRepresentable: UIViewControllerRepresentable {
let controller: UIViewController
func makeUIViewController(context: Context) -> UIViewController {
@VAndrJ
VAndrJ / Applyable.swift
Created January 12, 2021 17:43
Reflections about Kotlin's scope functions in Swift
protocol Applyable {}
func with<T, R>(_ lhs: T, _ rhs: (T) throws -> R) rethrows -> R {
return try rhs(lhs)
}
extension Applyable where Self: AnyObject {
@discardableResult
func apply(_ block: (Self) throws -> Void) rethrows -> Self {
import Foundation
func checkAsync() async -> [String] {
(0...10).map({ "\($0)" })
}
func checkAsyncAwait() async -> [String] {
await checkAsync()
}