Tusker/Tusker/Screens/Timeline/TimelinesPageViewController...

68 lines
2.1 KiB
Swift
Raw Normal View History

2019-09-14 19:55:06 +00:00
//
// TimelinesPageViewController.swift
// Tusker
//
// Created by Shadowfacts on 9/14/19.
// Copyright © 2019 Shadowfacts. All rights reserved.
//
import UIKit
class TimelinesPageViewController: SegmentedPageViewController {
private let homeTitle = NSLocalizedString("Home", comment: "home timeline tab title")
private let federatedTitle = NSLocalizedString("Federated", comment: "federated timeline tab title")
private let localTitle = NSLocalizedString("Local", comment: "local timeline tab title")
weak var mastodonController: MastodonController!
init(mastodonController: MastodonController) {
self.mastodonController = mastodonController
let home = TimelineViewController(for: .home, mastodonController: mastodonController)
2019-09-14 19:55:06 +00:00
home.title = homeTitle
2022-10-01 19:32:06 +00:00
let federated = TimelineViewController(for: .public(local: false), mastodonController: mastodonController)
2019-09-14 19:55:06 +00:00
federated.title = federatedTitle
2022-10-01 19:32:06 +00:00
let local = TimelineViewController(for: .public(local: true), mastodonController: mastodonController)
2019-09-14 19:55:06 +00:00
local.title = localTitle
super.init(titles: [
homeTitle,
federatedTitle,
localTitle
], pageControllers: [
home,
federated,
local
])
title = homeTitle
tabBarItem.image = UIImage(systemName: "house.fill")
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
2022-11-23 16:35:25 +00:00
func restoreActivity(_ activity: NSUserActivity) {
guard let timeline = UserActivityManager.getTimeline(from: activity) else {
return
}
switch timeline {
case .home:
selectPage(at: 0, animated: false)
case .public(local: false):
selectPage(at: 1, animated: false)
case .public(local: true):
selectPage(at: 2, animated: false)
default:
return
}
let timelineVC = pageControllers[currentIndex] as! TimelineViewController
timelineVC.restoreActivity(activity)
}
2019-09-14 19:55:06 +00:00
}