mastodon-app-ufficiale-ipho.../Mastodon/Scene/SuggestionAccount/RecommendAccountSection.swift

50 lines
1.5 KiB
Swift
Raw Normal View History

//
// RecommendAccountSection.swift
// Mastodon
//
// Created by sxiaojian on 2021/4/1.
//
import CoreData
import CoreDataStack
import Foundation
import MastodonSDK
import UIKit
import MetaTextKit
import MastodonMeta
import Combine
2022-10-08 07:43:06 +02:00
import MastodonCore
enum RecommendAccountSection: Equatable, Hashable {
case main
}
extension RecommendAccountSection {
struct Configuration {
let authContext: AuthContext
weak var suggestionAccountTableViewCellDelegate: SuggestionAccountTableViewCellDelegate?
}
static func tableViewDiffableDataSource(
tableView: UITableView,
context: AppContext,
configuration: Configuration
) -> UITableViewDiffableDataSource<RecommendAccountSection, RecommendAccountItem> {
UITableViewDiffableDataSource(tableView: tableView) { tableView, indexPath, item -> UITableViewCell? in
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: SuggestionAccountTableViewCell.self)) as! SuggestionAccountTableViewCell
switch item {
case .account(let record):
context.managedObjectContext.performAndWait {
guard let user = record.object(in: context.managedObjectContext) else { return }
2022-02-16 10:25:55 +01:00
cell.configure(user: user)
}
2022-02-16 10:25:55 +01:00
cell.delegate = configuration.suggestionAccountTableViewCellDelegate
}
return cell
}
}
}