65 lines
2.0 KiB
Swift
65 lines
2.0 KiB
Swift
//
|
|
// NotificationsPageViewController.swift
|
|
// Tusker
|
|
//
|
|
// Created by Shadowfacts on 9/13/19.
|
|
// Copyright © 2019 Shadowfacts. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
import Pachyderm
|
|
|
|
class NotificationsPageViewController: SegmentedPageViewController {
|
|
|
|
private let notificationsTitle = NSLocalizedString("Notifications", comment: "notifications tab title")
|
|
private let mentionsTitle = NSLocalizedString("Mentions", comment: "mentions tab title")
|
|
|
|
weak var mastodonController: MastodonController!
|
|
|
|
init(mastodonController: MastodonController) {
|
|
self.mastodonController = mastodonController
|
|
|
|
let notifications = NotificationsTableViewController(allowedTypes: Pachyderm.Notification.Kind.allCases, mastodonController: mastodonController)
|
|
notifications.title = notificationsTitle
|
|
notifications.userActivity = UserActivityManager.checkNotificationsActivity()
|
|
|
|
let mentions = NotificationsTableViewController(allowedTypes: [.mention], mastodonController: mastodonController)
|
|
mentions.title = mentionsTitle
|
|
mentions.userActivity = UserActivityManager.checkMentionsActivity()
|
|
|
|
super.init(titles: [
|
|
notificationsTitle,
|
|
mentionsTitle
|
|
], pageControllers: [
|
|
notifications,
|
|
mentions
|
|
])
|
|
|
|
title = notificationsTitle
|
|
tabBarItem.image = UIImage(systemName: "bell.fill")
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
|
|
selectMode(Preferences.shared.defaultNotificationsMode)
|
|
}
|
|
|
|
func selectMode(_ mode: NotificationsMode) {
|
|
let index: Int
|
|
switch mode {
|
|
case .allNotifications:
|
|
index = 0
|
|
case .mentionsOnly:
|
|
index = 1
|
|
}
|
|
segmentedControl.selectedSegmentIndex = index
|
|
selectPage(at: index, animated: false)
|
|
}
|
|
|
|
}
|