fix: 优化点位展示、选择滚动和收款信息
This commit is contained in:
@@ -153,7 +153,7 @@ final class DroneDockDeliveryViewController: BaseViewController {
|
||||
if case .point(let id) = item {
|
||||
let cell = list.dequeueReusableCell(withReuseIdentifier: "point", for: path) as! DroneMaterialFilterCell
|
||||
let title = self.viewModel.spots.first { $0.id == id }.map { Self.text($0.name, fallback: "点位 \(id)") } ?? "点位 \(id)"
|
||||
cell.apply(title: title, id: String(id), selected: self.viewModel.selectedSpotID == id, locked: self.locked)
|
||||
cell.apply(title: title, id: String(id), selected: self.viewModel.selectedSpotID == id, locked: self.locked, wrapsTitle: true)
|
||||
cell.accessibilityIdentifier = "drone.delivery.point.\(id)"
|
||||
return cell
|
||||
}
|
||||
@@ -207,11 +207,30 @@ final class DroneDockDeliveryViewController: BaseViewController {
|
||||
private var locked: Bool { isRefreshing || isPicking || isStartingSubmission || viewModel.isLoading || viewModel.isSubmitting }
|
||||
|
||||
private func makeLayout() -> UICollectionViewLayout {
|
||||
UICollectionViewCompositionalLayout { [weak self] index, _ in
|
||||
UICollectionViewCompositionalLayout { [weak self] index, environment in
|
||||
guard let self, let source = self.dataSource else { return nil }
|
||||
let sections = source.snapshot().sectionIdentifiers
|
||||
guard sections.indices.contains(index) else { return nil }
|
||||
let points = sections[index] == .points
|
||||
if points, !self.viewModel.spots.isEmpty {
|
||||
let maximumWidth = min(200, max(1, environment.container.effectiveContentSize.width - 32))
|
||||
let sizes = self.viewModel.spots.map {
|
||||
DroneMaterialFilterCell.wrappedSize(title: Self.text($0.name, fallback: "点位 \($0.id)"), maximumWidth: maximumWidth)
|
||||
}
|
||||
let width = sizes.reduce(0) { $0 + $1.width } + CGFloat(sizes.count - 1) * 10
|
||||
let height = sizes.map(\.height).max() ?? 40
|
||||
let group = NSCollectionLayoutGroup.custom(layoutSize: .init(widthDimension: .absolute(width), heightDimension: .absolute(height))) { _ in
|
||||
var x: CGFloat = 0
|
||||
return sizes.map { size in
|
||||
defer { x += size.width + 10 }
|
||||
return NSCollectionLayoutGroupCustomItem(frame: CGRect(x: x, y: 0, width: size.width, height: size.height))
|
||||
}
|
||||
}
|
||||
let section = NSCollectionLayoutSection(group: group)
|
||||
section.contentInsets = .init(top: 0, leading: 16, bottom: 12, trailing: 16)
|
||||
section.orthogonalScrollingBehavior = .continuous
|
||||
return section
|
||||
}
|
||||
let size = NSCollectionLayoutSize(widthDimension: points ? .estimated(112) : .fractionalWidth(1), heightDimension: points ? .absolute(40) : .estimated(100))
|
||||
let item = NSCollectionLayoutItem(layoutSize: .init(widthDimension: .fractionalWidth(1), heightDimension: points ? .fractionalHeight(1) : .estimated(100)))
|
||||
let group = NSCollectionLayoutGroup.vertical(layoutSize: size, subitems: [item])
|
||||
@@ -242,6 +261,7 @@ final class DroneDockDeliveryViewController: BaseViewController {
|
||||
snapshot.appendItems([.state], toSection: .state)
|
||||
let previous = Set(dataSource.snapshot().itemIdentifiers)
|
||||
snapshot.reconfigureItems(snapshot.itemIdentifiers.filter { previous.contains($0) })
|
||||
collectionView.collectionViewLayout.invalidateLayout()
|
||||
dataSource.apply(snapshot, animatingDifferences: animated)
|
||||
updateFooter()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user