This file contains 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
class SplashViewController: UIViewController { | |
init() { | |
super.init(nibName: nil, bundle: nil) | |
} | |
required init?(coder _: NSCoder) { fatalError() } | |
} |
This file contains 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
class SplashViewController: UIViewController { | |
... | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
view.backgroundColor = .white | |
setupSubviews() | |
} | |
private lazy var label: UILabel = { | |
let label = UILabel() |
This file contains 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
self.navigationController?.pushViewController(viewController, animated: true) |
This file contains 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
self.navigationController?.present(viewController, animated: true) |
This file contains 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
class EventsViewController: UIViewController { | |
... | |
private lazy var tableView: UITableView = { | |
let tableView = UITableView() | |
tableView.estimatedRowHeight = 50 | |
tableView.rowHeight = UITableViewAutomaticDimension | |
tableView.backgroundColor = .white | |
tableView.separatorInset = UIEdgeInsets(top: 0, left: 24, bottom: 0, right: 0) | |
tableView.separatorColor = .lightGray | |
talbeView.dataSource = self |
This file contains 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
class EventTableViewCell: UITableViewCell, Reusable { | |
.... | |
override init(style: UITableViewCellStyle, reuseIdentifier: String?) { | |
super.init(style: style, reuseIdentifier: reuseIdentifier) | |
setupSubviews() | |
} | |
required init?(coder aDecoder: NSCoder) { fatalError() } | |
.... | |
} |
This file contains 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
class EventTableViewCell: UITableViewCell, Reusable { | |
.... | |
override func layoutSubviews() { | |
super.layoutSubviews() | |
contentView.layoutIfNeeded() | |
iconImageView.layer.cornerRadius = iconImageView.frame.height / 2 | |
} | |
private lazy var iconImageView: UIImageView = { | |
let imageView = UIImageView() |
This file contains 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
protocol Reusable: class { | |
static var reuseIdentifier: String { get } | |
} | |
extension Reusable where Self: UIView { | |
static var reuseIdentifier: String { | |
return String(describing: self) | |
} | |
} |
This file contains 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 UITableView { | |
func register<T: UITableViewCell>(_: T.Type) where T: Reusable { | |
register(T.self, forCellReuseIdentifier: T.reuseIdentifier) | |
} | |
func dequeueReusableCell<T: UITableViewCell>(for indexPath: IndexPath) -> T where T: Reusable { | |
guard let cell = dequeueReusableCell(withIdentifier: T.reuseIdentifier, for: indexPath) as? T else { | |
fatalError("Could not dequeue cell with identifier: \(T.reuseIdentifier)") | |
} | |
return cell |
This file contains 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
render() { | |
return ( | |
<View style={styles.container}> | |
<FlatList | |
style={styles.flatList} | |
data={_rows} | |
renderItem={this._renderItem} | |
keyExtractor={_extractKey} | |
/> | |
</View> |
OlderNewer