diff --git a/TodoList/View Controllers/TodoTableViewController.swift b/TodoList/View Controllers/TodoTableViewController.swift
index 6d24d2a..a8c0579 100644
--- a/TodoList/View Controllers/TodoTableViewController.swift
+++ b/TodoList/View Controllers/TodoTableViewController.swift
@@ -60,35 +60,37 @@ final class TodoTableViewController: UITableViewController {
// MARK: - Helpers
private func setupUI() {
-
tableView.register(cellType: ItemTableViewCell.self)
tableView.keyboardDismissMode = .interactive
}
private func setState(isEmpty: Bool) {
- tableView.backgroundView = isEmpty ? emptyView : nil
+ UIView.animate(withDuration: 0.3) {
+ self.tableView.backgroundView = isEmpty ? self.emptyView : nil
+ }
+ }
+
+ private func completedDate(from item: Item) -> String? {
+
+ if let completionDate = item.completionDate {
+ return dateFormatter.string(from: completionDate)
+ }
+ return nil
}
// MARK: - TableView dataSource Delegate
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- UIView.animate(withDuration: 0.3) {
- self.setState(isEmpty: self.dataSource.isEmpty)
- }
-
+ setState(isEmpty: self.dataSource.isEmpty)
return dataSource.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let cell: ItemTableViewCell = tableView.dequeueReusableCell(for: indexPath)
+ let cell: ItemTableViewCell = tableView.dequeueReusableCell(for: indexPath)
let item = dataSource[indexPath.row]
- var date: String?
- if let completionDate = item.completionDate {
- date = dateFormatter.string(from: completionDate)
- }
cell.set(title: item.title,
- subtitle: date,
+ subtitle: completedDate(from: item),
isCompleted: item.isComplete)
return cell
diff --git a/TodoList/Views/EmptyView.swift b/TodoList/Views/EmptyView.swift
index 4854c66..bfc19e8 100644
--- a/TodoList/Views/EmptyView.swift
+++ b/TodoList/Views/EmptyView.swift
@@ -9,12 +9,14 @@ final class EmptyView: UIView {
label.text = NSLocalizedString("It's all a big black nothing", comment: "")
label.font = UIFont.preferredFont(forTextStyle: .largeTitle)
label.textColor = .black
+ label.numberOfLines = 0
+ label.adjustsFontForContentSizeCategory = true
+ label.textAlignment = .center
}
}
@IBOutlet var iconImage: UIImageView!
-
override func awakeFromNib() {
super.awakeFromNib()
diff --git a/TodoList/Views/EmptyView.xib b/TodoList/Views/EmptyView.xib
index 236b970..8d88cc9 100644
--- a/TodoList/Views/EmptyView.xib
+++ b/TodoList/Views/EmptyView.xib
@@ -37,7 +37,9 @@
+
+