Skip to content

Commit 01bf08f

Browse files
committed
update docs
Change-Id: Ic96b73b1ffcabd667d23653f8db893fd4b807a52
1 parent 356f09d commit 01bf08f

4 files changed

Lines changed: 84 additions & 78 deletions

File tree

FirebaseDatabaseUI/README.md

Lines changed: 14 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
FirebaseUI Database allows you to quickly connect common UI elements to the [Firebase Realtime Database](https://firebase.google.com/docs/database?utm_source=firebaseui-ios) for data storage, allowing views to be updated in realtime as they change, and providing simple interfaces for common tasks like displaying lists or collections of items.
44

55
## FirebaseUI Database
6-
Provides core data binding capabilities as well as specific datasources for lists of data. Skip to the [Core API overview](https://github.com/firebase/firebaseui-ios#firebaseui-core-api) for more information.
6+
Provides core data binding capabilities as well as specific data sources for lists of data.
77

88
Class | Description
99
-------------------------------- | --------------------------------
@@ -12,23 +12,19 @@ FUICollectionViewDataSource | Data source to bind a Firebase query to a UIC
1212
FUIIndexCollectionViewDataSource | Data source to populate a collection view with indexed data from Firebase DB.
1313
FUIIndexTableViewDataSource | Data source to populate a table view with indexed data from Firebase DB.
1414
FUIArray | Keeps an array synchronized to a Firebase query
15+
FUISortedArray | A synchronized array that automatically sorts its contents.
1516
FUIIndexArray | Keeps an array synchronized to indexed data from two Firebase references.
1617

17-
For a more in-depth explanation of each of the above, check the usage instructions below or read the [docs](https://firebaseui.firebaseapp.com/docs/ios/index.html).
18+
For a more in-depth explanation of each of the above, check the usage instructions below.
1819

19-
## FirebaseUI Database API
20+
## API Overview
2021
### FUITableViewDataSource
2122

2223
`FUITableViewDataSource` implements the `UITableViewDataSource` protocol to automatically use Firebase as a data source for your `UITableView`.
2324

2425
#### Swift
2526
```swift
26-
// YourViewController.swift
27-
28-
let firebaseRef = Database.database().reference()
29-
var dataSource: FUITableViewDataSource!
30-
31-
self.dataSource = self.tableView.bind(to: self.firebaseRef) { tableView, indexPath, snapshot in
27+
self.dataSource = self.tableView.bind(to: query) { tableView, indexPath, snapshot in
3228
// Dequeue cell
3329
let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath)
3430
/* populate cell */
@@ -39,15 +35,7 @@ self.dataSource = self.tableView.bind(to: self.firebaseRef) { tableView, indexPa
3935
#### Objective-C
4036

4137
```objc
42-
// YourViewController.h
43-
44-
@property (strong, nonatomic) FIRDatabaseReference *firebaseRef;
45-
@property (strong, nonatomic) FUITableViewDataSource *dataSource;
46-
```
47-
48-
```objc
49-
// YourViewController.m
50-
self.dataSource = [self.tableView bindToQuery:self.firebaseRef
38+
self.dataSource = [self.tableView bindToQuery:query
5139
populateCell:^UITableViewCell *(UITableView *tableView,
5240
NSIndexPath *indexPath,
5341
FIRDataSnapshot *snap) {
@@ -64,26 +52,16 @@ self.dataSource = [self.tableView bindToQuery:self.firebaseRef
6452
6553
#### Swift
6654
```swift
67-
// YourViewController.swift
68-
69-
self.dataSource = self.collectionView?.bind(to: self.firebaseRef) { collectionView, indexPath, snap in
55+
self.dataSource = self.collectionView.bind(to: self.firebaseRef) { collectionView, indexPath, snap in
7056
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "reuseIdentifier", for: indexPath)
7157
/* populate cell */
7258
return cell
7359
}
7460
```
7561

7662
#### Objective-C
77-
```objective-c
78-
// YourViewController.h
79-
80-
@property (strong, nonatomic) FIRDatabaseReference *firebaseRef;
81-
@property (strong, nonatomic) FUICollectionViewDataSource *dataSource;
82-
```
8363

8464
```objective-c
85-
// YourViewController.m
86-
8765
self.firebaseRef = [[FIRDatabase database] reference];
8866
self.dataSource = [self.collectionView bindToQuery:self.firebaseRef
8967
populateCell:^UICollectionViewCell *(UICollectionView *collectionView,
@@ -96,13 +74,9 @@ self.dataSource = [self.collectionView bindToQuery:self.firebaseRef
9674
}];
9775
```
9876
99-
## Customizing your UITableView or UICollectionView
100-
101-
You can use `FUITableViewDataSource` or `FUICollectionViewDataSource` in several ways to create custom UITableViews or UICollectionViews. For more information on how to create custom UITableViews, check out the following tutorial on [TutsPlus](http://code.tutsplus.com/tutorials/ios-sdk-crafting-custom-uitableview-cells--mobile-15702). For more information on how to create custom UICollectionViews, particularly how to implement a UICollectionViewLayout, check out the following tutorial on Ray Wenderlich in [Objective-C](http://www.raywenderlich.com/22324/beginning-uicollectionview-in-ios-6-part-12) and [Swift](http://www.raywenderlich.com/78550/beginning-ios-collection-views-swift-part-1).
102-
10377
### Using the Default Table/Collection View Cell
10478
105-
You can use the default `UITableViewCell` or `UICollectionViewCell` implementations to get up and running quickly. For `UITableViewCell`s, this allows for the `cell.textLabel` and the `cell.detailTextLabel` to be used directly out of the box. For `UICollectionViewCell`s, you will have to add subviews to the contentView in order for it to be useful.
79+
You can use the default `UITableViewCell` or `UICollectionViewCell` implementations to get up and running quickly. For `UITableViewCell`s, this allows for the `cell.textLabel` and the `cell.detailTextLabel` to be used directly out of the box. For `UICollectionViewCell`s, you will have to add subviews to the contentView in order for them to be useful.
10680
10781
#### Swift
10882
```swift
@@ -115,10 +89,10 @@ self.dataSource = self.tableView.bind(to: firebaseRef) { tableView, indexPath, s
11589
```
11690

11791
```swift
118-
self.dataSource = self.collectionView?.bind(to: firebaseRef) { collectionView, indexPath, snap in
92+
self.dataSource = self.collectionView.bind(to: firebaseRef) { collectionView, indexPath, snap in
11993
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "reuseIdentifier", for: indexPath)
120-
// Populate cell as you see fit by adding subviews as appropriate
121-
cell.contentView.addSubview(customView)
94+
// Populate cell as you see fit
95+
cell.contentView.accessibilityLabel = "A cell"
12296
return cell
12397
}
12498
```
@@ -144,8 +118,8 @@ self.dataSource = [self.collectionView bindToQuery:self.firebaseRef
144118
FIRDataSnapshot *snap) {
145119
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuseIdentifier"
146120
forIndexPath:indexPath];
147-
// Populate cell as you see fit by adding subviews as appropriate
148-
[cell.contentView addSubview:customView];
121+
// Populate cell as you see fit
122+
cell.contentView.accessibilityLabel = @"A cell";
149123
return cell;
150124
}];
151125
```
@@ -156,7 +130,7 @@ FirebaseUI has several building blocks that developers should understand before
156130

157131
### FUIArray and the FUICollectionDelegate Protocol
158132

159-
`FUIArray` is synchronized array connecting a Firebase `FIRDatabaseReference` with an array. It surfaces Firebase events through the `FUICollectionDelegate` Protocol. It is generally recommended that developers not directly access `FUIArray` without routing it through a custom data source, though if this is desired, check out `FUIDataSource` below. See the header files for more in-depth documentation.
133+
`FUIArray` is synchronized array connecting a Firebase `FIRDatabaseReference` with an array. It surfaces Firebase events through the `FUICollectionDelegate` Protocol. If you're building a multiple-section UI, you'll have to use this class directly instead of using one of the provided data sources.
160134

161135
#### Swift
162136
```swift

FirebaseFirestoreUI/README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#Firestore UI - UI Bindings for Cloud Firestore
2+
3+
Firestore UI provides a handful of classes that allow developers to easily bind
4+
UI elements to Cloud Firestore queries, and to update their UI elements when
5+
those queries change.
6+
7+
##API Overview
8+
9+
FUIFirestoreTableViewDataSource | Binds a Firestore query to a table view.
10+
FUIFirestoreCollectionViewDataSource | Binds a Firestore query to a collection view.
11+
FUIBatchedArray | Maintains a local array containing the contents of a Firestore query.
12+
FUISnapshotArrayDiff | Describes an array update in a manner friendly to table and collection views.
13+
14+
####FUIFirestoreTableViewDataSource
15+
16+
`FUIFirestoreTableViewDataSource` is responsible for observing a Firestore query
17+
and updating a UITableView as the query changes, suitable for single-section
18+
table views dependent on a single query. The query can be re-assigned while
19+
active, and the data source will generate an update from the two queries'
20+
contents and pass it to its table view. To get started, use the
21+
`bind(to:populateCell:)` method on `UITableView`. Usage is almost exactly the
22+
same as it is in Firebase Database UI.
23+
24+
```swift
25+
self.dataSource = tableView.bind(to: query) { tableView, indexPath, snapshot in
26+
// Dequeue cell
27+
let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath)
28+
/* populate cell */
29+
return cell
30+
}
31+
```
32+
33+
####FUIFirestoreCollectionViewDataSource
34+
35+
Like its table view counterpart, `FUIFirestoreCollectionViewDataSource` keeps a
36+
Firestore query in sync with a collection view instance, suitable for
37+
single-section collection views dependent on a single query. To get started, use
38+
the `bind(to:populateCell:)` method on `UICollectionView`.
39+
40+
```swift
41+
self.dataSource = collectionView.bind(to: query) { collectionView, indexPath, snap in
42+
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "reuseIdentifier", for: indexPath)
43+
/* populate cell */
44+
return cell
45+
}
46+
```
47+
48+
####FUIBatchedArray
49+
50+
`FUIBatchedArray` powers all of the updating logic in the data source classes
51+
by generating diffs from the document change data in Firestore query snapshot
52+
updates. The query assigned to a batched array is mutable, and may be changed
53+
while the array is observing its query. In this event, the array will compute
54+
an update by diffing the contents of the old and new query and pass an update
55+
to its delegate. This operation is relatively expensive, so try to avoid diffing
56+
large or unbounded queries.
57+
58+
If you're creating a more complex UI, chances are you'll have to use
59+
`FUIBatchedArray` directly.
60+
61+
```swift
62+
let array = FUIBatchedArray(query: query, delegate: self)
63+
array.observeQuery()
64+
```

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,14 @@ framework](https://firebase.google.com/docs/ios/setup) to your project.
5656

5757
## Documentation
5858

59-
The docs for individual subspecs of FirebaseUI can be found in their respective
59+
The READMEs for components of FirebaseUI can be found in their respective
6060
project folders.
6161

62+
- [Database](FirebaseDatabaseUI/README.md)
63+
- [Firestore](FirebaseFirestoreUI/README.md)
64+
- [Auth](FirebaseAuthUI/README.md)
65+
- [Storage](FirebaseStorageUI/README.md)
66+
6267
## Local Setup
6368

6469
If you'd like to contribute to FirebaseUI for iOS, you'll need to run the

create-docs.sh

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)