From dc91ebcd0a8578929043de8de509d8db91b9d1f9 Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Sun, 11 Dec 2022 23:59:30 +0100 Subject: [PATCH] Apply new style to server-rules (#690) --- Mastodon.xcodeproj/project.pbxproj | 4 +-- .../Cell/ServerRulesTableViewCell.swift | 26 +++++++++---------- .../MastodonServerRulesViewModel.swift | 4 +-- .../ServerRules}/ServerRuleItem.swift | 0 .../ServerRules}/ServerRuleSection.swift | 4 +-- 5 files changed, 19 insertions(+), 19 deletions(-) rename Mastodon/{Diffable/Onboarding => Scene/Onboarding/ServerRules}/ServerRuleItem.swift (100%) rename Mastodon/{Diffable/Onboarding => Scene/Onboarding/ServerRules}/ServerRuleSection.swift (88%) diff --git a/Mastodon.xcodeproj/project.pbxproj b/Mastodon.xcodeproj/project.pbxproj index 6dca1d070..6a047bf60 100644 --- a/Mastodon.xcodeproj/project.pbxproj +++ b/Mastodon.xcodeproj/project.pbxproj @@ -1906,8 +1906,6 @@ DB1E347725F519300079D7DF /* PickServerItem.swift */, DB1E346725F518E20079D7DF /* CategoryPickerSection.swift */, DB1FD45925F27898004CFCFC /* CategoryPickerItem.swift */, - DB0617F427855AB90030EE79 /* ServerRuleSection.swift */, - DB0617FC27855BFE0030EE79 /* ServerRuleItem.swift */, DB0618022785A7100030EE79 /* RegisterSection.swift */, DB0618042785A73D0030EE79 /* RegisterItem.swift */, ); @@ -2203,6 +2201,8 @@ DB7A9F922818F33C0016AF98 /* MastodonServerRulesViewController+Debug.swift */, DB72602625E36A6F00235243 /* MastodonServerRulesViewModel.swift */, DB0617FE27855D6C0030EE79 /* MastodonServerRulesViewModel+Diffable.swift */, + DB0617F427855AB90030EE79 /* ServerRuleSection.swift */, + DB0617FC27855BFE0030EE79 /* ServerRuleItem.swift */, ); path = ServerRules; sourceTree = ""; diff --git a/Mastodon/Scene/Onboarding/ServerRules/Cell/ServerRulesTableViewCell.swift b/Mastodon/Scene/Onboarding/ServerRules/Cell/ServerRulesTableViewCell.swift index a6fc25a40..bb51cdfcf 100644 --- a/Mastodon/Scene/Onboarding/ServerRules/Cell/ServerRulesTableViewCell.swift +++ b/Mastodon/Scene/Onboarding/ServerRules/Cell/ServerRulesTableViewCell.swift @@ -21,13 +21,13 @@ final class ServerRulesTableViewCell: UITableViewCell { let ruleLabel: UILabel = { let label = UILabel() - label.font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 17, weight: .semibold)) + label.font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 17, weight: .regular)) label.textColor = Asset.Colors.Label.primary.color label.numberOfLines = 0 return label }() - let separalerLine: UIView = { + let separatorLine: UIView = { let view = UIView() view.backgroundColor = Asset.Theme.System.separator.color return view @@ -54,7 +54,7 @@ extension ServerRulesTableViewCell { indexImageView.translatesAutoresizingMaskIntoConstraints = false contentView.addSubview(indexImageView) NSLayoutConstraint.activate([ - indexImageView.topAnchor.constraint(greaterThanOrEqualTo: contentView.topAnchor, constant: ServerRulesTableViewCell.margin), + indexImageView.topAnchor.constraint(greaterThanOrEqualTo: contentView.topAnchor, constant: 11), indexImageView.leadingAnchor.constraint(equalTo: contentView.readableContentGuide.leadingAnchor), contentView.bottomAnchor.constraint(greaterThanOrEqualTo: indexImageView.bottomAnchor, constant: ServerRulesTableViewCell.margin), indexImageView.centerYAnchor.constraint(equalTo: contentView.centerYAnchor), @@ -65,20 +65,20 @@ extension ServerRulesTableViewCell { ruleLabel.translatesAutoresizingMaskIntoConstraints = false contentView.addSubview(ruleLabel) NSLayoutConstraint.activate([ - ruleLabel.topAnchor.constraint(greaterThanOrEqualTo: contentView.topAnchor, constant: ServerRulesTableViewCell.margin), - ruleLabel.leadingAnchor.constraint(equalTo: indexImageView.trailingAnchor, constant: 16), - ruleLabel.trailingAnchor.constraint(equalTo: contentView.readableContentGuide.trailingAnchor), - contentView.bottomAnchor.constraint(greaterThanOrEqualTo: ruleLabel.bottomAnchor, constant: ServerRulesTableViewCell.margin), + ruleLabel.topAnchor.constraint(greaterThanOrEqualTo: contentView.topAnchor, constant: 11), + ruleLabel.leadingAnchor.constraint(equalTo: indexImageView.trailingAnchor, constant: 14), + ruleLabel.trailingAnchor.constraint(equalTo: contentView.readableContentGuide.trailingAnchor, constant: 16), + contentView.bottomAnchor.constraint(greaterThanOrEqualTo: ruleLabel.bottomAnchor, constant: 11), ruleLabel.centerYAnchor.constraint(equalTo: contentView.centerYAnchor), ]) - separalerLine.translatesAutoresizingMaskIntoConstraints = false - contentView.addSubview(separalerLine) + separatorLine.translatesAutoresizingMaskIntoConstraints = false + contentView.addSubview(separatorLine) NSLayoutConstraint.activate([ - separalerLine.leadingAnchor.constraint(equalTo: contentView.readableContentGuide.leadingAnchor), - separalerLine.trailingAnchor.constraint(equalTo: contentView.readableContentGuide.trailingAnchor), - separalerLine.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), - separalerLine.heightAnchor.constraint(equalToConstant: UIView.separatorLineHeight(of: contentView)).priority(.required - 1), + separatorLine.leadingAnchor.constraint(equalTo: ruleLabel.leadingAnchor), + separatorLine.trailingAnchor.constraint(equalTo: contentView.trailingAnchor), + separatorLine.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), + separatorLine.heightAnchor.constraint(equalToConstant: UIView.separatorLineHeight(of: contentView)).priority(.required - 1), ]) } diff --git a/Mastodon/Scene/Onboarding/ServerRules/MastodonServerRulesViewModel.swift b/Mastodon/Scene/Onboarding/ServerRules/MastodonServerRulesViewModel.swift index 29869be09..945c92522 100644 --- a/Mastodon/Scene/Onboarding/ServerRules/MastodonServerRulesViewModel.swift +++ b/Mastodon/Scene/Onboarding/ServerRules/MastodonServerRulesViewModel.swift @@ -45,10 +45,10 @@ final class MastodonServerRulesViewModel { guard i < 50 else { return NSAttributedString(string: "\(i)" + separatorString + rule.text.trimmingCharacters(in: .whitespacesAndNewlines) + "\n\n") } - let imageName = String(i + 1) + ".circle.fill" + let imageName = String(i + 1) + ".circle" let image = UIImage(systemName: imageName, withConfiguration: configuration)! let attachment = NSTextAttachment() - attachment.image = image.withTintColor(Asset.Colors.Label.primary.color) + attachment.image = image.withTintColor(Asset.Colors.brand.color) let imageAttribute = NSMutableAttributedString(attachment: attachment) imageAttribute.addAttributes([NSAttributedString.Key.baselineOffset : -1.5], range: NSRange(location: 0, length: imageAttribute.length)) diff --git a/Mastodon/Diffable/Onboarding/ServerRuleItem.swift b/Mastodon/Scene/Onboarding/ServerRules/ServerRuleItem.swift similarity index 100% rename from Mastodon/Diffable/Onboarding/ServerRuleItem.swift rename to Mastodon/Scene/Onboarding/ServerRules/ServerRuleItem.swift diff --git a/Mastodon/Diffable/Onboarding/ServerRuleSection.swift b/Mastodon/Scene/Onboarding/ServerRules/ServerRuleSection.swift similarity index 88% rename from Mastodon/Diffable/Onboarding/ServerRuleSection.swift rename to Mastodon/Scene/Onboarding/ServerRules/ServerRuleSection.swift index c13e4ab2c..3ec8bb2dc 100644 --- a/Mastodon/Diffable/Onboarding/ServerRuleSection.swift +++ b/Mastodon/Scene/Onboarding/ServerRules/ServerRuleSection.swift @@ -22,12 +22,12 @@ extension ServerRuleSection { switch item { case .header(let domain): let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: OnboardingHeadlineTableViewCell.self), for: indexPath) as! OnboardingHeadlineTableViewCell - cell.titleLabel.text = L10n.Scene.ServerRules.title 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.fill") ?? UIImage(systemName: "questionmark.circle.fill") + cell.indexImageView.image = UIImage(systemName: "\(ruleContext.index + 1).circle") ?? UIImage(systemName: "questionmark.circle") + cell.indexImageView.tintColor = Asset.Colors.brand.color cell.ruleLabel.text = ruleContext.rule.text return cell }