@@ -1,28 +0,0 @@
|
||||
import UIKit
|
||||
|
||||
final class ColorDotView: UIView {
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
layer.borderWidth = 1
|
||||
updateBorder()
|
||||
}
|
||||
|
||||
@available(*, unavailable)
|
||||
required init?(coder: NSCoder) { fatalError() }
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
layer.cornerRadius = bounds.width / 2
|
||||
}
|
||||
|
||||
override func traitCollectionDidChange(_ previous: UITraitCollection?) {
|
||||
super.traitCollectionDidChange(previous)
|
||||
if traitCollection.hasDifferentColorAppearance(comparedTo: previous) {
|
||||
updateBorder()
|
||||
}
|
||||
}
|
||||
|
||||
private func updateBorder() {
|
||||
layer.borderColor = UIColor.label.withAlphaComponent(0.15).cgColor
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ import UIKit
|
||||
|
||||
final class WordCardCell: UITableViewCell {
|
||||
private let cardView = UIView()
|
||||
private let colorDot = ColorDotView()
|
||||
private let wordLabel = UILabel()
|
||||
private let phoneticLabel = UILabel()
|
||||
private let meaningLabel = UILabel()
|
||||
@@ -34,19 +33,7 @@ final class WordCardCell: UITableViewCell {
|
||||
meaningLabel.font = .preferredFont(forTextStyle: .subheadline)
|
||||
meaningLabel.textColor = .secondaryLabel
|
||||
|
||||
let wordRowSpacer = UIView()
|
||||
wordRowSpacer.setContentHuggingPriority(.init(1), for: .horizontal)
|
||||
let wordRow = UIStackView(arrangedSubviews: [wordLabel, colorDot, wordRowSpacer])
|
||||
wordRow.axis = .horizontal
|
||||
wordRow.alignment = .center
|
||||
wordRow.spacing = 8
|
||||
colorDot.translatesAutoresizingMaskIntoConstraints = false
|
||||
NSLayoutConstraint.activate([
|
||||
colorDot.widthAnchor.constraint(equalToConstant: 12),
|
||||
colorDot.heightAnchor.constraint(equalToConstant: 12)
|
||||
])
|
||||
|
||||
let textStack = UIStackView(arrangedSubviews: [wordRow, phoneticLabel, meaningLabel])
|
||||
let textStack = UIStackView(arrangedSubviews: [wordLabel, phoneticLabel, meaningLabel])
|
||||
textStack.axis = .vertical
|
||||
textStack.spacing = 8
|
||||
|
||||
@@ -81,8 +68,6 @@ final class WordCardCell: UITableViewCell {
|
||||
wordLabel.text = word.word
|
||||
phoneticLabel.text = word.phonetic
|
||||
meaningLabel.text = word.meaning
|
||||
colorDot.backgroundColor = word.color
|
||||
colorDot.isHidden = word.color == nil
|
||||
updateSpeakerState()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user