account switcher

This commit is contained in:
cheykrym 2025-08-14 03:33:21 +03:00
parent d8b683d570
commit 6c7716ec16

View File

@ -1,33 +1,105 @@
import SwiftUI 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 { struct SideMenuView: View {
@Binding var isPresented: Bool @Binding var isPresented: Bool
@State private var isAccountListExpanded = false
// Adjustable paddings // Adjustable paddings
private let topPadding: CGFloat = 66 private let topPadding: CGFloat = 66
private let bottomPadding: CGFloat = 34 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 { var body: some View {
VStack(alignment: .leading, spacing: 0) { VStack(alignment: .leading, spacing: 0) {
ScrollView { ScrollView {
VStack(alignment: .leading, spacing: 0) { // Parent VStack VStack(alignment: .leading, spacing: 0) { // Parent VStack
// Header
VStack(alignment: .leading) { // --- Header
Button(action: { }) {
Image(systemName: "person.circle.fill") Image(systemName: "person.circle.fill")
.resizable() .resizable()
.frame(width: 60, height: 60) .frame(width: 60, height: 60)
.foregroundColor(.gray) .foregroundColor(.gray)
.padding(.horizontal, 20)
.padding(.top, topPadding)
.padding(.bottom, 10)
}
// --- Header Button ---
Button(action: {
withAnimation(.spring()) {
isAccountListExpanded.toggle()
}
}) {
HStack {
VStack(alignment: .leading) {
Text("Your Name") Text("Your Name")
.font(.title3).bold() .font(.title3).bold()
Text("@yourusername") Text("@yourusername")
.font(.footnote) .font(.footnote)
}
.foregroundColor(.primary)
Spacer()
Image(systemName: isAccountListExpanded ? "chevron.up" : "chevron.down")
.font(.headline)
.foregroundColor(.secondary) .foregroundColor(.secondary)
} }
}
.padding(.horizontal, 20) .padding(.horizontal, 20)
.padding(.top, topPadding) .padding(.bottom, 10)
.padding(.bottom, 20)
// --- 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 // Menu Items
VStack(alignment: .leading, spacing: 20) { VStack(alignment: .leading, spacing: 20) {