完善任务流程、键盘适配与页面交互
This commit is contained in:
@ -65,7 +65,8 @@ final class AllFunctionsViewController: BaseViewController {
|
||||
|
||||
collectionView.backgroundColor = .clear
|
||||
collectionView.alwaysBounceVertical = true
|
||||
collectionView.allowsSelection = false
|
||||
collectionView.allowsSelection = true
|
||||
collectionView.delegate = self
|
||||
collectionView.contentInset = UIEdgeInsets(
|
||||
top: AppSpacing.xs,
|
||||
left: 0,
|
||||
@ -131,20 +132,12 @@ final class AllFunctionsViewController: BaseViewController {
|
||||
private func makeDataSource() -> UICollectionViewDiffableDataSource<AllFunctionSection, AllFunctionListItem> {
|
||||
let dataSource = UICollectionViewDiffableDataSource<AllFunctionSection, AllFunctionListItem>(
|
||||
collectionView: collectionView
|
||||
) { [weak self] collectionView, indexPath, item in
|
||||
) { collectionView, indexPath, item in
|
||||
let cell = collectionView.dequeueReusableCell(
|
||||
withReuseIdentifier: AllFunctionMenuCell.reuseIdentifier,
|
||||
for: indexPath
|
||||
) as! AllFunctionMenuCell
|
||||
cell.apply(menu: item.menu, actionStyle: item.actionStyle)
|
||||
cell.onActionTap = {
|
||||
switch item.section {
|
||||
case .common:
|
||||
self?.viewModel.removeFromCommon(item.menu)
|
||||
case .more:
|
||||
self?.viewModel.addToCommon(item.menu)
|
||||
}
|
||||
}
|
||||
return cell
|
||||
}
|
||||
|
||||
@ -214,6 +207,21 @@ final class AllFunctionsViewController: BaseViewController {
|
||||
}
|
||||
}
|
||||
|
||||
extension AllFunctionsViewController: UICollectionViewDelegate {
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||
guard let item = dataSource.itemIdentifier(for: indexPath) else { return }
|
||||
collectionView.deselectItem(at: indexPath, animated: true)
|
||||
|
||||
switch item.section {
|
||||
case .common:
|
||||
viewModel.removeFromCommon(item.menu)
|
||||
case .more:
|
||||
viewModel.addToCommon(item.menu)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 全部功能页分区标题。
|
||||
private final class AllFunctionSectionHeaderView: UICollectionReusableView {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user