mastodon-ios/Mastodon/Diffiable/Section/RecommendAccountSection.swift

34 lines
1.2 KiB
Swift
Raw Normal View History

2021-04-01 14:54:57 +02:00
//
// RecommendAccountSection.swift
// Mastodon
//
// Created by sxiaojian on 2021/4/1.
//
import Foundation
import MastodonSDK
import UIKit
import CoreData
import CoreDataStack
2021-04-01 14:54:57 +02:00
enum RecommendAccountSection: Equatable, Hashable {
case main
}
extension RecommendAccountSection {
static func collectionViewDiffableDataSource(
for collectionView: UICollectionView,
2021-04-09 07:59:33 +02:00
context: AppContext!
) -> UICollectionViewDiffableDataSource<RecommendAccountSection, NSManagedObjectID> {
UICollectionViewDiffableDataSource(collectionView: collectionView) { collectionView, indexPath, objectID -> UICollectionViewCell? in
2021-04-01 14:54:57 +02:00
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: String(describing: SearchRecommendAccountsCollectionViewCell.self), for: indexPath) as! SearchRecommendAccountsCollectionViewCell
2021-04-09 07:59:33 +02:00
let user = context.managedObjectContext.object(with: objectID) as! MastodonUser
cell.config(with: user)
if let currentUser = context.authenticationService.activeMastodonAuthentication.value?.user {
cell.configFollowButton(with: user, currentMastodonUser: currentUser)
}
2021-04-01 14:54:57 +02:00
return cell
}
}
}