chore: optimize the expand & scroll animation
This commit is contained in:
parent
861a70993c
commit
a932749bda
|
@ -384,13 +384,14 @@ extension PickServerViewController: PickServerCellDelegate {
|
|||
expandServerDomainSet.insert(server.domain)
|
||||
}
|
||||
|
||||
tableView.performBatchUpdates(updates) { _ in
|
||||
// Scroll to fully show the expanded cell, do not scroll when collapse
|
||||
tableView.beginUpdates()
|
||||
updates()
|
||||
tableView.endUpdates()
|
||||
|
||||
if newMode == .expand, let modeChangeIndex = self.viewModel.searchedServers.value.firstIndex(where: { $0 == server }), self.tableView.indexPathsForVisibleRows?.last?.row == modeChangeIndex {
|
||||
self.tableView.scrollToRow(at: IndexPath(row: modeChangeIndex, section: 3), at: .bottom, animated: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension PickServerViewController: PickServerSearchCellDelegate {
|
||||
|
|
|
@ -249,12 +249,12 @@ extension PickServerCell {
|
|||
// Set expandBox constraints
|
||||
expandBox.leadingAnchor.constraint(equalTo: bgView.leadingAnchor, constant: 16),
|
||||
bgView.trailingAnchor.constraint(equalTo: expandBox.trailingAnchor, constant: 16),
|
||||
expandBox.topAnchor.constraint(equalTo: descriptionLabel.bottomAnchor, constant: 8),
|
||||
expandBox.bottomAnchor.constraint(equalTo: infoStackView.bottomAnchor),
|
||||
expandBox.topAnchor.constraint(equalTo: descriptionLabel.bottomAnchor, constant: 8).priority(.defaultHigh),
|
||||
expandBox.bottomAnchor.constraint(equalTo: infoStackView.bottomAnchor).priority(.defaultHigh),
|
||||
|
||||
thumbImageView.leadingAnchor.constraint(equalTo: expandBox.leadingAnchor),
|
||||
expandBox.trailingAnchor.constraint(equalTo: thumbImageView.trailingAnchor),
|
||||
thumbImageView.topAnchor.constraint(equalTo: expandBox.topAnchor),
|
||||
thumbImageView.topAnchor.constraint(equalTo: expandBox.topAnchor).priority(.defaultHigh),
|
||||
thumbImageView.heightAnchor.constraint(equalTo: thumbImageView.widthAnchor, multiplier: 151.0 / 303.0).priority(.defaultHigh),
|
||||
|
||||
infoStackView.leadingAnchor.constraint(equalTo: expandBox.leadingAnchor),
|
||||
|
|
Loading…
Reference in New Issue