fix: statusView layout issue

This commit is contained in:
sunxiaojian 2021-04-15 12:35:40 +08:00
parent 845080a69d
commit ecf622b866
7 changed files with 34 additions and 28 deletions

View File

@ -123,10 +123,12 @@ extension HashtagTimelineViewModel.LoadOldestState {
assertionFailure()
return
}
DispatchQueue.main.async {
var snapshot = diffableDataSource.snapshot()
snapshot.deleteItems([.bottomLoader])
diffableDataSource.apply(snapshot)
}
}
}
}

View File

@ -103,9 +103,11 @@ extension HomeTimelineViewModel.LoadOldestState {
assertionFailure()
return
}
DispatchQueue.main.async {
var snapshot = diffableDataSource.snapshot()
snapshot.deleteItems([.bottomLoader])
diffableDataSource.apply(snapshot)
}
}
}
}

View File

@ -133,9 +133,11 @@ extension NotificationViewModel.LoadOldestState {
assertionFailure()
return
}
DispatchQueue.main.async {
var snapshot = diffableDataSource.snapshot()
snapshot.deleteItems([.bottomLoader])
diffableDataSource.apply(snapshot)
}
}
}
}

View File

@ -46,7 +46,6 @@ extension NotificationViewModel: NSFetchedResultsControllerDelegate {
guard let navigationBar = contentOffsetAdjustableTimelineViewControllerDelegate?.navigationBar() else { return }
guard let diffableDataSource = self.diffableDataSource else { return }
let oldSnapshot = diffableDataSource.snapshot()
let predicate = fetchedResultsController.fetchRequest.predicate
let parentManagedObjectContext = fetchedResultsController.managedObjectContext
@ -66,16 +65,18 @@ extension NotificationViewModel: NSFetchedResultsControllerDelegate {
}
}()
DispatchQueue.main.async {
let oldSnapshot = diffableDataSource.snapshot()
var newSnapshot = NSDiffableDataSourceSnapshot<NotificationSection, NotificationItem>()
newSnapshot.appendSections([.main])
newSnapshot.appendItems(notifications.map { NotificationItem.notification(objectID: $0.objectID) }, toSection: .main)
if !notifications.isEmpty, self.noMoreNotification.value == false {
newSnapshot.appendItems([.bottomLoader], toSection: .main)
}
DispatchQueue.main.async {
guard let difference = self.calculateReloadSnapshotDifference(navigationBar: navigationBar, tableView: tableView, oldSnapshot: oldSnapshot, newSnapshot: newSnapshot) else {
diffableDataSource.apply(newSnapshot)
diffableDataSource.apply(newSnapshot, animatingDifferences: false) {
tableView.reloadData()
}
self.isFetchingLatestNotification.value = false
return
}

View File

@ -58,7 +58,7 @@ final class NotificationStatusTableViewCell: UITableViewCell {
return label
}()
let statusContainer: UIView = {
let statusBorder: UIView = {
let view = UIView()
view.backgroundColor = .clear
view.layer.cornerRadius = 6
@ -147,8 +147,8 @@ extension NotificationStatusTableViewCell {
statusView.avatarView.removeFromSuperview()
statusView.usernameLabel.removeFromSuperview()
container.addSubview(statusContainer)
statusContainer.pin(top: 40, left: 63, bottom: 14, right: 14)
container.addSubview(statusBorder)
statusBorder.pin(top: 40, left: 63, bottom: 14, right: 14)
container.addSubview(statusView)
statusView.pin(top: NotificationStatusTableViewCell.statusPadding.top, left: NotificationStatusTableViewCell.statusPadding.left, bottom: NotificationStatusTableViewCell.statusPadding.bottom, right: NotificationStatusTableViewCell.statusPadding.right)
@ -156,7 +156,7 @@ extension NotificationStatusTableViewCell {
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
statusContainer.layer.borderColor = Asset.Colors.Border.notification.color.cgColor
statusBorder.layer.borderColor = Asset.Colors.Border.notification.color.cgColor
actionImageBackground.layer.borderColor = Asset.Colors.Background.pure.color.cgColor
}
}

View File

@ -136,9 +136,11 @@ extension SearchViewModel.LoadOldestState {
assertionFailure()
return
}
DispatchQueue.main.async {
var snapshot = diffableDataSource.snapshot()
snapshot.deleteItems([.bottomLoader])
diffableDataSource.apply(snapshot)
}
}
}
}

View File

@ -43,8 +43,5 @@ final class CommonBottomLoader: UITableViewCell {
backgroundColor = Asset.Colors.Background.systemGroupedBackground.color
contentView.addSubview(activityIndicatorView)
activityIndicatorView.constrainToCenter()
NSLayoutConstraint.activate([
contentView.heightAnchor.constraint(equalToConstant: 44)
])
}
}