Add settings-entry for server-details (IOS-14, IOS-20)
This commit is contained in:
parent
dff4c44889
commit
afd90d62e8
|
@ -715,6 +715,7 @@
|
|||
"notifications": "Notifications",
|
||||
"support_mastodon": "Support Mastodon",
|
||||
"about_mastodon": "About Mastodon",
|
||||
"server_details": "Server Details",
|
||||
"logout": "Logout %@"
|
||||
}
|
||||
|
||||
|
|
|
@ -715,6 +715,7 @@
|
|||
"notifications": "Notifications",
|
||||
"support_mastodon": "Support Mastodon",
|
||||
"about_mastodon": "About Mastodon",
|
||||
"server_details": "Server Details",
|
||||
"logout": "Logout %@"
|
||||
}
|
||||
|
||||
|
|
|
@ -715,6 +715,7 @@
|
|||
"notifications": "Notifications",
|
||||
"support_mastodon": "Support Mastodon",
|
||||
"about_mastodon": "About Mastodon",
|
||||
"server_details": "Server Details",
|
||||
"logout": "Logout %@"
|
||||
}
|
||||
|
||||
|
|
|
@ -129,6 +129,7 @@
|
|||
D807C6C029DE197900A4E17C /* EducationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D807C6BF29DE197900A4E17C /* EducationViewController.swift */; };
|
||||
D808B94C296ECFDC0031EB1E /* StatusEditHistoryViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D808B94B296ECFDC0031EB1E /* StatusEditHistoryViewModel.swift */; };
|
||||
D808B94E296EFBBA0031EB1E /* StatusEditHistoryTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D808B94D296EFBBA0031EB1E /* StatusEditHistoryTableViewCell.swift */; };
|
||||
D80911082AC4BFDE00EB4D15 /* ServerDetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D80911072AC4BFDE00EB4D15 /* ServerDetailsViewController.swift */; };
|
||||
D8099078294BC8A30050219F /* PrivacyTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8099077294BC8A30050219F /* PrivacyTableViewController.swift */; };
|
||||
D809907A294BC9390050219F /* PrivacyTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8099079294BC9390050219F /* PrivacyTableViewCell.swift */; };
|
||||
D809907C294D25510050219F /* PrivacyViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D809907B294D25510050219F /* PrivacyViewModel.swift */; };
|
||||
|
@ -775,6 +776,7 @@
|
|||
D807C6BF29DE197900A4E17C /* EducationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EducationViewController.swift; sourceTree = "<group>"; };
|
||||
D808B94B296ECFDC0031EB1E /* StatusEditHistoryViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusEditHistoryViewModel.swift; sourceTree = "<group>"; };
|
||||
D808B94D296EFBBA0031EB1E /* StatusEditHistoryTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusEditHistoryTableViewCell.swift; sourceTree = "<group>"; };
|
||||
D80911072AC4BFDE00EB4D15 /* ServerDetailsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerDetailsViewController.swift; sourceTree = "<group>"; };
|
||||
D8099077294BC8A30050219F /* PrivacyTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivacyTableViewController.swift; sourceTree = "<group>"; };
|
||||
D8099079294BC9390050219F /* PrivacyTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivacyTableViewCell.swift; sourceTree = "<group>"; };
|
||||
D809907B294D25510050219F /* PrivacyViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivacyViewModel.swift; sourceTree = "<group>"; };
|
||||
|
@ -1756,6 +1758,7 @@
|
|||
D8F916FF2A4AD898008A5370 /* Settings Overview */,
|
||||
D8F917042A4B0657008A5370 /* General Settings */,
|
||||
D81D12432A4E181C005009D4 /* Notification Settings */,
|
||||
D80911062AC4BFD100EB4D15 /* Server Details */,
|
||||
D8F917092A4B2AFF008A5370 /* About Mastodon */,
|
||||
D8318A7F2A4466D300C0FB73 /* SettingsCoordinator.swift */,
|
||||
);
|
||||
|
@ -1783,6 +1786,14 @@
|
|||
path = Bookmark;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D80911062AC4BFD100EB4D15 /* Server Details */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D80911072AC4BFDE00EB4D15 /* ServerDetailsViewController.swift */,
|
||||
);
|
||||
path = "Server Details";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D8099076294BC2BA0050219F /* Privacy */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
@ -3615,6 +3626,7 @@
|
|||
DB023D26279FFB0A005AC798 /* ShareActivityProvider.swift in Sources */,
|
||||
5D0393962612D266007FE196 /* WebViewModel.swift in Sources */,
|
||||
5B24BBDA262DB14800A9381B /* ReportViewModel.swift in Sources */,
|
||||
D80911082AC4BFDE00EB4D15 /* ServerDetailsViewController.swift in Sources */,
|
||||
2D5A3D3825CF8D9F002347D6 /* ScrollViewContainer.swift in Sources */,
|
||||
DB6180EF26391CA50018D199 /* MediaPreviewImageViewController.swift in Sources */,
|
||||
DB1E347825F519300079D7DF /* PickServerItem.swift in Sources */,
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright © 2023 Mastodon gGmbH. All rights reserved.
|
||||
|
||||
import UIKit
|
||||
|
||||
protocol ServerDetailsViewControllerDelegate: AnyObject {
|
||||
|
||||
}
|
||||
|
||||
class ServerDetailsViewController: UIViewController {
|
||||
weak var delegate: ServerDetailsViewControllerDelegate?
|
||||
|
||||
init() {
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
|
||||
view.backgroundColor = .systemGroupedBackground
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
||||
}
|
||||
|
|
@ -10,62 +10,78 @@ struct SettingsSection: Hashable {
|
|||
enum SettingsEntry: Hashable {
|
||||
case general
|
||||
case notifications
|
||||
case serverDetails(domain: String)
|
||||
case aboutMastodon
|
||||
case logout(accountName: String)
|
||||
|
||||
var title: String {
|
||||
switch self {
|
||||
case .general:
|
||||
return L10n.Scene.Settings.Overview.general
|
||||
case .notifications:
|
||||
return L10n.Scene.Settings.Overview.notifications
|
||||
case .aboutMastodon:
|
||||
return L10n.Scene.Settings.Overview.aboutMastodon
|
||||
case .logout(let accountName):
|
||||
return L10n.Scene.Settings.Overview.logout(accountName)
|
||||
case .general:
|
||||
return L10n.Scene.Settings.Overview.general
|
||||
case .notifications:
|
||||
return L10n.Scene.Settings.Overview.notifications
|
||||
case .serverDetails(_):
|
||||
return L10n.Scene.Settings.Overview.serverDetails
|
||||
case .aboutMastodon:
|
||||
return L10n.Scene.Settings.Overview.aboutMastodon
|
||||
case .logout(let accountName):
|
||||
return L10n.Scene.Settings.Overview.logout(accountName)
|
||||
}
|
||||
}
|
||||
|
||||
var secondaryTitle: String? {
|
||||
switch self {
|
||||
case .serverDetails(domain: let domain):
|
||||
return domain
|
||||
case .general, .notifications, .aboutMastodon, .logout(_):
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
var accessoryType: UITableViewCell.AccessoryType {
|
||||
switch self {
|
||||
case .general, .notifications, .aboutMastodon, .logout(_):
|
||||
return .disclosureIndicator
|
||||
case .general, .notifications, .serverDetails(_), .aboutMastodon, .logout(_):
|
||||
return .disclosureIndicator
|
||||
}
|
||||
}
|
||||
|
||||
var icon: UIImage? {
|
||||
switch self {
|
||||
case .general:
|
||||
return UIImage(systemName: "gear")
|
||||
case .notifications:
|
||||
return UIImage(systemName: "bell.badge")
|
||||
case .aboutMastodon:
|
||||
return UIImage(systemName: "info.circle.fill")
|
||||
case .logout(_):
|
||||
return nil
|
||||
case .general:
|
||||
return UIImage(systemName: "gear")
|
||||
case .notifications:
|
||||
return UIImage(systemName: "bell.badge")
|
||||
case .serverDetails(_):
|
||||
return UIImage(systemName: "server.rack")
|
||||
case .aboutMastodon:
|
||||
return UIImage(systemName: "info.circle.fill")
|
||||
case .logout(_):
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
var iconBackgroundColor: UIColor? {
|
||||
switch self {
|
||||
case .general:
|
||||
return .systemGray
|
||||
case .notifications:
|
||||
return .systemRed
|
||||
case .aboutMastodon:
|
||||
return .systemPurple
|
||||
case .logout(_):
|
||||
return nil
|
||||
case .general:
|
||||
return .systemGray
|
||||
case .notifications:
|
||||
return .systemRed
|
||||
case .serverDetails(_):
|
||||
return .systemTeal
|
||||
case .aboutMastodon:
|
||||
return .systemPurple
|
||||
case .logout(_):
|
||||
return nil
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var textColor: UIColor {
|
||||
switch self {
|
||||
case .general, .notifications, .aboutMastodon:
|
||||
return .label
|
||||
case .logout(_):
|
||||
return .red
|
||||
case .general, .notifications, .aboutMastodon, .serverDetails(_):
|
||||
return .label
|
||||
case .logout(_):
|
||||
return .red
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,9 @@ class SettingsTableViewCell: UITableViewCell {
|
|||
let iconImageView: UIImageView
|
||||
let iconImageBackgroundView: UIView
|
||||
let titleLabel: UILabel
|
||||
let secondaryLabel: UILabel
|
||||
|
||||
private let labelStackView: UIStackView
|
||||
private let contentStackView: UIStackView
|
||||
|
||||
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
||||
|
@ -21,8 +23,17 @@ class SettingsTableViewCell: UITableViewCell {
|
|||
iconImageBackgroundView.addSubview(iconImageView)
|
||||
|
||||
titleLabel = UILabel()
|
||||
titleLabel.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 17, weight: .regular))
|
||||
secondaryLabel = UILabel()
|
||||
secondaryLabel.font = UIFontMetrics(forTextStyle: .caption1).scaledFont(for: .systemFont(ofSize: 12, weight: .regular))
|
||||
secondaryLabel.textColor = .secondaryLabel
|
||||
|
||||
contentStackView = UIStackView(arrangedSubviews: [iconImageBackgroundView, titleLabel])
|
||||
labelStackView = UIStackView(arrangedSubviews: [titleLabel, secondaryLabel])
|
||||
labelStackView.axis = .vertical
|
||||
labelStackView.spacing = 2
|
||||
labelStackView.alignment = .leading
|
||||
|
||||
contentStackView = UIStackView(arrangedSubviews: [iconImageBackgroundView, labelStackView])
|
||||
contentStackView.translatesAutoresizingMaskIntoConstraints = false
|
||||
contentStackView.axis = .horizontal
|
||||
contentStackView.alignment = .center
|
||||
|
@ -50,8 +61,8 @@ class SettingsTableViewCell: UITableViewCell {
|
|||
iconImageView.centerXAnchor.constraint(equalTo: iconImageBackgroundView.centerXAnchor),
|
||||
iconImageView.widthAnchor.constraint(equalToConstant: 20),
|
||||
|
||||
titleLabel.topAnchor.constraint(greaterThanOrEqualTo: contentView.topAnchor, constant: 12),
|
||||
contentView.bottomAnchor.constraint(greaterThanOrEqualTo: titleLabel.bottomAnchor, constant: 12),
|
||||
labelStackView.topAnchor.constraint(greaterThanOrEqualTo: contentView.topAnchor, constant: 12),
|
||||
contentView.bottomAnchor.constraint(greaterThanOrEqualTo: labelStackView.bottomAnchor, constant: 12),
|
||||
]
|
||||
|
||||
NSLayoutConstraint.activate(constraints)
|
||||
|
@ -61,6 +72,13 @@ class SettingsTableViewCell: UITableViewCell {
|
|||
titleLabel.textColor = entry.textColor
|
||||
titleLabel.text = entry.title
|
||||
|
||||
if let secondaryTitle = entry.secondaryTitle {
|
||||
secondaryLabel.isHidden = false
|
||||
secondaryLabel.text = secondaryTitle
|
||||
} else {
|
||||
secondaryLabel.isHidden = true
|
||||
}
|
||||
|
||||
if let icon = entry.icon {
|
||||
iconImageView.image = icon
|
||||
iconImageView.tintColor = .white
|
||||
|
@ -73,7 +91,6 @@ class SettingsTableViewCell: UITableViewCell {
|
|||
iconImageBackgroundView.backgroundColor = entry.iconBackgroundColor
|
||||
|
||||
accessoryType = entry.accessoryType
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,11 +16,11 @@ class SettingsViewController: UIViewController {
|
|||
var tableViewDataSource: UITableViewDiffableDataSource<SettingsSection, SettingsEntry>?
|
||||
let tableView: UITableView
|
||||
|
||||
init(accountName: String) {
|
||||
init(accountName: String, domain: String) {
|
||||
|
||||
sections = [
|
||||
.init(entries: [.general, .notifications]),
|
||||
.init(entries: [.aboutMastodon]),
|
||||
.init(entries: [.serverDetails(domain: domain), .aboutMastodon]),
|
||||
.init(entries: [.logout(accountName: accountName)])
|
||||
]
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ class SettingsCoordinator: NSObject, Coordinator {
|
|||
self.appContext = appContext
|
||||
self.authContext = authContext
|
||||
|
||||
settingsViewController = SettingsViewController(accountName: accountName)
|
||||
settingsViewController = SettingsViewController(accountName: accountName, domain: authContext.mastodonAuthenticationBox.domain)
|
||||
}
|
||||
|
||||
func start() {
|
||||
|
@ -65,8 +65,12 @@ extension SettingsCoordinator: SettingsViewControllerDelegate {
|
|||
let notificationViewController = NotificationSettingsViewController(currentSetting: currentSetting, notificationsEnabled: notificationsEnabled)
|
||||
notificationViewController.delegate = self
|
||||
|
||||
self.navigationController.pushViewController(notificationViewController, animated: true)
|
||||
navigationController.pushViewController(notificationViewController, animated: true)
|
||||
case .serverDetails(_):
|
||||
let serverDetailsViewController = ServerDetailsViewController()
|
||||
serverDetailsViewController.delegate = self
|
||||
|
||||
navigationController.pushViewController(serverDetailsViewController, animated: true)
|
||||
case .aboutMastodon:
|
||||
let aboutViewController = AboutViewController()
|
||||
aboutViewController.delegate = self
|
||||
|
@ -183,3 +187,8 @@ extension SettingsCoordinator: PolicySelectionViewControllerDelegate {
|
|||
try? self.appContext.managedObjectContext.save()
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - ServerDetailsViewControllerDelegate
|
||||
extension SettingsCoordinator: ServerDetailsViewControllerDelegate {
|
||||
|
||||
}
|
||||
|
|
|
@ -1509,6 +1509,8 @@ public enum L10n {
|
|||
}
|
||||
/// Notifications
|
||||
public static let notifications = L10n.tr("Localizable", "Scene.Settings.Overview.Notifications", fallback: "Notifications")
|
||||
/// Server Details
|
||||
public static let serverDetails = L10n.tr("Localizable", "Scene.Settings.Overview.ServerDetails", fallback: "Server Details")
|
||||
/// Support Mastodon
|
||||
public static let supportMastodon = L10n.tr("Localizable", "Scene.Settings.Overview.SupportMastodon", fallback: "Support Mastodon")
|
||||
/// Settings
|
||||
|
|
|
@ -527,6 +527,7 @@ uploaded to Mastodon.";
|
|||
"Scene.Settings.Overview.General" = "General";
|
||||
"Scene.Settings.Overview.Notifications" = "Notifications";
|
||||
"Scene.Settings.Overview.SupportMastodon" = "Support Mastodon";
|
||||
"Scene.Settings.Overview.ServerDetails" = "Server Details";
|
||||
"Scene.Settings.Overview.AboutMastodon" = "About Mastodon";
|
||||
"Scene.Settings.Overview.Logout" = "Logout %@";
|
||||
|
||||
|
|
|
@ -527,6 +527,7 @@ uploaded to Mastodon.";
|
|||
"Scene.Settings.Overview.General" = "General";
|
||||
"Scene.Settings.Overview.Notifications" = "Notifications";
|
||||
"Scene.Settings.Overview.SupportMastodon" = "Support Mastodon";
|
||||
"Scene.Settings.Overview.ServerDetails" = "Server Details";
|
||||
"Scene.Settings.Overview.AboutMastodon" = "About Mastodon";
|
||||
"Scene.Settings.Overview.Logout" = "Logout %@";
|
||||
|
||||
|
|
Loading…
Reference in New Issue