Skip to content

Instantly share code, notes, and snippets.

View vialyx's full-sized avatar
🎯
Focusing

Maxim Vialyx vialyx

🎯
Focusing
View GitHub Profile
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var contentView: UIView!
override func viewDidLoad() {
super.viewDidLoad()
contentView.backgroundColor = .yellow
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)
import UIKit
final class ViewController: UIViewController {
@IBOutlet weak var collectionView: UICollectionView!
// Create constant data source
private let dataSource = DataSource()
override func viewDidLoad() {
super.viewDidLoad()
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()
// 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
@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)
........
} 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
}
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> {
import UIKit
final class ViewController: UIViewController {
let apiClient = APIClient()
override func viewDidLoad() {
super.viewDidLoad()
let resource = Resource(url: URL(string: "https://desolate-beyond-86929.herokuapp.com/arrival")!)
// <JsonCoddableUrlSession.ViewController: 0x7f925bd1bd10> retrive data: Optional("[{\"Airline\":\"AEROFLOT\",\"ScheduleTime\":\"00:25\",\"ActualTime\":\"00:11\",\"Flight\":\"SU1834\",\"DepartureAirport\":\"МОСКВА(ШЕРЕМЕТЬЕВО) \",\"Sector\":\"5\",\"Status\":\"\\u003cspan style=\\\"color:green\\\"\\u003eПРИБЫЛ\\u003c/span\\u003e\"},{\"Airline\":\"AUSTRIAN AIRLINES\",\"ScheduleTime\":\"00:40\",\"ActualTime\":\"00:15\",\"Flight\":\"OS689\",\"DepartureAirport\":\"ВЕНА \",\"Sector\":\"4\",\"Status\":\"\\u003cspan style=\\\"color:green\\\"\\u003eПРИБЫЛ\\u003c/span\\u003e\"},{\"Airline\":\"AEROFLOT\",\"ScheduleTime\":\"02:20\",\"ActualTime\":\"02:14\",\"Flight\":\"SU1838\",\"DepartureAirport\":\"МОСКВА(ШЕРЕМЕТЬЕВО) \"