Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
ra1028 committed Jul 28, 2019
1 parent 8c5f726 commit fef5d92
Show file tree
Hide file tree
Showing 46 changed files with 1,852 additions and 3,590 deletions.
9 changes: 2 additions & 7 deletions .jazzy.yml
Expand Up @@ -44,17 +44,12 @@ custom_categories:
- UICollectionViewReloadDataUpdater
- name: Interfaces
children:
- ComponentRenderable
- UITableViewComponentCell
- UITableViewComponentHeaderFooterView
- UICollectionViewComponentCell
- UICollectionComponentReusableView
- name: Content Protocols
children:
- UITableViewCellContent
- UITableViewHeaderFooterViewContent
- UICollectionViewCellContent
- UICollectionReusableViewContent
- name: Changesets
children:
- DataChangeset
- StagedDataChangeset
- StagedDataChangeset
56 changes: 35 additions & 21 deletions README.md
Expand Up @@ -327,7 +327,9 @@ class MenuItemContent: UIControl {
addTarget(self, action: #selector(handleSelect), for: .touchUpInside)
}
}
```

```swift
struct MenuItem: Component {
var text: String
var onSelect: () -> Void
Expand Down Expand Up @@ -406,18 +408,42 @@ let renderer = Renderer(
)
```

Furthermore, it can be customized the class of the elements(cell/header/footer) which becomes the container of component by setting it to `config`.
Furthermore, it can be customized the class of the elements(cell/header/footer) which becomes the container of components by overriding some methods in adapter as following.
You can also use `xib` by giving nib as parameter of init of the return value Registration.

```swift
class CustomTableViewAdapter: UITableViewAdapter {
// Use custom cell.
override func cellRegistration(tableView: UITableView, indexPath: IndexPath, node: CellNode) -> CellRegistration {
return CellRegistration(class: CustomTableViewCell.self)
}

// Use custom header view.
override func headerViewRegistration(tableView: UITableView, section: Int, node: ViewNode) -> ViewRegistration {
return ViewRegistration(class: CustomTableViewHeaderFooterView.self)
}

// Use custom footer view.
override func footerViewRegistration(tableView: UITableView, section: Int, node: ViewNode) -> ViewRegistration {
return ViewRegistration(class: CustomTableViewHeaderFooterView.self)
}
}
```

- **config**
The configuration which having the classes of elements. It can be specified only when adapter is initialized.
In UICollectionViewAdapter, you can select the node corresponding to a certain kind.

```swift
let config = UITableViewAdapter.Config(
cellClass: CustomCell.self,
headerViewClass: CustomHeaderView.self,
footerViewClass: CustomFooterView.self
)
let adapter = UITableViewAdapter(config: config)
class CustomCollectionViewAdapter: UICollectionViewAdapter {
override func supplementaryViewNode(forElementKind kind: String, collectionView: UICollectionView, at indexPath: IndexPath) -> ViewNode? {
switch kind {
case "CustomSupplementaryViewKindSectionHeader":
return headerNode(in: indexPath.section)

default:
return super.supplementaryViewNode(forElementKind: kind, collectionView: collectionView, at: indexPath)
}
}
}
```

[See more](https://ra1028.github.io/Carbon/Adapters.html)
Expand Down Expand Up @@ -458,18 +484,6 @@ Default is `false`.

[See more](https://ra1028.github.io/Carbon/Updaters.html)

#### Element-Specific Behaviors

The `content` of component can be received some emement-specific events such as when highlighted, selected, or immediately after rendered, by conforming to protocols below.
We recommend to do implementation that doesn't count on this protocols.

- **UITableViewCellContent**
- **UITableViewHeaderFooterViewContent**
- **UICollectionViewCellContent**
- **UICollectionReusableViewContent**

[See more](https://ra1028.github.io/Carbon/Content%20Protocols.html)

---

## Requirements
Expand Down
3 changes: 1 addition & 2 deletions Sources/Adapters/UICollectionViewAdapter.swift
Expand Up @@ -3,7 +3,6 @@ import UIKit
/// An adapter for `UICollectionView`.
/// It can be inherited to implement customized behavior or give some unimplemented
/// methods of delegate or dataSource.
/// Classes of cell, header and footer to be rendered can be customized by `UICollectionViewRenderConfig`.
///
/// Attention : In UIKit, if inheriting the @objc class which using generics, the delegate and dataSource
/// are don't work properly, so this class doesn't use generics, and also the class inherited
Expand All @@ -15,7 +14,7 @@ open class UICollectionViewAdapter: NSObject, Adapter {
/// A closure that to handle selection events of cell.
open var didSelect: ((SelectionContext) -> Void)?

/// Create an adapter with initial data and rendering config.
/// Create an adapter with initial data.
///
/// - Parameters:
/// - data: An initial data to be rendered.
Expand Down
3 changes: 1 addition & 2 deletions Sources/Adapters/UITableViewAdapter.swift
Expand Up @@ -3,7 +3,6 @@ import UIKit
/// An adapter for `UITableView`.
/// It can be inherited to implement customized behavior or give some unimplemented
/// methods of delegate or dataSource.
/// Classes of cell, header and footer to be rendered can be customized by `UITableViewRenderConfig`.
///
/// Attention : In UIKit, if inheriting the @objc class which using generics, the delegate and dataSource
/// are don't work properly, so this class doesn't use generics, and also the class inherited
Expand All @@ -15,7 +14,7 @@ open class UITableViewAdapter: NSObject, Adapter {
/// A closure that to handle selection events of cell.
open var didSelect: ((SelectionContext) -> Void)?

/// Create an adapter with initial data and rendering config.
/// Create an adapter with initial data.
///
/// - Parameters:
/// - data: An initial data to be rendered.
Expand Down
40 changes: 15 additions & 25 deletions docs/Adapters.html
Expand Up @@ -23,7 +23,7 @@
<a class="header-link" href="index.html">
Carbon Docs
</a>
(100% documented)
(93% documented)
</p>

<p class="header-col--secondary">
Expand Down Expand Up @@ -101,7 +101,10 @@
<a class="nav-group-task-link" href="Classes/UITableViewAdapter.html">UITableViewAdapter</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Classes/UITableViewAdapter/Config.html">– Config</a>
<a class="nav-group-task-link" href="Classes/UITableViewAdapter/CellRegistration.html">– CellRegistration</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Classes/UITableViewAdapter/ViewRegistration.html">– ViewRegistration</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Classes/UITableViewAdapter/SelectionContext.html">– SelectionContext</a>
Expand All @@ -110,7 +113,10 @@
<a class="nav-group-task-link" href="Classes/UICollectionViewAdapter.html">UICollectionViewAdapter</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Classes/UICollectionViewAdapter/Config.html">– Config</a>
<a class="nav-group-task-link" href="Classes/UICollectionViewAdapter/CellRegistration.html">– CellRegistration</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Classes/UICollectionViewAdapter/ViewRegistration.html">– ViewRegistration</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Classes/UICollectionViewAdapter/SelectionContext.html">– SelectionContext</a>
Expand Down Expand Up @@ -143,6 +149,9 @@
<li class="nav-group-name">
<a class="nav-group-name-link" href="Interfaces.html">Interfaces</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Protocols/ComponentRenderable.html">ComponentRenderable</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Classes/UITableViewComponentCell.html">UITableViewComponentCell</a>
</li>
Expand All @@ -157,23 +166,6 @@
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="Content Protocols.html">Content Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Protocols/UITableViewCellContent.html">UITableViewCellContent</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Protocols/UITableViewHeaderFooterViewContent.html">UITableViewHeaderFooterViewContent</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Protocols/UICollectionViewCellContent.html">UICollectionViewCellContent</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Protocols/UICollectionReusableViewContent.html">UICollectionReusableViewContent</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="Changesets.html">Changesets</a>
<ul class="nav-group-tasks">
Expand Down Expand Up @@ -247,8 +239,7 @@ <h4>Declaration</h4>
<div class="abstract">
<p>An adapter for <code>UITableView</code>.
It can be inherited to implement customized behavior or give some unimplemented
methods of delegate or dataSource.
Classes of cell, header and footer to be rendered can be customized by <code>UITableViewRenderConfig</code>.</p>
methods of delegate or dataSource.</p>

<p>Attention : In UIKit, if inheriting the @objc class which using generics, the delegate and dataSource
are don&rsquo;t work properly, so this class doesn&rsquo;t use generics, and also the class inherited
Expand Down Expand Up @@ -286,8 +277,7 @@ <h4>Declaration</h4>
<div class="abstract">
<p>An adapter for <code>UICollectionView</code>.
It can be inherited to implement customized behavior or give some unimplemented
methods of delegate or dataSource.
Classes of cell, header and footer to be rendered can be customized by <code>UICollectionViewRenderConfig</code>.</p>
methods of delegate or dataSource.</p>

<p>Attention : In UIKit, if inheriting the @objc class which using generics, the delegate and dataSource
are don&rsquo;t work properly, so this class doesn&rsquo;t use generics, and also the class inherited
Expand Down Expand Up @@ -346,7 +336,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2019 <a class="link" href="https://github.com/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2019-05-14)</p>
<p>&copy; 2019 <a class="link" href="https://github.com/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2019-07-29)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.4</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
Expand Down
34 changes: 13 additions & 21 deletions docs/Changesets.html
Expand Up @@ -23,7 +23,7 @@
<a class="header-link" href="index.html">
Carbon Docs
</a>
(100% documented)
(93% documented)
</p>

<p class="header-col--secondary">
Expand Down Expand Up @@ -101,7 +101,10 @@
<a class="nav-group-task-link" href="Classes/UITableViewAdapter.html">UITableViewAdapter</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Classes/UITableViewAdapter/Config.html">– Config</a>
<a class="nav-group-task-link" href="Classes/UITableViewAdapter/CellRegistration.html">– CellRegistration</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Classes/UITableViewAdapter/ViewRegistration.html">– ViewRegistration</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Classes/UITableViewAdapter/SelectionContext.html">– SelectionContext</a>
Expand All @@ -110,7 +113,10 @@
<a class="nav-group-task-link" href="Classes/UICollectionViewAdapter.html">UICollectionViewAdapter</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Classes/UICollectionViewAdapter/Config.html">– Config</a>
<a class="nav-group-task-link" href="Classes/UICollectionViewAdapter/CellRegistration.html">– CellRegistration</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Classes/UICollectionViewAdapter/ViewRegistration.html">– ViewRegistration</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Classes/UICollectionViewAdapter/SelectionContext.html">– SelectionContext</a>
Expand Down Expand Up @@ -143,6 +149,9 @@
<li class="nav-group-name">
<a class="nav-group-name-link" href="Interfaces.html">Interfaces</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Protocols/ComponentRenderable.html">ComponentRenderable</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Classes/UITableViewComponentCell.html">UITableViewComponentCell</a>
</li>
Expand All @@ -157,23 +166,6 @@
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="Content Protocols.html">Content Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Protocols/UITableViewCellContent.html">UITableViewCellContent</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Protocols/UITableViewHeaderFooterViewContent.html">UITableViewHeaderFooterViewContent</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Protocols/UICollectionViewCellContent.html">UICollectionViewCellContent</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Protocols/UICollectionReusableViewContent.html">UICollectionReusableViewContent</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="Changesets.html">Changesets</a>
<ul class="nav-group-tasks">
Expand Down Expand Up @@ -263,7 +255,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2019 <a class="link" href="https://github.com/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2019-05-14)</p>
<p>&copy; 2019 <a class="link" href="https://github.com/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2019-07-29)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.4</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
Expand Down

0 comments on commit fef5d92

Please sign in to comment.