mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-26 10:11:00 +00:00
Enable account switcher on macOS
This commit is contained in:
parent
9dc7fa00f9
commit
451cc7a4ac
2 changed files with 24 additions and 13 deletions
|
@ -16,15 +16,15 @@ struct SideBarView<Content: View>: View {
|
||||||
var body: some View {
|
var body: some View {
|
||||||
HStack(spacing: 0) {
|
HStack(spacing: 0) {
|
||||||
VStack(alignment: .center) {
|
VStack(alignment: .center) {
|
||||||
if let account = currentAccount.account {
|
|
||||||
Button {
|
Button {
|
||||||
selectedTab = .profile
|
selectedTab = .profile
|
||||||
} label: {
|
} label: {
|
||||||
AvatarView(url: account.avatar, size: .status)
|
AppAccountsSelectorView(routeurPath: RouterPath(),
|
||||||
|
accountCreationEnabled: false,
|
||||||
|
avatarSize: .status)
|
||||||
}
|
}
|
||||||
.frame(width: 70, height: 50)
|
.frame(width: 70, height: 60)
|
||||||
.background(selectedTab == .profile ? theme.secondaryBackgroundColor : .clear)
|
.background(selectedTab == .profile ? theme.secondaryBackgroundColor : .clear)
|
||||||
}
|
|
||||||
ForEach(tabs) { tab in
|
ForEach(tabs) { tab in
|
||||||
Button {
|
Button {
|
||||||
if tab == selectedTab {
|
if tab == selectedTab {
|
||||||
|
|
|
@ -22,11 +22,20 @@ public struct AppAccountsSelectorView: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
public var body: some View {
|
public var body: some View {
|
||||||
|
Group {
|
||||||
|
if ProcessInfo.processInfo.isiOSAppOnMac {
|
||||||
|
labelView
|
||||||
|
.contextMenu {
|
||||||
|
menuView
|
||||||
|
}
|
||||||
|
} else {
|
||||||
Menu {
|
Menu {
|
||||||
menuView
|
menuView
|
||||||
} label: {
|
} label: {
|
||||||
labelView
|
labelView
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
.onAppear {
|
.onAppear {
|
||||||
refreshAccounts()
|
refreshAccounts()
|
||||||
}
|
}
|
||||||
|
@ -82,10 +91,12 @@ public struct AppAccountsSelectorView: View {
|
||||||
let viewModel: AppAccountViewModel = .init(appAccount: account)
|
let viewModel: AppAccountViewModel = .init(appAccount: account)
|
||||||
Task {
|
Task {
|
||||||
await viewModel.fetchAccount()
|
await viewModel.fetchAccount()
|
||||||
|
if !accountsViewModel.contains(where: { $0.acct == viewModel.acct }) {
|
||||||
accountsViewModel.append(viewModel)
|
accountsViewModel.append(viewModel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue