mastodon-ios/Mastodon/Scene/Notification/NotificationViewModel.swift

63 lines
1.5 KiB
Swift
Raw Normal View History

2021-04-12 10:31:53 +02:00
//
// NotificationViewModel.swift
// Mastodon
//
// Created by sxiaojian on 2021/4/12.
//
import os.log
2021-04-15 04:16:30 +02:00
import UIKit
import Combine
import MastodonAsset
import MastodonLocalization
import Pageboy
2021-04-12 10:31:53 +02:00
final class NotificationViewModel {
2021-04-12 10:31:53 +02:00
var disposeBag = Set<AnyCancellable>()
// input
let context: AppContext
2021-04-13 15:31:49 +02:00
let viewDidLoad = PassthroughSubject<Void, Never>()
2021-04-12 10:31:53 +02:00
// output
let scopes = NotificationTimelineViewModel.Scope.allCases
@Published var viewControllers: [UIViewController] = []
@Published var currentPageIndex = 0
2021-04-15 04:16:30 +02:00
2021-04-14 13:04:11 +02:00
init(context: AppContext) {
2021-04-12 10:31:53 +02:00
self.context = context
// end init
2021-04-27 10:54:23 +02:00
}
}
2021-04-27 10:54:23 +02:00
extension NotificationTimelineViewModel.Scope {
var title: String {
switch self {
case .everything:
return L10n.Scene.Notification.Title.everything
case .mentions:
return L10n.Scene.Notification.Title.mentions
}
2021-04-27 10:54:23 +02:00
}
2021-04-12 10:31:53 +02:00
}
2021-04-16 07:45:54 +02:00
// MARK: - PageboyViewControllerDataSource
extension NotificationViewModel: PageboyViewControllerDataSource {
func numberOfViewControllers(in pageboyViewController: PageboyViewController) -> Int {
return viewControllers.count
2021-04-16 07:45:54 +02:00
}
func viewController(for pageboyViewController: PageboyViewController, at index: PageboyViewController.PageIndex) -> UIViewController? {
return viewControllers[index]
}
func defaultPage(for pageboyViewController: PageboyViewController) -> PageboyViewController.Page? {
return .first
}
2021-04-16 07:45:54 +02:00
}