Context Sensitive actionSheet


#1

I have an app that requires different options to be presented to the user depending on the state of the selected item. (e.g. Complete Order, Cancel Order, Update Order).

In the scenario above, i do not want the Cancel or Update order to be visible if the order is complete. I imagine that I can generate the array at runtime to display different buttons depending on state but as the buttonClick event uses an index then this will almost certainly become problematic as the index number will not be consistent.

Is there any design guidelines surrounding more dynamic action sheets?


#2

I’ve worked around this by having several actionSheets and it calls the right one depending on order state. It works but feels a bit clunky, would it not be better to have a callback on the buttons object as well as a ng-show directive? Thinking something like…

$ionicActionSheet.show({
    buttons: [
        {
            text: 'Complete Booking',
            onclick: doSomething(),
            visible: true
        }
    ],
    cancelText: 'Cancel',
}