-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a2d2a35
Showing
82 changed files
with
4,497 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
##### | ||
# OS X temporary files that should never be committed | ||
# | ||
# c.f. http://www.westwind.com/reference/os-x/invisibles.html | ||
|
||
.DS_Store | ||
|
||
# c.f. http://www.westwind.com/reference/os-x/invisibles.html | ||
|
||
.Trashes | ||
|
||
# c.f. http://www.westwind.com/reference/os-x/invisibles.html | ||
|
||
*.swp | ||
|
||
# *.lock - this is used and abused by many editors for many different things. | ||
# For the main ones I use (e.g. Eclipse), it should be excluded | ||
# from source-control, but YMMV | ||
|
||
*.lock | ||
|
||
# | ||
# profile - REMOVED temporarily (on double-checking, this seems incorrect; I can't find it in OS X docs?) | ||
#profile | ||
|
||
|
||
#### | ||
# Xcode temporary files that should never be committed | ||
# | ||
# NB: NIB/XIB files still exist even on Storyboard projects, so we want this... | ||
|
||
*~.nib | ||
|
||
|
||
#### | ||
# Xcode build files - | ||
# | ||
# NB: slash on the end, so we only remove the FOLDER, not any files that were badly named "DerivedData" | ||
|
||
DerivedData/ | ||
|
||
# NB: slash on the end, so we only remove the FOLDER, not any files that were badly named "build" | ||
|
||
build/ | ||
|
||
|
||
##### | ||
# Xcode private settings (window sizes, bookmarks, breakpoints, custom executables, smart groups) | ||
# | ||
# This is complicated: | ||
# | ||
# SOMETIMES you need to put this file in version control. | ||
# Apple designed it poorly - if you use "custom executables", they are | ||
# saved in this file. | ||
# 99% of projects do NOT use those, so they do NOT want to version control this file. | ||
# ..but if you're in the 1%, comment out the line "*.pbxuser" | ||
|
||
# .pbxuser: http://lists.apple.com/archives/xcode-users/2004/Jan/msg00193.html | ||
|
||
*.pbxuser | ||
|
||
# .mode1v3: http://lists.apple.com/archives/xcode-users/2007/Oct/msg00465.html | ||
|
||
*.mode1v3 | ||
|
||
# .mode2v3: http://lists.apple.com/archives/xcode-users/2007/Oct/msg00465.html | ||
|
||
*.mode2v3 | ||
|
||
# .perspectivev3: http://stackoverflow.com/questions/5223297/xcode-projects-what-is-a-perspectivev3-file | ||
|
||
*.perspectivev3 | ||
|
||
# NB: also, whitelist the default ones, some projects need to use these | ||
!default.pbxuser | ||
!default.mode1v3 | ||
!default.mode2v3 | ||
!default.perspectivev3 | ||
|
||
|
||
#### | ||
# Xcode 4 - semi-personal settings | ||
# | ||
# | ||
# OPTION 1: --------------------------------- | ||
# throw away ALL personal settings (including custom schemes! | ||
# - unless they are "shared") | ||
# | ||
# NB: this is exclusive with OPTION 2 below | ||
xcuserdata | ||
|
||
# OPTION 2: --------------------------------- | ||
# get rid of ALL personal settings, but KEEP SOME OF THEM | ||
# - NB: you must manually uncomment the bits you want to keep | ||
# | ||
# NB: this is exclusive with OPTION 1 above | ||
# | ||
#xcuserdata/**/* | ||
|
||
# (requires option 2 above): Personal Schemes | ||
# | ||
#!xcuserdata/**/xcschemes/* | ||
|
||
#### | ||
# XCode 4 workspaces - more detailed | ||
# | ||
# Workspaces are important! They are a core feature of Xcode - don't exclude them :) | ||
# | ||
# Workspace layout is quite spammy. For reference: | ||
# | ||
# /(root)/ | ||
# /(project-name).xcodeproj/ | ||
# project.pbxproj | ||
# /project.xcworkspace/ | ||
# contents.xcworkspacedata | ||
# /xcuserdata/ | ||
# /(your name)/xcuserdatad/ | ||
# UserInterfaceState.xcuserstate | ||
# /xcsshareddata/ | ||
# /xcschemes/ | ||
# (shared scheme name).xcscheme | ||
# /xcuserdata/ | ||
# /(your name)/xcuserdatad/ | ||
# (private scheme).xcscheme | ||
# xcschememanagement.plist | ||
# | ||
# | ||
|
||
#### | ||
# Xcode 4 - Deprecated classes | ||
# | ||
# Allegedly, if you manually "deprecate" your classes, they get moved here. | ||
# | ||
# We're using source-control, so this is a "feature" that we do not want! | ||
|
||
*.moved-aside | ||
|
||
#### | ||
# UNKNOWN: recommended by others, but I can't discover what these files are | ||
# | ||
# ...none. Everything is now explained. | ||
|
||
#### | ||
# | ||
# Pods and Gems | ||
# | ||
/pods | ||
.bundle/ | ||
|
||
# Builds | ||
*.ipa | ||
|
||
# ssl certificates | ||
*.crt | ||
.idea/.name | ||
.idea/babylon-partners.iml | ||
.idea/encodings.xml | ||
.idea/misc.xml | ||
.idea/modules.xml | ||
.idea/runConfigurations/Babylon.xml | ||
.idea/runConfigurations/BabylonAnalysis.xml | ||
.idea/scopes/scope_settings.xml | ||
.idea/vcs.xml | ||
.idea/workspace.xml | ||
.idea/xcode.xml | ||
|
||
Iconr\n | ||
Crashlytics.framework | ||
Crashlytics.framework/ | ||
Crashlytics.* | ||
Crashlytics | ||
Babylon/dist/ | ||
dist.zip | ||
Babylon.xcworkspace | ||
Babylon.xcworkspace/ | ||
Pods/ | ||
Pods | ||
|
||
# Orig files skipped | ||
*.orig | ||
|
||
Carthage/Checkouts/* | ||
Carthage/Build/* | ||
backboneLocalizationBuilder | ||
.idea/babylon-ios.iml | ||
.idea/runConfigurations/Babylon_STAGING1.xml | ||
|
||
# Fastlane | ||
fastlane/README.md | ||
fastlane/report.xml | ||
vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
4.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Pod::Spec.new do |s| | ||
|
||
s.name = "Bento" | ||
s.version = "0.1" | ||
s.summary = "Component based abstraction on top of UITableView and UICollectionView" | ||
|
||
s.description = <<-DESC | ||
Component-based abstraction on top of UITableView and UICollectionView. | ||
Provides a declarative way to render data in UITableView and UICollectionView | ||
DESC | ||
|
||
s.homepage = "https://github.com/Babylonpartners/Bento" | ||
s.license = { :type => "MIT", :file => "LICENSE" } | ||
s.author = { "Babylon iOS" => "[email protected]" } | ||
s.ios.deployment_target = '9.0' | ||
s.source = { :git => "https://github.com/Babylonpartners/Bento.git", :tag => "#{s.version}" } | ||
s.source_files = 'Bento/*.swift', 'Bento/**/*.swift' | ||
|
||
s.dependency "FlexibleDiff", "= 0.0.5" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import UIKit | ||
import FlexibleDiff | ||
|
||
final class SectionedFormAdapter<SectionId: Hashable, RowId: Hashable> | ||
: NSObject, | ||
UITableViewDataSource, | ||
UITableViewDelegate { | ||
private var sections: [Section<SectionId, RowId>] = [] | ||
private weak var tableView: UITableView? | ||
|
||
init(with tableView: UITableView) { | ||
self.sections = [] | ||
self.tableView = tableView | ||
super.init() | ||
tableView.dataSource = self | ||
tableView.delegate = self | ||
} | ||
|
||
|
||
func update(sections: [Section<SectionId, RowId>], with animation: TableViewAnimation) { | ||
guard let tableView = tableView else { | ||
return | ||
} | ||
let diff = TableViewSectionDiff(oldSections: self.sections, | ||
newSections: sections, | ||
animation: animation) | ||
self.sections = sections | ||
diff.apply(to: tableView) | ||
} | ||
func update(sections: [Section<SectionId, RowId>]) { | ||
self.sections = sections | ||
tableView?.reloadData() | ||
} | ||
|
||
func numberOfSections(in tableView: UITableView) -> Int { | ||
return sections.count | ||
} | ||
|
||
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
return sections[section].rows.count | ||
} | ||
|
||
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
let component = node(at: indexPath).component | ||
let reuseIdentifier = component.reuseIdentifier | ||
guard let cell = tableView.dequeueReusableCell(withIdentifier: reuseIdentifier) as? TableViewCell else { | ||
tableView.register(TableViewCell.self, forCellReuseIdentifier: reuseIdentifier) | ||
return self.tableView(tableView, cellForRowAt: indexPath) | ||
} | ||
let componentView: UIView | ||
if let containedView = cell.containedView { | ||
componentView = containedView | ||
} else { | ||
componentView = component.generate() | ||
cell.install(view: componentView) | ||
} | ||
component.render(in: componentView) | ||
return cell | ||
|
||
} | ||
|
||
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { | ||
return sections[section].header | ||
.map { | ||
return self.render(node: $0, in: tableView) | ||
} | ||
} | ||
|
||
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? { | ||
return sections[section].footer | ||
.map { | ||
return self.render(node: $0, in: tableView) | ||
} | ||
} | ||
|
||
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { | ||
return sections[section].header == nil ? CGFloat.leastNonzeroMagnitude : UITableViewAutomaticDimension | ||
} | ||
|
||
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { | ||
return sections[section].footer == nil ? CGFloat.leastNonzeroMagnitude : UITableViewAutomaticDimension | ||
} | ||
|
||
private func node(at indexPath: IndexPath) -> Node<RowId> { | ||
return sections[indexPath.section].rows[indexPath.row] | ||
} | ||
|
||
private func render(node: AnyRenderable, in tableView: UITableView) -> UIView { | ||
guard let header = tableView.dequeueReusableHeaderFooterView(withIdentifier: node.reuseIdentifier) as? TableViewHeaderFooterView else { | ||
tableView.register(TableViewHeaderFooterView.self, forHeaderFooterViewReuseIdentifier: node.reuseIdentifier) | ||
return render(node: node, in: tableView) | ||
} | ||
let componentView: UIView | ||
if let containedView = header.containedView { | ||
componentView = containedView | ||
} else { | ||
componentView = node.generate() | ||
header.install(view: componentView) | ||
} | ||
node.render(in: componentView) | ||
return header | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import UIKit | ||
|
||
public struct TableViewAnimation { | ||
let sectionInsertion: UITableViewRowAnimation | ||
let sectionDeletion: UITableViewRowAnimation | ||
let rowDeletion: UITableViewRowAnimation | ||
let rowInsertion: UITableViewRowAnimation | ||
|
||
public init(sectionInsertion: UITableViewRowAnimation = .fade, | ||
sectionDeletion: UITableViewRowAnimation = .fade, | ||
rowDeletion: UITableViewRowAnimation = .fade, | ||
rowInsertion: UITableViewRowAnimation = .fade) { | ||
self.sectionInsertion = sectionInsertion | ||
self.sectionDeletion = sectionDeletion | ||
self.rowDeletion = rowDeletion | ||
self.rowInsertion = rowInsertion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#import <UIKit/UIKit.h> | ||
|
||
FOUNDATION_EXPORT double BentoVersionNumber; | ||
|
||
FOUNDATION_EXPORT const unsigned char BentoVersionString[]; |
Oops, something went wrong.