import SwiftUI struct StatusBadge: View { let statusCode: Int? var color: Color { guard let code = statusCode else { return .secondary } switch code { case 200..<300: return .green case 300..<400: return .blue case 400..<500: return .yellow case 500..<600: return .red default: return .secondary } } var text: String { guard let code = statusCode else { return "..." } switch code { case 200: return "200 OK" case 201: return "201 Created" case 204: return "204 No Content" case 301: return "301 Moved" case 302: return "302 Found" case 304: return "304 Not Modified" case 400: return "400 Bad Request" case 401: return "401 Unauthorized" case 403: return "403 Forbidden" case 404: return "404 Not Found" case 500: return "500 Server Error" case 502: return "502 Bad Gateway" case 503: return "503 Unavailable" default: return "\(code)" } } var body: some View { Text(text) .font(.caption2.weight(.medium)) .foregroundStyle(color) .padding(.horizontal, 6) .padding(.vertical, 2) .background(color.opacity(0.12), in: RoundedRectangle(cornerRadius: 4)) } }