yattee/Shared/Navigation/AccountsMenuView.swift

37 lines
1.2 KiB
Swift
Raw Normal View History

2021-09-25 08:18:22 +00:00
import Defaults
import SwiftUI
struct AccountsMenuView: View {
@ObservedObject private var model = AccountsModel.shared
2022-12-11 22:15:56 +00:00
private var navigation = NavigationModel.shared
2021-09-25 08:18:22 +00:00
@Default(.accounts) private var accounts
2021-09-25 08:18:22 +00:00
@Default(.instances) private var instances
@Default(.accountPickerDisplaysUsername) private var accountPickerDisplaysUsername
@Default(.accountPickerDisplaysAnonymousAccounts) private var accountPickerDisplaysAnonymousAccounts
2021-09-25 08:18:22 +00:00
@ViewBuilder var body: some View {
if !instances.isEmpty {
2022-12-11 22:15:56 +00:00
Button {
navigation.presentingAccounts = true
} label: {
HStack {
if !accountPickerDisplaysUsername || !(model.current?.isPublic ?? true) {
Image(systemName: "globe")
}
if accountPickerDisplaysUsername {
label
.labelStyle(.titleOnly)
}
2021-11-28 14:37:55 +00:00
}
}
.transaction { t in t.animation = .none }
2021-09-25 08:18:22 +00:00
}
}
2021-11-28 14:37:55 +00:00
private var label: some View {
Label(model.current?.description ?? "Select Account", systemImage: "globe")
2021-11-28 14:37:55 +00:00
}
2021-09-25 08:18:22 +00:00
}