Implement adding list using new sidebar
This commit is contained in:
parent
7c7af945e4
commit
ce10c7d6e2
|
@ -269,8 +269,9 @@ class MainSidebarViewController: UIViewController {
|
|||
}
|
||||
|
||||
private func showAddList() {
|
||||
let service = CreateListService(mastodonController: mastodonController, present: { self.present($0, animated: true
|
||||
) }) { list in
|
||||
let service = CreateListService(mastodonController: mastodonController, present: {
|
||||
self.present($0, animated: true)
|
||||
}) { list in
|
||||
let oldItem = self.selectedItem
|
||||
self.select(item: .list(list), animated: false)
|
||||
let list = ListTimelineViewController(for: list, mastodonController: self.mastodonController)
|
||||
|
|
|
@ -12,7 +12,7 @@ import Pachyderm
|
|||
import TuskerPreferences
|
||||
|
||||
@available(iOS 18.0, *)
|
||||
class NewMainTabBarViewController: BaseMainTabBarViewController {
|
||||
final class NewMainTabBarViewController: BaseMainTabBarViewController {
|
||||
|
||||
private let composePlaceholder = UIViewController()
|
||||
|
||||
|
@ -61,8 +61,8 @@ class NewMainTabBarViewController: BaseMainTabBarViewController {
|
|||
}
|
||||
listsGroup.preferredPlacement = .sidebarOnly
|
||||
listsGroup.sidebarActions = [
|
||||
UIAction(title: "New List…", image: UIImage(systemName: "plus"), handler: { _ in
|
||||
fatalError("TODO")
|
||||
UIAction(title: "New List…", image: UIImage(systemName: "plus"), handler: { [unowned self] _ in
|
||||
self.showAddList()
|
||||
})
|
||||
]
|
||||
reloadLists(mastodonController.lists)
|
||||
|
@ -129,7 +129,7 @@ class NewMainTabBarViewController: BaseMainTabBarViewController {
|
|||
if nav.viewControllers.count > 1 {
|
||||
switch nav.viewControllers[1] {
|
||||
case let listVC as ListTimelineViewController:
|
||||
if let tab = listsGroup.tab(forIdentifier: "list:\(listVC.list.id)") {
|
||||
if let tab = listsGroup.tab(forIdentifier: Self.listTabIdentifier(listVC.list)) {
|
||||
newTab = (tab, Array(nav.viewControllers[1...]))
|
||||
nav.viewControllers = [
|
||||
nav.viewControllers[0], // leave the ExploreVC in place
|
||||
|
@ -218,12 +218,16 @@ class NewMainTabBarViewController: BaseMainTabBarViewController {
|
|||
|
||||
private func reloadLists(_ lists: [List]) {
|
||||
listsGroup.children = lists.map { list in
|
||||
UITab(title: list.title, image: UIImage(systemName: "list.bullet"), identifier: "list:\(list.id)") { [unowned self] _ in
|
||||
UITab(title: list.title, image: UIImage(systemName: "list.bullet"), identifier: Self.listTabIdentifier(list)) { [unowned self] _ in
|
||||
return ListTimelineViewController(for: list, mastodonController: self.mastodonController)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static func listTabIdentifier(_ list: List) -> String {
|
||||
"list:\(list.id)"
|
||||
}
|
||||
|
||||
@objc func handleComposeKeyCommand() {
|
||||
compose(editing: nil)
|
||||
}
|
||||
|
@ -232,6 +236,18 @@ class NewMainTabBarViewController: BaseMainTabBarViewController {
|
|||
fastAccountSwitcher?.hide()
|
||||
}
|
||||
|
||||
private func showAddList() {
|
||||
let service = CreateListService(mastodonController: mastodonController, present: {
|
||||
self.present($0, animated: true)
|
||||
}) { list in
|
||||
let tab = self.listsGroup.tab(forIdentifier: Self.listTabIdentifier(list))!
|
||||
let listVC = tab.viewController as! ListTimelineViewController
|
||||
listVC.presentEditOnAppear = true
|
||||
self.selectedTab = tab
|
||||
}
|
||||
service.run()
|
||||
}
|
||||
|
||||
fileprivate func updateViewControllerSafeAreaInsets(_ vc: UIViewController) {
|
||||
guard vc is MultiColumnNavigationController || (vc as? AdaptableNavigationController)?.current is MultiColumnNavigationController else {
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue