-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathBlogDetailsViewController+FAB.swift
41 lines (33 loc) · 1.48 KB
/
BlogDetailsViewController+FAB.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
extension BlogDetailsViewController {
/// Make a create button coordinator with
/// - Returns: CreateButtonCoordinator with new post, page, and story actions.
@objc func makeCreateButtonCoordinator() -> CreateButtonCoordinator {
let newPage = { [weak self] in
let controller = self?.tabBarController as? WPTabBarController
let blog = controller?.currentOrLastBlog()
controller?.showPageEditor(forBlog: blog)
}
let newPost = { [weak self] in
let controller = self?.tabBarController as? WPTabBarController
controller?.showPostTab(completion: {
self?.startAlertTimer()
})
}
let newStory = { [weak self] in
let controller = self?.tabBarController as? WPTabBarController
let blog = controller?.currentOrLastBlog()
controller?.showStoryEditor(forBlog: blog)
}
let source = "my_site"
var actions: [ActionSheetItem] = [PostAction(handler: newPost, source: source), PageAction(handler: newPage, source: source)]
if shouldShowNewStory {
actions.append(StoryAction(handler: newStory, source: source))
}
let coordinator = CreateButtonCoordinator(self, actions: actions, source: source)
return coordinator
}
//TODO: Can be removed after stories launches
private var shouldShowNewStory: Bool {
return Feature.enabled(.stories) && blog.supports(.stories)
}
}