Get rid of highlight-indicator (#690)
This commit is contained in:
parent
fc25e12e05
commit
185a3f5aa4
|
@ -1203,6 +1203,8 @@
|
||||||
DB1FD43525F26899004CFCFC /* MastodonPickServerViewModel+LoadIndexedServerState.swift */,
|
DB1FD43525F26899004CFCFC /* MastodonPickServerViewModel+LoadIndexedServerState.swift */,
|
||||||
DB1FD44325F26CCC004CFCFC /* PickServerSection.swift */,
|
DB1FD44325F26CCC004CFCFC /* PickServerSection.swift */,
|
||||||
DB1E347725F519300079D7DF /* PickServerItem.swift */,
|
DB1E347725F519300079D7DF /* PickServerItem.swift */,
|
||||||
|
DB1E346725F518E20079D7DF /* CategoryPickerSection.swift */,
|
||||||
|
DB1FD45925F27898004CFCFC /* CategoryPickerItem.swift */,
|
||||||
);
|
);
|
||||||
path = PickServer;
|
path = PickServer;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -1907,8 +1909,6 @@
|
||||||
DB4F097826A039B400D62E92 /* Onboarding */ = {
|
DB4F097826A039B400D62E92 /* Onboarding */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
DB1E346725F518E20079D7DF /* CategoryPickerSection.swift */,
|
|
||||||
DB1FD45925F27898004CFCFC /* CategoryPickerItem.swift */,
|
|
||||||
DB0618022785A7100030EE79 /* RegisterSection.swift */,
|
DB0618022785A7100030EE79 /* RegisterSection.swift */,
|
||||||
DB0618042785A73D0030EE79 /* RegisterItem.swift */,
|
DB0618042785A73D0030EE79 /* RegisterItem.swift */,
|
||||||
);
|
);
|
||||||
|
|
|
@ -18,41 +18,6 @@ enum CategoryPickerItem {
|
||||||
|
|
||||||
extension 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 {
|
var title: String {
|
||||||
switch self {
|
switch self {
|
||||||
case .all:
|
case .all:
|
|
@ -23,7 +23,7 @@ extension CategoryPickerSection {
|
||||||
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: String(describing: PickServerCategoryCollectionViewCell.self), for: indexPath) as! PickServerCategoryCollectionViewCell
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: String(describing: PickServerCategoryCollectionViewCell.self), for: indexPath) as! PickServerCategoryCollectionViewCell
|
||||||
cell.categoryView.titleLabel.text = item.title
|
cell.categoryView.titleLabel.text = item.title
|
||||||
cell.observe(\.isSelected, options: [.initial, .new]) { cell, _ in
|
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
|
cell.categoryView.titleLabel.textColor = cell.isSelected ? Asset.Colors.Label.primary.color : Asset.Colors.Label.secondary.color
|
||||||
}
|
}
|
||||||
.store(in: &cell.observations)
|
.store(in: &cell.observations)
|
|
@ -12,51 +12,49 @@ import MastodonUI
|
||||||
import MastodonLocalization
|
import MastodonLocalization
|
||||||
|
|
||||||
class PickServerCategoryView: UIView {
|
class PickServerCategoryView: UIView {
|
||||||
|
|
||||||
let highlightedIndicatorView: UIView = {
|
|
||||||
let view = UIView()
|
|
||||||
view.backgroundColor = Asset.Colors.Label.primary.color
|
|
||||||
return view
|
|
||||||
}()
|
|
||||||
|
|
||||||
let titleLabel: UILabel = {
|
let titleLabel: UILabel = {
|
||||||
let label = UILabel()
|
let label = UILabel()
|
||||||
label.textAlignment = .center
|
label.textAlignment = .center
|
||||||
label.font = .systemFont(ofSize: 17, weight: .semibold)
|
label.font = .systemFont(ofSize: 15, weight: .semibold)
|
||||||
label.textColor = Asset.Colors.Label.secondary.color
|
label.textColor = Asset.Colors.Label.secondary.color
|
||||||
return label
|
return label
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
//TODO: @zeitschlag add chevron
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
super.init(frame: .zero)
|
super.init(frame: .zero)
|
||||||
configure()
|
_init()
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder: NSCoder) {
|
||||||
super.init(coder: coder)
|
super.init(coder: coder)
|
||||||
configure()
|
_init()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
extension PickServerCategoryView {
|
private func _init() {
|
||||||
|
|
||||||
private func configure() {
|
|
||||||
let container = UIStackView()
|
let container = UIStackView()
|
||||||
container.axis = .vertical
|
container.axis = .horizontal
|
||||||
container.spacing = 2
|
container.spacing = 4
|
||||||
container.distribution = .fillProportionally
|
container.distribution = .fillProportionally
|
||||||
|
|
||||||
container.translatesAutoresizingMaskIntoConstraints = false
|
container.translatesAutoresizingMaskIntoConstraints = false
|
||||||
addSubview(container)
|
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)
|
container.addArrangedSubview(titleLabel)
|
||||||
highlightedIndicatorView.translatesAutoresizingMaskIntoConstraints = false
|
|
||||||
container.addArrangedSubview(highlightedIndicatorView)
|
layer.borderColor = UIColor.black.cgColor
|
||||||
NSLayoutConstraint.activate([
|
layer.borderWidth = 1.0
|
||||||
highlightedIndicatorView.heightAnchor.constraint(equalToConstant: 3)//.priority(.required - 1),
|
applyCornerRadius(radius: 15)
|
||||||
])
|
|
||||||
titleLabel.setContentHuggingPriority(.required - 1, for: .vertical)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue