From 10239d14c9f38b562e6549eafe15655dafd7049c Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 29 Oct 2022 15:08:03 -0400 Subject: [PATCH] Fix selected segment not updating on profiles when switching tabs with keyboard shortcuts --- .../Screens/Profile/ProfileHeaderCollectionViewCell.swift | 8 ++++++++ Tusker/Screens/Profile/ProfileViewController.swift | 2 ++ 2 files changed, 10 insertions(+) diff --git a/Tusker/Screens/Profile/ProfileHeaderCollectionViewCell.swift b/Tusker/Screens/Profile/ProfileHeaderCollectionViewCell.swift index 32c08bf1..e2ba1e71 100644 --- a/Tusker/Screens/Profile/ProfileHeaderCollectionViewCell.swift +++ b/Tusker/Screens/Profile/ProfileHeaderCollectionViewCell.swift @@ -12,6 +12,14 @@ class ProfileHeaderCollectionViewCell: UICollectionViewCell { private var state: State = .unloaded + var view: ProfileHeaderView? { + if case .view(let view) = state { + return view + } else { + return nil + } + } + override init(frame: CGRect) { super.init(frame: frame) diff --git a/Tusker/Screens/Profile/ProfileViewController.swift b/Tusker/Screens/Profile/ProfileViewController.swift index 94007404..47d3d794 100644 --- a/Tusker/Screens/Profile/ProfileViewController.swift +++ b/Tusker/Screens/Profile/ProfileViewController.swift @@ -297,11 +297,13 @@ extension ProfileViewController: ProfileHeaderViewDelegate { extension ProfileViewController: TabbedPageViewController { func selectNextPage() { guard currentIndex < pageControllers.count - 1 else { return } + currentViewController.headerCell?.view?.pagesSegmentedControl.selectedSegmentIndex = currentIndex + 1 selectPage(at: currentIndex + 1, animated: true) } func selectPrevPage() { guard currentIndex > 0 else { return } + currentViewController.headerCell?.view?.pagesSegmentedControl.selectedSegmentIndex = currentIndex - 1 selectPage(at: currentIndex - 1, animated: true) } }