-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add UIActionSheet wrapper? #367
Comments
I could try doing a PR... |
This could be cool - would love a PR for it. What would your API look like? |
Maybe something like BW::UIActionSheet.new(
origin: UIBarButtonItem.alloc.init, # ignored on an iPhone
buttons: [
{
title: "Cancel",
type: :cancel
},
{
title: "Delete Note",
type: :destructive,
action: :delete_note
},
{
title: "Something Else",
action: :do_something_else
}
],
animated: true
) I like the simplicity of having all the buttons in one hash, but with this API, there would have to be some kind of check to make sure there is only one |
Seems pretty reasonable, and definitely helpful. Are the as = BW::UIActionSheet.new()
as.on(:delete_note) do
end
as.on(:do_something_else) do
end |
I like that. What do you think about also being able to, as an alternative, pass a lambda? |
I like the direction this conversation is going. I'll be watching :) |
@clayallsopp how would that link to titles? |
@supermarin I think the idea was that you would define the action as a symbol, and then reference the symbol in the event callback. For example, above, the action is defined as as.on(:delete_note) do
end |
Yeah I really like that |
Let's also add |
I was playing around with what this would look like in SugarCube's existing BW::UIAlertView.new('Confirm action!',
message: 'Are you sure you want to do this?',
buttons: {
cancel: 'No!', # special treatment
success: 'Sure!',
unsure: 'Hmmm',
}) do |button|
# button will be :cancel, :success or :unsure
end
BW::UIActionSheet.new('Well, how bout it?',
buttons: {
help: 'Tell me more',
cancel: 'Cancel', # special treatment
destructive: 'Kill it with fire!', # special treatment
}) do |button|
# button is :cancel, :destructive or :help
end |
This would have the advantage of having the two interfaces identical... haha, hmm, is that an advantage or confusing? 😕 |
Maybe. What about |
Oh I fixed that, it should be |
I feel like the problem about |
That's not an issue; |
I'd like to rescind the code above - I forgot that bubble-wrap already added a wrapper for All I meant to propose was a syntax for the buttons that would obviate the need for an So, basically, I'm just adding a lot of noise to this conversation and it should be largely ignored! Sorry @ALL! :-) |
I think that the reason it makes sense to have |
Sounds reasonable, but |
Oops, I was getting confused with |
Oh and I didn't even know about that one! Different APIs for I think a similar thing could be done here - if |
Combining some of the ideas from above, and just to put another idea out there, we could get rid of the first parameter BW::UIActionSheet.new({
title: 'Some title',
animated: true,
origin: UIBarButtonItem.alloc.init, # ignored on iPhone
style: :black_translucent,
buttons: {
help: 'Tell me more',
cancel: 'Cancel', # special treatment
destructive: 'Kill it with fire!', # special treatment
}) do |button|
# button is :help, :cancel, or :destructive
end Then again, I like having the possibility of using a lambda directly in the |
anyone working on this? |
Looks like these classes have been replaced with
|
An example:
![](https://cloud.githubusercontent.com/assets/4062448/2735274/f67aef04-c65d-11e3-88ce-71742e75221a.png)
For more information, see the UIActionSheet Class Reference.
Action sheets are used really often, and have an ugly API, so it seems like a good spot for BubbleWrap to step in?
The text was updated successfully, but these errors were encountered: