From 185a3f5aa479b0b8d657d259ba27db645ae41b6f Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Wed, 14 Dec 2022 23:18:47 +0100 Subject: [PATCH] Get rid of highlight-indicator (#690) --- Mastodon.xcodeproj/project.pbxproj | 4 +- .../PickServer}/CategoryPickerItem.swift | 35 ---------------- .../PickServer}/CategoryPickerSection.swift | 2 +- .../View/PickServerCategoryView.swift | 42 +++++++++---------- 4 files changed, 23 insertions(+), 60 deletions(-) rename Mastodon/{Diffable/Onboarding => Scene/Onboarding/PickServer}/CategoryPickerItem.swift (81%) rename Mastodon/{Diffable/Onboarding => Scene/Onboarding/PickServer}/CategoryPickerSection.swift (93%) diff --git a/Mastodon.xcodeproj/project.pbxproj b/Mastodon.xcodeproj/project.pbxproj index 39fced246..f9b05362f 100644 --- a/Mastodon.xcodeproj/project.pbxproj +++ b/Mastodon.xcodeproj/project.pbxproj @@ -1203,6 +1203,8 @@ DB1FD43525F26899004CFCFC /* MastodonPickServerViewModel+LoadIndexedServerState.swift */, DB1FD44325F26CCC004CFCFC /* PickServerSection.swift */, DB1E347725F519300079D7DF /* PickServerItem.swift */, + DB1E346725F518E20079D7DF /* CategoryPickerSection.swift */, + DB1FD45925F27898004CFCFC /* CategoryPickerItem.swift */, ); path = PickServer; sourceTree = ""; @@ -1907,8 +1909,6 @@ DB4F097826A039B400D62E92 /* Onboarding */ = { isa = PBXGroup; children = ( - DB1E346725F518E20079D7DF /* CategoryPickerSection.swift */, - DB1FD45925F27898004CFCFC /* CategoryPickerItem.swift */, DB0618022785A7100030EE79 /* RegisterSection.swift */, DB0618042785A73D0030EE79 /* RegisterItem.swift */, ); diff --git a/Mastodon/Diffable/Onboarding/CategoryPickerItem.swift b/Mastodon/Scene/Onboarding/PickServer/CategoryPickerItem.swift similarity index 81% rename from Mastodon/Diffable/Onboarding/CategoryPickerItem.swift rename to Mastodon/Scene/Onboarding/PickServer/CategoryPickerItem.swift index f6f364108..a860e2e15 100644 --- a/Mastodon/Diffable/Onboarding/CategoryPickerItem.swift +++ b/Mastodon/Scene/Onboarding/PickServer/CategoryPickerItem.swift @@ -18,41 +18,6 @@ enum CategoryPickerItem { extension CategoryPickerItem { - var emoji: String { - switch self { - case .all: - return "💬" - case .category(let category): - switch category.category { - case .academia: - return "📚" - case .activism: - return "✊" - case .food: - return "🍕" - case .furry: - return "🦁" - case .games: - return "🕹" - case .general: - return "🐘" - case .journalism: - return "📰" - case .lgbt: - return "🏳️‍🌈" - case .regional: - return "📍" - case .art: - return "🎨" - case .music: - return "🎼" - case .tech: - return "📱" - case ._other: - return "❓" - } - } - } var title: String { switch self { case .all: diff --git a/Mastodon/Diffable/Onboarding/CategoryPickerSection.swift b/Mastodon/Scene/Onboarding/PickServer/CategoryPickerSection.swift similarity index 93% rename from Mastodon/Diffable/Onboarding/CategoryPickerSection.swift rename to Mastodon/Scene/Onboarding/PickServer/CategoryPickerSection.swift index 191d4d166..d43c676b7 100644 --- a/Mastodon/Diffable/Onboarding/CategoryPickerSection.swift +++ b/Mastodon/Scene/Onboarding/PickServer/CategoryPickerSection.swift @@ -23,7 +23,7 @@ extension CategoryPickerSection { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: String(describing: PickServerCategoryCollectionViewCell.self), for: indexPath) as! PickServerCategoryCollectionViewCell cell.categoryView.titleLabel.text = item.title cell.observe(\.isSelected, options: [.initial, .new]) { cell, _ in - cell.categoryView.highlightedIndicatorView.alpha = cell.isSelected ? 1 : 0 +// cell.categoryView.highlightedIndicatorView.alpha = cell.isSelected ? 1 : 0 cell.categoryView.titleLabel.textColor = cell.isSelected ? Asset.Colors.Label.primary.color : Asset.Colors.Label.secondary.color } .store(in: &cell.observations) diff --git a/Mastodon/Scene/Onboarding/PickServer/View/PickServerCategoryView.swift b/Mastodon/Scene/Onboarding/PickServer/View/PickServerCategoryView.swift index aba5a87dc..6c10ad48d 100644 --- a/Mastodon/Scene/Onboarding/PickServer/View/PickServerCategoryView.swift +++ b/Mastodon/Scene/Onboarding/PickServer/View/PickServerCategoryView.swift @@ -12,51 +12,49 @@ import MastodonUI import MastodonLocalization class PickServerCategoryView: UIView { - - let highlightedIndicatorView: UIView = { - let view = UIView() - view.backgroundColor = Asset.Colors.Label.primary.color - return view - }() let titleLabel: UILabel = { let label = UILabel() label.textAlignment = .center - label.font = .systemFont(ofSize: 17, weight: .semibold) + label.font = .systemFont(ofSize: 15, weight: .semibold) label.textColor = Asset.Colors.Label.secondary.color return label }() + + //TODO: @zeitschlag add chevron init() { super.init(frame: .zero) - configure() + _init() } required init?(coder: NSCoder) { super.init(coder: coder) - configure() + _init() } -} -extension PickServerCategoryView { - - private func configure() { + private func _init() { let container = UIStackView() - container.axis = .vertical - container.spacing = 2 + container.axis = .horizontal + container.spacing = 4 container.distribution = .fillProportionally container.translatesAutoresizingMaskIntoConstraints = false addSubview(container) - container.pinToParent() + let constraints = [ + container.topAnchor.constraint(equalTo: topAnchor, constant: 6), + container.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 12), + trailingAnchor.constraint(equalTo: container.trailingAnchor, constant: 12), + bottomAnchor.constraint(equalTo: container.bottomAnchor, constant: 6), + ] + + NSLayoutConstraint.activate(constraints) container.addArrangedSubview(titleLabel) - highlightedIndicatorView.translatesAutoresizingMaskIntoConstraints = false - container.addArrangedSubview(highlightedIndicatorView) - NSLayoutConstraint.activate([ - highlightedIndicatorView.heightAnchor.constraint(equalToConstant: 3)//.priority(.required - 1), - ]) - titleLabel.setContentHuggingPriority(.required - 1, for: .vertical) + + layer.borderColor = UIColor.black.cgColor + layer.borderWidth = 1.0 + applyCornerRadius(radius: 15) } }