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
| extension ShoppingListDataSource: UITableViewDataSource { | |
| func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
| let cell = tableView.dequeueReusableCell(for: indexPath) | |
| if indexPath.row == 0 { | |
| cell.prepare(withListTitle: "Lista zakupów") | |
| } | |
| else { | |
| if advertsEnabled { | |
| if advertIndexes.contains(indexPath.row - 1) { |
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
| extension ShoppingListDataSource: UITableViewDataSource { | |
| func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
| let cell = tableView.dequeueReusableCell(for: indexPath) | |
| if indexPath.row == 0 { | |
| cell.prepare(withListTitle: "Lista zakupów") | |
| } | |
| else { | |
| if advertIndexes.contains(indexPath.row - 1) { | |
| cell.prepare(withAdvert: "Reklama") |
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
| extension ShoppingListDataSource: UITableViewDataSource { | |
| func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
| let cell = tableView.dequeueReusableCell(for: indexPath) | |
| if indexPath.row == 0 { | |
| cell.prepare(withListTitle: "Lista zakupów") | |
| } | |
| else { | |
| cell.prepare(withShoppingItem: shoppingItems[indexPath.row - 1]) | |
| } |
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
| extension ShoppingListDataSource: UITableViewDataSource { | |
| func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
| let cell = tableView.dequeueReusableCell(for: indexPath) | |
| cell.prepare(withShoppingItem: shoppingItems[indexPath.row]) | |
| return cell | |
| } | |
| func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
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 KeyboardHandler { | |
| private let bottomConstraint: NSLayoutConstraint | |
| private let animate: () -> Void | |
| init( | |
| withBottomConstraint bottomConstraint: NSLayoutConstraint, | |
| andAnimations animate: @escaping () -> Void | |
| ) { |
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
| func perform(wrappedAnimation: WrappedAnimation) { | |
| let animation = wrappedAnimation.unwrapped() | |
| animation.perform() | |
| } |
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
| enum WrappedAnimation { | |
| case fromBottom | |
| case specific(Animation) | |
| func unwrapped() -> Animation { | |
| switch self { | |
| case .fromBottom: | |
| return createFromBottomAnimation() // Here is a meaning of the nil | |
| case .specific(let animation): | |
| return animation |
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
| object.show(withWrappedAnimation: .fromBottom) |
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
| enum WrappedAnimation { | |
| case fromBottom // Anonymous nil before | |
| case specific(Animation) | |
| } |
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
| object.show(withAnimation: nil) |