EddyVerbruggen / cordova-plugin-actionsheet

:clipboard: ActionSheet plugin for Cordova iOS and Android apps
208 stars 71 forks source link

Position of destructive button #40

Closed hirbod closed 8 years ago

hirbod commented 8 years ago

Hi @EddyVerbruggen,

the destructive button is always on first position, even when added later to the options array. Is there any way to decide where to show it? Or at least to put it at bottom?

EddyVerbruggen commented 8 years ago

Hi, this is on Android, right?

hirbod commented 8 years ago

Sorry, forgot to mention. It's on iOS

EddyVerbruggen commented 8 years ago

According to this SO answer that should be possible. I hope to add a preference soon.

hirbod commented 8 years ago

This would be perfect. It would be awesome to also provide something like

destructiveButtonIndex = integer or destructiveButtonIndex = "first"; (default) destructiveButtonIndex = "last";

This would save us time calculating the offset (just a nice to have, as ActionSheets usally dont have more then 3-5 items.

EddyVerbruggen commented 8 years ago

I'm refactoring the iOS code as we speak because I'm using a class that's been deprecated since iOS8.. and with iOS10 on our doorstep I don't have an excuse not to move on. I will try to maintain backward compat with iOS7 and lower though.

Note that the appearance of the ActionSheet will not change for iOS, it's mostly an internal thingy in iOS' codebase.

@Hirbod I'll take that request into account and provide a new destructiveButtonLast boolean property which is default false so it's the same as it is now (per your suggestion).

EddyVerbruggen commented 8 years ago

Available in 2.3.0 on all platforms. See the updated example in the readme (look for destructiveButtonLast).

hirbod commented 8 years ago

Wow.. this was, again, @EddyVerbruggen light speed development. Guess I will send some beer again.

EddyVerbruggen commented 8 years ago

Good. My stock dried up in the meanwhile! Cheers mate 🍻

hirbod commented 8 years ago

@EddyVerbruggen while the combination with destructiveButtonLast works pretty good, single ActionSheets (with just one option) don't work anymore on 2.3.0. I don't even receive an error or something. I will try to find out if "destructiveButtonLast" is causing this or not.

hirbod commented 8 years ago

Identified the bug.

    var options = {
        'buttonLabels': [$scope.trans.BLOCKED_NEIGHBORS],
        'addCancelButtonWithLabel': $scope.trans.ABORT,
        'androidEnableCancelButton': true, // default false
        'winphoneEnableCancelButton': true, // default false
    };

    window.plugins.actionsheet.show(options, function(index) {

        alert(index);

        switch (index) {
            case 1:
            appNavigator.pushPage('blocked_user.html', {
                animation: 'lift'
            });
            break;
        }

    });

will return 2 as index, while it should be 1 (worked before updating to 2.3.0)

EddyVerbruggen commented 8 years ago

OMG I didn't test that case. Let me do so (4 platforms to test really).

hirbod commented 8 years ago

Just tested on iOS 9.3. Will fire up Android now and tell you my results

EddyVerbruggen commented 8 years ago

Seems like iOS is the only platform with the issue..

hirbod commented 8 years ago

Confirmed. Android is working as expected.

EddyVerbruggen commented 8 years ago

2.3.0 is dead, long live 2.3.1, thanks for the quick test!

hirbod commented 8 years ago

Confirmed! it works! Thank you very much

lammie1971 commented 6 years ago

How can I get the action sheet to work in iOS?