2
2
mirror of https://github.com/mastodon/mastodon-ios synced 2025-04-11 22:58:02 +02:00

Show subtitle (IOS-241)

This commit is contained in:
Nathan Mattes 2024-07-08 12:09:01 +02:00
parent 151880f661
commit 0b749816dd
5 changed files with 34 additions and 8 deletions

View File

@ -24,6 +24,7 @@ class NotificationPolicyFilterTableViewCell: ToggleTableViewCell {
public func configure(with filterItem: NotificationFilterItem, viewModel: NotificationFilterViewModel) {
label.text = filterItem.title
subtitleLabel.text = filterItem.subtitle
self.filterItem = filterItem
let toggleIsOn: Bool

View File

@ -25,6 +25,19 @@ enum NotificationFilterItem: Hashable, CaseIterable {
return "Unsolicited private mentions"
}
}
var subtitle: String {
switch self {
case .notFollowing:
return "Until you manually approve them"
case .noFollower:
return "Including people who have been following you fewer than 3 days"
case .newAccount:
return "Created within the past 30 days"
case .privateMentions:
return "Filtered unless its in reply to your own mention or if you follow the sender"
}
}
}
struct NotificationFilterViewModel {

View File

@ -17,6 +17,7 @@ class GeneralSettingToggleTableViewCell: ToggleTableViewCell {
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
subtitleLabel.isHidden = true
toggle.addTarget(self, action: #selector(GeneralSettingToggleTableViewCell.toggleValueChanged(_:)), for: .valueChanged)
}

View File

@ -18,6 +18,7 @@ class NotificationSettingTableViewToggleCell: ToggleTableViewCell {
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
subtitleLabel.isHidden = true
toggle.addTarget(self, action: #selector(NotificationSettingTableViewToggleCell.toggleValueChanged(_:)), for: .valueChanged)
}

View File

@ -9,22 +9,32 @@ class ToggleTableViewCell: UITableViewCell {
}
let label: UILabel
let subtitleLabel: UILabel
private let labelStackView: UIStackView
let toggle: UISwitch
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 17, weight: .regular))
label.numberOfLines = 0
subtitleLabel = UILabel()
subtitleLabel.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 15, weight: .regular))
subtitleLabel.numberOfLines = 0
labelStackView = UIStackView(arrangedSubviews: [label, subtitleLabel])
labelStackView.translatesAutoresizingMaskIntoConstraints = false
labelStackView.alignment = .leading
labelStackView.axis = .vertical
toggle = UISwitch()
toggle.translatesAutoresizingMaskIntoConstraints = false
toggle.onTintColor = Asset.Colors.Brand.blurple.color
super.init(style: style, reuseIdentifier: reuseIdentifier)
contentView.addSubview(label)
contentView.addSubview(labelStackView)
contentView.addSubview(toggle)
setupConstraints()
}
@ -33,11 +43,11 @@ class ToggleTableViewCell: UITableViewCell {
private func setupConstraints() {
let constraints = [
label.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 11),
label.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 16),
contentView.bottomAnchor.constraint(equalTo: label.bottomAnchor, constant: 11),
toggle.leadingAnchor.constraint(greaterThanOrEqualTo: label.trailingAnchor, constant: 16),
labelStackView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 11),
labelStackView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 16),
contentView.bottomAnchor.constraint(equalTo: labelStackView.bottomAnchor, constant: 11),
toggle.leadingAnchor.constraint(greaterThanOrEqualTo: labelStackView.trailingAnchor, constant: 16),
toggle.centerYAnchor.constraint(equalTo: contentView.centerYAnchor),
contentView.trailingAnchor.constraint(equalTo: toggle.trailingAnchor, constant: 16)