Remove items from secondary navigation when browsing

This commit is contained in:
Justin Mazzocchi 2021-01-31 06:25:31 -08:00
parent b0132640ab
commit 15cc811102
No known key found for this signature in database
GPG Key ID: E223E6937AAFB01C
1 changed files with 28 additions and 26 deletions

View File

@ -29,35 +29,37 @@ struct SecondaryNavigationView: View {
Label("secondary-navigation.accounts", systemImage: "rectangle.stack.person.crop")
}
}
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)
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)
}
}
}
}
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))
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")
}
} icon: {
Image(systemName: "person.badge.plus")
}
}
}