From cc8ff7d078bdebd8479862557d2a9c4fcd7d9b96 Mon Sep 17 00:00:00 2001 From: Morgan Chen Date: Thu, 3 Nov 2016 14:50:39 -0700 Subject: [PATCH] rename sample classes to adhere to swift convention --- .../Base.lproj/Main.storyboard | 10 +++++----- ...ViewCell.swift => ChatCollectionViewCell.swift} | 14 +++++++------- ...ewController.swift => ChatViewController.swift} | 12 ++++++------ .../Samples/{FIRSample.swift => Sample.swift} | 10 +++++----- .../{FIRSampleCell.swift => SampleCell.swift} | 6 +++--- ...ontroller.swift => SamplesViewController.swift} | 12 ++++++------ ...ontroller.swift => StorageViewController.swift} | 2 +- 7 files changed, 33 insertions(+), 33 deletions(-) rename samples/swift/FirebaseUI-demo-swift/Samples/Chat/{FIRChatCollectionViewCell.swift => ChatCollectionViewCell.swift} (87%) rename samples/swift/FirebaseUI-demo-swift/Samples/Chat/{FIRChatViewController.swift => ChatViewController.swift} (96%) rename samples/swift/FirebaseUI-demo-swift/Samples/{FIRSample.swift => Sample.swift} (89%) rename samples/swift/FirebaseUI-demo-swift/Samples/{FIRSampleCell.swift => SampleCell.swift} (89%) rename samples/swift/FirebaseUI-demo-swift/Samples/{FIRSamplesViewController.swift => SamplesViewController.swift} (82%) rename samples/swift/FirebaseUI-demo-swift/Samples/{FIRStorageViewController.swift => StorageViewController.swift} (98%) diff --git a/samples/swift/FirebaseUI-demo-swift/Base.lproj/Main.storyboard b/samples/swift/FirebaseUI-demo-swift/Base.lproj/Main.storyboard index 422ba717efe..492b37c752a 100644 --- a/samples/swift/FirebaseUI-demo-swift/Base.lproj/Main.storyboard +++ b/samples/swift/FirebaseUI-demo-swift/Base.lproj/Main.storyboard @@ -10,7 +10,7 @@ - + @@ -22,7 +22,7 @@ - + @@ -78,7 +78,7 @@ - + @@ -95,7 +95,7 @@ - + @@ -433,7 +433,7 @@ - + diff --git a/samples/swift/FirebaseUI-demo-swift/Samples/Chat/FIRChatCollectionViewCell.swift b/samples/swift/FirebaseUI-demo-swift/Samples/Chat/ChatCollectionViewCell.swift similarity index 87% rename from samples/swift/FirebaseUI-demo-swift/Samples/Chat/FIRChatCollectionViewCell.swift rename to samples/swift/FirebaseUI-demo-swift/Samples/Chat/ChatCollectionViewCell.swift index 65f686f43da..13565fd2fca 100644 --- a/samples/swift/FirebaseUI-demo-swift/Samples/Chat/FIRChatCollectionViewCell.swift +++ b/samples/swift/FirebaseUI-demo-swift/Samples/Chat/ChatCollectionViewCell.swift @@ -17,16 +17,16 @@ import UIKit import Firebase -/// Displays an individual chat message inside of a FIRChatViewController. -class FIRChatCollectionViewCell: UICollectionViewCell { +/// Displays an individual chat message inside of a ChatViewController. +class ChatCollectionViewCell: UICollectionViewCell { @IBOutlet fileprivate(set) var textLabel: UILabel! { didSet { - textLabel.font = FIRChatCollectionViewCell.messageFont + textLabel.font = ChatCollectionViewCell.messageFont } } static func boundingRectForText(_ text: String, maxWidth: CGFloat) -> CGRect { - let attributes = [NSFontAttributeName: FIRChatCollectionViewCell.messageFont] + let attributes = [NSFontAttributeName: ChatCollectionViewCell.messageFont] let rect = text.boundingRect(with: CGSize(width: maxWidth, height: CGFloat.greatestFiniteMagnitude), options: [.usesLineFragmentOrigin], attributes: attributes, @@ -76,19 +76,19 @@ class FIRChatCollectionViewCell: UICollectionViewCell { self.textLabel.text = chat.text let leftRightPadding: CGFloat = 24 - let rect = FIRChatCollectionViewCell.boundingRectForText(self.textLabel.text!, + let rect = ChatCollectionViewCell.boundingRectForText(self.textLabel.text!, maxWidth: maxWidth) let constant = max(maxWidth - rect.size.width - leftRightPadding, CGFloat.leastNormalMagnitude) if chat.uid == user?.uid ?? "" { - let colors = FIRChatCollectionViewCell.selfColors + let colors = ChatCollectionViewCell.selfColors self.containerView.backgroundColor = colors.background self.textLabel.textColor = colors.text self.trailingConstraint.isActive = false self.leadingConstraint.constant = constant self.leadingConstraint.isActive = true } else { - let colors = FIRChatCollectionViewCell.othersColors + let colors = ChatCollectionViewCell.othersColors self.containerView.backgroundColor = colors.background self.textLabel.textColor = colors.text self.leadingConstraint.isActive = false diff --git a/samples/swift/FirebaseUI-demo-swift/Samples/Chat/FIRChatViewController.swift b/samples/swift/FirebaseUI-demo-swift/Samples/Chat/ChatViewController.swift similarity index 96% rename from samples/swift/FirebaseUI-demo-swift/Samples/Chat/FIRChatViewController.swift rename to samples/swift/FirebaseUI-demo-swift/Samples/Chat/ChatViewController.swift index aacd3bab47c..1c8289ff259 100644 --- a/samples/swift/FirebaseUI-demo-swift/Samples/Chat/FIRChatViewController.swift +++ b/samples/swift/FirebaseUI-demo-swift/Samples/Chat/ChatViewController.swift @@ -22,11 +22,11 @@ import FirebaseAuthUI /// View controller demonstrating using a FUICollectionViewDataSource /// to populate a collection view with chat messages. The relevant code /// is in the call to `collectionViewDataSource.populateCellWithBlock`. -class FIRChatViewController: UIViewController, UICollectionViewDelegateFlowLayout { +class ChatViewController: UIViewController, UICollectionViewDelegateFlowLayout { // All of the error handling in this controller is done with `fatalError`; // please don't copy paste it into your production code. - fileprivate static let reuseIdentifier = "FIRChatCollectionViewCell" + fileprivate static let reuseIdentifier = "ChatCollectionViewCell" @IBOutlet fileprivate var collectionView: UICollectionView! @IBOutlet fileprivate var textView: UITextView! { @@ -65,8 +65,8 @@ class FIRChatViewController: UIViewController, UICollectionViewDelegateFlowLayou FUICollectionViewDataSource(query: self.query!, view: self.collectionView, populateCell: { (view, indexPath, snap) -> UICollectionViewCell in - let cell = view.dequeueReusableCell(withReuseIdentifier: FIRChatViewController.reuseIdentifier, - for: indexPath) as! FIRChatCollectionViewCell + let cell = view.dequeueReusableCell(withReuseIdentifier: ChatViewController.reuseIdentifier, + for: indexPath) as! ChatCollectionViewCell let chat = Chat(snapshot: snap)! cell.populateCellWithChat(chat, user: self.user, maxWidth: self.view.frame.size.width) return cell @@ -79,7 +79,7 @@ class FIRChatViewController: UIViewController, UICollectionViewDelegateFlowLayou // on new insertions we still need to use the query directly. self.query!.observe(.childAdded, with: { [unowned self] _ in self.scrollToBottom(animated: true) - }) + }) } self.auth?.signInAnonymously { (user, error) in @@ -189,7 +189,7 @@ class FIRChatViewController: UIViewController, UICollectionViewDelegateFlowLayou let blob = self.collectionViewDataSource.object(at: UInt((indexPath as NSIndexPath).row)) as! FIRDataSnapshot let text = Chat(snapshot: blob)!.text - let rect = FIRChatCollectionViewCell.boundingRectForText(text, maxWidth: width) + let rect = ChatCollectionViewCell.boundingRectForText(text, maxWidth: width) let height = CGFloat(ceil(Double(rect.size.height))) + heightPadding return CGSize(width: width, height: height) diff --git a/samples/swift/FirebaseUI-demo-swift/Samples/FIRSample.swift b/samples/swift/FirebaseUI-demo-swift/Samples/Sample.swift similarity index 89% rename from samples/swift/FirebaseUI-demo-swift/Samples/FIRSample.swift rename to samples/swift/FirebaseUI-demo-swift/Samples/Sample.swift index cd152c902e3..14d0c6c9743 100644 --- a/samples/swift/FirebaseUI-demo-swift/Samples/FIRSample.swift +++ b/samples/swift/FirebaseUI-demo-swift/Samples/Sample.swift @@ -17,9 +17,9 @@ import UIKit // This enum represents the samples that this app knows about, and -// is used by the FIRSamplesViewController to layout all of the samples +// is used by the SamplesViewController to layout all of the samples // and display basic information about them. -enum FIRSample: Int, RawRepresentable { +enum Sample: Int, RawRepresentable { // When adding new samples, add a new value here and fill // out the switch statements below as necessary. @@ -29,7 +29,7 @@ enum FIRSample: Int, RawRepresentable { static var total: Int { var count = 0 - while let _ = FIRSample(rawValue: count) { + while let _ = Sample(rawValue: count) { count += 1 } return count @@ -58,11 +58,11 @@ enum FIRSample: Int, RawRepresentable { func controller() -> UIViewController { switch self { case .chat: - return UIStoryboard.instantiateViewController("Main", identifier: "FIRChatViewController") + return UIStoryboard.instantiateViewController("Main", identifier: "ChatViewController") case .auth: return UIStoryboard.instantiateViewController("Main", identifier: "FIRAuthViewController") case .storage: - return UIStoryboard.instantiateViewController("Main", identifier: "FIRStorageViewController") + return UIStoryboard.instantiateViewController("Main", identifier: "StorageViewController") } } } diff --git a/samples/swift/FirebaseUI-demo-swift/Samples/FIRSampleCell.swift b/samples/swift/FirebaseUI-demo-swift/Samples/SampleCell.swift similarity index 89% rename from samples/swift/FirebaseUI-demo-swift/Samples/FIRSampleCell.swift rename to samples/swift/FirebaseUI-demo-swift/Samples/SampleCell.swift index 4cbb80cc78e..19f5ea804c5 100644 --- a/samples/swift/FirebaseUI-demo-swift/Samples/FIRSampleCell.swift +++ b/samples/swift/FirebaseUI-demo-swift/Samples/SampleCell.swift @@ -16,7 +16,7 @@ import UIKit -class FIRSampleCell: UITableViewCell { +class SampleCell: UITableViewCell { @IBOutlet fileprivate var titleLabel: UILabel! @IBOutlet fileprivate var subtitleLabel: UILabel! @@ -29,13 +29,13 @@ class FIRSampleCell: UITableViewCell { super.init(style: .default, reuseIdentifier: reuseIdentifier) } - convenience init(type: FIRSample, reuseIdentifier: String) { + convenience init(type: Sample, reuseIdentifier: String) { self.init(reuseIdentifier: reuseIdentifier) self.configureWithType(type) } - func configureWithType(_ type: FIRSample) { + func configureWithType(_ type: Sample) { let labels = type.labels self.titleLabel.text = labels.title self.subtitleLabel.text = labels.subtitle diff --git a/samples/swift/FirebaseUI-demo-swift/Samples/FIRSamplesViewController.swift b/samples/swift/FirebaseUI-demo-swift/Samples/SamplesViewController.swift similarity index 82% rename from samples/swift/FirebaseUI-demo-swift/Samples/FIRSamplesViewController.swift rename to samples/swift/FirebaseUI-demo-swift/Samples/SamplesViewController.swift index be381fa5d46..4a91d48d475 100644 --- a/samples/swift/FirebaseUI-demo-swift/Samples/FIRSamplesViewController.swift +++ b/samples/swift/FirebaseUI-demo-swift/Samples/SamplesViewController.swift @@ -19,9 +19,9 @@ import UIKit // This controller exists solely to list the samples we've defined thus far. // Because all of that stuff is static and unchanging, if the app ever crashes // in here it's probably a typo or some other small accident. -class FIRSamplesViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { +class SamplesViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { - fileprivate let reuseIdentifier = "FIRSamplesViewControllerCell" + fileprivate let reuseIdentifier = "SamplesViewControllerCell" @IBOutlet fileprivate var tableView: UITableView! @@ -39,7 +39,7 @@ class FIRSamplesViewController: UIViewController, UITableViewDelegate, UITableVi func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let navController = self.navigationController! // assert nonnull - let targetController = FIRSample(rawValue: (indexPath as NSIndexPath).row)!.controller() + let targetController = Sample(rawValue: (indexPath as NSIndexPath).row)!.controller() navController.pushViewController(targetController, animated: true) tableView.deselectRow(at: indexPath, animated: true) @@ -48,9 +48,9 @@ class FIRSamplesViewController: UIViewController, UITableViewDelegate, UITableVi // MARK: - UITableView Data Source func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let sampleType = FIRSample(rawValue: (indexPath as NSIndexPath).row)! + let sampleType = Sample(rawValue: (indexPath as NSIndexPath).row)! - let cell = self.tableView.dequeueReusableCell(withIdentifier: reuseIdentifier) as! FIRSampleCell + let cell = self.tableView.dequeueReusableCell(withIdentifier: reuseIdentifier) as! SampleCell cell.configureWithType(sampleType) @@ -58,6 +58,6 @@ class FIRSamplesViewController: UIViewController, UITableViewDelegate, UITableVi } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return FIRSample.total + return Sample.total } } diff --git a/samples/swift/FirebaseUI-demo-swift/Samples/FIRStorageViewController.swift b/samples/swift/FirebaseUI-demo-swift/Samples/StorageViewController.swift similarity index 98% rename from samples/swift/FirebaseUI-demo-swift/Samples/FIRStorageViewController.swift rename to samples/swift/FirebaseUI-demo-swift/Samples/StorageViewController.swift index accf5ce7575..fd74003a025 100644 --- a/samples/swift/FirebaseUI-demo-swift/Samples/FIRStorageViewController.swift +++ b/samples/swift/FirebaseUI-demo-swift/Samples/StorageViewController.swift @@ -18,7 +18,7 @@ import UIKit import FirebaseStorageUI -class FIRStorageViewController: UIViewController { +class StorageViewController: UIViewController { @IBOutlet fileprivate var imageView: UIImageView! @IBOutlet fileprivate var textField: UITextField!