I have a travel app view with a list of category totals. If the user taps on any category in the list, the app then displays only the filtered entries assigned to the tapped category.
I am using GeometryReader to define the parent space, but I am unable to pass the GeometryReader status through the category filter filteredCategories() to the child space. The error I am seeing (Extra argument 'g' in call) is only occurring where filterCategories() is called.
I know that the arguments in the calling function must appear in the same order in the called function, but that seem to be working here. I have tried placement of GeometryReader like this:
filteredCategories(g: g, filter: categories.catItem[index].catName)
see #1 in filteredCategories()
and this:
filteredCategories(filter: categories.catItem[index].catName, g: g)
see #2 in filteredCategories()
In both case I get the same error Extra argument 'g' in call where filteredCategories() is called.
// display entries belonging to a single category
struct ShowCatEntries: View {
@EnvironmentObject var categories: Categories
var g: GeometryProxy
var index: Int
var body: some View {
VStack {
// fiter coreData
FilteredCategories(filter: categories.catItem[index].catName)
}.navigationTitle("\(categories.catItem[index].catName) Entries")
}
}
struct FilteredCategories: View {
//var g: GeometryProxy // #1
var fetchRequest: FetchRequest<CurrTrans>
init(filter: String) {
let predicate: NSPredicate? = NSPredicate(format: "entryCatName CONTAINS %@", filter)
fetchRequest = FetchRequest<CurrTrans>(sortDescriptors: [
NSSortDescriptor(keyPath: \CurrTrans.entryCatName, ascending: true)],
predicate: predicate)
}
//var g: GeometryProxy // #2
var body: some View {
List(fetchRequest.wrappedValue, id: \.self) { entry in
ShwProRow(g: g, entry: entry) // portrait
}.listStyle(PlainListStyle())
}
}