mirror of
https://github.com/mastodon/mastodon-ios.git
synced 2025-01-30 09:04:58 +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 */; };
|
0FAA101C25E10E760017CCDE /* UIFont.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FAA101B25E10E760017CCDE /* UIFont.swift */; };
|
||||||
0FAA102725E1126A0017CCDE /* MastodonPickServerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FAA102625E1126A0017CCDE /* MastodonPickServerViewController.swift */; };
|
0FAA102725E1126A0017CCDE /* MastodonPickServerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FAA102625E1126A0017CCDE /* MastodonPickServerViewController.swift */; };
|
||||||
0FB3D2F725E4C24D00AAD544 /* MastodonPickServerViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FB3D2F625E4C24D00AAD544 /* MastodonPickServerViewModel.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 */; };
|
0FB3D30F25E525CD00AAD544 /* PickServerCategoryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FB3D30E25E525CD00AAD544 /* PickServerCategoryView.swift */; };
|
||||||
0FB3D31E25E534C700AAD544 /* PickServerCategoryCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FB3D31D25E534C700AAD544 /* PickServerCategoryCollectionViewCell.swift */; };
|
0FB3D31E25E534C700AAD544 /* PickServerCategoryCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FB3D31D25E534C700AAD544 /* PickServerCategoryCollectionViewCell.swift */; };
|
||||||
0FB3D33825E6401400AAD544 /* PickServerCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FB3D33725E6401400AAD544 /* PickServerCell.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>"; };
|
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>"; };
|
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>"; };
|
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>"; };
|
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>"; };
|
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>"; };
|
0FB3D33725E6401400AAD544 /* PickServerCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PickServerCell.swift; sourceTree = "<group>"; };
|
||||||
@ -2157,7 +2155,6 @@
|
|||||||
DB029E94266A20430062874E /* MastodonAuthenticationController.swift */,
|
DB029E94266A20430062874E /* MastodonAuthenticationController.swift */,
|
||||||
2D82B9FE25E7863200E36F0F /* OnboardingViewControllerAppearance.swift */,
|
2D82B9FE25E7863200E36F0F /* OnboardingViewControllerAppearance.swift */,
|
||||||
DB0617EC277F02C50030EE79 /* OnboardingNavigationController.swift */,
|
DB0617EC277F02C50030EE79 /* OnboardingNavigationController.swift */,
|
||||||
0FB3D2FD25E4CB6400AAD544 /* OnboardingHeadlineTableViewCell.swift */,
|
|
||||||
DB0617EE277F12720030EE79 /* NavigationActionView.swift */,
|
DB0617EE277F12720030EE79 /* NavigationActionView.swift */,
|
||||||
);
|
);
|
||||||
path = Share;
|
path = Share;
|
||||||
@ -3413,7 +3410,6 @@
|
|||||||
6213AF5A28939C8400BCADB6 /* BookmarkViewModel.swift in Sources */,
|
6213AF5A28939C8400BCADB6 /* BookmarkViewModel.swift in Sources */,
|
||||||
5B24BBDB262DB14800A9381B /* ReportStatusViewModel+Diffable.swift in Sources */,
|
5B24BBDB262DB14800A9381B /* ReportStatusViewModel+Diffable.swift in Sources */,
|
||||||
DB4F0968269ED8AD00D62E92 /* SearchHistoryTableHeaderView.swift in Sources */,
|
DB4F0968269ED8AD00D62E92 /* SearchHistoryTableHeaderView.swift in Sources */,
|
||||||
0FB3D2FE25E4CB6400AAD544 /* OnboardingHeadlineTableViewCell.swift in Sources */,
|
|
||||||
5DA732CC2629CEF500A92342 /* UIView+Remove.swift in Sources */,
|
5DA732CC2629CEF500A92342 /* UIView+Remove.swift in Sources */,
|
||||||
2A506CF4292CD85800059C37 /* FollowedTagsViewController.swift in Sources */,
|
2A506CF4292CD85800059C37 /* FollowedTagsViewController.swift in Sources */,
|
||||||
DB1D843026566512000346B3 /* KeyboardPreference.swift in Sources */,
|
DB1D843026566512000346B3 /* KeyboardPreference.swift in Sources */,
|
||||||
|
@ -71,7 +71,7 @@ class PrivacyTableViewController: UIViewController, NeedsDependency {
|
|||||||
|
|
||||||
private func setupConstraints() {
|
private func setupConstraints() {
|
||||||
let constraints = [
|
let constraints = [
|
||||||
tableView.topAnchor.constraint(equalTo: view.topAnchor),
|
tableView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
|
||||||
tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
||||||
view.trailingAnchor.constraint(equalTo: tableView.trailingAnchor),
|
view.trailingAnchor.constraint(equalTo: tableView.trailingAnchor),
|
||||||
view.bottomAnchor.constraint(equalTo: tableView.bottomAnchor)
|
view.bottomAnchor.constraint(equalTo: tableView.bottomAnchor)
|
||||||
@ -79,6 +79,12 @@ class PrivacyTableViewController: UIViewController, NeedsDependency {
|
|||||||
NSLayoutConstraint.activate(constraints)
|
NSLayoutConstraint.activate(constraints)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
|
||||||
|
setupOnboardingAppearance()
|
||||||
|
}
|
||||||
|
|
||||||
//MARK: - Actions
|
//MARK: - Actions
|
||||||
@objc private func backButtonPressed(_ sender: UIButton) {
|
@objc private func backButtonPressed(_ sender: UIButton) {
|
||||||
navigationController?.popViewController(animated: true)
|
navigationController?.popViewController(animated: true)
|
||||||
@ -124,4 +130,26 @@ extension PrivacyTableViewController: UITableViewDelegate {
|
|||||||
|
|
||||||
_ = coordinator.present(scene: .safari(url: url), from: self, transition: .safariPresent(animated: true))
|
_ = 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
|
return label
|
||||||
}()
|
}()
|
||||||
|
|
||||||
let separatorLine: UIView = {
|
|
||||||
let view = UIView()
|
|
||||||
view.backgroundColor = Asset.Theme.System.separator.color
|
|
||||||
return view
|
|
||||||
}()
|
|
||||||
|
|
||||||
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)
|
||||||
_init()
|
_init()
|
||||||
|
@ -29,10 +29,8 @@ final class MastodonServerRulesViewController: UIViewController, NeedsDependency
|
|||||||
|
|
||||||
let tableView: UITableView = {
|
let tableView: UITableView = {
|
||||||
let tableView = UITableView(frame: .zero, style: .insetGrouped)
|
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.register(ServerRulesTableViewCell.self, forCellReuseIdentifier: String(describing: ServerRulesTableViewCell.self))
|
||||||
tableView.rowHeight = UITableView.automaticDimension
|
tableView.rowHeight = UITableView.automaticDimension
|
||||||
tableView.backgroundColor = .secondarySystemGroupedBackground
|
|
||||||
tableView.keyboardDismissMode = .onDrag
|
tableView.keyboardDismissMode = .onDrag
|
||||||
tableView.sectionHeaderTopPadding = 0
|
tableView.sectionHeaderTopPadding = 0
|
||||||
return tableView
|
return tableView
|
||||||
@ -54,7 +52,6 @@ extension MastodonServerRulesViewController {
|
|||||||
tableView.delegate = self
|
tableView.delegate = self
|
||||||
viewModel.setupDiffableDataSource(tableView: tableView)
|
viewModel.setupDiffableDataSource(tableView: tableView)
|
||||||
|
|
||||||
|
|
||||||
navigationItem.rightBarButtonItem = UIBarButtonItem(title: L10n.Scene.ServerRules.Button.confirm, style: .done, target: self, action: #selector(MastodonServerRulesViewController.nextButtonPressed(_:)))
|
navigationItem.rightBarButtonItem = UIBarButtonItem(title: L10n.Scene.ServerRules.Button.confirm, style: .done, target: self, action: #selector(MastodonServerRulesViewController.nextButtonPressed(_:)))
|
||||||
title = L10n.Scene.ServerRules.title
|
title = L10n.Scene.ServerRules.title
|
||||||
}
|
}
|
||||||
@ -86,20 +83,24 @@ extension MastodonServerRulesViewController: OnboardingViewControllerAppearance
|
|||||||
// MARK: - UITableViewDelegate
|
// MARK: - UITableViewDelegate
|
||||||
extension MastodonServerRulesViewController: UITableViewDelegate {
|
extension MastodonServerRulesViewController: UITableViewDelegate {
|
||||||
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
||||||
return UIView()
|
let wrapper = UIView()
|
||||||
}
|
|
||||||
|
|
||||||
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
|
let label = UILabel()
|
||||||
guard let diffableDataSource = viewModel.diffableDataSource,
|
label.translatesAutoresizingMaskIntoConstraints = false
|
||||||
section < diffableDataSource.snapshot().numberOfSections
|
label.font = MastodonPickServerViewController.subTitleFont
|
||||||
else { return .leastNonzeroMagnitude }
|
label.textColor = Asset.Colors.Label.primary.color
|
||||||
|
label.adjustsFontForContentSizeCategory = true
|
||||||
|
label.numberOfLines = 0
|
||||||
|
label.text = L10n.Scene.ServerRules.subtitle(viewModel.domain)
|
||||||
|
wrapper.addSubview(label)
|
||||||
|
|
||||||
let sectionItem = diffableDataSource.snapshot().sectionIdentifiers[section]
|
NSLayoutConstraint.activate([
|
||||||
switch sectionItem {
|
label.topAnchor.constraint(equalTo: wrapper.topAnchor, constant: 16),
|
||||||
case .header:
|
label.leadingAnchor.constraint(equalTo: wrapper.leadingAnchor),
|
||||||
return .leastNonzeroMagnitude
|
wrapper.trailingAnchor.constraint(equalTo: label.trailingAnchor),
|
||||||
case .rules:
|
wrapper.bottomAnchor.constraint(equalTo: label.bottomAnchor, constant: 16),
|
||||||
return 16
|
])
|
||||||
}
|
|
||||||
|
return wrapper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,7 @@ extension MastodonServerRulesViewModel {
|
|||||||
diffableDataSource = ServerRuleSection.tableViewDiffableDataSource(tableView: tableView)
|
diffableDataSource = ServerRuleSection.tableViewDiffableDataSource(tableView: tableView)
|
||||||
|
|
||||||
var snapshot = NSDiffableDataSourceSnapshot<ServerRuleSection, ServerRuleItem>()
|
var snapshot = NSDiffableDataSourceSnapshot<ServerRuleSection, ServerRuleItem>()
|
||||||
snapshot.appendSections([.header, .rules])
|
snapshot.appendSections([.rules])
|
||||||
snapshot.appendItems([.header(domain: domain)], toSection: .header)
|
|
||||||
let ruleItems: [ServerRuleItem] = rules.enumerated().map { i, rule in
|
let ruleItems: [ServerRuleItem] = rules.enumerated().map { i, rule in
|
||||||
let ruleContext = ServerRuleItem.RuleContext(index: i, rule: rule)
|
let ruleContext = ServerRuleItem.RuleContext(index: i, rule: rule)
|
||||||
return ServerRuleItem.rule(ruleContext)
|
return ServerRuleItem.rule(ruleContext)
|
||||||
|
@ -9,7 +9,6 @@ import Foundation
|
|||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
|
|
||||||
enum ServerRuleItem: Hashable {
|
enum ServerRuleItem: Hashable {
|
||||||
case header(domain: String)
|
|
||||||
case rule(RuleContext)
|
case rule(RuleContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ import MastodonAsset
|
|||||||
import MastodonLocalization
|
import MastodonLocalization
|
||||||
|
|
||||||
enum ServerRuleSection: Hashable {
|
enum ServerRuleSection: Hashable {
|
||||||
case header
|
|
||||||
case rules
|
case rules
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,10 +19,6 @@ extension ServerRuleSection {
|
|||||||
) -> UITableViewDiffableDataSource<ServerRuleSection, ServerRuleItem> {
|
) -> UITableViewDiffableDataSource<ServerRuleSection, ServerRuleItem> {
|
||||||
return UITableViewDiffableDataSource(tableView: tableView) { tableView, indexPath, item in
|
return UITableViewDiffableDataSource(tableView: tableView) { tableView, indexPath, item in
|
||||||
switch item {
|
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):
|
case .rule(let ruleContext):
|
||||||
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: ServerRulesTableViewCell.self), for: indexPath) as! ServerRulesTableViewCell
|
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")
|
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