Skip to content

Commit

Permalink
#538, #539, & #540 | PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Morgan committed Apr 11, 2022
1 parent baaa037 commit 0d1846a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 44 deletions.
8 changes: 4 additions & 4 deletions Vocable.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
A9E665A7241A785F00FE577A /* CarouselGridCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9E665A6241A785F00FE577A /* CarouselGridCollectionViewController.swift */; };
A9F56FC824365BE8008162B6 /* SpeakFunctionKeyboardKeyCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9F56FC724365BE8008162B6 /* SpeakFunctionKeyboardKeyCollectionViewCell.xib */; };
A9FD68A528008AD3006ABA3F /* AddPhraseCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9FD68A428008AD3006ABA3F /* AddPhraseCollectionViewCell.swift */; };
A9FD68A728009646006ABA3F /* AttributedString+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9FD68A628009646006ABA3F /* AttributedString+Helpers.swift */; };
A9FD68A728009646006ABA3F /* NSAttributedString+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9FD68A628009646006ABA3F /* NSAttributedString+Helpers.swift */; };
B838200F23F4B011005A79CD /* VocableCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B838200E23F4B011005A79CD /* VocableCollectionViewCell.swift */; };
B879831523E0DA8300DC1A81 /* PresetItemCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B879831323E0DA8300DC1A81 /* PresetItemCollectionViewCell.swift */; };
B8DA9DE823EB833200FEBE19 /* BorderedView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8DA9DE723EB833200FEBE19 /* BorderedView.swift */; };
Expand Down Expand Up @@ -403,7 +403,7 @@
A9E665A6241A785F00FE577A /* CarouselGridCollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarouselGridCollectionViewController.swift; sourceTree = "<group>"; };
A9F56FC724365BE8008162B6 /* SpeakFunctionKeyboardKeyCollectionViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SpeakFunctionKeyboardKeyCollectionViewCell.xib; sourceTree = "<group>"; };
A9FD68A428008AD3006ABA3F /* AddPhraseCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddPhraseCollectionViewCell.swift; sourceTree = "<group>"; };
A9FD68A628009646006ABA3F /* AttributedString+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AttributedString+Helpers.swift"; sourceTree = "<group>"; };
A9FD68A628009646006ABA3F /* NSAttributedString+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSAttributedString+Helpers.swift"; sourceTree = "<group>"; };
B838200E23F4B011005A79CD /* VocableCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VocableCollectionViewCell.swift; sourceTree = "<group>"; };
B879831323E0DA8300DC1A81 /* PresetItemCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PresetItemCollectionViewCell.swift; sourceTree = "<group>"; };
B8D55689242FE8B900B0F6FE /* Phrases v2.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Phrases v2.xcdatamodel"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -846,7 +846,7 @@
6B5C743F27E8CBBE00004713 /* VocableListCell */,
A91030B727E3C4FD00281C97 /* NSLayoutConstraint+Priority.swift */,
6B05020527F3516F000CFE5A /* CategoryReordering */,
A9FD68A628009646006ABA3F /* AttributedString+Helpers.swift */,
A9FD68A628009646006ABA3F /* NSAttributedString+Helpers.swift */,
);
path = Common;
sourceTree = "<group>";
Expand Down Expand Up @@ -1199,7 +1199,7 @@
6B1C7F3223F5BB5200BB3FD9 /* HeadGazeTrackingInterpolator.swift in Sources */,
64D04A58242951C00006962D /* GazeableAlertPresentationController.swift in Sources */,
64599431258938F50010EEFF /* ListeningResponseViewController.swift in Sources */,
A9FD68A728009646006ABA3F /* AttributedString+Helpers.swift in Sources */,
A9FD68A728009646006ABA3F /* NSAttributedString+Helpers.swift in Sources */,
6BD84F9D2604F8F600D4CD3E /* ListenModeDebugView.swift in Sources */,
6B8A6E3324536085004B5220 /* UIHeadGazeCursorWindow.swift in Sources */,
6B0501FE27EBA471000CFE5A /* VocableListCellAction.swift in Sources */,
Expand Down
57 changes: 19 additions & 38 deletions Vocable/Common/AddPhraseCollectionViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,9 @@
import UIKit

class AddPhraseCollectionViewCell: VocableCollectionViewCell {
let textLabel = UILabel(frame: .zero)
private let textLabel = UILabel(frame: .zero)

let dashedBorderView = CAShapeLayer()

override func updateContentViews() {
super.updateContentViews()

if isHighlighted && !isSelected {
dashedBorderView.strokeColor = UIColor.cellBorderHighlightColor.cgColor
} else if isSelected {
dashedBorderView.strokeColor = nil
} else {
dashedBorderView.strokeColor = UIColor.categoryBackgroundColor.cgColor
}

textLabel.textColor = isSelected ? .selectedTextColor : .defaultTextColor
dashedBorderView.fillColor = isSelected ? UIColor.cellSelectionColor.cgColor : nil
}
private let dashedBorderView = CAShapeLayer()

override init(frame: CGRect) {
super.init(frame: frame)
Expand Down Expand Up @@ -61,11 +46,9 @@ class AddPhraseCollectionViewCell: VocableCollectionViewCell {

// Needs a weak spot that can break while resizing to avoid
// constraint errors
let rightConstraint = textLabel.rightAnchor.constraint(equalTo: contentView.layoutMarginsGuide.rightAnchor)
rightConstraint.priority = .init(999)
let rightConstraint = textLabel.rightAnchor.constraint(equalTo: contentView.layoutMarginsGuide.rightAnchor).withPriority(999)
let bottomConstraint = textLabel.bottomAnchor.constraint(equalTo: contentView.layoutMarginsGuide.bottomAnchor).withPriority(999)

let bottomConstraint = textLabel.bottomAnchor.constraint(equalTo: contentView.layoutMarginsGuide.bottomAnchor)
bottomConstraint.priority = .init(999)
NSLayoutConstraint.activate([
rightConstraint,
textLabel.topAnchor.constraint(equalTo: contentView.layoutMarginsGuide.topAnchor),
Expand All @@ -76,27 +59,25 @@ class AddPhraseCollectionViewCell: VocableCollectionViewCell {
updateContentViews()
}

override func layoutSubviews() {
super.layoutSubviews()
dashedBorderView.frame = bounds
dashedBorderView.path = UIBezierPath(roundedRect: bounds, cornerRadius: 8).cgPath
}

func setup(title: String) {
textLabel.text = title
updateContentViews()
}
override func updateContentViews() {
super.updateContentViews()

func setup(with image: UIImage?) {
guard let image = image else {
return
if isHighlighted && !isSelected {
dashedBorderView.strokeColor = UIColor.cellBorderHighlightColor.cgColor
} else if isSelected {
dashedBorderView.strokeColor = nil
} else {
dashedBorderView.strokeColor = UIColor.categoryBackgroundColor.cgColor
}

let systemImageAttachment = NSTextAttachment(image: image)
let attributedString = NSAttributedString(attachment: systemImageAttachment)
textLabel.textColor = isSelected ? .selectedTextColor : .defaultTextColor
dashedBorderView.fillColor = isSelected ? UIColor.cellSelectionColor.cgColor : nil
}

textLabel.attributedText = attributedString
updateContentViews()
override func layoutSubviews() {
super.layoutSubviews()
dashedBorderView.frame = bounds
dashedBorderView.path = UIBezierPath(roundedRect: bounds, cornerRadius: 8).cgPath
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// AttributedString+Helpers.swift
// NSAttributedString+Helpers.swift
// Vocable
//
// Created by Jesse Morgan on 4/8/22.
Expand Down
2 changes: 1 addition & 1 deletion Vocable/Features/Root/CategoryDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CategoryDetailViewController: PagingCarouselViewController, NSFetchedResul

private var disposables = Set<AnyCancellable>()

enum CategoryItem: Hashable {
private enum CategoryItem: Hashable {
case persistedPhrase(NSManagedObjectID)
case addNewPhrase
}
Expand Down

0 comments on commit 0d1846a

Please sign in to comment.