Please consider submitting the following information (if relevant):
Library setup method: file, Carthage, CocoaPods or Swift Package Manager.
-cocoapods
Version of the library. Example: 8.0.
-cosmos (22.1.0) (in podfile.lock)
Xcode version. Example: 8.3.3.
-xcode 12.2
OS version. Example: iOS 10.3.2.
-iOS 13 and up
I have a food app where users can post food. I want to prevent them from rating their own posts. The thing is I do need the .didTouchCosmos delegate method to get called so that I can show them an alert "you can't rate your own post". If I don't initialize the delegate method then when they touch it nothing will happen which isn't good ux. I need it touchable, I just need the rating to be ignored.
I tried this but the stars still show the rating once the user touches .didTouchCosmos. However I set .didFinishTouchingCosmos to nil and that never gets called because I don't need it.
cosmosView.didTouchCosmos = { [weak self](rating) in
if let postUID = self?.post.uid, let currentUID = Auth.auth().currentUser?.uid {
if postUID == currentUID {
// 1. show alert "you can't rate your own post"
// 2. set didFinishTouchingCosmos to nil
self?.cosmosView.didFinishTouchingCosmos = nil
return
}
// ...
}
}
// this code never runs because I set this to nil above
cosmosView.didFinishTouchingCosmos = { [weak self](rating) in
if let postUID = self?.post.uid, let currentUID = Auth.auth().currentUser?.uid {
if postUID == currentUID {
return
}
}
}
Just to be clear. If it's the same user who posted the food, the only thing that should happen is an alert will appear every time they touch it, but whatever star/rating that they selected will be ignored.
Please consider submitting the following information (if relevant):
Library setup method: file, Carthage, CocoaPods or Swift Package Manager. -cocoapods
Version of the library. Example: 8.0. -cosmos (22.1.0) (in podfile.lock)
Xcode version. Example: 8.3.3. -xcode 12.2
OS version. Example: iOS 10.3.2. -iOS 13 and up
I have a food app where users can post food. I want to prevent them from rating their own posts. The thing is I do need the
.didTouchCosmos
delegate method to get called so that I can show them an alert "you can't rate your own post". If I don't initialize the delegate method then when they touch it nothing will happen which isn't good ux. I need it touchable, I just need the rating to be ignored.I tried this but the stars still show the rating once the user touches
.didTouchCosmos
. However I set.didFinishTouchingCosmos
to nil and that never gets called because I don't need it.Just to be clear. If it's the same user who posted the food, the only thing that should happen is an alert will appear every time they touch it, but whatever star/rating that they selected will be ignored.