mastodon-ios/Mastodon/Scene/Search/SearchViewController+recome...

50 lines
1.4 KiB
Swift
Raw Normal View History

2021-03-31 13:29:54 +02:00
//
// SearchViewController+recommendView.swift
2021-03-31 13:29:54 +02:00
// Mastodon
//
// Created by sxiaojian on 2021/3/31.
//
import Foundation
import UIKit
extension SearchViewController {
func setuprecommendView() {
recommendView.register(SearchRecommendTagsCollectionViewCell.self, forCellWithReuseIdentifier: String(describing: SearchRecommendTagsCollectionViewCell.self))
recommendView.dataSource = self
recommendView.delegate = self
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
recommendView.collectionViewLayout.invalidateLayout()
2021-03-31 13:29:54 +02:00
}
}
extension SearchViewController: UICollectionViewDelegate {
}
extension SearchViewController: UICollectionViewDataSource {
func numberOfSections(in collectionView: UICollectionView) -> Int {
return (self.viewModel.recommendAccounts.isEmpty ? 0 : 1) + (self.viewModel.recommendHashTags.isEmpty ? 0 : 1)
}
2021-03-31 13:29:54 +02:00
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
switch section {
case 0:
return viewModel.recommendHashTags.count
case 1:
return viewModel.recommendAccounts.count
default:
return 0
}
2021-03-31 13:29:54 +02:00
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
return UICollectionViewCell()
}
}