Created
July 15, 2017 03:34
-
-
Save wspl/40210b90512d0ef1ee4153d7faa98f1a to your computer and use it in GitHub Desktop.
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
v += tableView => { v in | |
v~.backgroundColor = .clear | |
v.top = v.prev.top - 5 | |
v.bottom = v.parent.bottom | |
v.edgesX = v.parent.edgesX | |
v += self.refresher => { v in | |
v~.tintColor = .white | |
v~.addTarget(self, action: #selector(self.refresh), for: .valueChanged) | |
} | |
v~.tableHeaderView = ( | |
v += UIViewWithRadius(frame: CGRect(x: 0, y: 0, width: 0, height: 100)) => { v in | |
v~.backgroundColor = .white | |
} | |
)~ | |
v~.tableFooterView = ( | |
v += self.loadMoreView => { v in | |
v += NVActivityIndicatorView( | |
frame: CGRect(x: 0, y: 0, width: 25, height: 25), | |
type: .ballPulse, | |
color: THEME_TEXT_LIGHT_COLOR | |
) => { v in | |
v.center = v.parent.center | |
v~.startAnimating() | |
} | |
} | |
)~ | |
v~.tableFooterView = UIView() | |
v.onDidScroll { _ in | |
v~.bounces = v~.contentOffset.y <= 0 | |
tableBg~.transform.ty = -v~.contentOffset.y > 0 ? -v~.contentOffset.y : 0 | |
if !self.isLoading, v~.contentOffset.y + v~.frame.height > v~.tableFooterView!.frame.origin.y { | |
self.loadMore() | |
} | |
} | |
v.cell(model: self.data, component: PostCell.self) | |
} | |
class UIViewWithRadius: UIView { | |
override func layoutSubviews() { | |
super.layoutSubviews() | |
roundCorners([.topLeft, .topRight], radius: 5) | |
} | |
} | |
class UITableViewWithRadius: UITableView { | |
override func layoutSubviews() { | |
super.layoutSubviews() | |
roundCorners([.topLeft, .topRight], radius: 5) | |
} | |
func setFirstTopRadius() { | |
if let firstCell = cellForRow(at: IndexPath(row: 0, section: 0)) { | |
if !firstCell.hasRoundCorners() { | |
firstCell.roundCorners([.topLeft, .topRight], radius: 5) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment