uber / uber-ios-sdk

Uber iOS SDK (beta)
https://developer.uber.com/docs
MIT License
376 stars 125 forks source link

Add showDefaultView() method to RideRequestButton that resets metadata #133

Open clairebear opened 7 years ago

clairebear commented 7 years ago

In our application, we keep refreshing the request button periodically to give user information about best fare. Because when user is travelling, user's current location changes.

Therefore, I would like to set the Request button to default when there is an error occurs after button loadRideInformation.

We can get errors, e.g. when Wi-Fi is down, or didReceiveError callbacks method is invoked.

At this point we would like to set uber button to default view as the information (e.g. estimate price) showed on uber button previously is not valid anymore.

So we call

[self.rideRequestButton setContent]

I think this method might be equivalent to the android SDK, setDefaultView() https://github.com/uber/rides-android-sdk/blob/master/rides-android/src/main/java/com/uber/sdk/android/rides/RideRequestButton.java

However I found two problems with iOS SDK setContent method:

  1. The uber button content is not updated immediately, I found I have to refresh the button for around 3 times, to update the content.

  2. The content information is incorrect. The price estimate label still appears.

screen shot 2016-11-21 at 11 32 58 am

jbrophy17 commented 7 years ago

Hi @clairebear, if I'm reading this correctly, it sounds like you want some way to clear the ride information from the button and set it back to the default text? Currently the only way to do that would be to clear the ride parameters and then call loadRideInformation() again, but I agree that that is not ideal.

To address your two points,

  1. When you are refreshing the button, what method are you using exactly? loadRideInformation() is intended as the manual data refresh, but it sounds like you might be using setContent().

  2. setContent() is intended more for initially setting up the button, rather than resetting it. It does update the title of the button, but doesn't clear out the metadata label.

I think your issue could be solved by adding in a way to reset the button to the default state, so I'm going to add the enhancement tag. But let me know if you think this is actually a bug

clairebear commented 7 years ago

Hi @jbrophy17, Thanks for your response. By calling loadRideInformation() again won't solve our problem. Previous ride estimate info will still stay on the button. I think we need an equivalent method as showDefaultView in Android SDK, so we can clear out the metadata info and set the button to default state.

jbrophy17 commented 7 years ago

That sounds reasonable. I can't give an exact timeline on when we will be able to implement this, as we want to get the updated Swift support out first.

But if you want to submit a PR, I would be happy to review it