metatext/Views/SecondaryNavigationView.swift

80 lines
3.1 KiB
Swift
Raw Normal View History

2020-08-08 06:01:45 +00:00
// Copyright © 2020 Metabolist. All rights reserved.
import SwiftUI
import KingfisherSwiftUI
2020-09-01 07:33:49 +00:00
import ViewModels
2020-08-08 06:01:45 +00:00
struct SecondaryNavigationView: View {
@StateObject var viewModel: SecondaryNavigationViewModel
@Environment(\.presentationMode) var presentationMode
@Environment(\.displayScale) var displayScale: CGFloat
var body: some View {
NavigationView {
Form {
Section {
NavigationLink(
2020-08-29 03:50:58 +00:00
destination: IdentitiesView(viewModel: viewModel.identitiesViewModel()),
2020-08-08 06:01:45 +00:00
label: {
HStack {
KFImage(viewModel.identity.image,
options: .downsampled(dimension: 50, scaleFactor: displayScale))
VStack(alignment: .leading) {
2020-08-08 09:10:05 +00:00
if let account = viewModel.identity.account {
CustomEmojiText(
text: account.displayName,
emoji: account.emojis,
textStyle: .headline)
}
2020-08-08 06:01:45 +00:00
Text(viewModel.identity.handle)
2020-08-08 09:10:05 +00:00
.font(.subheadline)
.foregroundColor(.secondary)
2020-08-08 06:01:45 +00:00
.lineLimit(1)
.minimumScaleFactor(0.5)
Spacer()
2020-08-08 09:10:05 +00:00
Text("secondary-navigation.manage-accounts")
2020-08-08 06:01:45 +00:00
.font(.subheadline)
}
.padding()
}
})
}
2020-08-29 03:50:58 +00:00
Section {
NavigationLink(destination: ListsView(viewModel: viewModel.listsViewModel())) {
Label("secondary-navigation.lists", systemImage: "scroll")
}
}
2020-08-08 06:01:45 +00:00
Section {
NavigationLink(
"secondary-navigation.preferences",
destination: PreferencesView(
viewModel: viewModel.preferencesViewModel()))
}
}
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button {
presentationMode.wrappedValue.dismiss()
} label: {
Image(systemName: "xmark.circle.fill")
}
}
}
}
.navigationViewStyle(StackNavigationViewStyle())
}
}
#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-01 07:33:49 +00:00
SecondaryNavigationView(viewModel: .mock())
.environmentObject(RootViewModel.mock())
.environmentObject(TabNavigationViewModel.mock())
2020-08-08 06:01:45 +00:00
}
}
#endif