mirror of
https://github.com/zhigang1992/GitHawk.git
synced 2026-05-25 01:12:24 +08:00
more swifty class handling
This commit is contained in:
@@ -96,22 +96,16 @@ final class IssuesViewController: UIViewController, ListAdapterDataSource, FeedD
|
||||
}
|
||||
|
||||
func listAdapter(_ listAdapter: ListAdapter, sectionControllerFor object: Any) -> ListSectionController {
|
||||
if object is NSAttributedStringSizing {
|
||||
return IssueTitleSectionController()
|
||||
} else if object is IssueCommentModel {
|
||||
return IssueCommentSectionController(client: client)
|
||||
} else if object is IssueLabelsModel {
|
||||
return IssueLabelsSectionController()
|
||||
} else if object is IssueStatusModel {
|
||||
return IssueStatusSectionController()
|
||||
} else if object is IssueLabeledModel {
|
||||
return IssueLabeledSectionController()
|
||||
} else if object is IssueClosedModel {
|
||||
return IssueClosedSectionController()
|
||||
} else if object is IssueMergedModel {
|
||||
return IssueMergedSectionController()
|
||||
switch object {
|
||||
case is NSAttributedStringSizing: return IssueTitleSectionController()
|
||||
case is IssueCommentModel: return IssueCommentSectionController(client: client)
|
||||
case is IssueLabelsModel: return IssueLabelsSectionController()
|
||||
case is IssueStatusModel: return IssueStatusSectionController()
|
||||
case is IssueLabeledModel: return IssueLabeledSectionController()
|
||||
case is IssueClosedModel: return IssueClosedSectionController()
|
||||
case is IssueMergedModel: return IssueMergedSectionController()
|
||||
default: fatalError("Unhandled object: \(object)")
|
||||
}
|
||||
return ListSectionController()
|
||||
}
|
||||
|
||||
func emptyView(for listAdapter: ListAdapter) -> UIView? {
|
||||
|
||||
@@ -80,12 +80,10 @@ RepoNotificationsSectionControllerDelegate {
|
||||
}
|
||||
|
||||
func listAdapter(_ listAdapter: ListAdapter, sectionControllerFor object: Any) -> ListSectionController {
|
||||
if object is SegmentedControlModel {
|
||||
let controller = SegmentedControlSectionController()
|
||||
controller.delegate = self
|
||||
return controller
|
||||
} else {
|
||||
return RepoNotificationsSectionController(client: client, delegate: self)
|
||||
switch object {
|
||||
case is SegmentedControlModel: return SegmentedControlSectionController(delegate: self)
|
||||
case is NotificationViewModel: return RepoNotificationsSectionController(client: client, delegate: self)
|
||||
default: fatalError("Unhandled object: \(object)")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,10 @@ protocol SegmentedControlSectionControllerDelegate: class {
|
||||
final class SegmentedControlSectionController: ListGenericSectionController<SegmentedControlModel>, SegmentedControlCellDelegate {
|
||||
|
||||
weak var delegate: SegmentedControlSectionControllerDelegate? = nil
|
||||
init(delegate: SegmentedControlSectionControllerDelegate?) {
|
||||
self.delegate = delegate
|
||||
super.init()
|
||||
}
|
||||
|
||||
override func sizeForItem(at index: Int) -> CGSize {
|
||||
guard let context = collectionContext else { fatalError("Collection context must be set") }
|
||||
|
||||
@@ -90,16 +90,17 @@ final class SettingsViewController: UIViewController, ListAdapterDataSource, Git
|
||||
}
|
||||
|
||||
func listAdapter(_ listAdapter: ListAdapter, sectionControllerFor object: Any) -> ListSectionController {
|
||||
guard let object = object as? ListDiffable else { fatalError() }
|
||||
guard let object = object as? ListDiffable else { fatalError("Object not diffable") }
|
||||
if object === addKey, let mgr = rootNavigationManager {
|
||||
return SettingsAddAccountSectionController(rootNavigationManager: mgr)
|
||||
} else if object === signoutKey {
|
||||
return SettingsSignoutSectionController(sessionManager: sessionManager)
|
||||
} else if object === reportKey {
|
||||
return SettingsReportSectionController()
|
||||
} else {
|
||||
} else if object is GithubSessionManager {
|
||||
return SettingsUsersSectionController()
|
||||
}
|
||||
fatalError("Unhandled object: \(object)")
|
||||
}
|
||||
|
||||
func emptyView(for listAdapter: ListAdapter) -> UIView? { return nil }
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>154</string>
|
||||
<string>160</string>
|
||||
<key>LSApplicationQueriesSchemes</key>
|
||||
<array>
|
||||
<string>org-appextension-feature-password-management</string>
|
||||
|
||||
Reference in New Issue
Block a user