-
-
Notifications
You must be signed in to change notification settings - Fork 297
Expand file tree
/
Copy pathServerRuleSection.swift
More file actions
31 lines (28 loc) · 1.07 KB
/
ServerRuleSection.swift
File metadata and controls
31 lines (28 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//
// ServerRuleSection.swift
// Mastodon
//
// Created by MainasuK on 2022-1-5.
//
import UIKit
import MastodonAsset
import MastodonLocalization
enum ServerRuleSection: Hashable {
case rules
}
extension ServerRuleSection {
static func tableViewDiffableDataSource(
tableView: UITableView
) -> UITableViewDiffableDataSource<ServerRuleSection, ServerRuleItem> {
return UITableViewDiffableDataSource(tableView: tableView) { tableView, indexPath, item in
switch item {
case .rule(let index, let rule):
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: ServerRulesTableViewCell.self), for: indexPath) as? ServerRulesTableViewCell else { fatalError("WTF?! Wrong cell.") }
cell.indexImageView.image = UIImage(systemName: "\(index + 1).circle") ?? UIImage(systemName: "questionmark.circle")
cell.indexImageView.tintColor = Asset.Colors.Brand.lightBlurple.color
cell.ruleLabel.text = rule.text
return cell
}
}
}
}