forked from shadowfacts/Tusker
Fix assorted issues collapsing/expanding split VC
This commit is contained in:
parent
9fc4aa8a40
commit
ee651ae96a
|
@ -225,6 +225,7 @@ extension MainSplitViewController: UISplitViewControllerDelegate {
|
||||||
// so that explore items aren't shown multiple times.
|
// so that explore items aren't shown multiple times.
|
||||||
|
|
||||||
let exploreNav = tabBarViewController.viewController(for: .explore) as! UINavigationController
|
let exploreNav = tabBarViewController.viewController(for: .explore) as! UINavigationController
|
||||||
|
// make sure there's a root ExploreViewController
|
||||||
let explore: ExploreViewController
|
let explore: ExploreViewController
|
||||||
if let existing = exploreNav.viewControllers.first as? ExploreViewController {
|
if let existing = exploreNav.viewControllers.first as? ExploreViewController {
|
||||||
explore = existing
|
explore = existing
|
||||||
|
@ -238,14 +239,23 @@ extension MainSplitViewController: UISplitViewControllerDelegate {
|
||||||
explore.loadViewIfNeeded()
|
explore.loadViewIfNeeded()
|
||||||
|
|
||||||
let search = secondaryNavController.viewControllers.first as! InlineTrendsViewController
|
let search = secondaryNavController.viewControllers.first as! InlineTrendsViewController
|
||||||
// Copy the search query from the search VC to the Explore VC's search controller.
|
if search.searchController.isActive {
|
||||||
let query = search.searchController.searchBar.text ?? ""
|
// Copy the search query from the search VC to the Explore VC's search controller.
|
||||||
explore.searchController.searchBar.text = query
|
let query = search.searchController.searchBar.text ?? ""
|
||||||
// Instruct the explore controller to show its search controller immediately upon its first appearance.
|
explore.searchController.searchBar.text = query
|
||||||
// explore.searchController.isActive can't be set directly, see FB7814561
|
// Instruct the explore controller to show its search controller immediately upon its first appearance.
|
||||||
explore.searchControllerStatusOnAppearance = !query.isEmpty
|
// explore.searchController.isActive can't be set directly, see FB7814561
|
||||||
// Copy the results from the search VC's results controller to avoid the delay introduced by an extra network request
|
explore.searchControllerStatusOnAppearance = !query.isEmpty
|
||||||
explore.resultsController.loadResults(from: search.resultsController)
|
// Copy the results from the search VC's results controller to avoid the delay introduced by an extra network request
|
||||||
|
explore.resultsController.loadResults(from: search.resultsController)
|
||||||
|
} else {
|
||||||
|
// if there is more than just the InlineTrendsVC, and the search VC is not active,
|
||||||
|
// then the user selected something from the trends screen
|
||||||
|
if secondaryNavController.viewControllers.count >= 2 {
|
||||||
|
// make sure there's a corresponding trends VC in the collapsed nav that they can go back to
|
||||||
|
exploreNav.pushViewController(TrendsViewController(mastodonController: mastodonController), animated: false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Transfer the navigation stack, dropping the search VC, to keep anything the user has opened
|
// Transfer the navigation stack, dropping the search VC, to keep anything the user has opened
|
||||||
transferNavigationStack(from: .explore, to: exploreNav, dropFirst: true, append: true)
|
transferNavigationStack(from: .explore, to: exploreNav, dropFirst: true, append: true)
|
||||||
|
@ -329,14 +339,16 @@ extension MainSplitViewController: UISplitViewControllerDelegate {
|
||||||
exploreItem = .favorites
|
exploreItem = .favorites
|
||||||
case let listVC as ListTimelineViewController:
|
case let listVC as ListTimelineViewController:
|
||||||
exploreItem = .list(listVC.list)
|
exploreItem = .list(listVC.list)
|
||||||
case let hashtagVC as HashtagTimelineViewController:
|
case let hashtagVC as HashtagTimelineViewController where hashtagVC.isHashtagSaved:
|
||||||
exploreItem = .savedHashtag(hashtagVC.hashtag)
|
exploreItem = .savedHashtag(hashtagVC.hashtag)
|
||||||
case let instanceVC as InstanceTimelineViewController:
|
case let instanceVC as InstanceTimelineViewController:
|
||||||
exploreItem = .savedInstance(instanceVC.instanceURL)
|
exploreItem = .savedInstance(instanceVC.instanceURL)
|
||||||
case is TrendingStatusesViewController, is TrendingHashtagsViewController, is TrendingLinksViewController:
|
case is TrendsViewController:
|
||||||
exploreItem = .explore
|
exploreItem = .explore
|
||||||
// these three VCs are part of the root SearchViewController, so we don't need to transfer them
|
// skip transferring the ExploreViewController and TrendsViewController
|
||||||
skipFirst = 2
|
skipFirst = 2
|
||||||
|
// prepend the InlineTrendsViewController
|
||||||
|
toPrepend = getOrCreateNavigationStack(item: .explore).first!
|
||||||
default:
|
default:
|
||||||
// transfer the navigation stack prepending, the existing explore VC
|
// transfer the navigation stack prepending, the existing explore VC
|
||||||
// if there was other stuff on the explore stack, it will get discarded
|
// if there was other stuff on the explore stack, it will get discarded
|
||||||
|
|
|
@ -15,7 +15,7 @@ class HashtagTimelineViewController: TimelineViewController {
|
||||||
|
|
||||||
var toggleSaveButton: UIBarButtonItem!
|
var toggleSaveButton: UIBarButtonItem!
|
||||||
|
|
||||||
private var isHashtagSaved: Bool {
|
var isHashtagSaved: Bool {
|
||||||
let req = SavedHashtag.fetchRequest(name: hashtag.name, account: mastodonController.accountInfo!)
|
let req = SavedHashtag.fetchRequest(name: hashtag.name, account: mastodonController.accountInfo!)
|
||||||
return mastodonController.persistentContainer.viewContext.objectExists(for: req)
|
return mastodonController.persistentContainer.viewContext.objectExists(for: req)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue