-
Notifications
You must be signed in to change notification settings - Fork 729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add generation of Table and Collection cell reuseIdentifiers #134
Closed
Closed
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
152fb43
Update #66 to latest master
phatblat 852dbb7
Add .xib files containing only tableview and tableviewcell views
phatblat 2bf40f5
Rename StoryboardCell and StoryboardCellType
phatblat a28e3d2
Add build rule to copy .xib files as-is into test bundle
phatblat 2e8157a
Add custom class to table cell in .xib
phatblat ef09758
Remove TableView.xib
phatblat 8874e1a
Add .xib test fixtures for collection view cells
phatblat a4a6ad2
Add tableview extension for dequeing cells using StoryboardCellType
phatblat f2e3858
Add initial table cell XIB parsing
phatblat fbaf32a
Remove CollectionReusableView.xib fixture
phatblat 3c6a296
Remove readyForPrototypes
phatblat b42bb4c
Change table cell reuseIdentifier in xib
phatblat 062047e
Rename Xibs-TableViewCell-Defaults.swift.out
phatblat 5bc2573
Add CollectionViewCell.xib test
phatblat a7a354e
Add xib file parsing when given a directory path
phatblat e30890a
Add cellEnumName option to storyboards command
phatblat d34e636
Add standalone table and collection view cells
phatblat 3c0774c
Change prefix to Xib
phatblat 9721c9d
Add ReuseID to end of reuseIdentifiers
phatblat ad8079a
Fix parsing customClass attribute on collectionViewCell
phatblat 1177964
Add extensions for all cells with customClass specifying their reuseI…
phatblat fb7a821
Handle path to .xib file
phatblat af6f4bf
Change reuseIdentifier to computed property in cell class extensions
phatblat 6eba75c
Merge branch 'master' into table-collection-cells
phatblat 3459468
Update Xib template expected output
phatblat ea89054
Merge branch 'gotta-return' into table-collection-cells
phatblat acf2eb1
Update test fixtures for change in #138
phatblat 45355ae
Make reuseIdentifier public in default template
phatblat feb1794
Merge branch 'master' into table-collection-cells
phatblat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
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 |
---|---|---|
|
@@ -30,17 +30,35 @@ extension StoryboardSceneType where Self: RawRepresentable, Self.RawValue == Str | |
} | ||
|
||
protocol StoryboardSegueType: RawRepresentable { } | ||
protocol StoryboardCellType: RawRepresentable { } | ||
|
||
extension UIViewController { | ||
func performSegue<S: StoryboardSegueType where S.RawValue == String>(segue: S, sender: AnyObject? = nil) { | ||
performSegueWithIdentifier(segue.rawValue, sender: sender) | ||
} | ||
} | ||
|
||
extension UITableView { | ||
func dequeueReusableCellWithIdentifier<C: StoryboardCellType where C.RawValue == String>(identifier: C, | ||
forIndexPath indexPath: NSIndexPath) -> UITableViewCell { | ||
return dequeueReusableCellWithIdentifier(identifier.rawValue, forIndexPath: indexPath) | ||
} | ||
} | ||
|
||
extension UICollectionView { | ||
func dequeueReusableCellWithReuseIdentifier<C: StoryboardCellType where C.RawValue == String>(identifier: C, | ||
forIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { | ||
return dequeueReusableCellWithReuseIdentifier(identifier.rawValue, forIndexPath: indexPath) | ||
} | ||
} | ||
|
||
struct XCTStoryboardsScene { | ||
enum Anonymous: StoryboardSceneType { | ||
static let storyboardName = "Anonymous" | ||
} | ||
enum CollectionViewCell: StoryboardSceneType { | ||
static let storyboardName = "CollectionViewCell" | ||
} | ||
enum Dependency: String, StoryboardSceneType { | ||
static let storyboardName = "Dependency" | ||
|
||
|
@@ -96,6 +114,9 @@ struct XCTStoryboardsScene { | |
return vc | ||
} | ||
} | ||
enum TableViewCell: StoryboardSceneType { | ||
static let storyboardName = "TableViewCell" | ||
} | ||
enum Wizard: String, StoryboardSceneType { | ||
static let storyboardName = "Wizard" | ||
|
||
|
@@ -140,3 +161,31 @@ struct XCTStoryboardsSegue { | |
case ShowPassword = "ShowPassword" | ||
} | ||
} | ||
|
||
extension XibCollectionViewCell { public static var reuseIdentifier: String { return "XibCollectionViewCellReuseID" } } | ||
extension CustomCollectionViewCell { public static var reuseIdentifier: String { return "CustomCollectionViewCellReuseID" } } | ||
extension CustomMessageCell { public static var reuseIdentifier: String { return "CustomMessageCellReuseID" } } | ||
extension StandaloneCollectionViewCell { public static var reuseIdentifier: String { return "StandaloneCollectionViewCellReuseID" } } | ||
extension StandaloneTableViewCell { public static var reuseIdentifier: String { return "StandaloneTableViewCellReuseID" } } | ||
extension XibTableViewCell { public static var reuseIdentifier: String { return "XibTableViewCellReuseID" } } | ||
|
||
struct XCTStoryboardsCell { | ||
enum Anonymous: String, StoryboardCellType { | ||
case ReuseCellID = "ReuseCellID" | ||
} | ||
enum CollectionViewCell: String, StoryboardCellType { | ||
case XibCollectionViewCellReuseID = "XibCollectionViewCellReuseID" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think calling this |
||
} | ||
enum Message: String, StoryboardCellType { | ||
case CustomCollectionViewCellReuseID = "CustomCollectionViewCellReuseID" | ||
case CustomMessageCellReuseID = "CustomMessageCellReuseID" | ||
case StandaloneCollectionViewCellReuseID = "StandaloneCollectionViewCellReuseID" | ||
case StandaloneTableViewCellReuseID = "StandaloneTableViewCellReuseID" | ||
} | ||
enum TableViewCell: String, StoryboardCellType { | ||
case XibTableViewCellReuseID = "XibTableViewCellReuseID" | ||
} | ||
enum Wizard: String, StoryboardCellType { | ||
case PrefCell = "PrefCell" | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels strange to conform a cell to some protocol named "…SceneType". Maybe it's time to rename that protocol
StoryboardBasedType
instead ofStoryboardSceneType
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it is a little weird since XIBs don't have "scenes". I think in this case the
TableViewCell
"scene" should just be suppressed because you can'tinstantiateInitialViewController
from a XIB.