2022-12-27 09:25:26 +01:00
|
|
|
import Foundation
|
|
|
|
import Status
|
|
|
|
import Account
|
|
|
|
import Explore
|
|
|
|
import SwiftUI
|
|
|
|
|
2023-01-04 12:50:57 +01:00
|
|
|
enum Tab: Int, Identifiable, Hashable {
|
2023-01-05 12:21:54 +01:00
|
|
|
case timeline, notifications, explore, messages, settings, other
|
2023-01-16 14:40:23 +01:00
|
|
|
case trending, federated, local
|
|
|
|
case profile
|
2022-12-27 09:25:26 +01:00
|
|
|
|
|
|
|
var id: Int {
|
|
|
|
rawValue
|
|
|
|
}
|
|
|
|
|
|
|
|
static func loggedOutTab() -> [Tab] {
|
|
|
|
[.timeline, .settings]
|
|
|
|
}
|
|
|
|
|
|
|
|
static func loggedInTabs() -> [Tab] {
|
2023-01-16 14:40:23 +01:00
|
|
|
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
|
|
|
|
return [.timeline, .trending, .federated, .local, .notifications, .explore, .messages, .settings]
|
|
|
|
} else {
|
|
|
|
return [.timeline, .notifications, .explore, .messages, .settings]
|
|
|
|
}
|
2022-12-27 09:25:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@ViewBuilder
|
|
|
|
func makeContentView(popToRootTab: Binding<Tab>) -> some View {
|
|
|
|
switch self {
|
|
|
|
case .timeline:
|
|
|
|
TimelineTab(popToRootTab: popToRootTab)
|
2023-01-16 14:40:23 +01:00
|
|
|
case .trending:
|
|
|
|
TimelineTab(popToRootTab: popToRootTab, timeline: .trending)
|
|
|
|
case .local:
|
|
|
|
TimelineTab(popToRootTab: popToRootTab, timeline: .local)
|
|
|
|
case .federated:
|
|
|
|
TimelineTab(popToRootTab: popToRootTab, timeline: .federated)
|
2022-12-27 09:25:26 +01:00
|
|
|
case .notifications:
|
|
|
|
NotificationsTab(popToRootTab: popToRootTab)
|
|
|
|
case .explore:
|
|
|
|
ExploreTab(popToRootTab: popToRootTab)
|
2023-01-05 12:21:54 +01:00
|
|
|
case .messages:
|
|
|
|
MessagesTab(popToRootTab: popToRootTab)
|
2022-12-27 09:25:26 +01:00
|
|
|
case .settings:
|
2023-01-10 06:58:50 +01:00
|
|
|
SettingsTabs(popToRootTab: popToRootTab)
|
2023-01-16 14:40:23 +01:00
|
|
|
case .other, .profile:
|
2022-12-27 09:25:26 +01:00
|
|
|
EmptyView()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@ViewBuilder
|
|
|
|
var label: some View {
|
|
|
|
switch self {
|
|
|
|
case .timeline:
|
2023-01-16 14:40:23 +01:00
|
|
|
Label("Timeline", systemImage: iconName)
|
|
|
|
case .trending:
|
|
|
|
Label("Trending", systemImage: iconName)
|
|
|
|
case .local:
|
|
|
|
Label("Local", systemImage: iconName)
|
|
|
|
case .federated:
|
|
|
|
Label("Federated", systemImage: iconName)
|
2022-12-27 09:25:26 +01:00
|
|
|
case .notifications:
|
2023-01-16 14:40:23 +01:00
|
|
|
Label("Notifications", systemImage: iconName)
|
2022-12-27 09:25:26 +01:00
|
|
|
case .explore:
|
2023-01-16 14:40:23 +01:00
|
|
|
Label("Explore", systemImage: iconName)
|
2023-01-05 12:21:54 +01:00
|
|
|
case .messages:
|
2023-01-16 14:40:23 +01:00
|
|
|
Label("Messages", systemImage: iconName)
|
2022-12-27 09:25:26 +01:00
|
|
|
case .settings:
|
2023-01-16 14:40:23 +01:00
|
|
|
Label("Settings", systemImage: iconName)
|
|
|
|
case .other, .profile:
|
2022-12-27 09:25:26 +01:00
|
|
|
EmptyView()
|
|
|
|
}
|
|
|
|
}
|
2023-01-16 14:40:23 +01:00
|
|
|
|
|
|
|
var iconName: String {
|
|
|
|
switch self {
|
|
|
|
case .timeline:
|
|
|
|
return "rectangle.on.rectangle"
|
|
|
|
case .trending:
|
|
|
|
return "chart.line.uptrend.xyaxis"
|
|
|
|
case .local:
|
|
|
|
return "person.2"
|
|
|
|
case .federated:
|
|
|
|
return "globe.americas"
|
|
|
|
case .notifications:
|
|
|
|
return "bell"
|
|
|
|
case .explore:
|
|
|
|
return "magnifyingglass"
|
|
|
|
case .messages:
|
|
|
|
return "tray"
|
|
|
|
case .settings:
|
|
|
|
return "gear"
|
|
|
|
case .other, .profile:
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
2022-12-27 09:25:26 +01:00
|
|
|
}
|
|
|
|
|