mirror of
https://github.com/mastodon/mastodon-ios.git
synced 2025-01-28 16:20:10 +01:00
Add explanatory text to privacy screen (#690)
This also includes a refactor on the ServerRules-screen. It's built the same way
This commit is contained in:
parent
2e4ff59bc2
commit
e6d6fd63fb
@ -17,7 +17,6 @@
|
||||
0FAA101C25E10E760017CCDE /* UIFont.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FAA101B25E10E760017CCDE /* UIFont.swift */; };
|
||||
0FAA102725E1126A0017CCDE /* MastodonPickServerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FAA102625E1126A0017CCDE /* MastodonPickServerViewController.swift */; };
|
||||
0FB3D2F725E4C24D00AAD544 /* MastodonPickServerViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FB3D2F625E4C24D00AAD544 /* MastodonPickServerViewModel.swift */; };
|
||||
0FB3D2FE25E4CB6400AAD544 /* OnboardingHeadlineTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FB3D2FD25E4CB6400AAD544 /* OnboardingHeadlineTableViewCell.swift */; };
|
||||
0FB3D30F25E525CD00AAD544 /* PickServerCategoryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FB3D30E25E525CD00AAD544 /* PickServerCategoryView.swift */; };
|
||||
0FB3D31E25E534C700AAD544 /* PickServerCategoryCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FB3D31D25E534C700AAD544 /* PickServerCategoryCollectionViewCell.swift */; };
|
||||
0FB3D33825E6401400AAD544 /* PickServerCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FB3D33725E6401400AAD544 /* PickServerCell.swift */; };
|
||||
@ -546,7 +545,6 @@
|
||||
0FAA101B25E10E760017CCDE /* UIFont.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIFont.swift; sourceTree = "<group>"; };
|
||||
0FAA102625E1126A0017CCDE /* MastodonPickServerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MastodonPickServerViewController.swift; sourceTree = "<group>"; };
|
||||
0FB3D2F625E4C24D00AAD544 /* MastodonPickServerViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MastodonPickServerViewModel.swift; sourceTree = "<group>"; };
|
||||
0FB3D2FD25E4CB6400AAD544 /* OnboardingHeadlineTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingHeadlineTableViewCell.swift; sourceTree = "<group>"; };
|
||||
0FB3D30E25E525CD00AAD544 /* PickServerCategoryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PickServerCategoryView.swift; sourceTree = "<group>"; };
|
||||
0FB3D31D25E534C700AAD544 /* PickServerCategoryCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PickServerCategoryCollectionViewCell.swift; sourceTree = "<group>"; };
|
||||
0FB3D33725E6401400AAD544 /* PickServerCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PickServerCell.swift; sourceTree = "<group>"; };
|
||||
@ -2157,7 +2155,6 @@
|
||||
DB029E94266A20430062874E /* MastodonAuthenticationController.swift */,
|
||||
2D82B9FE25E7863200E36F0F /* OnboardingViewControllerAppearance.swift */,
|
||||
DB0617EC277F02C50030EE79 /* OnboardingNavigationController.swift */,
|
||||
0FB3D2FD25E4CB6400AAD544 /* OnboardingHeadlineTableViewCell.swift */,
|
||||
DB0617EE277F12720030EE79 /* NavigationActionView.swift */,
|
||||
);
|
||||
path = Share;
|
||||
@ -3413,7 +3410,6 @@
|
||||
6213AF5A28939C8400BCADB6 /* BookmarkViewModel.swift in Sources */,
|
||||
5B24BBDB262DB14800A9381B /* ReportStatusViewModel+Diffable.swift in Sources */,
|
||||
DB4F0968269ED8AD00D62E92 /* SearchHistoryTableHeaderView.swift in Sources */,
|
||||
0FB3D2FE25E4CB6400AAD544 /* OnboardingHeadlineTableViewCell.swift in Sources */,
|
||||
5DA732CC2629CEF500A92342 /* UIView+Remove.swift in Sources */,
|
||||
2A506CF4292CD85800059C37 /* FollowedTagsViewController.swift in Sources */,
|
||||
DB1D843026566512000346B3 /* KeyboardPreference.swift in Sources */,
|
||||
|
@ -71,7 +71,7 @@ class PrivacyTableViewController: UIViewController, NeedsDependency {
|
||||
|
||||
private func setupConstraints() {
|
||||
let constraints = [
|
||||
tableView.topAnchor.constraint(equalTo: view.topAnchor),
|
||||
tableView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
|
||||
tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
||||
view.trailingAnchor.constraint(equalTo: tableView.trailingAnchor),
|
||||
view.bottomAnchor.constraint(equalTo: tableView.bottomAnchor)
|
||||
@ -79,6 +79,12 @@ class PrivacyTableViewController: UIViewController, NeedsDependency {
|
||||
NSLayoutConstraint.activate(constraints)
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
setupOnboardingAppearance()
|
||||
}
|
||||
|
||||
//MARK: - Actions
|
||||
@objc private func backButtonPressed(_ sender: UIButton) {
|
||||
navigationController?.popViewController(animated: true)
|
||||
@ -124,4 +130,26 @@ extension PrivacyTableViewController: UITableViewDelegate {
|
||||
|
||||
_ = coordinator.present(scene: .safari(url: url), from: self, transition: .safariPresent(animated: true))
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
||||
let wrapper = UIView()
|
||||
|
||||
let label = UILabel()
|
||||
label.translatesAutoresizingMaskIntoConstraints = false
|
||||
label.numberOfLines = 0
|
||||
label.text = L10n.Scene.Privacy.description
|
||||
label.textColor = Asset.Colors.Label.primary.color
|
||||
wrapper.addSubview(label)
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
label.topAnchor.constraint(equalTo: wrapper.topAnchor, constant: 16),
|
||||
label.leadingAnchor.constraint(equalTo: wrapper.leadingAnchor),
|
||||
wrapper.trailingAnchor.constraint(equalTo: label.trailingAnchor),
|
||||
wrapper.bottomAnchor.constraint(equalTo: label.bottomAnchor, constant: 16),
|
||||
])
|
||||
|
||||
return wrapper
|
||||
}
|
||||
}
|
||||
|
||||
extension PrivacyTableViewController: OnboardingViewControllerAppearance { }
|
||||
|
@ -27,12 +27,6 @@ final class ServerRulesTableViewCell: UITableViewCell {
|
||||
return label
|
||||
}()
|
||||
|
||||
let separatorLine: UIView = {
|
||||
let view = UIView()
|
||||
view.backgroundColor = Asset.Theme.System.separator.color
|
||||
return view
|
||||
}()
|
||||
|
||||
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
||||
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||
_init()
|
||||
|
@ -29,10 +29,8 @@ final class MastodonServerRulesViewController: UIViewController, NeedsDependency
|
||||
|
||||
let tableView: UITableView = {
|
||||
let tableView = UITableView(frame: .zero, style: .insetGrouped)
|
||||
tableView.register(OnboardingHeadlineTableViewCell.self, forCellReuseIdentifier: String(describing: OnboardingHeadlineTableViewCell.self))
|
||||
tableView.register(ServerRulesTableViewCell.self, forCellReuseIdentifier: String(describing: ServerRulesTableViewCell.self))
|
||||
tableView.rowHeight = UITableView.automaticDimension
|
||||
tableView.backgroundColor = .secondarySystemGroupedBackground
|
||||
tableView.keyboardDismissMode = .onDrag
|
||||
tableView.sectionHeaderTopPadding = 0
|
||||
return tableView
|
||||
@ -54,7 +52,6 @@ extension MastodonServerRulesViewController {
|
||||
tableView.delegate = self
|
||||
viewModel.setupDiffableDataSource(tableView: tableView)
|
||||
|
||||
|
||||
navigationItem.rightBarButtonItem = UIBarButtonItem(title: L10n.Scene.ServerRules.Button.confirm, style: .done, target: self, action: #selector(MastodonServerRulesViewController.nextButtonPressed(_:)))
|
||||
title = L10n.Scene.ServerRules.title
|
||||
}
|
||||
@ -86,20 +83,24 @@ extension MastodonServerRulesViewController: OnboardingViewControllerAppearance
|
||||
// MARK: - UITableViewDelegate
|
||||
extension MastodonServerRulesViewController: UITableViewDelegate {
|
||||
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
||||
return UIView()
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
|
||||
guard let diffableDataSource = viewModel.diffableDataSource,
|
||||
section < diffableDataSource.snapshot().numberOfSections
|
||||
else { return .leastNonzeroMagnitude }
|
||||
|
||||
let sectionItem = diffableDataSource.snapshot().sectionIdentifiers[section]
|
||||
switch sectionItem {
|
||||
case .header:
|
||||
return .leastNonzeroMagnitude
|
||||
case .rules:
|
||||
return 16
|
||||
}
|
||||
let wrapper = UIView()
|
||||
|
||||
let label = UILabel()
|
||||
label.translatesAutoresizingMaskIntoConstraints = false
|
||||
label.font = MastodonPickServerViewController.subTitleFont
|
||||
label.textColor = Asset.Colors.Label.primary.color
|
||||
label.adjustsFontForContentSizeCategory = true
|
||||
label.numberOfLines = 0
|
||||
label.text = L10n.Scene.ServerRules.subtitle(viewModel.domain)
|
||||
wrapper.addSubview(label)
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
label.topAnchor.constraint(equalTo: wrapper.topAnchor, constant: 16),
|
||||
label.leadingAnchor.constraint(equalTo: wrapper.leadingAnchor),
|
||||
wrapper.trailingAnchor.constraint(equalTo: label.trailingAnchor),
|
||||
wrapper.bottomAnchor.constraint(equalTo: label.bottomAnchor, constant: 16),
|
||||
])
|
||||
|
||||
return wrapper
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,7 @@ extension MastodonServerRulesViewModel {
|
||||
diffableDataSource = ServerRuleSection.tableViewDiffableDataSource(tableView: tableView)
|
||||
|
||||
var snapshot = NSDiffableDataSourceSnapshot<ServerRuleSection, ServerRuleItem>()
|
||||
snapshot.appendSections([.header, .rules])
|
||||
snapshot.appendItems([.header(domain: domain)], toSection: .header)
|
||||
snapshot.appendSections([.rules])
|
||||
let ruleItems: [ServerRuleItem] = rules.enumerated().map { i, rule in
|
||||
let ruleContext = ServerRuleItem.RuleContext(index: i, rule: rule)
|
||||
return ServerRuleItem.rule(ruleContext)
|
||||
|
@ -9,7 +9,6 @@ import Foundation
|
||||
import MastodonSDK
|
||||
|
||||
enum ServerRuleItem: Hashable {
|
||||
case header(domain: String)
|
||||
case rule(RuleContext)
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@ import MastodonAsset
|
||||
import MastodonLocalization
|
||||
|
||||
enum ServerRuleSection: Hashable {
|
||||
case header
|
||||
case rules
|
||||
}
|
||||
|
||||
@ -20,10 +19,6 @@ extension ServerRuleSection {
|
||||
) -> UITableViewDiffableDataSource<ServerRuleSection, ServerRuleItem> {
|
||||
return UITableViewDiffableDataSource(tableView: tableView) { tableView, indexPath, item in
|
||||
switch item {
|
||||
case .header(let domain):
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: OnboardingHeadlineTableViewCell.self), for: indexPath) as! OnboardingHeadlineTableViewCell
|
||||
cell.subTitleLabel.text = L10n.Scene.ServerRules.subtitle(domain)
|
||||
return cell
|
||||
case .rule(let ruleContext):
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: ServerRulesTableViewCell.self), for: indexPath) as! ServerRulesTableViewCell
|
||||
cell.indexImageView.image = UIImage(systemName: "\(ruleContext.index + 1).circle") ?? UIImage(systemName: "questionmark.circle")
|
||||
|
@ -1,57 +0,0 @@
|
||||
//
|
||||
// OnboardingHeadlineTableViewCell.swift
|
||||
// Mastodon
|
||||
//
|
||||
// Created by BradGao on 2021/2/23.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import MastodonAsset
|
||||
import MastodonLocalization
|
||||
|
||||
final class OnboardingHeadlineTableViewCell: UITableViewCell {
|
||||
|
||||
static let reuseIdentifier = "OnboardingHeadlineTableViewCell"
|
||||
|
||||
let subTitleLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.font = MastodonPickServerViewController.subTitleFont
|
||||
label.textColor = Asset.Colors.Label.primary.color
|
||||
label.adjustsFontForContentSizeCategory = true
|
||||
label.numberOfLines = 0
|
||||
return label
|
||||
}()
|
||||
|
||||
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
||||
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||
_init()
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
super.init(coder: coder)
|
||||
_init()
|
||||
}
|
||||
}
|
||||
|
||||
extension OnboardingHeadlineTableViewCell {
|
||||
|
||||
private func _init() {
|
||||
selectionStyle = .none
|
||||
backgroundColor = Asset.Scene.Onboarding.background.color
|
||||
|
||||
let container = UIStackView()
|
||||
container.axis = .vertical
|
||||
container.spacing = 16
|
||||
container.translatesAutoresizingMaskIntoConstraints = false
|
||||
contentView.addSubview(container)
|
||||
NSLayoutConstraint.activate([
|
||||
container.topAnchor.constraint(equalTo: contentView.topAnchor),
|
||||
container.leadingAnchor.constraint(equalTo: contentView.readableContentGuide.leadingAnchor),
|
||||
container.trailingAnchor.constraint(equalTo: contentView.readableContentGuide.trailingAnchor),
|
||||
contentView.bottomAnchor.constraint(equalTo: container.bottomAnchor),
|
||||
])
|
||||
|
||||
container.addArrangedSubview(subTitleLabel)
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user