diff --git a/FirebaseUI.podspec b/FirebaseUI.podspec index babf00e8fa3..8f970b4cbaa 100644 --- a/FirebaseUI.podspec +++ b/FirebaseUI.podspec @@ -1,12 +1,12 @@ Pod::Spec.new do |s| s.name = "FirebaseUI" - s.version = "0.2.1" + s.version = "0.2.3" s.summary = "UI binding libraries for Firebase." s.homepage = "https://github.com/firebase/FirebaseUI-iOS" s.license = { :type => 'MIT', :file => 'LICENSE' } s.author = { "Firebase" => "support@firebase.com" } s.social_media_url = "https://twitter.com/firebase" - s.source = { :git => "https://github.com/firebase/FirebaseUI-iOS.git", :tag => 'v0.2.1' } + s.source = { :git => "https://github.com/firebase/FirebaseUI-iOS.git", :tag => 'v0.2.3' } s.source_files = "FirebaseUI/**/*.{h,m}" s.dependency "Firebase", "~> 2.2" s.platform = :ios diff --git a/FirebaseUI.xcodeproj/project.pbxproj b/FirebaseUI.xcodeproj/project.pbxproj index c63385af011..e50f08837b4 100644 --- a/FirebaseUI.xcodeproj/project.pbxproj +++ b/FirebaseUI.xcodeproj/project.pbxproj @@ -119,10 +119,10 @@ D8B6ACEA1B5839F7005CDDB2 /* Implementation */ = { isa = PBXGroup; children = ( - D8DF55611B742DB40030E996 /* FirebaseCollectionViewDataSource.m */, D8B6ACEF1B583C41005CDDB2 /* FirebaseArray.m */, D8B6ACF21B583C41005CDDB2 /* FirebaseDataSource.m */, D8B6ACF11B583C41005CDDB2 /* FirebaseTableViewDataSource.m */, + D8DF55611B742DB40030E996 /* FirebaseCollectionViewDataSource.m */, ); name = Implementation; sourceTree = ""; diff --git a/FirebaseUI/API/FirebaseCollectionViewDataSource.h b/FirebaseUI/API/FirebaseCollectionViewDataSource.h index c53b2f68e06..7148003fbe4 100644 --- a/FirebaseUI/API/FirebaseCollectionViewDataSource.h +++ b/FirebaseUI/API/FirebaseCollectionViewDataSource.h @@ -43,6 +43,11 @@ */ @property (strong, nonatomic, __NON_NULL) Class modelClass; +/** + * The cell class to coerce UICollectionViewCells to (if desired). For instance, if the cellClass is set to [CustomCollectionViewCell class] in Obj-C or CustomCollectionViewCell in Swift, then objects of type CustomCollectionViewCell will be returned instead of type UICollectionViewCell. + */ +@property (strong, nonatomic, __NON_NULL) Class cellClass; + /** * The reuse identifier for cells in the UICollectionView. */ @@ -53,10 +58,15 @@ */ @property (strong, nonatomic, __NON_NULL) UICollectionView *collectionView; +/** + * Property to keep track of prototype cell use, to not register a class for the UICollectionView or do similar book keeping. + */ +@property BOOL hasPrototypeCell; + /** * The callback to populate a subclass of UICollectionViewCell with an object provided by the datasource. */ -@property (strong, nonatomic, __NON_NULL) void(^populateCell)(UICollectionViewCell * __NON_NULL_PTR cell, NSObject * __NON_NULL_PTR object); +@property (strong, nonatomic, __NON_NULL) void(^populateCell)(__kindof UICollectionViewCell * __NON_NULL_PTR cell, __kindof NSObject * __NON_NULL_PTR object); /** * Initialize an instance of FirebaseCollectionViewDataSource that populates UICollectionViewCells with FDataSnapshots. @@ -65,7 +75,16 @@ * @param collectionView An instance of a UICollectionView to bind to * @return An instance of FirebaseCollectionViewDataSource that populates UICollectionViewCells with FDataSnapshots */ -- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref reuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UICollectionView *)collectionView; +- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref cellReuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UICollectionView *)collectionView; + +/** + * Initialize an instance of FirebaseCollectionViewDataSource that populates UICollectionViewCells with FDataSnapshots. Note that this method is used when using prototype cells, where the cells don't need to be registered in the class. + * @param ref A Firebase reference to bind the datasource to + * @param identifier A string to use as a CellReuseIdentifier + * @param collectionView An instance of a UICollectionView to bind to + * @return An instance of FirebaseCollectionViewDataSource that populates UICollectionViewCells with FDataSnapshots + */ +- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref prototypeReuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UICollectionView *)collectionView; /** * Initialize an instance of FirebaseCollectionViewDataSource that populates a custom subclass of UICollectionViewCell with FDataSnapshots. @@ -75,7 +94,7 @@ * @param collectionView An instance of a UICollectionView to bind to * @return An instance of FirebaseCollectionViewDataSource that populates a custom subclass of UICollectionViewCell with FDataSnapshots */ -- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref cellClass:(__NULLABLE Class)cell reuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UICollectionView *)collectionView; +- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref cellClass:(__NULLABLE Class)cell cellReuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UICollectionView *)collectionView; /** * Initialize an instance of FirebaseCollectionViewDataSource that populates a custom xib with FDataSnapshots. @@ -85,7 +104,7 @@ * @param collectionView An instance of a UICollectionView to bind to * @return An instance of FirebaseCollectionViewDataSource that populates a custom xib with FDataSnapshots */ -- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref nibNamed:(__NON_NULL NSString *)nibName reuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UICollectionView *)collectionView; +- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref nibNamed:(__NON_NULL NSString *)nibName cellReuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UICollectionView *)collectionView; /** * Initialize an instance of FirebaseCollectionViewDataSource that populates UICollectionViewCells with a custom model class. @@ -95,7 +114,17 @@ * @param collectionView An instance of a UICollectionView to bind to * @return An instance of FirebaseCollectionViewDataSource that populates UICollectionViewCells with a custom model class */ -- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref modelClass:(__NULLABLE Class)model reuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UICollectionView *)collectionView; +- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref modelClass:(__NULLABLE Class)model cellReuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UICollectionView *)collectionView; + +/** + * Initialize an instance of FirebaseCollectionViewDataSource that populates UICollectionViewCells with a custom model class. Note that this method is used when using prototype cells, where the cells don't need to be registered in the class. + * @param ref A Firebase reference to bind the datasource to + * @param model A custom class that FDataSnapshots are coerced to, defaults to FDataSnapshot if nil + * @param identifier A string to use as a CellReuseIdentifier + * @param collectionView An instance of a UICollectionView to bind to + * @return An instance of FirebaseCollectionViewDataSource that populates UICollectionViewCells with a custom model class + */ +- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref modelClass:(__NULLABLE Class)model prototypeReuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UICollectionView *)collectionView; /** * Initialize an instance of FirebaseCollectionViewDataSource that populates a custom subclass of UICollectionViewCell with a custom model class. @@ -106,7 +135,7 @@ * @param collectionView An instance of a UICollectionView to bind to * @return An instance of FirebaseCollectionViewDataSource that populates a custom subclass of UICollectionViewCell with a custom model class */ -- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref modelClass:(__NULLABLE Class)model cellClass:(__NULLABLE Class)cell reuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UICollectionView *)collectionView; +- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref modelClass:(__NULLABLE Class)model cellClass:(__NULLABLE Class)cell cellReuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UICollectionView *)collectionView; /** * Initialize an instance of FirebaseCollectionViewDataSource that populates a custom xib with a custom model class. @@ -117,12 +146,12 @@ * @param collectionView An instance of a UICollectionView to bind to * @return An instance of FirebaseCollectionViewDataSource that populates a custom xib with a custom model class */ -- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref modelClass:(__NULLABLE Class)model nibNamed:(__NON_NULL NSString *)nibName reuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UICollectionView *)collectionView; +- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref modelClass:(__NULLABLE Class)model nibNamed:(__NON_NULL NSString *)nibName cellReuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UICollectionView *)collectionView; /** * This method populates the fields of a UICollectionViewCell or subclass given an FDataSnapshot (or custom model object). * @param callback A block which returns an initialized UICollectionViewCell (or subclass) and the corresponding object to populate the cell with. */ -- (void)populateCellWithBlock:(__NON_NULL void(^)(UICollectionViewCell * __NON_NULL_PTR cell, NSObject * __NON_NULL_PTR object))callback; +- (void)populateCellWithBlock:(__NON_NULL void(^)(__kindof UICollectionViewCell * __NON_NULL_PTR cell, __kindof NSObject * __NON_NULL_PTR object))callback; @end diff --git a/FirebaseUI/API/FirebaseTableViewDataSource.h b/FirebaseUI/API/FirebaseTableViewDataSource.h index 32f8f5ba140..19addd5f1b2 100644 --- a/FirebaseUI/API/FirebaseTableViewDataSource.h +++ b/FirebaseUI/API/FirebaseTableViewDataSource.h @@ -53,10 +53,15 @@ */ @property (strong, nonatomic, __NON_NULL) UITableView *tableView; +/** + * Property to keep track of prototype cell use, to not register a class for the UICollectionView or do similar book keeping. + */ +@property BOOL hasPrototypeCell; + /** * The callback to populate a subclass of UITableViewCell with an object provided by the datasource. */ -@property (strong, nonatomic, __NON_NULL) void(^populateCell)(UITableViewCell * __NON_NULL_PTR cell, NSObject * __NON_NULL_PTR object); +@property (strong, nonatomic, __NON_NULL) void(^populateCell)(__kindof UITableViewCell * __NON_NULL_PTR cell, __kindof NSObject * __NON_NULL_PTR object); /** * Initialize an instance of FirebaseTableViewDataSource that populates UITableViewCells with FDataSnapshots. @@ -65,7 +70,16 @@ * @param tableView An instance of a UITableView to bind to * @return An instance of FirebaseTableViewDataSource that populates UITableViewCells with FDataSnapshots */ -- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref reuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UITableView *)tableView; +- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref cellReuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UITableView *)tableView; + +/** + * Initialize an instance of FirebaseTableViewDataSource that populates UITableViewCells with FDataSnapshots. Note that this method is used when using prototype cells, where the cells don't need to be registered in the class. + * @param ref A Firebase reference to bind the datasource to + * @param identifier A string to use as a CellReuseIdentifier + * @param tableView An instance of a UITableView to bind to + * @return An instance of FirebaseTableViewDataSource that populates UITableViewCells with FDataSnapshots + */ +- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref prototypeReuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UITableView *)tableView; /** * Initialize an instance of FirebaseTableViewDataSource that populates a custom subclass of UITableViewCell with FDataSnapshots. @@ -75,7 +89,7 @@ * @param tableView An instance of a UITableView to bind to * @return An instance of FirebaseTableViewDataSource that populates a custom subclass of UITableViewCell with FDataSnapshots */ -- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref cellClass:(__NULLABLE Class)cell reuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UITableView *)tableView; +- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref cellClass:(__NULLABLE Class)cell cellReuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UITableView *)tableView; /** * Initialize an instance of FirebaseTableViewDataSource that populates a custom xib with FDataSnapshots. @@ -85,7 +99,7 @@ * @param tableView An instance of a UITableView to bind to * @return An instance of FirebaseTableViewDataSource that populates a custom xib with FDataSnapshots */ -- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref nibNamed:(__NON_NULL NSString *)nibName reuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UITableView *)tableView; +- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref nibNamed:(__NON_NULL NSString *)nibName cellReuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UITableView *)tableView; /** * Initialize an instance of FirebaseTableViewDataSource that populates UITableViewCells with a custom model class. @@ -95,7 +109,17 @@ * @param tableView An instance of a UITableView to bind to * @return An instance of FirebaseTableViewDataSource that populates UITableViewCells with a custom model class */ -- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref modelClass:(__NULLABLE Class)model reuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UITableView *)tableView; +- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref modelClass:(__NULLABLE Class)model cellReuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UITableView *)tableView; + +/** + * Initialize an instance of FirebaseTableViewDataSource that populates UITableViewCells with a custom model class. Note that this method is used when using prototype cells, where the cells don't need to be registered in the class. + * @param ref A Firebase reference to bind the datasource to + * @param model A custom class that FDataSnapshots are coerced to, defaults to FDataSnapshot if nil + * @param identifier A string to use as a CellReuseIdentifier + * @param tableView An instance of a UITableView to bind to + * @return An instance of FirebaseTableViewDataSource that populates UITableViewCells with a custom model class + */ +- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref modelClass:(__NULLABLE Class)model prototypeReuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UITableView *)tableView; /** * Initialize an instance of FirebaseTableViewDataSource that populates a custom subclass of UITableViewCell with a custom model class. @@ -106,7 +130,7 @@ * @param tableView An instance of a UITableView to bind to * @return An instance of FirebaseTableViewDataSource that populates a custom subclass of UITableViewCell with a custom model class */ -- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref modelClass:(__NULLABLE Class)model cellClass:(__NULLABLE Class)cell reuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UITableView *)tableView; +- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref modelClass:(__NULLABLE Class)model cellClass:(__NULLABLE Class)cell cellReuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UITableView *)tableView; /** * Initialize an instance of FirebaseTableViewDataSource that populates a custom xib with a custom model class. @@ -117,13 +141,13 @@ * @param tableView An instance of a UITableView to bind to * @return An instance of FirebaseTableViewDataSource that populates a custom xib with a custom model class */ -- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref modelClass:(__NULLABLE Class)model nibNamed:(__NON_NULL NSString *)nibName reuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UITableView *)tableView; +- (__NON_NULL instancetype)initWithRef:(__NON_NULL Firebase *)ref modelClass:(__NULLABLE Class)model nibNamed:(__NON_NULL NSString *)nibName cellReuseIdentifier:(__NON_NULL NSString *)identifier view:(__NON_NULL UITableView *)tableView; /** * This method populates the fields of a UITableViewCell or subclass given a model object (or FDataSnapshot). * @param callback A block which returns an initialized UITableViewCell (or subclass) and the corresponding object to populate the cell with. */ -- (void)populateCellWithBlock:(__NON_NULL void(^)(UITableViewCell * __NON_NULL_PTR cell, NSObject * __NON_NULL_PTR object))callback; +- (void)populateCellWithBlock:(nonnull void (^)(__kindof UITableViewCell * __NON_NULL_PTR cell, __kindof NSObject * __NON_NULL_PTR object))callback; @end diff --git a/FirebaseUI/Implementation/FirebaseCollectionViewDataSource.m b/FirebaseUI/Implementation/FirebaseCollectionViewDataSource.m index 1b74db2613f..2218cbe14cd 100644 --- a/FirebaseUI/Implementation/FirebaseCollectionViewDataSource.m +++ b/FirebaseUI/Implementation/FirebaseCollectionViewDataSource.m @@ -35,27 +35,39 @@ @implementation FirebaseCollectionViewDataSource #pragma mark - #pragma mark FirebaseDataSource initializer methods -- (instancetype)initWithRef:(Firebase *)ref reuseIdentifier:(NSString *)identifier view:(UICollectionView *)collectionView; +- (instancetype)initWithRef:(Firebase *)ref cellReuseIdentifier:(NSString *)identifier view:(UICollectionView *)collectionView; { - return [self initWithRef:ref modelClass:nil cellClass:nil reuseIdentifier:identifier view:collectionView]; + return [self initWithRef:ref modelClass:nil cellClass:nil cellReuseIdentifier:identifier view:collectionView]; } -- (instancetype)initWithRef:(Firebase *)ref cellClass:(Class)cell reuseIdentifier:(NSString *)identifier view:(UICollectionView *)collectionView; +- (instancetype)initWithRef:(Firebase *)ref prototypeReuseIdentifier:(NSString *)identifier view:(UICollectionView *)collectionView; { - return [self initWithRef:ref modelClass:nil cellClass:cell reuseIdentifier:identifier view:collectionView]; + self.hasPrototypeCell = YES; + return [self initWithRef:ref modelClass:nil cellClass:nil cellReuseIdentifier:identifier view:collectionView]; } -- (instancetype)initWithRef:(Firebase *)ref nibNamed:(NSString *)nibName reuseIdentifier:(NSString *)identifier view:(UICollectionView *)collectionView; +- (instancetype)initWithRef:(Firebase *)ref cellClass:(Class)cell cellReuseIdentifier:(NSString *)identifier view:(UICollectionView *)collectionView; { - return [self initWithRef:ref modelClass:nil nibNamed:nibName reuseIdentifier:identifier view:collectionView]; + return [self initWithRef:ref modelClass:nil cellClass:cell cellReuseIdentifier:identifier view:collectionView]; } -- (instancetype)initWithRef:(Firebase *)ref modelClass:(Class)model reuseIdentifier:(NSString *)identifier view:(UICollectionView *)collectionView; +- (instancetype)initWithRef:(Firebase *)ref nibNamed:(NSString *)nibName cellReuseIdentifier:(NSString *)identifier view:(UICollectionView *)collectionView; { - return [self initWithRef:ref modelClass:model cellClass:nil reuseIdentifier:identifier view:collectionView]; + return [self initWithRef:ref modelClass:nil nibNamed:nibName cellReuseIdentifier:identifier view:collectionView]; } -- (instancetype)initWithRef:(Firebase *)ref modelClass:(Class)model cellClass:(Class)cell reuseIdentifier:(NSString *)identifier view:(UICollectionView *)collectionView; +- (instancetype)initWithRef:(Firebase *)ref modelClass:(Class)model cellReuseIdentifier:(NSString *)identifier view:(UICollectionView *)collectionView; +{ + return [self initWithRef:ref modelClass:model cellClass:nil cellReuseIdentifier:identifier view:collectionView]; +} + +- (instancetype)initWithRef:(Firebase *)ref modelClass:(Class)model prototypeReuseIdentifier:(NSString *)identifier view:(UICollectionView *)collectionView; +{ + self.hasPrototypeCell = YES; + return [self initWithRef:ref modelClass:model cellClass:nil cellReuseIdentifier:identifier view:collectionView]; +} + +- (instancetype)initWithRef:(Firebase *)ref modelClass:(Class)model cellClass:(Class)cell cellReuseIdentifier:(NSString *)identifier view:(UICollectionView *)collectionView; { FirebaseArray *array = [[FirebaseArray alloc] initWithRef:ref]; self = [super initWithArray:array]; @@ -71,15 +83,18 @@ - (instancetype)initWithRef:(Firebase *)ref modelClass:(Class)model cellClass:(C self.collectionView = collectionView; self.modelClass = model; + self.cellClass = cell; self.reuseIdentifier = identifier; self.populateCell = ^(id cell, id object) {}; - [self.collectionView registerClass:cell forCellWithReuseIdentifier:self.reuseIdentifier]; + if (!self.hasPrototypeCell) { + [self.collectionView registerClass:self.cellClass forCellWithReuseIdentifier:self.reuseIdentifier]; + } } return self; } -- (instancetype)initWithRef:(Firebase *)ref modelClass:(Class)model nibNamed:(NSString *)nibName reuseIdentifier:(NSString *)identifier view:(UICollectionView *)collectionView; +- (instancetype)initWithRef:(Firebase *)ref modelClass:(Class)model nibNamed:(NSString *)nibName cellReuseIdentifier:(NSString *)identifier view:(UICollectionView *)collectionView; { FirebaseArray *array = [[FirebaseArray alloc] initWithRef:ref]; self = [super initWithArray:array]; @@ -93,7 +108,7 @@ - (instancetype)initWithRef:(Firebase *)ref modelClass:(Class)model nibNamed:(NS self.modelClass = model; self.reuseIdentifier = identifier; self.populateCell = ^(id cell, id object) {}; - + UINib *nib = [UINib nibWithNibName:nibName bundle:nil]; [self.collectionView registerNib:nib forCellWithReuseIdentifier:self.reuseIdentifier]; } @@ -154,7 +169,7 @@ -(NSInteger)collectionView:(nonnull UICollectionView *)collectionView numberOfIt return [self.array count]; } -- (void)populateCellWithBlock:(__NON_NULL void(^)(UICollectionViewCell * __NON_NULL_PTR cell, NSObject * __NON_NULL_PTR object))callback; +- (void)populateCellWithBlock:(__NON_NULL void(^)(__kindof UICollectionViewCell * __NON_NULL_PTR cell, __kindof NSObject * __NON_NULL_PTR object))callback; { self.populateCell = callback; } diff --git a/FirebaseUI/Implementation/FirebaseTableViewDataSource.m b/FirebaseUI/Implementation/FirebaseTableViewDataSource.m index 7046f5d31bb..595fb843d12 100644 --- a/FirebaseUI/Implementation/FirebaseTableViewDataSource.m +++ b/FirebaseUI/Implementation/FirebaseTableViewDataSource.m @@ -35,27 +35,39 @@ @implementation FirebaseTableViewDataSource #pragma mark - #pragma mark FirebaseDataSource initializer methods -- (instancetype)initWithRef:(Firebase *)ref reuseIdentifier:(NSString *)identifier view:(UITableView *)tableView; +- (instancetype)initWithRef:(Firebase *)ref cellReuseIdentifier:(NSString *)identifier view:(UITableView *)tableView; { - return [self initWithRef:ref modelClass:nil cellClass:nil reuseIdentifier:identifier view:tableView]; + return [self initWithRef:ref modelClass:nil cellClass:nil cellReuseIdentifier:identifier view:tableView]; } -- (instancetype)initWithRef:(Firebase *)ref cellClass:(Class)cell reuseIdentifier:(NSString *)identifier view:(UITableView *)tableView; +- (instancetype)initWithRef:(Firebase *)ref prototypeReuseIdentifier:(NSString *)identifier view:(UITableView *)tableView; { - return [self initWithRef:ref modelClass:nil cellClass:cell reuseIdentifier:identifier view:tableView]; + self.hasPrototypeCell = YES; + return [self initWithRef:ref modelClass:nil cellClass:nil cellReuseIdentifier:identifier view:tableView]; } -- (instancetype)initWithRef:(Firebase *)ref nibNamed:(NSString *)nibName reuseIdentifier:(NSString *)identifier view:(UITableView *)tableView; +- (instancetype)initWithRef:(Firebase *)ref cellClass:(Class)cell cellReuseIdentifier:(NSString *)identifier view:(UITableView *)tableView; { - return [self initWithRef:ref modelClass:nil nibNamed:nibName reuseIdentifier:identifier view:tableView]; + return [self initWithRef:ref modelClass:nil cellClass:cell cellReuseIdentifier:identifier view:tableView]; } -- (instancetype)initWithRef:(Firebase *)ref modelClass:(Class)model reuseIdentifier:(NSString *)identifier view:(UITableView *)tableView; +- (instancetype)initWithRef:(Firebase *)ref nibNamed:(NSString *)nibName cellReuseIdentifier:(NSString *)identifier view:(UITableView *)tableView; { - return [self initWithRef:ref modelClass:model cellClass:nil reuseIdentifier:identifier view:tableView]; + return [self initWithRef:ref modelClass:nil nibNamed:nibName cellReuseIdentifier:identifier view:tableView]; } -- (instancetype)initWithRef:(Firebase *)ref modelClass:(Class)model cellClass:(Class)cell reuseIdentifier:(NSString *)identifier view:(UITableView *)tableView; +- (instancetype)initWithRef:(Firebase *)ref modelClass:(Class)model cellReuseIdentifier:(NSString *)identifier view:(UITableView *)tableView; +{ + return [self initWithRef:ref modelClass:model cellClass:nil cellReuseIdentifier:identifier view:tableView]; +} + +- (instancetype)initWithRef:(Firebase *)ref modelClass:(Class)model prototypeReuseIdentifier:(NSString *)identifier view:(UITableView *)tableView; +{ + self.hasPrototypeCell = YES; + return [self initWithRef:ref modelClass:model cellClass:nil cellReuseIdentifier:identifier view:tableView]; +} + +- (instancetype)initWithRef:(Firebase *)ref modelClass:(Class)model cellClass:(Class)cell cellReuseIdentifier:(NSString *)identifier view:(UITableView *)tableView; { FirebaseArray *array = [[FirebaseArray alloc] initWithRef:ref]; self = [super initWithArray:array]; @@ -74,14 +86,14 @@ - (instancetype)initWithRef:(Firebase *)ref modelClass:(Class)model cellClass:(C self.reuseIdentifier = identifier; self.populateCell = ^(id cell, id object) {}; - if (![self.tableView dequeueReusableCellWithIdentifier:self.reuseIdentifier]) { + if (!self.hasPrototypeCell) { [self.tableView registerClass:cell forCellReuseIdentifier:self.reuseIdentifier]; } } return self; } -- (instancetype)initWithRef:(Firebase *)ref modelClass:(Class)model nibNamed:(NSString *)nibName reuseIdentifier:(NSString *)identifier view:(UITableView *)tableView; +- (instancetype)initWithRef:(Firebase *)ref modelClass:(Class)model nibNamed:(NSString *)nibName cellReuseIdentifier:(NSString *)identifier view:(UITableView *)tableView; { FirebaseArray *array = [[FirebaseArray alloc] initWithRef:ref]; self = [super initWithArray:array]; @@ -96,7 +108,7 @@ - (instancetype)initWithRef:(Firebase *)ref modelClass:(Class)model nibNamed:(NS self.reuseIdentifier = identifier; self.populateCell = ^(id cell, id object) {}; - if (![self.tableView dequeueReusableCellWithIdentifier:self.reuseIdentifier]) { + if (!self.hasPrototypeCell) { UINib *nib = [UINib nibWithNibName:nibName bundle:nil]; [self.tableView registerNib:nib forCellReuseIdentifier:self.reuseIdentifier]; } @@ -160,7 +172,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger return [self.array count]; } -- (void)populateCellWithBlock:(__NON_NULL void(^)(UITableViewCell * __NON_NULL_PTR cell, NSObject * __NON_NULL_PTR object))callback; +- (void)populateCellWithBlock:(nonnull void (^)(__kindof UITableViewCell * __NON_NULL_PTR cell, __kindof NSObject * __NON_NULL_PTR object))callback; { self.populateCell = callback; } diff --git a/examples/FirebaseUIChat/.gitignore b/examples/FirebaseUIChat/.gitignore new file mode 100644 index 00000000000..c4319c3f7f8 --- /dev/null +++ b/examples/FirebaseUIChat/.gitignore @@ -0,0 +1,21 @@ +# Xcode +# +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +*.xccheckout +*.moved-aside +DerivedData +*.hmap +*.ipa +*.xcuserstate +*.xcworkspace +Podfile.lock +Pods/ diff --git a/examples/FirebaseUIChat/FirebaseUIChat.xcodeproj/project.pbxproj b/examples/FirebaseUIChat/FirebaseUIChat.xcodeproj/project.pbxproj new file mode 100644 index 00000000000..e0ef8abd148 --- /dev/null +++ b/examples/FirebaseUIChat/FirebaseUIChat.xcodeproj/project.pbxproj @@ -0,0 +1,516 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 812864A440E7F9929EE6CE11 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F3A6C38C3FB99BDE832EC5EB /* libPods.a */; }; + D81A05F61B86A78700498183 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D81A05F51B86A78700498183 /* main.m */; }; + D81A05F91B86A78700498183 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D81A05F81B86A78700498183 /* AppDelegate.m */; }; + D81A05FC1B86A78700498183 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D81A05FB1B86A78700498183 /* ViewController.m */; }; + D81A05FF1B86A78700498183 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D81A05FD1B86A78700498183 /* Main.storyboard */; }; + D81A06011B86A78700498183 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D81A06001B86A78700498183 /* Images.xcassets */; }; + D81A06041B86A78700498183 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = D81A06021B86A78700498183 /* LaunchScreen.xib */; }; + D81A06101B86A78700498183 /* FirebaseUIChatTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D81A060F1B86A78700498183 /* FirebaseUIChatTests.m */; }; + D81A061B1B86AE7100498183 /* Message.m in Sources */ = {isa = PBXBuildFile; fileRef = D81A061A1B86AE7100498183 /* Message.m */; }; + D852D9411B86DEA500C732E2 /* MessageTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D852D9401B86DEA500C732E2 /* MessageTableViewCell.m */; }; + D852D9431B86DEB500C732E2 /* MessageTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = D852D9421B86DEB500C732E2 /* MessageTableViewCell.xib */; }; + D852D9461B86E7A100C732E2 /* MessageDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = D852D9451B86E7A100C732E2 /* MessageDataSource.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + D81A060A1B86A78700498183 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D81A05E81B86A78700498183 /* Project object */; + proxyType = 1; + remoteGlobalIDString = D81A05EF1B86A78700498183; + remoteInfo = FirebaseUIChat; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 6D57EB4D8BFBE7A4BDD335F0 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; + 9BACE546357A3207276416D6 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; + D81A05F01B86A78700498183 /* FirebaseUIChat.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FirebaseUIChat.app; sourceTree = BUILT_PRODUCTS_DIR; }; + D81A05F41B86A78700498183 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + D81A05F51B86A78700498183 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + D81A05F71B86A78700498183 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + D81A05F81B86A78700498183 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + D81A05FA1B86A78700498183 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + D81A05FB1B86A78700498183 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + D81A05FE1B86A78700498183 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + D81A06001B86A78700498183 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; + D81A06031B86A78700498183 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; + D81A06091B86A78700498183 /* FirebaseUIChatTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FirebaseUIChatTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + D81A060E1B86A78700498183 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + D81A060F1B86A78700498183 /* FirebaseUIChatTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FirebaseUIChatTests.m; sourceTree = ""; }; + D81A06191B86AE7100498183 /* Message.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Message.h; sourceTree = ""; }; + D81A061A1B86AE7100498183 /* Message.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Message.m; sourceTree = ""; }; + D852D93F1B86DEA500C732E2 /* MessageTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageTableViewCell.h; sourceTree = ""; }; + D852D9401B86DEA500C732E2 /* MessageTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessageTableViewCell.m; sourceTree = ""; }; + D852D9421B86DEB500C732E2 /* MessageTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MessageTableViewCell.xib; sourceTree = ""; }; + D852D9441B86E7A100C732E2 /* MessageDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageDataSource.h; sourceTree = ""; }; + D852D9451B86E7A100C732E2 /* MessageDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessageDataSource.m; sourceTree = ""; }; + F3A6C38C3FB99BDE832EC5EB /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + D81A05ED1B86A78700498183 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 812864A440E7F9929EE6CE11 /* libPods.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D81A06061B86A78700498183 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 3BE6E98E12CDA78858CDE283 /* Frameworks */ = { + isa = PBXGroup; + children = ( + F3A6C38C3FB99BDE832EC5EB /* libPods.a */, + ); + name = Frameworks; + sourceTree = ""; + }; + 59DB8B58E9AC309FD73ED180 /* Pods */ = { + isa = PBXGroup; + children = ( + 6D57EB4D8BFBE7A4BDD335F0 /* Pods.debug.xcconfig */, + 9BACE546357A3207276416D6 /* Pods.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; + D81A05E71B86A78700498183 = { + isa = PBXGroup; + children = ( + D81A05F21B86A78700498183 /* FirebaseUIChat */, + D81A060C1B86A78700498183 /* FirebaseUIChatTests */, + D81A05F11B86A78700498183 /* Products */, + 59DB8B58E9AC309FD73ED180 /* Pods */, + 3BE6E98E12CDA78858CDE283 /* Frameworks */, + ); + sourceTree = ""; + }; + D81A05F11B86A78700498183 /* Products */ = { + isa = PBXGroup; + children = ( + D81A05F01B86A78700498183 /* FirebaseUIChat.app */, + D81A06091B86A78700498183 /* FirebaseUIChatTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + D81A05F21B86A78700498183 /* FirebaseUIChat */ = { + isa = PBXGroup; + children = ( + D81A05F71B86A78700498183 /* AppDelegate.h */, + D81A05F81B86A78700498183 /* AppDelegate.m */, + D81A05FA1B86A78700498183 /* ViewController.h */, + D81A05FB1B86A78700498183 /* ViewController.m */, + D81A05FD1B86A78700498183 /* Main.storyboard */, + D81A06001B86A78700498183 /* Images.xcassets */, + D81A06021B86A78700498183 /* LaunchScreen.xib */, + D81A05F31B86A78700498183 /* Supporting Files */, + D81A06191B86AE7100498183 /* Message.h */, + D81A061A1B86AE7100498183 /* Message.m */, + D852D93F1B86DEA500C732E2 /* MessageTableViewCell.h */, + D852D9401B86DEA500C732E2 /* MessageTableViewCell.m */, + D852D9421B86DEB500C732E2 /* MessageTableViewCell.xib */, + D852D9441B86E7A100C732E2 /* MessageDataSource.h */, + D852D9451B86E7A100C732E2 /* MessageDataSource.m */, + ); + path = FirebaseUIChat; + sourceTree = ""; + }; + D81A05F31B86A78700498183 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + D81A05F41B86A78700498183 /* Info.plist */, + D81A05F51B86A78700498183 /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + D81A060C1B86A78700498183 /* FirebaseUIChatTests */ = { + isa = PBXGroup; + children = ( + D81A060F1B86A78700498183 /* FirebaseUIChatTests.m */, + D81A060D1B86A78700498183 /* Supporting Files */, + ); + path = FirebaseUIChatTests; + sourceTree = ""; + }; + D81A060D1B86A78700498183 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + D81A060E1B86A78700498183 /* Info.plist */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + D81A05EF1B86A78700498183 /* FirebaseUIChat */ = { + isa = PBXNativeTarget; + buildConfigurationList = D81A06131B86A78700498183 /* Build configuration list for PBXNativeTarget "FirebaseUIChat" */; + buildPhases = ( + 1A811453529C72D6564995EF /* Check Pods Manifest.lock */, + D81A05EC1B86A78700498183 /* Sources */, + D81A05ED1B86A78700498183 /* Frameworks */, + D81A05EE1B86A78700498183 /* Resources */, + 7540E200A4937FA3FD4DA402 /* Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = FirebaseUIChat; + productName = FirebaseUIChat; + productReference = D81A05F01B86A78700498183 /* FirebaseUIChat.app */; + productType = "com.apple.product-type.application"; + }; + D81A06081B86A78700498183 /* FirebaseUIChatTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = D81A06161B86A78700498183 /* Build configuration list for PBXNativeTarget "FirebaseUIChatTests" */; + buildPhases = ( + D81A06051B86A78700498183 /* Sources */, + D81A06061B86A78700498183 /* Frameworks */, + D81A06071B86A78700498183 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + D81A060B1B86A78700498183 /* PBXTargetDependency */, + ); + name = FirebaseUIChatTests; + productName = FirebaseUIChatTests; + productReference = D81A06091B86A78700498183 /* FirebaseUIChatTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + D81A05E81B86A78700498183 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0640; + ORGANIZATIONNAME = "Firebase, Inc."; + TargetAttributes = { + D81A05EF1B86A78700498183 = { + CreatedOnToolsVersion = 6.4; + }; + D81A06081B86A78700498183 = { + CreatedOnToolsVersion = 6.4; + TestTargetID = D81A05EF1B86A78700498183; + }; + }; + }; + buildConfigurationList = D81A05EB1B86A78700498183 /* Build configuration list for PBXProject "FirebaseUIChat" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = D81A05E71B86A78700498183; + productRefGroup = D81A05F11B86A78700498183 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + D81A05EF1B86A78700498183 /* FirebaseUIChat */, + D81A06081B86A78700498183 /* FirebaseUIChatTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + D81A05EE1B86A78700498183 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D81A05FF1B86A78700498183 /* Main.storyboard in Resources */, + D852D9431B86DEB500C732E2 /* MessageTableViewCell.xib in Resources */, + D81A06041B86A78700498183 /* LaunchScreen.xib in Resources */, + D81A06011B86A78700498183 /* Images.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D81A06071B86A78700498183 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 1A811453529C72D6564995EF /* Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; + 7540E200A4937FA3FD4DA402 /* Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + D81A05EC1B86A78700498183 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D81A05FC1B86A78700498183 /* ViewController.m in Sources */, + D81A061B1B86AE7100498183 /* Message.m in Sources */, + D852D9461B86E7A100C732E2 /* MessageDataSource.m in Sources */, + D852D9411B86DEA500C732E2 /* MessageTableViewCell.m in Sources */, + D81A05F91B86A78700498183 /* AppDelegate.m in Sources */, + D81A05F61B86A78700498183 /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D81A06051B86A78700498183 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D81A06101B86A78700498183 /* FirebaseUIChatTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + D81A060B1B86A78700498183 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = D81A05EF1B86A78700498183 /* FirebaseUIChat */; + targetProxy = D81A060A1B86A78700498183 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + D81A05FD1B86A78700498183 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + D81A05FE1B86A78700498183 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + D81A06021B86A78700498183 /* LaunchScreen.xib */ = { + isa = PBXVariantGroup; + children = ( + D81A06031B86A78700498183 /* Base */, + ); + name = LaunchScreen.xib; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + D81A06111B86A78700498183 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.4; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + D81A06121B86A78700498183 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.4; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + D81A06141B86A78700498183 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 6D57EB4D8BFBE7A4BDD335F0 /* Pods.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = FirebaseUIChat/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + D81A06151B86A78700498183 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9BACE546357A3207276416D6 /* Pods.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = FirebaseUIChat/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; + D81A06171B86A78700498183 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + ); + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + INFOPLIST_FILE = FirebaseUIChatTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FirebaseUIChat.app/FirebaseUIChat"; + }; + name = Debug; + }; + D81A06181B86A78700498183 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + ); + INFOPLIST_FILE = FirebaseUIChatTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FirebaseUIChat.app/FirebaseUIChat"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + D81A05EB1B86A78700498183 /* Build configuration list for PBXProject "FirebaseUIChat" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + D81A06111B86A78700498183 /* Debug */, + D81A06121B86A78700498183 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + D81A06131B86A78700498183 /* Build configuration list for PBXNativeTarget "FirebaseUIChat" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + D81A06141B86A78700498183 /* Debug */, + D81A06151B86A78700498183 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + D81A06161B86A78700498183 /* Build configuration list for PBXNativeTarget "FirebaseUIChatTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + D81A06171B86A78700498183 /* Debug */, + D81A06181B86A78700498183 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = D81A05E81B86A78700498183 /* Project object */; +} diff --git a/examples/FirebaseUIChat/FirebaseUIChat.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/examples/FirebaseUIChat/FirebaseUIChat.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000000..4b0d5c024ca --- /dev/null +++ b/examples/FirebaseUIChat/FirebaseUIChat.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/examples/FirebaseUIChat/FirebaseUIChat.xcworkspace/contents.xcworkspacedata b/examples/FirebaseUIChat/FirebaseUIChat.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000000..6df464c0527 --- /dev/null +++ b/examples/FirebaseUIChat/FirebaseUIChat.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/examples/FirebaseUIChat/FirebaseUIChat/AppDelegate.h b/examples/FirebaseUIChat/FirebaseUIChat/AppDelegate.h new file mode 100644 index 00000000000..a7988029fb4 --- /dev/null +++ b/examples/FirebaseUIChat/FirebaseUIChat/AppDelegate.h @@ -0,0 +1,17 @@ +// +// AppDelegate.h +// FirebaseUIChat +// +// Created by Mike Mcdonald on 8/20/15. +// Copyright (c) 2015 Firebase, Inc. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + + +@end + diff --git a/examples/FirebaseUIChat/FirebaseUIChat/AppDelegate.m b/examples/FirebaseUIChat/FirebaseUIChat/AppDelegate.m new file mode 100644 index 00000000000..55267387bf2 --- /dev/null +++ b/examples/FirebaseUIChat/FirebaseUIChat/AppDelegate.m @@ -0,0 +1,45 @@ +// +// AppDelegate.m +// FirebaseUIChat +// +// Created by Mike Mcdonald on 8/20/15. +// Copyright (c) 2015 Firebase, Inc. All rights reserved. +// + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Override point for customization after application launch. + return YES; +} + +- (void)applicationWillResignActive:(UIApplication *)application { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. +} + +- (void)applicationDidEnterBackground:(UIApplication *)application { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + +- (void)applicationWillEnterForeground:(UIApplication *)application { + // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. +} + +- (void)applicationDidBecomeActive:(UIApplication *)application { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + +- (void)applicationWillTerminate:(UIApplication *)application { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + +@end diff --git a/examples/FirebaseUIChat/FirebaseUIChat/Base.lproj/LaunchScreen.xib b/examples/FirebaseUIChat/FirebaseUIChat/Base.lproj/LaunchScreen.xib new file mode 100644 index 00000000000..538c894c191 --- /dev/null +++ b/examples/FirebaseUIChat/FirebaseUIChat/Base.lproj/LaunchScreen.xib @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/FirebaseUIChat/FirebaseUIChat/Base.lproj/Main.storyboard b/examples/FirebaseUIChat/FirebaseUIChat/Base.lproj/Main.storyboard new file mode 100644 index 00000000000..5bb33a20c0f --- /dev/null +++ b/examples/FirebaseUIChat/FirebaseUIChat/Base.lproj/Main.storyboard @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/FirebaseUIChat/FirebaseUIChat/Images.xcassets/AppIcon.appiconset/Contents.json b/examples/FirebaseUIChat/FirebaseUIChat/Images.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000000..118c98f7461 --- /dev/null +++ b/examples/FirebaseUIChat/FirebaseUIChat/Images.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,38 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/examples/FirebaseUIChat/FirebaseUIChat/Info.plist b/examples/FirebaseUIChat/FirebaseUIChat/Info.plist new file mode 100644 index 00000000000..7cdac2a6838 --- /dev/null +++ b/examples/FirebaseUIChat/FirebaseUIChat/Info.plist @@ -0,0 +1,40 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + Firebase.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/examples/FirebaseUIChat/FirebaseUIChat/Message.h b/examples/FirebaseUIChat/FirebaseUIChat/Message.h new file mode 100644 index 00000000000..6c43f327ebb --- /dev/null +++ b/examples/FirebaseUIChat/FirebaseUIChat/Message.h @@ -0,0 +1,18 @@ +// +// Message.h +// FirebaseUIChat +// +// Created by Mike Mcdonald on 8/20/15. +// Copyright (c) 2015 Firebase, Inc. All rights reserved. +// + +#import + +@interface Message : NSObject + +@property (strong, nonatomic) NSString *name; +@property (strong, nonatomic) NSString *message; + +-(instancetype)initWithName:(NSString *)name andMessage:(NSString *)message; + +@end diff --git a/examples/FirebaseUIChat/FirebaseUIChat/Message.m b/examples/FirebaseUIChat/FirebaseUIChat/Message.m new file mode 100644 index 00000000000..582abb12e1b --- /dev/null +++ b/examples/FirebaseUIChat/FirebaseUIChat/Message.m @@ -0,0 +1,28 @@ +// +// Message.m +// FirebaseUIChat +// +// Created by Mike Mcdonald on 8/20/15. +// Copyright (c) 2015 Firebase, Inc. All rights reserved. +// + +#import "Message.h" + +@implementation Message + +- (instancetype)init; +{ + return [self initWithName:@"" andMessage:@""]; +} + +-(instancetype)initWithName:(NSString *)name andMessage:(NSString *)message; +{ + self = [super init]; + if (self) { + self.name = name; + self.message = message; + } + return self; +} + +@end diff --git a/examples/FirebaseUIChat/FirebaseUIChat/MessageDataSource.h b/examples/FirebaseUIChat/FirebaseUIChat/MessageDataSource.h new file mode 100644 index 00000000000..2e6924a8054 --- /dev/null +++ b/examples/FirebaseUIChat/FirebaseUIChat/MessageDataSource.h @@ -0,0 +1,15 @@ +// +// MessageDataSource.h +// FirebaseUIChat +// +// Created by Mike Mcdonald on 8/20/15. +// Copyright © 2015 Firebase, Inc. All rights reserved. +// + +#import "FirebaseTableViewDataSource.h" + +#import + +@interface MessageDataSource : FirebaseTableViewDataSource + +@end diff --git a/examples/FirebaseUIChat/FirebaseUIChat/MessageDataSource.m b/examples/FirebaseUIChat/FirebaseUIChat/MessageDataSource.m new file mode 100644 index 00000000000..c719febf5f5 --- /dev/null +++ b/examples/FirebaseUIChat/FirebaseUIChat/MessageDataSource.m @@ -0,0 +1,25 @@ +// +// MessageDataSource.m +// FirebaseUIChat +// +// Created by Mike Mcdonald on 8/20/15. +// Copyright © 2015 Firebase, Inc. All rights reserved. +// + +#import "MessageDataSource.h" + +@implementation MessageDataSource + +-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath; +{ + return YES; +} + +-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath; +{ + if (editingStyle == UITableViewCellEditingStyleDelete) { + [[self.array refForIndex:indexPath.row] removeValue]; + } +} + +@end diff --git a/examples/FirebaseUIChat/FirebaseUIChat/MessageTableViewCell.h b/examples/FirebaseUIChat/FirebaseUIChat/MessageTableViewCell.h new file mode 100644 index 00000000000..025e815dbb5 --- /dev/null +++ b/examples/FirebaseUIChat/FirebaseUIChat/MessageTableViewCell.h @@ -0,0 +1,18 @@ +// +// MessageTableViewCell.h +// FirebaseUIChat +// +// Created by Mike Mcdonald on 8/20/15. +// Copyright © 2015 Firebase, Inc. All rights reserved. +// + +#import + +@interface MessageTableViewCell : UITableViewCell +@property (weak, nonatomic) IBOutlet UILabel *myMessageLabel; +@property (weak, nonatomic) IBOutlet UILabel *myNameLabel; + +@property (weak, nonatomic) IBOutlet UILabel *otherMessageLabel; +@property (weak, nonatomic) IBOutlet UILabel *otherNameLabel; + +@end diff --git a/examples/FirebaseUIChat/FirebaseUIChat/MessageTableViewCell.m b/examples/FirebaseUIChat/FirebaseUIChat/MessageTableViewCell.m new file mode 100644 index 00000000000..f125a91cb32 --- /dev/null +++ b/examples/FirebaseUIChat/FirebaseUIChat/MessageTableViewCell.m @@ -0,0 +1,23 @@ +// +// MessageTableViewCell.m +// FirebaseUIChat +// +// Created by Mike Mcdonald on 8/20/15. +// Copyright © 2015 Firebase, Inc. All rights reserved. +// + +#import "MessageTableViewCell.h" + +@implementation MessageTableViewCell + +-(void)awakeFromNib; +{ + +} + +-(instancetype)initWithFrame:(CGRect)frame; +{ + return [super initWithFrame:frame]; +} + +@end diff --git a/examples/FirebaseUIChat/FirebaseUIChat/MessageTableViewCell.xib b/examples/FirebaseUIChat/FirebaseUIChat/MessageTableViewCell.xib new file mode 100644 index 00000000000..e511b0a631a --- /dev/null +++ b/examples/FirebaseUIChat/FirebaseUIChat/MessageTableViewCell.xib @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/FirebaseUIChat/FirebaseUIChat/ViewController.h b/examples/FirebaseUIChat/FirebaseUIChat/ViewController.h new file mode 100644 index 00000000000..033b3041375 --- /dev/null +++ b/examples/FirebaseUIChat/FirebaseUIChat/ViewController.h @@ -0,0 +1,22 @@ +// +// ViewController.h +// FirebaseUIChat +// +// Created by Mike Mcdonald on 8/20/15. +// Copyright (c) 2015 Firebase, Inc. All rights reserved. +// + +#import +#import +#import + +@interface ViewController : UIViewController + +@property (strong, nonatomic) Firebase *ref; +@property (strong, nonatomic) FirebaseTableViewDataSource *dataSource; + +@property (weak, nonatomic) IBOutlet UITableView *tableView; +@property (weak, nonatomic) IBOutlet UITextField *inputTextField; + +@end + diff --git a/examples/FirebaseUIChat/FirebaseUIChat/ViewController.m b/examples/FirebaseUIChat/FirebaseUIChat/ViewController.m new file mode 100644 index 00000000000..2ae21d06a45 --- /dev/null +++ b/examples/FirebaseUIChat/FirebaseUIChat/ViewController.m @@ -0,0 +1,68 @@ +// +// ViewController.m +// FirebaseUIChat +// +// Created by Mike Mcdonald on 8/20/15. +// Copyright (c) 2015 Firebase, Inc. All rights reserved. +// + +#import "ViewController.h" +#import "Message.h" +#import "MessageTableViewCell.h" +#import "MessageDataSource.h" + +@interface ViewController () + +@end + +@implementation ViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view, typically from a nib. + + self.ref = [[Firebase alloc] initWithUrl:@"https://nanochat.firebaseio.com"]; + + self.dataSource = [[MessageDataSource alloc] initWithRef:self.ref modelClass:[Message class] nibNamed:@"MessageTableViewCell" cellReuseIdentifier:@"cellReuseIdentifier" view:self.tableView]; + + [self.dataSource populateCellWithBlock:^void(MessageTableViewCell * __nonnull cell, Message * __nonnull message) { + if ([message.name isEqualToString:@"iOS User"]) { + cell.myMessageLabel.text = message.message; + cell.myNameLabel.text = message.name; + cell.myNameLabel.textColor = [UIColor colorWithRed:52.0/255.0 green:170.0/255.0 blue:220.0/255.0 alpha:1.0]; + [cell.otherMessageLabel setHidden:YES]; + [cell.otherNameLabel setHidden:YES]; + [cell.myMessageLabel setHidden:NO]; + [cell.myNameLabel setHidden:NO]; + } else { + cell.otherMessageLabel.text = message.message; + cell.otherNameLabel.text = message.name; + cell.otherNameLabel.textColor = [UIColor colorWithRed:164.0/255.0 green:199.0/255.0 blue:57.0/255.0 alpha:1.0]; + [cell.otherMessageLabel setHidden:NO]; + [cell.otherNameLabel setHidden:NO]; + [cell.myMessageLabel setHidden:YES]; + [cell.myNameLabel setHidden:YES]; + } + }]; + + self.tableView.dataSource = self.dataSource; + self.tableView.delegate = self; +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; +} + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath; +{ + [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; +} + +-(BOOL)textFieldShouldReturn:(UITextField *)textField; +{ + [[self.ref childByAutoId] setValue:@{@"name": @"iOS User", @"message": textField.text}]; + textField.text = @""; + return YES; +} + +@end diff --git a/examples/FirebaseUIChat/FirebaseUIChat/main.m b/examples/FirebaseUIChat/FirebaseUIChat/main.m new file mode 100644 index 00000000000..d1a59a283d5 --- /dev/null +++ b/examples/FirebaseUIChat/FirebaseUIChat/main.m @@ -0,0 +1,16 @@ +// +// main.m +// FirebaseUIChat +// +// Created by Mike Mcdonald on 8/20/15. +// Copyright (c) 2015 Firebase, Inc. All rights reserved. +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/examples/FirebaseUIChat/FirebaseUIChatTests/FirebaseUIChatTests.m b/examples/FirebaseUIChat/FirebaseUIChatTests/FirebaseUIChatTests.m new file mode 100644 index 00000000000..3fcce09e0d1 --- /dev/null +++ b/examples/FirebaseUIChat/FirebaseUIChatTests/FirebaseUIChatTests.m @@ -0,0 +1,40 @@ +// +// FirebaseUIChatTests.m +// FirebaseUIChatTests +// +// Created by Mike Mcdonald on 8/20/15. +// Copyright (c) 2015 Firebase, Inc. All rights reserved. +// + +#import +#import + +@interface FirebaseUIChatTests : XCTestCase + +@end + +@implementation FirebaseUIChatTests + +- (void)setUp { + [super setUp]; + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testExample { + // This is an example of a functional test case. + XCTAssert(YES, @"Pass"); +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the time of here. + }]; +} + +@end diff --git a/examples/FirebaseUIChat/FirebaseUIChatTests/Info.plist b/examples/FirebaseUIChat/FirebaseUIChatTests/Info.plist new file mode 100644 index 00000000000..2fb984ca7e1 --- /dev/null +++ b/examples/FirebaseUIChat/FirebaseUIChatTests/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + Firebase.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/examples/FirebaseUIChat/Podfile b/examples/FirebaseUIChat/Podfile new file mode 100644 index 00000000000..a9622828bad --- /dev/null +++ b/examples/FirebaseUIChat/Podfile @@ -0,0 +1,13 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '6.0' + +pod 'FirebaseUI', :path => '~/Development/Firebase/FirebaseUI' + +target 'FirebaseUIChat' do + +end + +target 'FirebaseUIChatTests' do + +end + diff --git a/examples/FirebaseUIChat/README.md b/examples/FirebaseUIChat/README.md new file mode 100644 index 00000000000..b2ee4cf2628 --- /dev/null +++ b/examples/FirebaseUIChat/README.md @@ -0,0 +1,17 @@ +FirebaseUI Chat Demo +==================== + +This is a super simple FirebaseUI Chat demo. It shows: + 1. The ease of integrating with FirebaseUI + 1. Using a `UITableView` outside of a `UITableViewController` + 1. Using custom XIBs in FirebaseUI to achieve a custom look and feel + 1. Using a model object to get strongly typed objects from Firebase + 1. Using a custom `FirebaseTableViewDataSource` to add deletion + +In order to install and run, simply: +``` bash +git clone https://github.com/firebase/FirebaseUI-iOS.git +cd FirebaseUI-iOS/examples/FirebaseUI +pod install +open FirebaseUIChat.xcworkspace +```