diff --git a/Classes/Issues/NeckLoad/IssueNeckLoadCell.swift b/Classes/Issues/NeckLoad/IssueNeckLoadCell.swift deleted file mode 100644 index f1817c6ef..000000000 --- a/Classes/Issues/NeckLoad/IssueNeckLoadCell.swift +++ /dev/null @@ -1,50 +0,0 @@ -// -// IssueNeckLoadCell.swift -// Freetime -// -// Created by Ryan Nystrom on 7/27/17. -// Copyright © 2017 Ryan Nystrom. All rights reserved. -// - -import UIKit -import SnapKit - -final class IssueNeckLoadCell: SelectableCell { - - private let activity = UIActivityIndicatorView(activityIndicatorStyle: .gray) - private let label = UILabel() - - override init(frame: CGRect) { - super.init(frame: frame) - - label.text = NSLocalizedString("Load More", comment: "") - label.textColor = Styles.Colors.Blue.medium.color - label.font = Styles.Text.secondaryBold.preferredFont - contentView.addSubview(label) - label.snp.makeConstraints { make in - make.center.equalToSuperview() - } - - activity.hidesWhenStopped = true - contentView.addSubview(activity) - activity.snp.makeConstraints { make in - make.center.equalToSuperview() - } - } - - required init?(coder aDecoder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - // MARK: Public API - - func configure(loading: Bool) { - label.isHidden = loading - if loading { - activity.startAnimating() - } else { - activity.stopAnimating() - } - } - -} diff --git a/Classes/Issues/NeckLoad/IssueNeckLoadSectionController.swift b/Classes/Issues/NeckLoad/IssueNeckLoadSectionController.swift index 7f1fb5222..660b85320 100644 --- a/Classes/Issues/NeckLoad/IssueNeckLoadSectionController.swift +++ b/Classes/Issues/NeckLoad/IssueNeckLoadSectionController.swift @@ -28,7 +28,7 @@ final class IssueNeckLoadSectionController: ListSectionController { } override func cellForItem(at index: Int) -> UICollectionViewCell { - guard let cell = collectionContext?.dequeueReusableCell(of: IssueNeckLoadCell.self, for: self, at: index) as? IssueNeckLoadCell + guard let cell = collectionContext?.dequeueReusableCell(of: LoadMoreCell.self, for: self, at: index) as? LoadMoreCell else { fatalError("Missing collection context, cell incorrect type, or object missing") } cell.configure(loading: loadingOverride) return cell diff --git a/Classes/Section Controllers/LoadMore/LoadMoreCell.swift b/Classes/Section Controllers/LoadMore/LoadMoreCell.swift index f17715080..a43cc9126 100644 --- a/Classes/Section Controllers/LoadMore/LoadMoreCell.swift +++ b/Classes/Section Controllers/LoadMore/LoadMoreCell.swift @@ -10,46 +10,50 @@ import UIKit import SnapKit import IGListKit -final class LoadMoreCell: UICollectionViewCell { - +final class LoadMoreCell: SelectableCell { + + private let activity = UIActivityIndicatorView(activityIndicatorStyle: .gray) private let label = UILabel() - + override init(frame: CGRect) { super.init(frame: frame) - + accessibilityTraits |= UIAccessibilityTraitButton isAccessibilityElement = true label.font = Styles.Text.button.preferredFont - label.textColor = Styles.Colors.Gray.light.color + label.textColor = Styles.Colors.Blue.light.color contentView.addSubview(label) label.snp.makeConstraints { make in make.center.equalTo(contentView) } + + activity.hidesWhenStopped = true + contentView.addSubview(activity) + activity.snp.makeConstraints { make in + make.center.equalTo(contentView) + } label.text = NSLocalizedString("Load More", comment: "") } - + required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } - + override func layoutSubviews() { super.layoutSubviews() layoutContentViewForSafeAreaInsets() } - + override var accessibilityLabel: String? { get { return NSLocalizedString("Load More", comment: "") } set { } } - - override var isSelected: Bool { - didSet { - if isSelected { - label.alpha = 0.5 - } else { - label.alpha = 1 - } - } - } + + func configure(loading: Bool) { + label.isHidden = loading + loading + ? activity.startAnimating() + : activity.stopAnimating() + } } diff --git a/Classes/Section Controllers/LoadMore/LoadMoreSectionController.swift b/Classes/Section Controllers/LoadMore/LoadMoreSectionController.swift index 4800042db..3d9dc7e41 100644 --- a/Classes/Section Controllers/LoadMore/LoadMoreSectionController.swift +++ b/Classes/Section Controllers/LoadMore/LoadMoreSectionController.swift @@ -27,7 +27,7 @@ final class LoadMoreSectionController: ListSectionController { } override func cellForItem(at index: Int) -> UICollectionViewCell { - guard let cell = collectionContext?.dequeueReusableCell(of: IssueNeckLoadCell.self, for: self, at: index) as? IssueNeckLoadCell else { + guard let cell = collectionContext?.dequeueReusableCell(of: LoadMoreCell.self, for: self, at: index) as? LoadMoreCell else { fatalError("Missing context, or cell is wrong type") } cell.configure(loading: loadingOverride) diff --git a/Freetime.xcodeproj/project.pbxproj b/Freetime.xcodeproj/project.pbxproj index 85008f445..2e78a2b50 100644 --- a/Freetime.xcodeproj/project.pbxproj +++ b/Freetime.xcodeproj/project.pbxproj @@ -384,7 +384,6 @@ 29F3A18C20CD790F00645CB7 /* UIViewController+CommonActionItems.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29F3A18B20CD790F00645CB7 /* UIViewController+CommonActionItems.swift */; }; 29F7F05C1F2A751B00F6075D /* IssueResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29F7F05B1F2A751B00F6075D /* IssueResult.swift */; }; 29F7F05F1F2A839100F6075D /* IssueNeckLoadSectionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29F7F05E1F2A839100F6075D /* IssueNeckLoadSectionController.swift */; }; - 29F7F0611F2A83AA00F6075D /* IssueNeckLoadCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29F7F0601F2A83AA00F6075D /* IssueNeckLoadCell.swift */; }; 29F7F0631F2A875C00F6075D /* IssueNeckLoadModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29F7F0621F2A875C00F6075D /* IssueNeckLoadModel.swift */; }; 29FB942C1EE750DB0016E6D4 /* IssueLabeledModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29FB942B1EE750DB0016E6D4 /* IssueLabeledModel.swift */; }; 29FB942E1EE751F70016E6D4 /* IssueLabeledSectionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29FB942D1EE751F70016E6D4 /* IssueLabeledSectionController.swift */; }; @@ -909,7 +908,6 @@ 29F3A18B20CD790F00645CB7 /* UIViewController+CommonActionItems.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+CommonActionItems.swift"; sourceTree = ""; }; 29F7F05B1F2A751B00F6075D /* IssueResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IssueResult.swift; sourceTree = ""; }; 29F7F05E1F2A839100F6075D /* IssueNeckLoadSectionController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IssueNeckLoadSectionController.swift; sourceTree = ""; }; - 29F7F0601F2A83AA00F6075D /* IssueNeckLoadCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IssueNeckLoadCell.swift; sourceTree = ""; }; 29F7F0621F2A875C00F6075D /* IssueNeckLoadModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IssueNeckLoadModel.swift; sourceTree = ""; }; 29FB942B1EE750DB0016E6D4 /* IssueLabeledModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IssueLabeledModel.swift; sourceTree = ""; }; 29FB942D1EE751F70016E6D4 /* IssueLabeledSectionController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IssueLabeledSectionController.swift; sourceTree = ""; }; @@ -1930,7 +1928,6 @@ 29F7F05D1F2A833E00F6075D /* NeckLoad */ = { isa = PBXGroup; children = ( - 29F7F0601F2A83AA00F6075D /* IssueNeckLoadCell.swift */, 29F7F0621F2A875C00F6075D /* IssueNeckLoadModel.swift */, 29F7F05E1F2A839100F6075D /* IssueNeckLoadSectionController.swift */, ); @@ -2827,7 +2824,6 @@ 29BBD82920CAC7D5004D62FE /* NotificationViewModel.swift in Sources */, 299F63E2205DE1470015D901 /* UIView+DateDetails.swift in Sources */, 9870B9031FC73EE70009719C /* Secrets.swift in Sources */, - 29F7F0611F2A83AA00F6075D /* IssueNeckLoadCell.swift in Sources */, 29A5AF451F9298360065D529 /* GitHubClient+Repository.swift in Sources */, 29F7F0631F2A875C00F6075D /* IssueNeckLoadModel.swift in Sources */, 2946FA5120367FC100C37435 /* GithubClient+Merge.swift in Sources */,