Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions samples/swift/FirebaseUI-demo-swift/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<!--Samples View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController automaticallyAdjustsScrollViewInsets="NO" id="BYZ-38-t0r" customClass="FIRSamplesViewController" customModule="FirebaseUI_demo_swift" customModuleProvider="target" sceneMemberID="viewController">
<viewController automaticallyAdjustsScrollViewInsets="NO" id="BYZ-38-t0r" customClass="SamplesViewController" customModule="FirebaseUI_demo_swift" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
Expand All @@ -22,7 +22,7 @@
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="60" sectionHeaderHeight="1" sectionFooterHeight="1" translatesAutoresizingMaskIntoConstraints="NO" id="EMf-5k-tRY">
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="FIRSamplesViewControllerCell" id="mwf-Pe-7Xw" customClass="FIRSampleCell" customModule="FirebaseUI_demo_swift">
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="SamplesViewControllerCell" id="mwf-Pe-7Xw" customClass="SampleCell" customModule="FirebaseUI_demo_swift">
<rect key="frame" x="0.0" y="1" width="375" height="60"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="mwf-Pe-7Xw" id="su3-0f-Qc4">
Expand Down Expand Up @@ -78,7 +78,7 @@
<!--Chat View Controller-->
<scene sceneID="JRY-Ou-cBR">
<objects>
<viewController storyboardIdentifier="FIRChatViewController" id="DlP-uj-LdB" customClass="FIRChatViewController" customModule="FirebaseUI_demo_swift" customModuleProvider="target" sceneMemberID="viewController">
<viewController storyboardIdentifier="ChatViewController" id="DlP-uj-LdB" customClass="ChatViewController" customModule="FirebaseUI_demo_swift" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Hrd-jq-l3U"/>
<viewControllerLayoutGuide type="bottom" id="CT4-Lk-WT2"/>
Expand All @@ -95,7 +95,7 @@
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
</collectionViewFlowLayout>
<cells>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="FIRChatCollectionViewCell" id="Wc2-OF-raU" customClass="FIRChatCollectionViewCell" customModule="FirebaseUI_demo_swift" customModuleProvider="target">
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="ChatCollectionViewCell" id="Wc2-OF-raU" customClass="ChatCollectionViewCell" customModule="FirebaseUI_demo_swift" customModuleProvider="target">
<rect key="frame" x="87" y="0.0" width="202" height="130"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
Expand Down Expand Up @@ -433,7 +433,7 @@
<!--Storage View Controller-->
<scene sceneID="AUm-G9-f66">
<objects>
<viewController storyboardIdentifier="FIRStorageViewController" title="Storage View Controller" id="WET-Ai-gqs" customClass="FIRStorageViewController" customModule="FirebaseUI_demo_swift" customModuleProvider="target" sceneMemberID="viewController">
<viewController storyboardIdentifier="StorageViewController" title="Storage View Controller" id="WET-Ai-gqs" customClass="StorageViewController" customModule="FirebaseUI_demo_swift" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="fLb-ZX-Bfw"/>
<viewControllerLayoutGuide type="bottom" id="l9a-lf-5Sv"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import UIKit

class FIRSampleCell: UITableViewCell {
class SampleCell: UITableViewCell {

@IBOutlet fileprivate var titleLabel: UILabel!
@IBOutlet fileprivate var subtitleLabel: UILabel!
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!

Expand All @@ -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)
Expand All @@ -48,16 +48,16 @@ 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)

return cell
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return FIRSample.total
return Sample.total
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import UIKit

import FirebaseStorageUI

class FIRStorageViewController: UIViewController {
class StorageViewController: UIViewController {

@IBOutlet fileprivate var imageView: UIImageView!
@IBOutlet fileprivate var textField: UITextField!
Expand Down