Skip to content

Commit ec2a594

Browse files
authored
Improve tag filter labels (#1137)
* Cleanup unused code * Improve code * Make TagFilterCell label adjustable
1 parent cf74df6 commit ec2a594

File tree

8 files changed

+199
-272
lines changed

8 files changed

+199
-272
lines changed

Zotero.xcodeproj/project.pbxproj

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -901,8 +901,6 @@
901901
B39C9AB7252B589F00462D27 /* Threading+Extras.swift in Sources */ = {isa = PBXBuildFile; fileRef = B305650423FC051E003304F2 /* Threading+Extras.swift */; };
902902
B39D336823FFD96C00EF2ACB /* Note.swift in Sources */ = {isa = PBXBuildFile; fileRef = B39D336723FFD96C00EF2ACB /* Note.swift */; };
903903
B39D33712400150B00EF2ACB /* CreateAttachmentsDbRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B39D33702400150B00EF2ACB /* CreateAttachmentsDbRequest.swift */; };
904-
B39D42D229BF84FA0035CDA9 /* TagFilterContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B39D42D129BF84FA0035CDA9 /* TagFilterContentView.swift */; };
905-
B39D42D429BF85930035CDA9 /* TagFilterContentView.xib in Resources */ = {isa = PBXBuildFile; fileRef = B39D42D329BF85930035CDA9 /* TagFilterContentView.xib */; };
906904
B39D42D929C0B82F0035CDA9 /* TagFilterCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B39D42D729C0B82F0035CDA9 /* TagFilterCell.swift */; };
907905
B39D42DA29C0B82F0035CDA9 /* TagFilterCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = B39D42D829C0B82F0035CDA9 /* TagFilterCell.xib */; };
908906
B39D42DF29C0CE7D0035CDA9 /* TagsFlowLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = B39D42DE29C0CE7D0035CDA9 /* TagsFlowLayout.swift */; };
@@ -1962,8 +1960,6 @@
19621960
B39C7BDD251237D600C2CCF1 /* ReadUpdatedItemUpdateParametersSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReadUpdatedItemUpdateParametersSpec.swift; sourceTree = "<group>"; };
19631961
B39D336723FFD96C00EF2ACB /* Note.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Note.swift; sourceTree = "<group>"; };
19641962
B39D33702400150B00EF2ACB /* CreateAttachmentsDbRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateAttachmentsDbRequest.swift; sourceTree = "<group>"; };
1965-
B39D42D129BF84FA0035CDA9 /* TagFilterContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagFilterContentView.swift; sourceTree = "<group>"; };
1966-
B39D42D329BF85930035CDA9 /* TagFilterContentView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = TagFilterContentView.xib; sourceTree = "<group>"; };
19671963
B39D42D729C0B82F0035CDA9 /* TagFilterCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagFilterCell.swift; sourceTree = "<group>"; };
19681964
B39D42D829C0B82F0035CDA9 /* TagFilterCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = TagFilterCell.xib; sourceTree = "<group>"; };
19691965
B39D42DE29C0CE7D0035CDA9 /* TagsFlowLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagsFlowLayout.swift; sourceTree = "<group>"; };
@@ -2903,8 +2899,6 @@
29032899
children = (
29042900
B39D42D729C0B82F0035CDA9 /* TagFilterCell.swift */,
29052901
B39D42D829C0B82F0035CDA9 /* TagFilterCell.xib */,
2906-
B39D42D129BF84FA0035CDA9 /* TagFilterContentView.swift */,
2907-
B39D42D329BF85930035CDA9 /* TagFilterContentView.xib */,
29082902
B30A44AD29B88E7200332B4E /* TagFilterViewController.swift */,
29092903
B39D42DE29C0CE7D0035CDA9 /* TagsFlowLayout.swift */,
29102904
);
@@ -4682,7 +4676,6 @@
46824676
B3F9A4C12B04CED600684030 /* ReaderSettingsSegmentedCellContentView.xib in Resources */,
46834677
B3E1BECA254B0B9500D9BB27 /* ItemDetailFieldEditContentView.xib in Resources */,
46844678
B30B550524B85A6200F94B59 /* Images.xcassets in Resources */,
4685-
B39D42D429BF85930035CDA9 /* TagFilterContentView.xib in Resources */,
46864679
B3C9D60624DA921B003EA1EE /* CollectionsSearchViewController.xib in Resources */,
46874680
B3593AD824B601AB00CA0B57 /* PDFSearchCell.xib in Resources */,
46884681
B3F0C3FE250A1DB8002D557A /* LibraryCell.xib in Resources */,
@@ -5321,7 +5314,6 @@
53215314
B305667F23FC051F003304F2 /* UIView+Extensions.swift in Sources */,
53225315
B3DCDEE12408F5200039ED0D /* MainViewController.swift in Sources */,
53235316
B3574E3F2AC5C53E009234BE /* HtmlEpubCoordinator.swift in Sources */,
5324-
B39D42D229BF84FA0035CDA9 /* TagFilterContentView.swift in Sources */,
53255317
B30566A923FC051F003304F2 /* File.swift in Sources */,
53265318
B305669B23FC051F003304F2 /* RSearch.swift in Sources */,
53275319
B37AA28C289960FF00A1C643 /* ItemDetailNoteContentView.swift in Sources */,

Zotero/Scenes/Master/TagFiltering/Models/TagFilterState.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ struct TagFilterState: ViewModelState {
4343
var changes: Changes
4444

4545
init(selectedTags: Set<String>, showAutomatic: Bool, displayAll: Bool) {
46-
self.tags = []
47-
self.searchTerm = ""
46+
tags = []
47+
searchTerm = ""
4848
self.selectedTags = selectedTags
4949
self.showAutomatic = showAutomatic
5050
self.displayAll = displayAll
51-
self.changes = []
51+
changes = []
5252
}
5353

5454
mutating func cleanup() {
55-
self.changes = []
56-
self.error = nil
57-
self.automaticCount = nil
55+
changes = []
56+
error = nil
57+
automaticCount = nil
5858
}
5959
}

Zotero/Scenes/Master/TagFiltering/Views/TagFilterCell.swift

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,43 +13,42 @@ class TagFilterCell: UICollectionViewCell {
1313
@IBOutlet private weak var roundBackground: UIView!
1414
@IBOutlet private var maxWidthConstraint: NSLayoutConstraint! {
1515
didSet {
16-
self.maxWidthConstraint.isActive = false
16+
maxWidthConstraint.isActive = false
1717
}
1818
}
1919

2020
var maxWidth: CGFloat? {
2121
didSet {
22-
guard let maxWidth = self.maxWidth else { return }
23-
self.maxWidthConstraint.isActive = true
24-
self.maxWidthConstraint.constant = maxWidth
22+
guard let maxWidth else { return }
23+
maxWidthConstraint.isActive = true
24+
maxWidthConstraint.constant = maxWidth
2525
}
2626
}
2727

2828
override func awakeFromNib() {
2929
super.awakeFromNib()
3030

31-
self.roundBackground.layer.masksToBounds = true
32-
self.roundBackground.layer.borderWidth = 1
33-
self.roundBackground.layer.borderColor = Asset.Colors.zoteroBlueWithDarkMode.color.cgColor
34-
self.roundBackground.backgroundColor = Asset.Colors.zoteroBlueWithDarkMode.color.withAlphaComponent(0.25)
31+
roundBackground.layer.masksToBounds = true
32+
roundBackground.layer.borderWidth = 1
33+
roundBackground.layer.borderColor = Asset.Colors.zoteroBlueWithDarkMode.color.cgColor
34+
roundBackground.backgroundColor = Asset.Colors.zoteroBlueWithDarkMode.color.withAlphaComponent(0.25)
3535
}
3636

3737
override func layoutSubviews() {
3838
super.layoutSubviews()
39-
40-
self.roundBackground.layer.cornerRadius = self.frame.height / 2
39+
roundBackground.layer.cornerRadius = frame.height / 2
4140
}
4241

4342
func set(selected: Bool) {
44-
self.roundBackground.isHidden = !selected
43+
roundBackground.isHidden = !selected
4544
}
4645

4746
func setup(with text: String, color: UIColor, bolded: Bool, isActive: Bool) {
48-
self.label.text = text
49-
self.label.textColor = color
50-
self.label.alpha = isActive ? 1 : 0.55
51-
self.label.font = .preferredFont(for: .body, weight: bolded ? .medium : .regular)
52-
self.roundBackground.isHidden = !self.isSelected
53-
self.roundBackground.alpha = isActive ? 1 : 0.55
47+
label.text = text
48+
label.textColor = color
49+
label.alpha = isActive ? 1 : 0.55
50+
label.font = .preferredFont(for: .body, weight: bolded ? .medium : .regular)
51+
roundBackground.isHidden = !isSelected
52+
roundBackground.alpha = isActive ? 1 : 0.55
5453
}
5554
}

Zotero/Scenes/Master/TagFiltering/Views/TagFilterCell.xib

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="24093.7" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
33
<device id="retina6_12" orientation="portrait" appearance="light"/>
44
<dependencies>
55
<deployment identifier="iOS"/>
6-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="24053.1"/>
77
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
88
<capability name="System colors in document resources" minToolsVersion="11.0"/>
99
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@@ -28,7 +28,7 @@
2828
<rect key="frame" x="0.0" y="0.0" width="251" height="125"/>
2929
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
3030
</view>
31-
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="1000" verticalHuggingPriority="1000" verticalCompressionResistancePriority="1000" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Xfu-oS-B9K">
31+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="1000" verticalHuggingPriority="1000" verticalCompressionResistancePriority="1000" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Xfu-oS-B9K">
3232
<rect key="frame" x="12" y="4" width="227" height="117"/>
3333
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
3434
<nil key="textColor"/>

Zotero/Scenes/Master/TagFiltering/Views/TagFilterContentView.swift

Lines changed: 0 additions & 18 deletions
This file was deleted.

Zotero/Scenes/Master/TagFiltering/Views/TagFilterContentView.xib

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)