Post

Replies

Boosts

Views

Activity

Reply to Trailing closure passed to parameter of type 'Int' that does not accept a closure
import SwiftUI struct DocumentTemplatesView: View { @StateObject private var documentService = DocumentService.shared @State private var selectedCategory: DocumentCategory? @State private var selectedTemplate: DocumentTemplate? @State private var searchText = "" var body: some View { NavigationView { VStack(spacing: 0) { // Search Bar HStack { Image(systemName: "magnifyingglass") .foregroundColor(.secondary) TextField("搜索模板", text: $searchText) if !searchText.isEmpty { Button(action: { searchText = "" }) { Image(systemName: "xmark.circle.fill") .foregroundColor(.secondary) } } } .padding() .background(Color(.systemBackground)) // Templates List if documentService.isLoading && documentService.categories.isEmpty { ProgressView("加载中...") .frame(maxWidth: .infinity, maxHeight: .infinity) } else if documentService.categories.isEmpty { VStack(spacing: 20) { Image(systemName: "doc.text") .font(.system(size: 60)) .foregroundColor(.gray) Text("暂无文书模板") .font(.headline) .foregroundColor(.gray) Button("重新加载") { Task { @MainActor in try? await documentService.fetchCategories() } } .buttonStyle(.bordered) } .frame(maxWidth: .infinity, maxHeight: .infinity) } else { ScrollView { LazyVStack(spacing: 16) { ForEach(filteredCategories) { category in CategorySection(category: category, searchText: searchText) { template in selectedTemplate = template } } } .padding() } } } .navigationTitle("文书模板") .sheet(item: $selectedTemplate) { template in if let category = documentService.categories.first(where: { $0.templates.contains(where: { $0.id == template.id }) }) { DocumentFormView(template: template, categoryType: category.id) } } .task { if documentService.categories.isEmpty { _ = try? await documentService.fetchCategories() } } } } private var filteredCategories: [DocumentCategory] { if searchText.isEmpty { return documentService.categories } return documentService.categories.compactMap { category in let filteredTemplates = category.templates.filter { template in template.name.localizedCaseInsensitiveContains(searchText) || template.desc.localizedCaseInsensitiveContains(searchText) } if filteredTemplates.isEmpty { return nil } return DocumentCategory( id: category.id, name: category.name, icon: category.icon, description: category.description, templates: filteredTemplates ) } } } // MARK: - Category Section struct CategorySection: View { let category: DocumentCategory let searchText: String let onTemplateSelect: (DocumentTemplate) -> Void var body: some View { VStack(alignment: .leading, spacing: 12) { // Category Header HStack { Image(systemName: iconName(for: category.icon)) .font(.title2) .foregroundColor(.blue) VStack(alignment: .leading, spacing: 4) { Text(category.name) .font(.headline) Text(category.description) .font(.caption) .foregroundColor(.secondary) } Spacer() Text("\(category.templates.count)个") .font(.caption) .foregroundColor(.secondary) } .padding() .background(Color(.systemBackground)) .cornerRadius(12) // Templates ForEach(category.templates) { template in Button(action: { onTemplateSelect(template) }) { HStack { VStack(alignment: .leading, spacing: 4) { Text(template.name) .font(.subheadline) .foregroundColor(.primary) Text(template.desc) .font(.caption) .foregroundColor(.secondary) .lineLimit(2) } Spacer() Image(systemName: "chevron.right") .font(.caption) .foregroundColor(.gray) } .padding() .background(Color(.secondarySystemBackground)) .cornerRadius(8) } } } } private func iconName(for icon: String) -> String { switch icon { case "gavel": return "gavel.fill" case "file-signature": return "doc.text.fill" case "building": return "building.2.fill" case "shield-check": return "checkmark.shield.fill" case "balance-scale": return "scale.3d" case "heart": return "heart.fill" case "globe": return "globe" case "lightbulb": return "lightbulb.fill" case "briefcase": return "briefcase.fill" case "house": return "house.fill" default: return "doc.text" } } } #Preview { DocumentTemplatesView() }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
5d
Reply to Trailing closure passed to parameter of type 'Int' that does not accept a closure
/Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Document/DocumentCategoriesView.swift:25:25 The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Document/DocumentFormView.swift /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Document/DocumentFormView.swift:140:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Document/DocumentFormViewEnhanced.swift /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Document/DocumentFormViewEnhanced.swift:106:18 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Document/DocumentFormViewEnhanced.swift:117:20 Referencing subscript 'subscript(dynamicMember:)' requires wrapper 'ObservedObject.Wrapper' /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Document/DocumentFormViewEnhanced.swift:117:30 Value of type 'DocumentViewModel' has no dynamic member 'isGenerating' using key path from root type 'DocumentViewModel' /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Document/DocumentFormViewEnhanced.swift:117:30 Cannot convert value of type 'Binding<_>' to expected condition type 'Bool' /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Document/DocumentFormViewEnhanced.swift:129:17 Referencing subscript 'subscript(dynamicMember:)' requires wrapper 'ObservedObject.Wrapper'
Topic: UI Frameworks SubTopic: SwiftUI Tags:
5d
Reply to Trailing closure passed to parameter of type 'Int' that does not accept a closure
/Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/TranslationViewModel.swift:53:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/FeedbackViewModel.swift /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/FeedbackViewModel.swift:26:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/FeedbackViewModel.swift:44:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/CalculatorViewModel.swift /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/CalculatorViewModel.swift:86:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/CalculatorViewModel.swift:267:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/CalculatorViewModel.swift:278:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/VIPViewModel.swift /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/VIPViewModel.swift:29:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/VIPViewModel.swift:49:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/VIPViewModel.swift:83:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Lawyer/AppointmentBookingView.swift /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Lawyer/AppointmentBookingView.swift:326:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Lawyer/LawyerDetailView.swift /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Lawyer/LawyerDetailView.swift:458:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Lawyer/ReviewSubmissionView.swift /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Lawyer/ReviewSubmissionView.swift:295:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/AIConsultation/NewConsultationView.swift /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/AIConsultation/NewConsultationView.swift:169:18 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Auth/ForgotPasswordView.swift /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Auth/ForgotPasswordView.swift:115:26 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Auth/ForgotPasswordView.swift:195:22 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Auth/LoginView.swift /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Auth/LoginView.swift:119:26 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Auth/LoginView.swift:219:22 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Auth/LoginView.swift:257:30 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Auth/RegisterView.swift /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Auth/RegisterView.swift:119:26 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Auth/RegisterView.swift:176:18 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Contract/ContractReviewView.swift /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Contract/ContractReviewView.swift:184:22 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Contract/ContractUploadSheet.swift /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Contract/ContractUploadSheet.swift:99:22 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Contract/ContractUploadSheet.swift:196:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Views/Document/DocumentCategoriesView.swift
Topic: UI Frameworks SubTopic: SwiftUI Tags:
5d
Reply to Trailing closure passed to parameter of type 'Int' that does not accept a closure
LegalAI /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Services/DocumentService.swift /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Services/DocumentService.swift:92:18 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Utilities/Extensions.swift /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/Utilities/Extensions.swift:235:22 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/DocumentViewModel.swift /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/DocumentViewModel.swift:192:8 Invalid redeclaration of 'FormFieldView' /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/ConsultationViewModel.swift /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/ConsultationViewModel.swift:54:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/CourseViewModel.swift /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/CourseViewModel.swift:29:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/CourseViewModel.swift:73:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/CourseViewModel.swift:93:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/CourseViewModel.swift:122:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/CourseViewModel.swift:170:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/FranchiseViewModel.swift /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/FranchiseViewModel.swift:40:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/FranchiseViewModel.swift:69:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/FranchiseViewModel.swift:98:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/FranchiseViewModel.swift:118:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/FranchiseViewModel.swift:133:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/FranchiseViewModel.swift:162:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/FranchiseViewModel.swift:191:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/LawFirmManagementViewModel.swift /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/LawFirmManagementViewModel.swift:34:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/LawFirmManagementViewModel.swift:62:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/LawFirmManagementViewModel.swift:86:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/LawFirmManagementViewModel.swift:110:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/LawFirmManagementViewModel.swift:133:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/LawFirmManagementViewModel.swift:146:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/LawFirmManagementViewModel.swift:159:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/LawFirmManagementViewModel.swift:172:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/LawFirmManagementViewModel.swift:185:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/LawyerOfficeViewModel.swift /Users/macbook/Documents/develop/2025-12-20/LegalAI_Native/LegalAI_app/ViewModels/LawyerOfficeViewModel.swift:31:14 Trailing closure passed to parameter of type 'any Decoder' that does not accept a closure
Topic: UI Frameworks SubTopic: SwiftUI Tags:
5d