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: Frameworks | |
import UIKit | |
// MARK: ViewController | |
class ShapeViewController: UIViewController { | |
// MARK: Outlets | |
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: Frameworks | |
import UIKit | |
// MARK: UIBezierPath Methods | |
extension UIBezierPath { | |
convenience init(homeIn rect: CGRect) { | |
self.init() | |
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: Frameworks | |
import UIKit | |
// MARK: Helper Methods | |
func radians(from degrees: CGFloat) -> CGFloat { | |
return ((degrees * .pi) / 180) | |
} |
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: LoginViewController | |
class LoginViewController: UIViewController { | |
func login(with username: String, | |
password: String) { | |
let authenticationSession = AuthenticationSession() | |
authenticationSession.performLogin(with: username, | |
password: password) | |
} |
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: LoginViewController | |
class LoginViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
NotificationCenter.default.addObserver(self, | |
selector: #selector(handleLogin(notification:)), | |
name: Notification.Name("UserIdentifier"), |
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: LoginViewController | |
class LoginViewController: UIViewController, AuthenticationSessionDelegate { | |
func login(with username: String, | |
password: String) { | |
let authenticationSession = AuthenticationSession() | |
authenticationSession.delegate = self | |
authenticationSession.performLogin(with: username, | |
password: password) |
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: LoginViewController | |
class LoginViewController: UIViewController { | |
func login(with username: String, | |
password: String) { | |
let authenticationSession = AuthenticationSession() | |
authenticationSession.performLogin(with: username, | |
password: password, | |
completion: { userIdentifier in |
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 setTorch(on: Bool) { | |
guard let device = AVCaptureDevice.default(for: AVMediaType.video), | |
device.hasTorch else { | |
return | |
} | |
do { | |
try device.lockForConfiguration() | |
if on { |
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: - Frameworks | |
import SwiftUI | |
// MARK: - Animal | |
struct Animal: Hashable, Identifiable { | |
// MARK: - Variables | |
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: - Animal Constants | |
extension Animal { | |
static let all: [Animal] = [.lion, .elephant, .giraffe, .zebra] | |
static let lion = Animal(id: 1, name: "Lion", | |
description: "Biggest cat in Africa, the king of the jungle.", | |
imageName: "lion") | |
static let elephant = Animal(id: 2, name: "Elephant", | |
description: "Huge plant eating animal with long nose.", |