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