2020-08-08 06:01:45 +00:00
|
|
|
// Copyright © 2020 Metabolist. All rights reserved.
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import Combine
|
|
|
|
|
|
|
|
class SidebarNavigationViewModel: ObservableObject {
|
|
|
|
@Published private(set) var identity: Identity
|
|
|
|
@Published var alertItem: AlertItem?
|
|
|
|
var selectedTab: Tab? = .timelines
|
|
|
|
|
2020-08-08 23:08:47 +00:00
|
|
|
private let identityService: IdentityService
|
2020-08-08 06:01:45 +00:00
|
|
|
private var cancellables = Set<AnyCancellable>()
|
|
|
|
|
2020-08-08 23:08:47 +00:00
|
|
|
init(identityService: IdentityService) {
|
|
|
|
self.identityService = identityService
|
|
|
|
identity = identityService.identity
|
|
|
|
identityService.$identity.dropFirst().assign(to: &$identity)
|
2020-08-08 06:01:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension SidebarNavigationViewModel {
|
|
|
|
enum Tab: CaseIterable {
|
|
|
|
case timelines
|
|
|
|
case search
|
|
|
|
case notifications
|
|
|
|
case messages
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension SidebarNavigationViewModel.Tab {
|
|
|
|
var title: String {
|
|
|
|
switch self {
|
|
|
|
case .timelines: return "Timelines"
|
|
|
|
case .search: return "Search"
|
|
|
|
case .notifications: return "Notifications"
|
|
|
|
case .messages: return "Messages"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var systemImageName: String {
|
|
|
|
switch self {
|
2020-08-08 23:36:35 +00:00
|
|
|
case .timelines: return "newspaper"
|
2020-08-08 06:01:45 +00:00
|
|
|
case .search: return "magnifyingglass"
|
|
|
|
case .notifications: return "bell"
|
|
|
|
case .messages: return "envelope"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension SidebarNavigationViewModel.Tab: Identifiable {
|
|
|
|
var id: Self { self }
|
|
|
|
}
|