Editor: Allow to select account

This commit is contained in:
Thomas Ricouard 2023-01-16 13:39:35 +01:00
parent 75e9516089
commit 05053c661d
2 changed files with 20 additions and 8 deletions

View file

@ -10,8 +10,15 @@ public struct AppAccountsSelectorView: View {
@State private var accountsViewModel: [AppAccountViewModel] = []
public init(routeurPath: RouterPath) {
private let accountCreationEnabled: Bool
private let avatarSize: AvatarView.Size
public init(routeurPath: RouterPath,
accountCreationEnabled: Bool = true,
avatarSize: AvatarView.Size = .badge) {
self.routeurPath = routeurPath
self.accountCreationEnabled = accountCreationEnabled
self.avatarSize = avatarSize
}
public var body: some View {
@ -35,15 +42,17 @@ public struct AppAccountsSelectorView: View {
}
}
}
Divider()
Button {
routeurPath.presentedSheet = .addAccount
} label: {
Label("Add Account", systemImage: "person.badge.plus")
if accountCreationEnabled {
Divider()
Button {
routeurPath.presentedSheet = .addAccount
} label: {
Label("Add Account", systemImage: "person.badge.plus")
}
}
} label: {
if let avatar = currentAccount.account?.avatar {
AvatarView(url: avatar, size: .badge)
AvatarView(url: avatar, size: avatarSize)
} else {
EmptyView()
}

View file

@ -9,6 +9,7 @@ import PhotosUI
import NukeUI
import EmojiText
import UIKit
import AppAccount
public struct StatusEditorView: View {
@EnvironmentObject private var preferences: UserPreferences
@ -156,7 +157,9 @@ public struct StatusEditorView: View {
private var accountHeaderView: some View {
if let account = currentAccount.account {
HStack {
AvatarView(url: account.avatar, size: .status)
AppAccountsSelectorView(routeurPath: RouterPath(),
accountCreationEnabled: false,
avatarSize: .status)
VStack(alignment: .leading, spacing: 4) {
privacyMenu
Text("@\(account.acct)")