104 lines
		
	
	
		
			3.8 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
			
		
		
	
	
			104 lines
		
	
	
		
			3.8 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
import SwiftUI
 | 
						||
 | 
						||
struct BlockedUsersView: View {
 | 
						||
    @State private var blockedUsers: [BlockedUser] = []
 | 
						||
 | 
						||
    var body: some View {
 | 
						||
        List {
 | 
						||
            if blockedUsers.isEmpty {
 | 
						||
                emptyState
 | 
						||
            } else {
 | 
						||
                Section(header: Text(NSLocalizedString("Заблокированные", comment: ""))) {
 | 
						||
                    ForEach(blockedUsers) { user in
 | 
						||
                        HStack(spacing: 12) {
 | 
						||
                            Circle()
 | 
						||
                                .fill(Color.accentColor.opacity(0.15))
 | 
						||
                                .frame(width: 44, height: 44)
 | 
						||
                                .overlay(
 | 
						||
                                    Text(user.initials)
 | 
						||
                                        .font(.headline)
 | 
						||
                                        .foregroundColor(.accentColor)
 | 
						||
                                )
 | 
						||
                            VStack(alignment: .leading, spacing: 4) {
 | 
						||
                                Text(user.displayName)
 | 
						||
                                    .font(.body)
 | 
						||
                                if let handle = user.handle {
 | 
						||
                                    Text(handle)
 | 
						||
                                        .font(.caption)
 | 
						||
                                        .foregroundColor(.secondary)
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
                            Spacer()
 | 
						||
                            Button(role: .destructive) {
 | 
						||
                                unblock(user)
 | 
						||
                            } label: {
 | 
						||
                                Text(NSLocalizedString("Разблокировать", comment: ""))
 | 
						||
                            }
 | 
						||
                            .buttonStyle(.borderless)
 | 
						||
                        }
 | 
						||
                        .padding(.vertical, 4)
 | 
						||
                    }
 | 
						||
                }
 | 
						||
            }
 | 
						||
        }
 | 
						||
        .navigationTitle(NSLocalizedString("Заблокированные", comment: ""))
 | 
						||
        .navigationBarTitleDisplayMode(.inline)
 | 
						||
        .task {
 | 
						||
            await loadBlockedUsers()
 | 
						||
        }
 | 
						||
    }
 | 
						||
 | 
						||
    private var emptyState: some View {
 | 
						||
        VStack(spacing: 12) {
 | 
						||
            Image(systemName: "hand.raised")
 | 
						||
                .font(.system(size: 48))
 | 
						||
                .foregroundColor(.secondary)
 | 
						||
            Text(NSLocalizedString("У вас нет заблокированных пользователей", comment: ""))
 | 
						||
                .font(.headline)
 | 
						||
                .multilineTextAlignment(.center)
 | 
						||
//            Text(NSLocalizedString("Заблокируйте аккаунт, чтобы скрыть его сообщения и взаимодействия", comment: ""))
 | 
						||
//                .font(.subheadline)
 | 
						||
//                .foregroundColor(.secondary)
 | 
						||
//                .multilineTextAlignment(.center)
 | 
						||
        }
 | 
						||
        .frame(maxWidth: .infinity, alignment: .center)
 | 
						||
        .padding(.vertical, 32)
 | 
						||
        .listRowInsets(EdgeInsets(top: 16, leading: 16, bottom: 16, trailing: 16))
 | 
						||
        .listRowSeparator(.hidden)
 | 
						||
    }
 | 
						||
 | 
						||
    private func loadBlockedUsers() async {
 | 
						||
        // TODO: integrate with real data source once available
 | 
						||
    }
 | 
						||
 | 
						||
    private func unblock(_ user: BlockedUser) {
 | 
						||
        // TODO: implement unblock logic when backend is ready
 | 
						||
        blockedUsers.removeAll { $0.id == user.id }
 | 
						||
    }
 | 
						||
}
 | 
						||
 | 
						||
private struct BlockedUser: Identifiable, Equatable {
 | 
						||
    let id: UUID
 | 
						||
    let displayName: String
 | 
						||
    let handle: String?
 | 
						||
 | 
						||
    var initials: String {
 | 
						||
        let components = displayName.split(separator: " ")
 | 
						||
        let nameInitials = components.prefix(2).compactMap { $0.first }
 | 
						||
        if !nameInitials.isEmpty {
 | 
						||
            return nameInitials
 | 
						||
                .map { String($0).uppercased() }
 | 
						||
                .joined()
 | 
						||
        }
 | 
						||
 | 
						||
        if let handle {
 | 
						||
            let filtered = handle.filter { $0.isLetter }.prefix(2)
 | 
						||
            if !filtered.isEmpty {
 | 
						||
                return filtered.uppercased()
 | 
						||
            }
 | 
						||
        }
 | 
						||
 | 
						||
        return "??"
 | 
						||
    }
 | 
						||
}
 |