summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--ios/MullvadVPN/View controllers/Settings/SettingsCellFactory.swift13
-rw-r--r--ios/MullvadVPN/View controllers/Settings/SettingsDataSource.swift24
2 files changed, 21 insertions, 16 deletions
diff --git a/ios/MullvadVPN/View controllers/Settings/SettingsCellFactory.swift b/ios/MullvadVPN/View controllers/Settings/SettingsCellFactory.swift
index 2fd62e6c41..e837f65cd4 100644
--- a/ios/MullvadVPN/View controllers/Settings/SettingsCellFactory.swift
+++ b/ios/MullvadVPN/View controllers/Settings/SettingsCellFactory.swift
@@ -30,12 +30,13 @@ final class SettingsCellFactory: @preconcurrency CellFactoryProtocol, Sendable {
func makeCell(for item: SettingsDataSource.Item, indexPath: IndexPath) -> UITableViewCell {
let cell: UITableViewCell
- // Instantiate cell based on the specific item type
- if item == .changelog {
- cell = SettingsCell(style: .subtitle, reuseIdentifier: item.reuseIdentifier.rawValue)
- } else {
- cell = tableView.dequeueReusableCell(withIdentifier: item.reuseIdentifier.rawValue, for: indexPath)
- }
+ cell = tableView
+ .dequeueReusableCell(
+ withIdentifier: item.reuseIdentifier.rawValue
+ ) ?? SettingsCell(
+ style: item.reuseIdentifier.cellStyle,
+ reuseIdentifier: item.reuseIdentifier.rawValue
+ )
// Configure the cell with the common logic
configureCell(cell, item: item, indexPath: indexPath)
diff --git a/ios/MullvadVPN/View controllers/Settings/SettingsDataSource.swift b/ios/MullvadVPN/View controllers/Settings/SettingsDataSource.swift
index 8b992ad077..138fabf450 100644
--- a/ios/MullvadVPN/View controllers/Settings/SettingsDataSource.swift
+++ b/ios/MullvadVPN/View controllers/Settings/SettingsDataSource.swift
@@ -11,12 +11,20 @@ import UIKit
final class SettingsDataSource: UITableViewDiffableDataSource<SettingsDataSource.Section, SettingsDataSource.Item>,
UITableViewDelegate {
- enum CellReuseIdentifiers: String, CaseIterable {
+ enum CellReuseIdentifier: String, CaseIterable {
case basic
+ case changelog
var reusableViewClass: AnyClass {
SettingsCell.self
}
+
+ var cellStyle: UITableViewCell.CellStyle {
+ switch self {
+ case .basic: .default
+ case .changelog: .subtitle
+ }
+ }
}
private enum HeaderFooterReuseIdentifier: String, CaseIterable, HeaderFooterIdentifierProtocol {
@@ -68,8 +76,11 @@ final class SettingsDataSource: UITableViewDiffableDataSource<SettingsDataSource
}
}
- var reuseIdentifier: CellReuseIdentifiers {
- .basic
+ var reuseIdentifier: CellReuseIdentifier {
+ switch self {
+ case .changelog: .changelog
+ default: .basic
+ }
}
}
@@ -132,13 +143,6 @@ final class SettingsDataSource: UITableViewDiffableDataSource<SettingsDataSource
// MARK: - Private
private func registerClasses() {
- CellReuseIdentifiers.allCases.forEach { cellIdentifier in
- tableView?.register(
- cellIdentifier.reusableViewClass,
- forCellReuseIdentifier: cellIdentifier.rawValue
- )
- }
-
HeaderFooterReuseIdentifier.allCases.forEach { reuseIdentifier in
tableView?.register(
reuseIdentifier.headerFooterClass,