Skip to content

Instantly share code, notes, and snippets.


Rita popcornomnom

View GitHub Profile
View ReachabilityObserverDelegate.swift
import Foundation
import Reachability
//declare this property where it won't go out of scope relative to your listener
fileprivate var reachability: Reachability!
protocol ReachabilityActionDelegate {
func reachabilityChanged(_ isReachable: Bool)
View FontManager4.swift
extension Font {
public static var title: Font { .init(.h3, .bold) }
View FontManager3.swift
extension UIFont {
public static var title: UIFont { .init(.h3, .bold) }
View FontManagerSwiftUI.swift
@available(iOS 13.0, *)
extension Font {
init(_ size: UIFont.Size, _ weight: UIFont.CustomWeight) {
self.init(.defaultFamily, size, weight)
init(_ family: UIFont.Family = .defaultFamily,
_ size: UIFont.Size, _ weight: UIFont.CustomWeight) {
self.init(UIFont(family, size, weight))
View FontManagerBasic.swift
// FontManager.swift
// Created by
// Copyright © 2019 Marharyta Lytvynenko. All rights reserved.
import UIKit
//MARK: - Font Parts
View FontManager2.swift
//put Family and Weight together
private class func stringName(_ family: Family, _ weight: CustomWeight) -> String {
let fontWeight: String
switch (family, weight) {
case (.inter, .heavy):
fontWeight = CustomWeight.semibold.rawValue
case (.inter, .light):
fontWeight = "\(weight.rawValue)BETA"
fontWeight = weight.rawValue
View FontManager.swift
// FontManager.swift
// Created by
// Copyright © 2020 Marharyta Lytvynenko. All rights reserved.
import UIKit
///optional type in case if you don't want to support scaled font yet
View FontManager+AccessibillitySupport.swift
///optional type in case if you want turn off acessability support
private let acessabilitySettings: DynamicTypeSettings? = DynamicTypeSettings()
private class DynamicTypeSettings {
let maxPointSizeScaleFactor: CGFloat
init(maxPointSizeScaleFactor: CGFloat = 1.25) {
self.maxPointSizeScaleFactor = maxPointSizeScaleFactor
View AccessibillitySupport+Update.swift
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
///Update fonts after dynamic fonts settings was changed
if traitCollection.preferredContentSizeCategory != previousTraitCollection?.preferredContentSizeCategory {
private func setFonts() {
title.font = UIFont(.h3, .black)
subtitle.font = UIFont(.bodyM, .medium)
View FontManager+AutoScaleSettings.swift
// somewhere here is a declaration of the Font Style parts
// and func stringName(_, _) -> String
///optional type in case if you don't want to support scaled font yet
private let autoScaleSettings: AutoScaleSettings? = AutoScaleSettings()
private class AutoScaleSettings {
let mostPopularScreenWidth: CGFloat = 375
You can’t perform that action at this time.