2020-08-08 06:01:45 +00:00
|
|
|
// Copyright © 2020 Metabolist. All rights reserved.
|
|
|
|
|
2021-01-08 02:29:08 +00:00
|
|
|
import Kingfisher
|
2020-09-05 02:31:43 +00:00
|
|
|
import SwiftUI
|
2020-09-01 07:33:49 +00:00
|
|
|
import ViewModels
|
2020-08-08 06:01:45 +00:00
|
|
|
|
|
|
|
struct SecondaryNavigationView: View {
|
2020-09-09 23:00:10 +00:00
|
|
|
@ObservedObject var viewModel: NavigationViewModel
|
2020-09-09 22:48:56 +00:00
|
|
|
@EnvironmentObject var rootViewModel: RootViewModel
|
2020-08-08 06:01:45 +00:00
|
|
|
@Environment(\.displayScale) var displayScale: CGFloat
|
|
|
|
|
|
|
|
var body: some View {
|
2021-01-21 08:45:09 +00:00
|
|
|
Form {
|
|
|
|
Section {
|
|
|
|
NavigationLink(
|
|
|
|
destination: IdentitiesView(viewModel: .init(identification: viewModel.identification))
|
|
|
|
.environmentObject(rootViewModel)
|
|
|
|
.environmentObject(viewModel.identification),
|
|
|
|
label: {
|
|
|
|
HStack {
|
|
|
|
KFImage(viewModel.identification.identity.image)
|
|
|
|
.downsampled(dimension: .avatarDimension, scaleFactor: displayScale)
|
|
|
|
VStack(alignment: .leading) {
|
|
|
|
if viewModel.identification.identity.authenticated {
|
|
|
|
if let account = viewModel.identification.identity.account {
|
|
|
|
CustomEmojiText(
|
|
|
|
text: account.displayName,
|
|
|
|
emojis: account.emojis,
|
|
|
|
textStyle: .headline)
|
|
|
|
}
|
|
|
|
Text(viewModel.identification.identity.handle)
|
|
|
|
.font(.subheadline)
|
|
|
|
.foregroundColor(.secondary)
|
|
|
|
.lineLimit(1)
|
|
|
|
.minimumScaleFactor(0.5)
|
|
|
|
} else {
|
|
|
|
Text(viewModel.identification.identity.handle)
|
|
|
|
.font(.headline)
|
|
|
|
if let instance = viewModel.identification.identity.instance {
|
|
|
|
Text(instance.uri)
|
2020-09-09 05:40:49 +00:00
|
|
|
.font(.subheadline)
|
|
|
|
.foregroundColor(.secondary)
|
|
|
|
.lineLimit(1)
|
|
|
|
.minimumScaleFactor(0.5)
|
2020-08-08 09:10:05 +00:00
|
|
|
}
|
2020-08-08 06:01:45 +00:00
|
|
|
}
|
2021-01-21 08:45:09 +00:00
|
|
|
|
|
|
|
Spacer()
|
|
|
|
Text("secondary-navigation.manage-accounts")
|
|
|
|
.font(.subheadline)
|
2020-08-08 06:01:45 +00:00
|
|
|
}
|
2021-01-21 08:45:09 +00:00
|
|
|
.padding()
|
|
|
|
}
|
|
|
|
})
|
2020-08-08 06:01:45 +00:00
|
|
|
}
|
2021-01-21 08:45:09 +00:00
|
|
|
Section {
|
|
|
|
NavigationLink(destination: ListsView(viewModel: .init(identification: viewModel.identification))
|
|
|
|
.environmentObject(rootViewModel)
|
|
|
|
.environmentObject(viewModel.identification)) {
|
|
|
|
Label("secondary-navigation.lists", systemImage: "scroll")
|
|
|
|
}
|
|
|
|
ForEach([Timeline.favorites, Timeline.bookmarks]) { timeline in
|
2020-08-08 06:01:45 +00:00
|
|
|
Button {
|
2021-01-21 08:45:09 +00:00
|
|
|
viewModel.navigate(timeline: timeline)
|
2020-08-08 06:01:45 +00:00
|
|
|
} label: {
|
2021-01-21 08:45:09 +00:00
|
|
|
Label {
|
|
|
|
Text(timeline.title).foregroundColor(.primary)
|
|
|
|
} icon: {
|
|
|
|
Image(systemName: timeline.systemImageName)
|
|
|
|
}
|
2020-08-08 06:01:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-01-21 08:45:09 +00:00
|
|
|
Section {
|
|
|
|
NavigationLink(
|
|
|
|
destination: PreferencesView(viewModel: .init(identification: viewModel.identification))
|
|
|
|
.environmentObject(rootViewModel)
|
|
|
|
.environmentObject(viewModel.identification)) {
|
|
|
|
Label("secondary-navigation.preferences", systemImage: "gear")
|
|
|
|
}
|
|
|
|
}
|
2020-08-08 06:01:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if DEBUG
|
2020-09-01 07:33:49 +00:00
|
|
|
import PreviewViewModels
|
|
|
|
|
2020-08-08 06:01:45 +00:00
|
|
|
struct SecondaryNavigationView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
2020-09-09 23:00:10 +00:00
|
|
|
SecondaryNavigationView(viewModel: NavigationViewModel(identification: .preview))
|
2020-09-09 22:48:56 +00:00
|
|
|
.environmentObject(RootViewModel.preview)
|
2020-08-08 06:01:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|