I’ve a picker the place I need to lock any index that isnt -1 behind a paywall:
Picker("", choice: $captureDelegate.userSelectedPeopleCount) {
ForEach(-1...4, id: .self) { i in
HStack(spacing: 68) { //HStack proven the picker is collapsed
Picture(systemName: i == -1 ? "eye.slash.fill" : self.pictures[i])
.resizable()
.body(width: 17, top: 17)
.rotationEffect(rotationAngle)
Textual content(i == -1 ? "" : "(i)")
.font(.system(dimension: 40))
.rotationEffect(rotationAngle)
}
.tag(i)
.rotationEffect(rotationAngle)
}
}
I need to add a picture in between the picture and textual content when the picker is expanded and when the person clicks on one of many choices above -1 (without having unlocked professional) it ought to take them to the acquisition web page. that is my try:
Picker("", choice: $captureDelegate.userSelectedPeopleCount) {
ForEach(-1...4, id: .self) { i in
HStack(spacing: 68) { //HStack proven the picker is collapsed
Picture(systemName: i == -1 ? "eye.slash.fill" : self.pictures[i])
.resizable()
.body(width: 17, top: 17)
.rotationEffect(rotationAngle)
if i >= 0 && purchaseManager.hasUnlockedPro {
Picture(systemName: "crown.fill")
.resizable()
.body(width: 17, top: 17)
.rotationEffect(rotationAngle)
}
Textual content(i == -1 ? "" : "(i)")
.font(.system(dimension: 40))
.rotationEffect(rotationAngle)
}
.tag(i)
.rotationEffect(rotationAngle)
}
}
The result’s that’s doesn’t even present this new picture however I additionally tried changing the textual content with it and it additionally simply is clean:
if i >= 0 && !purchaseManager.hasUnlockedPro {
Picture(systemName: "crown.fill")
.resizable()
.body(width: 17, top: 17)
.rotationEffect(rotationAngle)
} else {
Textual content(i == -1 ? "" : "(i)")
.font(.system(dimension: 40))
.rotationEffect(rotationAngle)
}
How do you management which choices in a Picker are locked behind a paywall in SwiftUI?