This file contains hidden or 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 | |
// TODO: - Move to the separated file Resource.swift | |
struct Resource { | |
let url: URL | |
let method: String = "GET" | |
} | |
// TODO: - Move to the separated file GenericResult.swift | |
enum Result<T> { |
This file contains hidden or 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
........ | |
} else { | |
// Check animations in label layer | |
guard label.layer.animationKeys()?.isEmpty ?? true else { | |
// Clear existed animations | |
label.layer.removeAllAnimations() | |
// Backup center position | |
label.center = CGPoint(x: view.center.x, y: label.center.y) | |
return | |
} |
This file contains hidden or 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
@IBAction func buttonDidTap(_ sender: Any) { | |
// Check text in field. Animation is starting only if text is empty | |
if field.text?.isEmpty ?? true { | |
UIView.animate(withDuration: 0.3, | |
delay: 0.0, | |
// Look options list here https://developer.apple.com/documentation/uikit/uiviewanimationoptions | |
options: [.autoreverse], | |
animations: { | |
// Create CGAffineTransform with 5 degree (CG works with radians) and convert in to radians | |
self.field.transform = CGAffineTransform(rotationAngle: CGFloat(5).degreesToRadians) |
This file contains hidden or 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: - Actions | |
@IBAction func buttonDidTap(_ sender: Any) { | |
// Check text in field. Animation is starting only if text is empty | |
if field.text?.isEmpty ?? true { | |
UIView.animate(withDuration: 0.3, | |
delay: 0.0, | |
// Look options list here https://developer.apple.com/documentation/uikit/uiviewanimationoptions | |
options: [.autoreverse], | |
animations: { | |
// Create CGAffineTransform with 5 degree (CG works with radians) and convert in to radians |
This file contains hidden or 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 | |
final class ViewController: UIViewController { | |
@IBOutlet weak var field: UITextField! | |
@IBOutlet weak var label: UILabel! | |
@IBOutlet weak var button: UIButton! | |
override func viewDidLoad() { | |
super.viewDidLoad() |
This file contains hidden or 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 | |
final class ViewController: UIViewController { | |
@IBOutlet weak var collectionView: UICollectionView! | |
// Create constant data source | |
private let dataSource = DataSource() | |
override func viewDidLoad() { | |
super.viewDidLoad() |
This file contains hidden or 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
class ViewController: UIViewController { | |
@IBOutlet weak var table: UITableView! | |
// Create constant data source | |
private let dataSource = TableDataSource() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Attach to table view | |
dataSource.attach(to: table) |
This file contains hidden or 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 | |
class ViewController: UIViewController { | |
@IBOutlet weak var contentView: UIView! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
contentView.backgroundColor = .yellow |
This file contains hidden or 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 | |
class ViewController: UIViewController { | |
@IBOutlet weak var contentView: UIView! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Write that code | |
contentView.backgroundColor = .yellow |
This file contains hidden or 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
infix operator +++: AdditionPrecedence | |
extension Engine { | |
static func +++ (left: Engine, right: Engine) -> Engine { | |
let tank = max(left.tank, right.tank) | |
let consumption = min(left.consumption, right.consumption) | |
return Engine(tank: tank, | |
consumption: consumption, | |
distance: tank / consumption * 100, |