From 6c7716ec164ddedf685547ae83a62aa98278475e Mon Sep 17 00:00:00 2001 From: cheykrym Date: Thu, 14 Aug 2025 03:33:21 +0300 Subject: [PATCH] account switcher --- Shared/Views/Tab/SideMenuView.swift | 96 +++++++++++++++++++++++++---- 1 file changed, 84 insertions(+), 12 deletions(-) diff --git a/Shared/Views/Tab/SideMenuView.swift b/Shared/Views/Tab/SideMenuView.swift index 5572e67..8922ad4 100644 --- a/Shared/Views/Tab/SideMenuView.swift +++ b/Shared/Views/Tab/SideMenuView.swift @@ -1,33 +1,105 @@ import SwiftUI +// Dummy data for the account list +struct Account: Identifiable { + let id = UUID() + let name: String + let username: String + let isCurrent: Bool +} + struct SideMenuView: View { @Binding var isPresented: Bool - + @State private var isAccountListExpanded = false + // Adjustable paddings private let topPadding: CGFloat = 66 private let bottomPadding: CGFloat = 34 + + // Dummy account data + private let accounts: [Account] = [ + Account(name: "Your Name", username: "@yourusername", isCurrent: true), + Account(name: "Second Account", username: "@second", isCurrent: false), + Account(name: "Another One", username: "@another", isCurrent: false), + Account(name: "Test User", username: "@test", isCurrent: false), + Account(name: "Creative Profile", username: "@creative", isCurrent: false) + ] var body: some View { VStack(alignment: .leading, spacing: 0) { ScrollView { VStack(alignment: .leading, spacing: 0) { // Parent VStack - // Header - VStack(alignment: .leading) { + + // --- Header + Button(action: { }) { Image(systemName: "person.circle.fill") .resizable() .frame(width: 60, height: 60) .foregroundColor(.gray) - Text("Your Name") - .font(.title3).bold() - Text("@yourusername") - .font(.footnote) - .foregroundColor(.secondary) + .padding(.horizontal, 20) + .padding(.top, topPadding) + .padding(.bottom, 10) + } + + // --- Header Button --- + Button(action: { + withAnimation(.spring()) { + isAccountListExpanded.toggle() + } + }) { + HStack { + VStack(alignment: .leading) { + Text("Your Name") + .font(.title3).bold() + Text("@yourusername") + .font(.footnote) + } + .foregroundColor(.primary) + + Spacer() + + Image(systemName: isAccountListExpanded ? "chevron.up" : "chevron.down") + .font(.headline) + .foregroundColor(.secondary) + } } .padding(.horizontal, 20) - .padding(.top, topPadding) - .padding(.bottom, 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: 40, height: 40) + .foregroundColor(.secondary) + + if account.isCurrent { + Image(systemName: "checkmark.circle.fill") + .foregroundColor(.blue) + .background(Circle().fill(Color(UIColor.systemBackground))) + .font(.title3) + .offset(x: 14, y: 14) + } + } + + VStack(alignment: .leading) { + Text(account.name).font(.subheadline).bold() + Text(account.username).font(.caption) + } + .foregroundColor(.primary) } + + Spacer() + } + } + } + .padding(.horizontal, 20) + .padding(.vertical, 10) + } // Menu Items VStack(alignment: .leading, spacing: 20) {