Skip to content

Instantly share code, notes, and snippets.

View Czajnikowski's full-sized avatar
🚀

Maciek Czarnik Czajnikowski

🚀
View GitHub Profile
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) {
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")
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])
}
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 {
import UIKit
class KeyboardHandler {
private let bottomConstraint: NSLayoutConstraint
private let animate: () -> Void
init(
withBottomConstraint bottomConstraint: NSLayoutConstraint,
andAnimations animate: @escaping () -> Void
) {
func perform(wrappedAnimation: WrappedAnimation) {
let animation = wrappedAnimation.unwrapped()
animation.perform()
}
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
object.show(withWrappedAnimation: .fromBottom)
enum WrappedAnimation {
case fromBottom // Anonymous nil before
case specific(Animation)
}
object.show(withAnimation: nil)