2020-08-08 08:01:45 +02:00
|
|
|
// Copyright © 2020 Metabolist. All rights reserved.
|
|
|
|
|
2021-01-08 03:29:08 +01:00
|
|
|
import Kingfisher
|
2020-09-05 04:31:43 +02:00
|
|
|
import SwiftUI
|
2020-09-01 09:33:49 +02:00
|
|
|
import ViewModels
|
2020-08-08 08:01:45 +02:00
|
|
|
|
|
|
|
struct SecondaryNavigationView: View {
|
2020-09-10 01:00:10 +02:00
|
|
|
@ObservedObject var viewModel: NavigationViewModel
|
2020-09-10 00:48:56 +02:00
|
|
|
@EnvironmentObject var rootViewModel: RootViewModel
|
2020-08-08 08:01:45 +02:00
|
|
|
@Environment(\.displayScale) var displayScale: CGFloat
|
|
|
|
|
|
|
|
var body: some View {
|
2021-01-21 09:45:09 +01:00
|
|
|
Form {
|
|
|
|
Section {
|
2021-01-28 00:49:13 +01:00
|
|
|
if let id = viewModel.identityContext.identity.account?.id {
|
|
|
|
Button {
|
|
|
|
viewModel.navigateToProfile(id: id)
|
|
|
|
} label: {
|
|
|
|
Label {
|
|
|
|
Text("secondary-navigation.my-profile").foregroundColor(.primary)
|
|
|
|
} icon: {
|
|
|
|
Image(systemName: "person.crop.square")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-01-21 09:45:09 +01:00
|
|
|
NavigationLink(
|
2021-01-29 00:15:22 +01:00
|
|
|
destination: IdentitiesView { .init(identityContext: viewModel.identityContext) }
|
2021-01-28 02:13:17 +01:00
|
|
|
.environmentObject(rootViewModel)) {
|
|
|
|
Label("secondary-navigation.accounts", systemImage: "rectangle.stack.person.crop")
|
|
|
|
}
|
2020-08-08 08:01:45 +02:00
|
|
|
}
|
2021-01-31 15:25:31 +01:00
|
|
|
if viewModel.identityContext.identity.authenticated && !viewModel.identityContext.identity.pending {
|
|
|
|
Section {
|
|
|
|
NavigationLink(destination: ListsView(viewModel: .init(identityContext: viewModel.identityContext))
|
|
|
|
.environmentObject(rootViewModel)) {
|
|
|
|
Label("secondary-navigation.lists", systemImage: "scroll")
|
|
|
|
}
|
|
|
|
ForEach([Timeline.favorites, Timeline.bookmarks]) { timeline in
|
|
|
|
Button {
|
|
|
|
viewModel.navigate(timeline: timeline)
|
|
|
|
} label: {
|
|
|
|
Label {
|
|
|
|
Text(timeline.title).foregroundColor(.primary)
|
|
|
|
} icon: {
|
|
|
|
Image(systemName: timeline.systemImageName)
|
|
|
|
}
|
2021-01-21 09:45:09 +01:00
|
|
|
}
|
2020-08-08 08:01:45 +02:00
|
|
|
}
|
2021-01-31 15:25:31 +01:00
|
|
|
if let followRequestCount = viewModel.identityContext.identity.account?.followRequestCount,
|
|
|
|
followRequestCount > 0 {
|
|
|
|
Button {
|
|
|
|
viewModel.navigateToFollowerRequests()
|
|
|
|
} label: {
|
|
|
|
Label {
|
|
|
|
HStack {
|
|
|
|
Text("follow-requests").foregroundColor(.primary)
|
|
|
|
Spacer()
|
|
|
|
Text(verbatim: String(followRequestCount))
|
|
|
|
}
|
|
|
|
} icon: {
|
|
|
|
Image(systemName: "person.badge.plus")
|
2021-01-26 07:57:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-08-08 08:01:45 +02:00
|
|
|
}
|
2021-01-21 09:45:09 +01:00
|
|
|
Section {
|
|
|
|
NavigationLink(
|
2021-01-26 01:06:35 +01:00
|
|
|
destination: PreferencesView(viewModel: .init(identityContext: viewModel.identityContext))
|
2021-01-26 01:45:18 +01:00
|
|
|
.environmentObject(rootViewModel)) {
|
2021-01-21 09:45:09 +01:00
|
|
|
Label("secondary-navigation.preferences", systemImage: "gear")
|
|
|
|
}
|
2021-01-29 02:08:57 +01:00
|
|
|
NavigationLink(
|
|
|
|
destination: AboutView()
|
|
|
|
.environmentObject(rootViewModel)) {
|
|
|
|
Label("secondary-navigation.about", systemImage: "info.circle")
|
|
|
|
}
|
2021-01-21 09:45:09 +01:00
|
|
|
}
|
2020-08-08 08:01:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if DEBUG
|
2020-09-01 09:33:49 +02:00
|
|
|
import PreviewViewModels
|
|
|
|
|
2020-08-08 08:01:45 +02:00
|
|
|
struct SecondaryNavigationView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
2021-01-26 01:06:35 +01:00
|
|
|
SecondaryNavigationView(viewModel: NavigationViewModel(identityContext: .preview))
|
2020-09-10 00:48:56 +02:00
|
|
|
.environmentObject(RootViewModel.preview)
|
2020-08-08 08:01:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|