Reputation: 571
I'm just placing some views in navigationBarItems, leading property. but Xcode keep complaining "Type of expression is ambiguous without more context" in my first Text element:
var body: some View {
NavigationView {
List {
ForEach(people) {person in
PersonView(person: person)
}
}.navigationBarItems(leading: VStack {
HStack(spacing: 100) {
Text("Find People").font(.system(size: 30)).bold()
Text("Follow All").foregroundColor(Color(ColorUtils.hexStringToUIColor(hex: Constants.THEME.THEME_COLOR)))
}
HStack(spacing: 100) {
Text("Import from: ")
ForEach(socialIcons, id: \.self) {icon in
Image(icon).resizable().frame(width: 25, height: 25)
}
}
},
trailing: nil
)
}
}
This is my snapshot of the code:
Upvotes: 2
Views: 1292
Reputation: 119380
Xcode is not very intelligent to tell you what is the real issue in SwiftUI enough (yet). So believing or not, the issue is with the trailing: nil
.
You should get rid of it!
So it would be:
.navigationBarItems(leading: VStack {
HStack(spacing: 100) {
Text("Find People").font(.system(size: 30)).bold()
Text("Follow All").foregroundColor(Color(ColorUtils.hexStringToUIColor(hex: Constants.THEME.THEME_COLOR)))
}
HStack(spacing: 100) {
Text("Import from: ")
ForEach(socialIcons, id: \.self) {icon in
Image(icon).resizable().frame(width: 25, height: 25)
}
}
}) /* `trailing: nil` removed */
Upvotes: 3