diff --git a/Shared/Views/Tab/SideMenuView.swift b/Shared/Views/Tab/SideMenuView.swift index 141385d..79a3f46 100644 --- a/Shared/Views/Tab/SideMenuView.swift +++ b/Shared/Views/Tab/SideMenuView.swift @@ -1,5 +1,7 @@ import SwiftUI +// --- HELPER STRUCTS & EXTENSIONS --- + // Dummy data for the account list struct Account: Identifiable { let id = UUID() @@ -8,6 +10,57 @@ struct Account: Identifiable { let isCurrent: Bool } +// Custom Transition for older Xcode versions +extension AnyTransition { + static var slideAndFade: AnyTransition { + let insertion = AnyTransition.move(edge: .top).combined(with: .opacity) + let removal = AnyTransition.move(edge: .top).combined(with: .opacity) + return .asymmetric(insertion: insertion, removal: removal) + } +} + +// Helper Views for buttons +struct SideMenuButton: View { + let icon: String + let title: String + let action: () -> Void + + var body: some View { + Button(action: action) { + HStack(spacing: 15) { + Image(systemName: icon) + .font(.title3) + .frame(width: 30) + Text(title) + .font(.subheadline) + } + .foregroundColor(.primary) + .padding(.vertical, 8) + } + } +} + +struct SideMenuFooterButton: View { + let icon: String + let title: String + let action: () -> Void + + var body: some View { + Button(action: action) { + VStack { + Image(systemName: icon) + .font(.title2) + Text(title) + .font(.caption2) + } + .foregroundColor(.primary) + } + } +} + + +// --- MAIN VIEW --- + struct SideMenuView: View { @Binding var isPresented: Bool @State private var isAccountListExpanded = false @@ -66,41 +119,45 @@ struct SideMenuView: View { .padding(.horizontal, 20) .padding(.bottom, 10) - // --- Collapsible Account List --- - if isAccountListExpanded { - VStack(alignment: .leading, spacing: 15) { - ForEach(accounts) { account in - HStack { - Button(action: { }) { - ZStack { - Image(systemName: "person.circle.fill") - .resizable() - .frame(width: 32, height: 32) // Smaller icon - .foregroundColor(.secondary) - - if account.isCurrent { - Image(systemName: "checkmark.circle.fill") - .foregroundColor(.blue) - .background(Circle().fill(Color(UIColor.systemBackground))) - .font(.body) // Smaller checkmark - .offset(x: 11, y: 11) // Adjusted offset + // --- Collapsible Account List in a clipped container --- + VStack { + if isAccountListExpanded { + VStack(alignment: .leading, spacing: 15) { + ForEach(accounts) { account in + HStack { + Button(action: { }) { + ZStack { + Image(systemName: "person.circle.fill") + .resizable() + .frame(width: 32, height: 32) // Smaller icon + .foregroundColor(.secondary) + + if account.isCurrent { + Image(systemName: "checkmark.circle.fill") + .foregroundColor(.blue) + .background(Circle().fill(Color(UIColor.systemBackground))) + .font(.body) // Smaller checkmark + .offset(x: 11, y: 11) // Adjusted offset + } } + + VStack(alignment: .leading) { + Text(account.name).font(.footnote).bold() // Smaller text + Text(account.username).font(.caption2) // Smaller text + } + .foregroundColor(.primary) } - - VStack(alignment: .leading) { - Text(account.name).font(.footnote).bold() // Smaller text - Text(account.username).font(.caption2) // Smaller text - } - .foregroundColor(.primary) + + Spacer() } - - Spacer() } } + .padding(.horizontal, 20) + .padding(.vertical, 10) + .transition(.slideAndFade) } - .padding(.horizontal, 20) - .padding(.vertical, 10) } + .clipped() // Menu Items VStack(alignment: .leading, spacing: 20) { @@ -143,6 +200,7 @@ struct SideMenuView: View { } .frame(maxWidth: .infinity, alignment: .leading) // Align to the left } + .clipped() Spacer() @@ -159,43 +217,4 @@ struct SideMenuView: View { } .background(Color(UIColor.systemBackground)) } -} - -// Helper Views for buttons -struct SideMenuButton: View { - let icon: String - let title: String - let action: () -> Void - - var body: some View { - Button(action: action) { - HStack(spacing: 15) { - Image(systemName: icon) - .font(.title3) - .frame(width: 30) - Text(title) - .font(.subheadline) - } - .foregroundColor(.primary) - .padding(.vertical, 8) - } - } -} - -struct SideMenuFooterButton: View { - let icon: String - let title: String - let action: () -> Void - - var body: some View { - Button(action: action) { - VStack { - Image(systemName: icon) - .font(.title2) - Text(title) - .font(.caption2) - } - .foregroundColor(.primary) - } - } -} +} \ No newline at end of file