2021-09-25 13:48:22 +05:30
|
|
|
import Defaults
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct AccountsMenuView: View {
|
2022-11-25 02:06:05 +05:30
|
|
|
@ObservedObject private var model = AccountsModel.shared
|
2022-12-12 03:45:56 +05:30
|
|
|
private var navigation = NavigationModel.shared
|
2021-09-25 13:48:22 +05:30
|
|
|
|
2021-10-20 02:57:04 +05:30
|
|
|
@Default(.accounts) private var accounts
|
2021-09-25 13:48:22 +05:30
|
|
|
@Default(.instances) private var instances
|
2022-01-03 01:04:50 +05:30
|
|
|
@Default(.accountPickerDisplaysUsername) private var accountPickerDisplaysUsername
|
2022-08-26 05:06:46 +05:30
|
|
|
@Default(.accountPickerDisplaysAnonymousAccounts) private var accountPickerDisplaysAnonymousAccounts
|
2021-09-25 13:48:22 +05:30
|
|
|
|
2022-07-02 02:58:32 +05:30
|
|
|
@ViewBuilder var body: some View {
|
|
|
|
if !instances.isEmpty {
|
2022-12-12 03:45:56 +05:30
|
|
|
Button {
|
|
|
|
navigation.presentingAccounts = true
|
2022-07-02 02:58:32 +05:30
|
|
|
} label: {
|
|
|
|
HStack {
|
|
|
|
if !accountPickerDisplaysUsername || !(model.current?.isPublic ?? true) {
|
|
|
|
Image(systemName: "globe")
|
|
|
|
}
|
|
|
|
|
|
|
|
if accountPickerDisplaysUsername {
|
|
|
|
label
|
|
|
|
.labelStyle(.titleOnly)
|
|
|
|
}
|
2021-11-28 20:07:55 +05:30
|
|
|
}
|
|
|
|
}
|
2022-07-02 02:58:32 +05:30
|
|
|
.transaction { t in t.animation = .none }
|
2021-09-25 13:48:22 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-28 20:07:55 +05:30
|
|
|
private var label: some View {
|
2022-07-02 02:58:32 +05:30
|
|
|
Label(model.current?.description ?? "Select Account", systemImage: "globe")
|
2021-11-28 20:07:55 +05:30
|
|
|
}
|
2021-09-25 13:48:22 +05:30
|
|
|
}
|