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
// | |
// File.swift | |
// | |
// | |
// Created by João Reichert on 06/09/22. | |
// | |
import UIKit | |
public extension UIView { |
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 | |
/// Provides a default value for missing `Decodable` data. | |
/// | |
/// `DefaultCodableStrategy` provides a generic strategy type that the `DefaultCodable` property wrapper can use to provide a reasonable default value for missing Decodable data. | |
public protocol DefaultCodableStrategy { | |
associatedtype RawValue: Codable | |
static var defaultValue: RawValue { get } | |
} |
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
/* | |
Copyright (C) 2016 Apple Inc. All Rights Reserved. | |
See LICENSE.txt for this sample’s licensing information | |
Abstract: | |
A struct for accessing generic password keychain items. | |
*/ | |
import Foundation |
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
// | |
// UITableView+.swift | |
// | |
// Created by Joao Reichert on 18/02/19. | |
// Copyright © 2019 Reichert. All rights reserved. | |
// | |
import UIKit | |
extension UITableView { |
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 UIKit | |
public struct Screen { | |
/// Retrieves the device bounds. | |
public static var bounds: CGRect { | |
return UIScreen.main.bounds | |
} | |
/// Retrieves the device width. | |
public static var width: CGFloat { |
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 | |
import RealmSwift | |
var realmConfiguration: Realm.Configuration? | |
public typealias VoidCompletion = () -> Void | |
extension Realm { | |
static var shared: Realm? { |
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
extension String { | |
func heightWithConstrainedWidth(width: CGFloat, font: UIFont) -> CGFloat { | |
let constraintRect = CGSize(width: width, height: .greatestFiniteMagnitude) | |
let boundingBox = self.boundingRect(with: constraintRect, | |
options: .usesLineFragmentOrigin, | |
attributes: [NSAttributedString.Key.font: font], | |
context: nil) | |
return boundingBox.height | |
} |
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 sortConvex(input: [CLLocationCoordinate2D]) -> [CLLocationCoordinate2D] { | |
// X = longitude | |
// Y = latitudeß | |
// 2D cross product of OA and OB vectors, i.e. z-component of their 3D cross product. | |
// Returns a positive value, if OAB makes a counter-clockwise turn, | |
// negative for clockwise turn, and zero if the points are collinear. | |
func cross(P: CLLocationCoordinate2D, A: CLLocationCoordinate2D, B: CLLocationCoordinate2D) -> Double { | |
let part1 = (A.longitude - P.longitude) * (B.latitude - P.latitude) |
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
// Site utilizado para execução durante a apresentação | |
// https://swift.sandbox.bluemix.net/ | |
import Foundation | |
// Extensão utilizada para arredondar as casas decimais | |
extension Double { | |
func roundTo(_ places:Int) -> Double { | |
let divisor = pow(10.0, Double(places)) |
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
public class AppManager: NSObject { | |
static let userDefaults = UserDefaults.standard | |
static let shared = AppManager() | |
static let dataKey = "AppManagerDataKey" | |
static let tutorialKey = "AppManagerTutorialKey" | |
public func reset(for key: String) { | |
if var data = userDefaults.object(forKey: dataKey) as? [String: Bool] { | |
data.removeValue(forKey: key) |