This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Swift | |
let label = UILabel() | |
label.font = UIFont(.h3, .bold) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// FontManager.swift | |
// | |
// Created by http://www.popcornomnom.com | |
// Copyright © 2019 Marharyta Lytvynenko. All rights reserved. | |
// | |
import UIKit | |
//MARK: - Font Parts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//MARK: - Font Parts | |
public extension UIFont { | |
enum Family: String, CaseIterable { | |
case system = ".SFUIText" //".SFUI" | |
case inter = "Inter" | |
} | |
enum CustomWeight: String, CaseIterable { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
deinit { | |
stopwatch.stop() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func timeString(from timeInterval: TimeInterval) -> String { | |
let seconds = Int(timeInterval.truncatingRemainder(dividingBy: 60)) | |
let minutes = Int(timeInterval.truncatingRemainder(dividingBy: 60 * 60) / 60) | |
let hours = Int(timeInterval / 3600) | |
return String(format: "%.2d:%.2d:%.2d", hours, minutes, seconds | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
class Stopwatch { | |
// MARK: Private Properties | |
private let step: Double | |
private var timer: Timer? | |
//The time when counting was started |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private let step: Double = 1.0 //1 second | |
private var timer: Timer? | |
//MARK: Timer lifecycle | |
private func initTimer() { | |
let action: (Timer)->Void = { [weak self] timer in | |
guard let strongSelf = self else { | |
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Localizable { | |
enum Global: String, LocalizableDelegate { | |
case cancel, close | |
} | |
enum WelcomePage: String, LocalizableDelegate { | |
case title = "welcomeTitle" | |
case ctaButtonTitle = "start" | |
case next |