Skip to content

Commit

Permalink
#531 | Updating title color when setting attributed text
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Morgan committed Apr 4, 2022
1 parent 61f1c86 commit 155dbcb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
6 changes: 6 additions & 0 deletions Vocable/Common/Views/GazeableButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class GazeableButton: UIButton {
setFillColor(.cellSelectionColor, for: [.selected, .highlighted])
setTitleColor(.collectionViewBackgroundColor, for: .selected)
setTitleColor(.collectionViewBackgroundColor, for: [.selected, .highlighted])
setTitleColor(.white.withAlphaComponent(0.5), for: .disabled)
titleLabel?.numberOfLines = 3
contentEdgeInsets = .init(top: 8, left: 8, bottom: 8, right: 8)
layoutMargins = .zero
Expand Down Expand Up @@ -194,6 +195,11 @@ class GazeableButton: UIButton {
}
}

override func setAttributedTitle(_ title: NSAttributedString?, for state: UIControl.State) {
super.setAttributedTitle(title, for: state)
setTitleColor(titleColor(for: state), for: state)
}

private func updateSelectionAppearance() {

func actions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ struct VocableListContentConfiguration: UIContentConfiguration, Equatable {
accessibilityLabel: String? = nil,
primaryAction: @escaping () -> Void
) {
let attributes: [NSAttributedString.Key: Any] = [.foregroundColor: UIColor.white,
.font: UIFont.systemFont(ofSize: 22, weight: .bold)]
let attributes: [NSAttributedString.Key: Any] = [.font: UIFont.systemFont(ofSize: 22, weight: .bold)]

let attributedText = NSAttributedString(string: title, attributes: attributes)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,17 +256,13 @@ private extension EditPhrasesViewController {
func phraseCellRegistration() ->
UICollectionView.CellRegistration<VocableListCell, Phrase> {
return .init { cell, _, phrase in
let attributes: [NSAttributedString.Key: Any] = [.foregroundColor: UIColor.white,
.font: UIFont.systemFont(ofSize: 22, weight: .bold)]

let attributedText = NSAttributedString(string: phrase.utterance ?? "", attributes: attributes)
let phraseIdentifier = phrase.objectID

let deleteAction = VocableListCellAction.delete { [weak self] in
self?.presentDeletionPromptForPhrase(with: phraseIdentifier)
}

cell.contentConfiguration = VocableListContentConfiguration(attributedText: attributedText,
cell.contentConfiguration = VocableListContentConfiguration(title: phrase.utterance ?? "",
actions: [deleteAction],
accessory: .disclosureIndicator()) { [weak self] in
self?.presentEditorForPhrase(with: phraseIdentifier)
Expand Down

0 comments on commit 155dbcb

Please sign in to comment.