mirror of
https://github.com/yattee/yattee.git
synced 2025-10-12 18:38:16 +00:00
Add Piped support
This commit is contained in:
@@ -2,33 +2,27 @@ import Defaults
|
||||
import SwiftUI
|
||||
|
||||
struct AccountsMenuView: View {
|
||||
@EnvironmentObject<AccountsModel> private var model
|
||||
@EnvironmentObject<InstancesModel> private var instancesModel
|
||||
@EnvironmentObject<InvidiousAPI> private var api
|
||||
|
||||
@Default(.instances) private var instances
|
||||
|
||||
var body: some View {
|
||||
Menu {
|
||||
ForEach(instances) { instance in
|
||||
Button(accountButtonTitle(instance: instance, account: instance.anonymousAccount)) {
|
||||
api.setAccount(instance.anonymousAccount)
|
||||
}
|
||||
|
||||
ForEach(instancesModel.accounts(instance.id)) { account in
|
||||
Button(accountButtonTitle(instance: instance, account: account)) {
|
||||
api.setAccount(account)
|
||||
}
|
||||
ForEach(model.all, id: \.id) { account in
|
||||
Button(accountButtonTitle(account: account)) {
|
||||
model.setAccount(account)
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
Label(api.account?.name ?? "Accounts", systemImage: "person.crop.circle")
|
||||
Label(model.account?.name ?? "Select Account", systemImage: "person.crop.circle")
|
||||
.labelStyle(.titleAndIcon)
|
||||
}
|
||||
.disabled(instances.isEmpty)
|
||||
.transaction { t in t.animation = .none }
|
||||
}
|
||||
|
||||
func accountButtonTitle(instance: Instance, account: Instance.Account) -> String {
|
||||
instances.count > 1 ? "\(account.description) — \(instance.shortDescription)" : account.description
|
||||
func accountButtonTitle(account: Instance.Account) -> String {
|
||||
instances.count > 1 ? "\(account.description) — \(account.instance.description)" : account.description
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user