Get rid of highlight-indicator (#690)

This commit is contained in:
Nathan Mattes 2022-12-14 23:18:47 +01:00
parent fc25e12e05
commit 185a3f5aa4
4 changed files with 23 additions and 60 deletions

View File

@ -1203,6 +1203,8 @@
DB1FD43525F26899004CFCFC /* MastodonPickServerViewModel+LoadIndexedServerState.swift */,
DB1FD44325F26CCC004CFCFC /* PickServerSection.swift */,
DB1E347725F519300079D7DF /* PickServerItem.swift */,
DB1E346725F518E20079D7DF /* CategoryPickerSection.swift */,
DB1FD45925F27898004CFCFC /* CategoryPickerItem.swift */,
);
path = PickServer;
sourceTree = "<group>";
@ -1907,8 +1909,6 @@
DB4F097826A039B400D62E92 /* Onboarding */ = {
isa = PBXGroup;
children = (
DB1E346725F518E20079D7DF /* CategoryPickerSection.swift */,
DB1FD45925F27898004CFCFC /* CategoryPickerItem.swift */,
DB0618022785A7100030EE79 /* RegisterSection.swift */,
DB0618042785A73D0030EE79 /* RegisterItem.swift */,
);

View File

@ -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:

View File

@ -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)

View File

@ -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)
}
}