Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 966cb1a

Browse files
Huddiernystrom
authored andcommitted
Load Consistency (#2159)
* Combine 2 load cells into 1 * Fixed load more in BaseViewController * Switch if-else to ternary
1 parent 6974a75 commit 966cb1a

File tree

5 files changed

+24
-74
lines changed

5 files changed

+24
-74
lines changed

Classes/Issues/NeckLoad/IssueNeckLoadCell.swift

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

Classes/Issues/NeckLoad/IssueNeckLoadSectionController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ final class IssueNeckLoadSectionController: ListSectionController {
2828
}
2929

3030
override func cellForItem(at index: Int) -> UICollectionViewCell {
31-
guard let cell = collectionContext?.dequeueReusableCell(of: IssueNeckLoadCell.self, for: self, at: index) as? IssueNeckLoadCell
31+
guard let cell = collectionContext?.dequeueReusableCell(of: LoadMoreCell.self, for: self, at: index) as? LoadMoreCell
3232
else { fatalError("Missing collection context, cell incorrect type, or object missing") }
3333
cell.configure(loading: loadingOverride)
3434
return cell

Classes/Section Controllers/LoadMore/LoadMoreCell.swift

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,46 +10,50 @@ import UIKit
1010
import SnapKit
1111
import IGListKit
1212

13-
final class LoadMoreCell: UICollectionViewCell {
14-
13+
final class LoadMoreCell: SelectableCell {
14+
15+
private let activity = UIActivityIndicatorView(activityIndicatorStyle: .gray)
1516
private let label = UILabel()
16-
17+
1718
override init(frame: CGRect) {
1819
super.init(frame: frame)
19-
20+
2021
accessibilityTraits |= UIAccessibilityTraitButton
2122
isAccessibilityElement = true
2223
label.font = Styles.Text.button.preferredFont
23-
label.textColor = Styles.Colors.Gray.light.color
24+
label.textColor = Styles.Colors.Blue.light.color
2425
contentView.addSubview(label)
2526
label.snp.makeConstraints { make in
2627
make.center.equalTo(contentView)
2728
}
29+
30+
activity.hidesWhenStopped = true
31+
contentView.addSubview(activity)
32+
activity.snp.makeConstraints { make in
33+
make.center.equalTo(contentView)
34+
}
2835
label.text = NSLocalizedString("Load More", comment: "")
2936
}
30-
37+
3138
required init?(coder aDecoder: NSCoder) {
3239
fatalError("init(coder:) has not been implemented")
3340
}
34-
41+
3542
override func layoutSubviews() {
3643
super.layoutSubviews()
3744
layoutContentViewForSafeAreaInsets()
3845
}
39-
46+
4047
override var accessibilityLabel: String? {
4148
get { return NSLocalizedString("Load More", comment: "") }
4249
set { }
4350
}
44-
45-
override var isSelected: Bool {
46-
didSet {
47-
if isSelected {
48-
label.alpha = 0.5
49-
} else {
50-
label.alpha = 1
51-
}
52-
}
53-
}
5451

52+
53+
func configure(loading: Bool) {
54+
label.isHidden = loading
55+
loading
56+
? activity.startAnimating()
57+
: activity.stopAnimating()
58+
}
5559
}

Classes/Section Controllers/LoadMore/LoadMoreSectionController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ final class LoadMoreSectionController: ListSectionController {
2727
}
2828

2929
override func cellForItem(at index: Int) -> UICollectionViewCell {
30-
guard let cell = collectionContext?.dequeueReusableCell(of: IssueNeckLoadCell.self, for: self, at: index) as? IssueNeckLoadCell else {
30+
guard let cell = collectionContext?.dequeueReusableCell(of: LoadMoreCell.self, for: self, at: index) as? LoadMoreCell else {
3131
fatalError("Missing context, or cell is wrong type")
3232
}
3333
cell.configure(loading: loadingOverride)

Freetime.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,6 @@
384384
29F3A18C20CD790F00645CB7 /* UIViewController+CommonActionItems.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29F3A18B20CD790F00645CB7 /* UIViewController+CommonActionItems.swift */; };
385385
29F7F05C1F2A751B00F6075D /* IssueResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29F7F05B1F2A751B00F6075D /* IssueResult.swift */; };
386386
29F7F05F1F2A839100F6075D /* IssueNeckLoadSectionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29F7F05E1F2A839100F6075D /* IssueNeckLoadSectionController.swift */; };
387-
29F7F0611F2A83AA00F6075D /* IssueNeckLoadCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29F7F0601F2A83AA00F6075D /* IssueNeckLoadCell.swift */; };
388387
29F7F0631F2A875C00F6075D /* IssueNeckLoadModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29F7F0621F2A875C00F6075D /* IssueNeckLoadModel.swift */; };
389388
29FB942C1EE750DB0016E6D4 /* IssueLabeledModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29FB942B1EE750DB0016E6D4 /* IssueLabeledModel.swift */; };
390389
29FB942E1EE751F70016E6D4 /* IssueLabeledSectionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29FB942D1EE751F70016E6D4 /* IssueLabeledSectionController.swift */; };
@@ -909,7 +908,6 @@
909908
29F3A18B20CD790F00645CB7 /* UIViewController+CommonActionItems.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+CommonActionItems.swift"; sourceTree = "<group>"; };
910909
29F7F05B1F2A751B00F6075D /* IssueResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IssueResult.swift; sourceTree = "<group>"; };
911910
29F7F05E1F2A839100F6075D /* IssueNeckLoadSectionController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IssueNeckLoadSectionController.swift; sourceTree = "<group>"; };
912-
29F7F0601F2A83AA00F6075D /* IssueNeckLoadCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IssueNeckLoadCell.swift; sourceTree = "<group>"; };
913911
29F7F0621F2A875C00F6075D /* IssueNeckLoadModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IssueNeckLoadModel.swift; sourceTree = "<group>"; };
914912
29FB942B1EE750DB0016E6D4 /* IssueLabeledModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IssueLabeledModel.swift; sourceTree = "<group>"; };
915913
29FB942D1EE751F70016E6D4 /* IssueLabeledSectionController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IssueLabeledSectionController.swift; sourceTree = "<group>"; };
@@ -1930,7 +1928,6 @@
19301928
29F7F05D1F2A833E00F6075D /* NeckLoad */ = {
19311929
isa = PBXGroup;
19321930
children = (
1933-
29F7F0601F2A83AA00F6075D /* IssueNeckLoadCell.swift */,
19341931
29F7F0621F2A875C00F6075D /* IssueNeckLoadModel.swift */,
19351932
29F7F05E1F2A839100F6075D /* IssueNeckLoadSectionController.swift */,
19361933
);
@@ -2832,7 +2829,6 @@
28322829
29BBD82920CAC7D5004D62FE /* NotificationViewModel.swift in Sources */,
28332830
299F63E2205DE1470015D901 /* UIView+DateDetails.swift in Sources */,
28342831
9870B9031FC73EE70009719C /* Secrets.swift in Sources */,
2835-
29F7F0611F2A83AA00F6075D /* IssueNeckLoadCell.swift in Sources */,
28362832
29A5AF451F9298360065D529 /* GitHubClient+Repository.swift in Sources */,
28372833
29F7F0631F2A875C00F6075D /* IssueNeckLoadModel.swift in Sources */,
28382834
2946FA5120367FC100C37435 /* GithubClient+Merge.swift in Sources */,

0 commit comments

Comments
 (0)