Skip to content

Instantly share code, notes, and snippets.

View popcornomnom's full-sized avatar
:octocat:

Rita Lytvynenko popcornomnom

:octocat:
View GitHub Profile
import Foundation
import Reachability
//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)
//
// FontManager.swift
//
// Created by http://www.popcornomnom.com
// Copyright © 2019 Marharyta Lytvynenko. All rights reserved.
//
import UIKit
import SwiftUI
class ReachabilityHandler: ReachabilityObserverDelegate {
//MARK: Lifecycle
required init() {
try? addReachabilityObserver()
}
deinit {
removeReachabilityObserver()
extension Font {
public static var title: Font { .init(.h3, .bold) }
}
extension UIFont {
public static var title: UIFont { .init(.h3, .bold) }
}
@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))
//
// FontManager.swift
//
// Created by http://www.popcornomnom.com
// Copyright © 2019 Marharyta Lytvynenko. All rights reserved.
//
import UIKit
//MARK: - Font Parts
//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"
default:
fontWeight = weight.rawValue
//
// FontManager.swift
//
// Created by http://www.popcornomnom.com
// Copyright © 2020 Marharyta Lytvynenko. All rights reserved.
//
import UIKit
///optional type in case if you don't want to support scaled font yet
///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