UI/UX-improvements (IOS-241)
This commit is contained in:
parent
94ad86cd66
commit
363a521e68
@ -17,6 +17,9 @@ class NotificationPolicyFilterTableViewCell: ToggleTableViewCell {
|
|||||||
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
||||||
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||||
|
|
||||||
|
label.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 17, weight: .semibold))
|
||||||
|
subtitleLabel.textColor = .secondaryLabel
|
||||||
|
|
||||||
toggle.addTarget(self, action: #selector(NotificationPolicyFilterTableViewCell.toggleValueChanged(_:)), for: .valueChanged)
|
toggle.addTarget(self, action: #selector(NotificationPolicyFilterTableViewCell.toggleValueChanged(_:)), for: .valueChanged)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
import MastodonLocalization
|
import MastodonLocalization
|
||||||
|
import MastodonAsset
|
||||||
|
|
||||||
enum NotificationFilterSection: Hashable {
|
enum NotificationFilterSection: Hashable {
|
||||||
case main
|
case main
|
||||||
@ -14,6 +15,7 @@ enum NotificationFilterItem: Hashable, CaseIterable {
|
|||||||
case privateMentions
|
case privateMentions
|
||||||
|
|
||||||
var title: String {
|
var title: String {
|
||||||
|
// TODO: Localization
|
||||||
switch self {
|
switch self {
|
||||||
case .notFollowing:
|
case .notFollowing:
|
||||||
return "People you don't follow"
|
return "People you don't follow"
|
||||||
@ -27,6 +29,7 @@ enum NotificationFilterItem: Hashable, CaseIterable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var subtitle: String {
|
var subtitle: String {
|
||||||
|
// TODO: Localization
|
||||||
switch self {
|
switch self {
|
||||||
case .notFollowing:
|
case .notFollowing:
|
||||||
return "Until you manually approve them"
|
return "Until you manually approve them"
|
||||||
@ -56,7 +59,6 @@ struct NotificationFilterViewModel {
|
|||||||
|
|
||||||
class NotificationPolicyViewController: UIViewController {
|
class NotificationPolicyViewController: UIViewController {
|
||||||
|
|
||||||
//TODO: DataSource, Source, Items
|
|
||||||
let tableView: UITableView
|
let tableView: UITableView
|
||||||
var dataSource: UITableViewDiffableDataSource<NotificationFilterSection, NotificationFilterItem>?
|
var dataSource: UITableViewDiffableDataSource<NotificationFilterSection, NotificationFilterItem>?
|
||||||
let items: [NotificationFilterItem]
|
let items: [NotificationFilterItem]
|
||||||
@ -77,8 +79,6 @@ class NotificationPolicyViewController: UIViewController {
|
|||||||
fatalError("No NotificationPolicyFilterTableViewCell")
|
fatalError("No NotificationPolicyFilterTableViewCell")
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Configuration
|
|
||||||
|
|
||||||
let item = items[indexPath.row]
|
let item = items[indexPath.row]
|
||||||
cell.configure(with: item, viewModel: self.viewModel)
|
cell.configure(with: item, viewModel: self.viewModel)
|
||||||
cell.delegate = self
|
cell.delegate = self
|
||||||
@ -86,6 +86,9 @@ class NotificationPolicyViewController: UIViewController {
|
|||||||
return cell
|
return cell
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Localization
|
||||||
|
title = "Filter Notifications from"
|
||||||
|
|
||||||
tableView.dataSource = dataSource
|
tableView.dataSource = dataSource
|
||||||
tableView.delegate = self
|
tableView.delegate = self
|
||||||
|
|
||||||
@ -137,6 +140,22 @@ class NotificationPolicyViewController: UIViewController {
|
|||||||
extension NotificationPolicyViewController: UITableViewDelegate {
|
extension NotificationPolicyViewController: UITableViewDelegate {
|
||||||
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||||
tableView.deselectRow(at: indexPath, animated: true)
|
tableView.deselectRow(at: indexPath, animated: true)
|
||||||
|
|
||||||
|
let filterItem = items[indexPath.row]
|
||||||
|
switch filterItem {
|
||||||
|
case .notFollowing:
|
||||||
|
viewModel.notFollowing.toggle()
|
||||||
|
case .noFollower:
|
||||||
|
viewModel.noFollower.toggle()
|
||||||
|
case .newAccount:
|
||||||
|
viewModel.newAccount.toggle()
|
||||||
|
case .privateMentions:
|
||||||
|
viewModel.privateMentions.toggle()
|
||||||
|
}
|
||||||
|
|
||||||
|
if let snapshot = dataSource?.snapshot() {
|
||||||
|
dataSource?.applySnapshotUsingReloadData(snapshot)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ class ToggleTableViewCell: UITableViewCell {
|
|||||||
labelStackView.translatesAutoresizingMaskIntoConstraints = false
|
labelStackView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
labelStackView.alignment = .leading
|
labelStackView.alignment = .leading
|
||||||
labelStackView.axis = .vertical
|
labelStackView.axis = .vertical
|
||||||
|
labelStackView.spacing = 4
|
||||||
|
|
||||||
toggle = UISwitch()
|
toggle = UISwitch()
|
||||||
toggle.translatesAutoresizingMaskIntoConstraints = false
|
toggle.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user