mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-26 18:21:00 +00:00
Fix bugs in macOS app
This commit is contained in:
parent
e9b7d48622
commit
9dc7fa00f9
7 changed files with 73 additions and 54 deletions
|
@ -84,14 +84,12 @@ struct IceCubesApp: App {
|
|||
private var sidebarView: some View {
|
||||
SideBarView(selectedTab: $selectedTab,
|
||||
popToRootTab: $popToRootTab,
|
||||
tabs: availableTabs) { selectedTab in
|
||||
tabs: availableTabs) {
|
||||
ZStack {
|
||||
ForEach(availableTabs) { tab in
|
||||
if let account = currentAccount.account {
|
||||
if let account = currentAccount.account, selectedTab == .profile {
|
||||
AccountDetailView(account: account)
|
||||
.opacity(selectedTab == .profile ? 1 : 0)
|
||||
.id(account.id)
|
||||
}
|
||||
ForEach(availableTabs) { tab in
|
||||
if tab == selectedTab || sideBarLoadedTabs.contains(tab) {
|
||||
tab
|
||||
.makeContentView(popToRootTab: $popToRootTab)
|
||||
|
|
|
@ -2,6 +2,7 @@ import SwiftUI
|
|||
import Env
|
||||
import Account
|
||||
import DesignSystem
|
||||
import AppAccount
|
||||
|
||||
struct SideBarView<Content: View>: View {
|
||||
@EnvironmentObject private var currentAccount: CurrentAccount
|
||||
|
@ -10,18 +11,19 @@ struct SideBarView<Content: View>: View {
|
|||
@Binding var selectedTab: Tab
|
||||
@Binding var popToRootTab: Tab
|
||||
var tabs: [Tab]
|
||||
@ViewBuilder var content: (Tab) -> Content
|
||||
@ViewBuilder var content: () -> Content
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 0) {
|
||||
VStack(alignment: .center) {
|
||||
if let account = currentAccount.account {
|
||||
AvatarView(url: account.avatar)
|
||||
Button {
|
||||
selectedTab = .profile
|
||||
} label: {
|
||||
AvatarView(url: account.avatar, size: .status)
|
||||
}
|
||||
.frame(width: 70, height: 50)
|
||||
.background(selectedTab == .profile ? theme.secondaryBackgroundColor : .clear)
|
||||
.onTapGesture {
|
||||
selectedTab = .profile
|
||||
}
|
||||
}
|
||||
ForEach(tabs) { tab in
|
||||
Button {
|
||||
|
@ -48,7 +50,7 @@ struct SideBarView<Content: View>: View {
|
|||
.background(.clear)
|
||||
Divider()
|
||||
.edgesIgnoringSafeArea(.top)
|
||||
content(selectedTab)
|
||||
content()
|
||||
}
|
||||
.background(.thinMaterial)
|
||||
}
|
||||
|
|
|
@ -22,11 +22,13 @@ struct ExploreTab: View {
|
|||
.toolbar {
|
||||
statusEditorToolbarItem(routeurPath: routeurPath,
|
||||
visibility: preferences.serverPreferences?.postVisibility ?? .pub)
|
||||
if !ProcessInfo.processInfo.isiOSAppOnMac {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
AppAccountsSelectorView(routeurPath: routeurPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.withSafariRouteur()
|
||||
.environmentObject(routeurPath)
|
||||
.onChange(of: $popToRootTab.wrappedValue) { popToRootTab in
|
||||
|
|
|
@ -21,10 +21,12 @@ struct MessagesTab: View {
|
|||
.withAppRouteur()
|
||||
.withSheetDestinations(sheetDestinations: $routeurPath.presentedSheet)
|
||||
.toolbar {
|
||||
if !ProcessInfo.processInfo.isiOSAppOnMac {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
AppAccountsSelectorView(routeurPath: routeurPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
.id(currentAccount.account?.id)
|
||||
}
|
||||
.onChange(of: $popToRootTab.wrappedValue) { popToRootTab in
|
||||
|
|
|
@ -21,10 +21,12 @@ struct NotificationsTab: View {
|
|||
.toolbar {
|
||||
statusEditorToolbarItem(routeurPath: routeurPath,
|
||||
visibility: userPreferences.serverPreferences?.postVisibility ?? .pub)
|
||||
if !ProcessInfo.processInfo.isiOSAppOnMac {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
AppAccountsSelectorView(routeurPath: routeurPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
.id(currentAccount.account?.id)
|
||||
}
|
||||
.onAppear {
|
||||
|
|
|
@ -138,9 +138,11 @@ struct TimelineTab: View {
|
|||
}
|
||||
}
|
||||
if client.isAuth {
|
||||
if !ProcessInfo.processInfo.isiOSAppOnMac {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
AppAccountsSelectorView(routeurPath: routeurPath)
|
||||
}
|
||||
}
|
||||
statusEditorToolbarItem(routeurPath: routeurPath,
|
||||
visibility: preferences.serverPreferences?.postVisibility ?? .pub)
|
||||
} else {
|
||||
|
|
|
@ -23,6 +23,29 @@ public struct AppAccountsSelectorView: View {
|
|||
|
||||
public var body: some View {
|
||||
Menu {
|
||||
menuView
|
||||
} label: {
|
||||
labelView
|
||||
}
|
||||
.onAppear {
|
||||
refreshAccounts()
|
||||
}
|
||||
.onChange(of: currentAccount.account?.id) { _ in
|
||||
refreshAccounts()
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var labelView: some View {
|
||||
if let avatar = currentAccount.account?.avatar {
|
||||
AvatarView(url: avatar, size: avatarSize)
|
||||
} else {
|
||||
EmptyView()
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var menuView: some View {
|
||||
ForEach(accountsViewModel, id: \.appAccount.id) { viewModel in
|
||||
Section(viewModel.acct) {
|
||||
Button {
|
||||
|
@ -50,19 +73,6 @@ public struct AppAccountsSelectorView: View {
|
|||
Label("Add Account", systemImage: "person.badge.plus")
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
if let avatar = currentAccount.account?.avatar {
|
||||
AvatarView(url: avatar, size: avatarSize)
|
||||
} else {
|
||||
EmptyView()
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
refreshAccounts()
|
||||
}
|
||||
.onChange(of: currentAccount.account?.id) { _ in
|
||||
refreshAccounts()
|
||||
}
|
||||
}
|
||||
|
||||
private func refreshAccounts() {
|
||||
|
@ -77,4 +87,5 @@ public struct AppAccountsSelectorView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue