Skip to content

Commit 83bb16c

Browse files
committed
implement FIR Demo samples controller
1 parent 785c0ab commit 83bb16c

19 files changed

+477
-51
lines changed

samples/objc/FirebaseUIChat.xcodeproj/project.pbxproj

Lines changed: 151 additions & 28 deletions
Large diffs are not rendered by default.

samples/objc/FirebaseUIChat/Base.lproj/Main.storyboard

Lines changed: 72 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="7RW-VL-qNI">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15G1004" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="7RW-VL-qNI">
33
<dependencies>
44
<deployment identifier="iOS"/>
55
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
66
</dependencies>
77
<scenes>
8-
<!--FirebaseUI Chat-->
8+
<!--Navigation Controller-->
99
<scene sceneID="5Vi-Ss-a4T">
1010
<objects>
11-
<navigationController title="FirebaseUI Chat" id="7RW-VL-qNI" sceneMemberID="viewController">
11+
<navigationController id="7RW-VL-qNI" sceneMemberID="viewController">
1212
<navigationBar key="navigationBar" contentMode="scaleToFill" id="77g-XZ-4ot">
1313
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
1414
<autoresizingMask key="autoresizingMask"/>
15+
<textAttributes key="titleTextAttributes">
16+
<color key="textColor" red="0.43529411759999997" green="0.4431372549" blue="0.47450980390000003" alpha="1" colorSpace="calibratedRGB"/>
17+
</textAttributes>
1518
</navigationBar>
1619
<connections>
17-
<segue destination="vXZ-lx-hvc" kind="relationship" relationship="rootViewController" id="nDk-iY-Ue3"/>
20+
<segue destination="S3Q-gf-8AQ" kind="relationship" relationship="rootViewController" id="6WL-yB-OaR"/>
1821
</connections>
1922
</navigationController>
2023
<placeholder placeholderIdentifier="IBFirstResponder" id="1gA-3Y-kdg" userLabel="First Responder" sceneMemberID="firstResponder"/>
@@ -24,7 +27,7 @@
2427
<!--FirebaseUI Chat-->
2528
<scene sceneID="ufC-wZ-h7g">
2629
<objects>
27-
<viewController title="FirebaseUI Chat" id="vXZ-lx-hvc" customClass="ViewController" sceneMemberID="viewController">
30+
<viewController storyboardIdentifier="ViewController" title="FirebaseUI Chat" useStoryboardIdentifierAsRestorationIdentifier="YES" id="vXZ-lx-hvc" customClass="ViewController" sceneMemberID="viewController">
2831
<layoutGuides>
2932
<viewControllerLayoutGuide type="top" id="jyV-Pf-zRb"/>
3033
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
@@ -66,7 +69,70 @@
6669
</viewController>
6770
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
6871
</objects>
69-
<point key="canvasLocation" x="396" y="315"/>
72+
<point key="canvasLocation" x="1064" y="315"/>
73+
</scene>
74+
<!--FirebaseUI Demo-->
75+
<scene sceneID="kgy-Av-Wvg">
76+
<objects>
77+
<tableViewController title="FirebaseUI Demo" id="S3Q-gf-8AQ" customClass="FIRSamplesViewController" sceneMemberID="viewController">
78+
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="80" sectionHeaderHeight="28" sectionFooterHeight="28" id="WhE-Mc-Kss">
79+
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
80+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
81+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
82+
<prototypes>
83+
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="FIRSampleCell" textLabel="cAY-q4-fwa" detailTextLabel="SPU-XD-Wjm" style="IBUITableViewCellStyleSubtitle" id="qVR-uJ-bhD">
84+
<rect key="frame" x="0.0" y="92" width="600" height="80"/>
85+
<autoresizingMask key="autoresizingMask"/>
86+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="qVR-uJ-bhD" id="xcz-xR-Hj5">
87+
<rect key="frame" x="0.0" y="0.0" width="567" height="79"/>
88+
<autoresizingMask key="autoresizingMask"/>
89+
<subviews>
90+
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="cAY-q4-fwa">
91+
<rect key="frame" x="15" y="23" width="32" height="20"/>
92+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
93+
<fontDescription key="fontDescription" type="system" pointSize="16"/>
94+
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
95+
<nil key="highlightedColor"/>
96+
</label>
97+
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Subtitle" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="SPU-XD-Wjm">
98+
<rect key="frame" x="15" y="43" width="41" height="14"/>
99+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
100+
<fontDescription key="fontDescription" type="system" pointSize="11"/>
101+
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
102+
<nil key="highlightedColor"/>
103+
</label>
104+
</subviews>
105+
</tableViewCellContentView>
106+
</tableViewCell>
107+
</prototypes>
108+
<connections>
109+
<outlet property="dataSource" destination="S3Q-gf-8AQ" id="Z2r-OW-AYK"/>
110+
<outlet property="delegate" destination="S3Q-gf-8AQ" id="YJJ-Gw-k9Z"/>
111+
</connections>
112+
</tableView>
113+
<navigationItem key="navigationItem" id="2NI-bx-8Ik"/>
114+
</tableViewController>
115+
<placeholder placeholderIdentifier="IBFirstResponder" id="bxB-kc-QEG" userLabel="First Responder" sceneMemberID="firstResponder"/>
116+
</objects>
117+
<point key="canvasLocation" x="380" y="315"/>
118+
</scene>
119+
<!--Auth View Controller-->
120+
<scene sceneID="8ct-Gf-RI6">
121+
<objects>
122+
<viewController storyboardIdentifier="FIRAuthViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="LmU-7s-TNo" customClass="FIRAuthViewController" sceneMemberID="viewController">
123+
<layoutGuides>
124+
<viewControllerLayoutGuide type="top" id="QAT-HV-OZV"/>
125+
<viewControllerLayoutGuide type="bottom" id="jNo-4u-MUs"/>
126+
</layoutGuides>
127+
<view key="view" contentMode="scaleToFill" id="TYT-qz-Ma5">
128+
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
129+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
130+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
131+
</view>
132+
</viewController>
133+
<placeholder placeholderIdentifier="IBFirstResponder" id="I5a-Mj-GLr" userLabel="First Responder" sceneMemberID="firstResponder"/>
134+
</objects>
135+
<point key="canvasLocation" x="1761" y="315"/>
70136
</scene>
71137
</scenes>
72138
</document>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
// FIRSampleContainer.h
3+
// FirebaseUIChat
4+
//
5+
// Created by Yury Ramanchuk on 9/8/16.
6+
// Copyright © 2016 Firebase, Inc. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
#import <UIKit/UIKit.h>
11+
12+
typedef UIViewController *(^FIRControllerBlock)();
13+
14+
@interface FIRSample : NSObject
15+
16+
+ (instancetype)sampleWithTitle:(NSString *)title
17+
sampleDescription:(NSString *)description
18+
controller:(FIRControllerBlock)block;
19+
20+
@property (nonatomic, copy) NSString *title;
21+
@property (nonatomic, copy) NSString *sampleDescription;
22+
@property (nonatomic, copy) FIRControllerBlock controllerBlock;
23+
24+
25+
@end
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// FIRSampleContainer.m
3+
// FirebaseUIChat
4+
//
5+
// Created by Yury Ramanchuk on 9/8/16.
6+
// Copyright © 2016 Firebase, Inc. All rights reserved.
7+
//
8+
9+
#import "FIRSample.h"
10+
11+
@implementation FIRSample
12+
13+
- (id)initWithTitle:(NSString *)title
14+
sampleDescription:(NSString *)description
15+
controller:(FIRControllerBlock)block {
16+
if (self = [self init]) {
17+
_title = title;
18+
_sampleDescription = description;
19+
_controllerBlock = block;
20+
}
21+
22+
return self;
23+
}
24+
25+
+ (instancetype)sampleWithTitle:(NSString *)title
26+
sampleDescription:(NSString *)description
27+
controller:(FIRControllerBlock)block {
28+
FIRSample *sample = [(FIRSample *)[self alloc] initWithTitle:title
29+
sampleDescription:description
30+
controller:block];
31+
32+
return sample;
33+
}
34+
35+
36+
@end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// SamplesViewController.h
3+
// FirebaseUIChat
4+
//
5+
// Created by Yury Ramanchuk on 9/7/16.
6+
// Copyright © 2016 Firebase, Inc. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
@interface FIRSamplesViewController : UITableViewController
12+
13+
@end
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
//
2+
// SamplesViewController.m
3+
// FirebaseUIChat
4+
//
5+
// Created by Yury Ramanchuk on 9/7/16.
6+
// Copyright © 2016 Firebase, Inc. All rights reserved.
7+
//
8+
9+
#import "FIRSample.h"
10+
#import "FIRSamplesViewController.h"
11+
#import "ViewController.h"
12+
13+
@interface FIRSamplesViewController ()
14+
15+
@property (nonatomic) NSArray *samplesContainer;
16+
17+
@end
18+
19+
@implementation FIRSamplesViewController
20+
21+
- (void)viewDidLoad {
22+
[super viewDidLoad];
23+
24+
self.navigationController.navigationBar.topItem.title = self.title;
25+
self.clearsSelectionOnViewWillAppear = NO;
26+
27+
[self populateSamples];
28+
}
29+
30+
- (void)populateSamples {
31+
NSMutableArray *samples = [[NSMutableArray alloc] init];
32+
33+
[samples addObject:[FIRSample sampleWithTitle:@"Auth"
34+
sampleDescription:@"Demonstrates the FirebaseAuthUI flow with customization options"
35+
controller:^UIViewController *{
36+
UIViewController *controller =
37+
[[UIStoryboard storyboardWithName:@"Main"
38+
bundle:NULL] instantiateViewControllerWithIdentifier:@"FIRAuthViewController"];
39+
return controller;
40+
}]];
41+
42+
[samples addObject:[FIRSample sampleWithTitle:@"Chat"
43+
sampleDescription:@"Demonstrates using a FirebaseCollectionViewDataSource to load data from Firebase Database into a UICollectionView for a basic chat app."
44+
controller:^UIViewController *{
45+
UIViewController *controller =
46+
[[UIStoryboard storyboardWithName:@"Main"
47+
bundle:NULL] instantiateViewControllerWithIdentifier:@"ViewController"];
48+
return controller;
49+
}]];
50+
51+
52+
_samplesContainer = samples;
53+
}
54+
55+
- (void)didReceiveMemoryWarning {
56+
[super didReceiveMemoryWarning];
57+
}
58+
59+
#pragma mark - Table view data source
60+
61+
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
62+
return 1;
63+
}
64+
65+
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
66+
return _samplesContainer.count;
67+
}
68+
69+
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
70+
static NSString *cellId = @"FIRSampleCell";
71+
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId forIndexPath:indexPath];
72+
73+
FIRSample *sample = _samplesContainer[indexPath.row];
74+
cell.textLabel.text = sample.title;
75+
cell.detailTextLabel.text = sample.sampleDescription;
76+
77+
78+
return cell;
79+
}
80+
81+
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
82+
FIRSample *sample = _samplesContainer[indexPath.row];
83+
UIViewController *viewController = sample.controllerBlock();
84+
85+
[self.navigationController pushViewController:viewController animated:YES];
86+
}
87+
88+
@end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// AuthViewController.h
3+
// FirebaseUIChat
4+
//
5+
// Created by Yury Ramanchuk on 9/7/16.
6+
// Copyright © 2016 Firebase, Inc. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
@interface FIRAuthViewController : UIViewController
12+
13+
@end
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// AuthViewController.m
3+
// FirebaseUIChat
4+
//
5+
// Created by Yury Ramanchuk on 9/7/16.
6+
// Copyright © 2016 Firebase, Inc. All rights reserved.
7+
//
8+
9+
#import "FIRAuthViewController.h"
10+
11+
@interface FIRAuthViewController ()
12+
13+
@end
14+
15+
@implementation FIRAuthViewController
16+
17+
- (void)viewDidLoad {
18+
[super viewDidLoad];
19+
// Do any additional setup after loading the view.
20+
}
21+
22+
- (void)didReceiveMemoryWarning {
23+
[super didReceiveMemoryWarning];
24+
// Dispose of any resources that can be recreated.
25+
}
26+
27+
28+
@end

samples/objc/FirebaseUIChat/MessageTableViewCell.xib renamed to samples/objc/FirebaseUIChat/Samples/Chat/MessageTableViewCell.xib

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10117" systemVersion="15G1004" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
33
<dependencies>
44
<deployment identifier="iOS"/>
55
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
@@ -13,7 +13,7 @@
1313
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
1414
<autoresizingMask key="autoresizingMask"/>
1515
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="d6M-nO-3us" id="oUR-sj-R1e">
16-
<rect key="frame" x="0.0" y="0.0" width="320" height="43.5"/>
16+
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
1717
<autoresizingMask key="autoresizingMask"/>
1818
<subviews>
1919
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Other Message" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5a3-Gg-71z">

0 commit comments

Comments
 (0)