Kurdtvs-Live-Kurdish-TV-Kur.../Mastodon/Scene/Onboarding/ServerRules/MastodonServerRulesViewMode...

27 lines
930 B
Swift
Raw Normal View History

2022-01-05 08:11:35 +01:00
//
// MastodonServerRulesViewModel+Diffable.swift
// Mastodon
//
// Created by MainasuK on 2022-1-5.
//
import UIKit
extension MastodonServerRulesViewModel {
func setupDiffableDataSource(
tableView: UITableView
) {
diffableDataSource = ServerRuleSection.tableViewDiffableDataSource(tableView: tableView)
var snapshot = NSDiffableDataSourceSnapshot<ServerRuleSection, ServerRuleItem>()
snapshot.appendSections([.header, .rules])
snapshot.appendItems([.header(domain: domain)], toSection: .header)
let ruleItems: [ServerRuleItem] = rules.enumerated().map { i, rule in
let ruleContext = ServerRuleItem.RuleContext(index: i, rule: rule)
return ServerRuleItem.rule(ruleContext)
}
snapshot.appendItems(ruleItems, toSection: .rules)
diffableDataSource?.applySnapshot(snapshot, animated: false, completion: nil)
}
}