1
0
mirror of https://github.com/mastodon/mastodon-ios.git synced 2025-01-23 22:11:22 +01:00

Add basic implementation of timeline-switch (IOS-235)

This commit is contained in:
Nathan Mattes 2024-03-27 16:18:42 +01:00
parent 5e1bb2cfaa
commit 1d2c08b997

View File

@ -46,15 +46,40 @@ final class HomeTimelineViewController: UIViewController, NeedsDependency, Media
let titleView = HomeTimelineNavigationBarTitleView() let titleView = HomeTimelineNavigationBarTitleView()
let timelineSelectorBarButtonItem: UIBarButtonItem = { lazy var timelineSelectorBarButtonItem: UIBarButtonItem = {
let menu = UIMenu(title: "", image: nil, identifier: nil, options: [], children: [
UIAction(title: "Following", image: .init(systemName: "house")) { action in
},
UIAction(title: "Local", image: .init(systemName: "building.2")) { action in
}
])
let button = UIButton(type: .custom) let button = UIButton(type: .custom)
let actions = [
UIAction(title: "Following", image: .init(systemName: "house")) { [weak self] action in
guard let self, let viewModel = self.viewModel else { return }
viewModel.timelineContext = .following
viewModel.dataController.records = []
viewModel.loadLatestStateMachine.enter(HomeTimelineViewModel.LoadLatestState.LoadingManually.self)
button.setAttributedTitle(
.init(string: "Following", attributes: [
.font: UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 16, weight: .bold))
]),
for: .normal)
button.sizeToFit()
},
UIAction(title: "Local", image: .init(systemName: "building.2")) { [weak self] _ in
guard let self, let viewModel = self.viewModel else { return }
viewModel.timelineContext = .community
viewModel.dataController.records = []
viewModel.loadLatestStateMachine.enter(HomeTimelineViewModel.LoadLatestState.LoadingManually.self)
button.setAttributedTitle(
.init(string: "Local", attributes: [
.font: UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 16, weight: .bold))
]),
for: .normal)
button.sizeToFit()
}
]
let menu = UIMenu(children: actions)
button.setAttributedTitle( button.setAttributedTitle(
.init(string: "Following", attributes: [ .init(string: "Following", attributes: [
.font: UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 16, weight: .bold)) .font: UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 16, weight: .bold))