-
Notifications
You must be signed in to change notification settings - Fork 0
/
ViewController.swift
48 lines (37 loc) · 1.18 KB
/
ViewController.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// ViewController.swift
// ToDo-App
//
// Created by Александр Ермаков on 13.05.2022.
//
import UIKit
class ViewController: UIViewController, RootViewGettable {
// MARK: -
// MARK: Associated Types
typealias RootView = ListView
// MARK: -
// MARK: Public variables
public var list: [String] = ["John", "Paul", "George", "Ringo"]
// MARK: -
// MARK: Public functions
func addTask() {
let alert = UIAlertController(title: "New task", message: "new to-do", preferredStyle: .alert)
let action = UIAlertAction(title: "Add", style: .default) { action in
if let text = alert.textFields?.first?.text {
self.list.append(text)
self.view().tableView?.reloadData()
}
}
alert.addAction(action)
alert.addTextField { toDoTextField in
toDoTextField.placeholder = "Enter a to-do"
}
self.present(alert, animated: true, completion: nil)
}
// MARK: -
// MARK: ViewController Life Cycle
override func viewDidLoad() {
super.viewDidLoad()
view().prepare(with: self)
}
}