mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-25 01:31:02 +00:00
92 lines
4.1 KiB
Swift
92 lines
4.1 KiB
Swift
// Copyright © 2020 Metabolist. All rights reserved.
|
|
|
|
import KingfisherSwiftUI
|
|
import SwiftUI
|
|
import ViewModels
|
|
|
|
struct SecondaryNavigationView: View {
|
|
@ObservedObject var viewModel: NavigationViewModel
|
|
@EnvironmentObject var rootViewModel: RootViewModel
|
|
@Environment(\.displayScale) var displayScale: CGFloat
|
|
|
|
var body: some View {
|
|
NavigationView {
|
|
Form {
|
|
Section {
|
|
NavigationLink(
|
|
destination: IdentitiesView(viewModel: .init(identification: viewModel.identification)),
|
|
label: {
|
|
HStack {
|
|
KFImage(viewModel.identification.identity.image,
|
|
options: .downsampled(dimension: .avatarDimension, scaleFactor: displayScale))
|
|
VStack(alignment: .leading) {
|
|
if viewModel.identification.identity.authenticated {
|
|
if let account = viewModel.identification.identity.account {
|
|
CustomEmojiText(
|
|
text: account.displayName,
|
|
emoji: 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)
|
|
.font(.subheadline)
|
|
.foregroundColor(.secondary)
|
|
.lineLimit(1)
|
|
.minimumScaleFactor(0.5)
|
|
}
|
|
}
|
|
|
|
Spacer()
|
|
Text("secondary-navigation.manage-accounts")
|
|
.font(.subheadline)
|
|
}
|
|
.padding()
|
|
}
|
|
})
|
|
}
|
|
Section {
|
|
NavigationLink(destination: ListsView(viewModel: .init(identification: viewModel.identification))) {
|
|
Label("secondary-navigation.lists", systemImage: "scroll")
|
|
}
|
|
}
|
|
Section {
|
|
NavigationLink(
|
|
"secondary-navigation.preferences",
|
|
destination: PreferencesView(
|
|
viewModel: .init(identification: viewModel.identification)))
|
|
}
|
|
}
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
.toolbar {
|
|
ToolbarItem(placement: .cancellationAction) {
|
|
Button {
|
|
viewModel.presentingSecondaryNavigation = false
|
|
} label: {
|
|
Image(systemName: "xmark.circle.fill")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.navigationViewStyle(StackNavigationViewStyle())
|
|
.environmentObject(viewModel.identification)
|
|
}
|
|
}
|
|
|
|
#if DEBUG
|
|
import PreviewViewModels
|
|
|
|
struct SecondaryNavigationView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
SecondaryNavigationView(viewModel: NavigationViewModel(identification: .preview))
|
|
.environmentObject(RootViewModel.preview)
|
|
}
|
|
}
|
|
#endif
|