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