chore: optimize the expand & scroll animation
This commit is contained in:
parent
861a70993c
commit
a932749bda
|
@ -384,11 +384,12 @@ extension PickServerViewController: PickServerCellDelegate {
|
|||
expandServerDomainSet.insert(server.domain)
|
||||
}
|
||||
|
||||
tableView.performBatchUpdates(updates) { _ in
|
||||
// Scroll to fully show the expanded cell, do not scroll when collapse
|
||||
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)
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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