Skip to content

Rework building action sheets #1239

@wutschel

Description

@wutschel

Taken from review discussions in #1232.

Current implementation uses a generic and complex action sheet handler, which compares localized strings to determine the action to take. Alternative solution is to create a set of the actions:

UIAlertAction *action1 = [UIAlertAction ... handler:^{ [self do_this] }];
UIAlertAction *action2 = [UIAlertAction ... handler:^{ [self do_that] }];

In this case I would need to move the logic of what I am finally showing in the action sheet (currently a simple array of action strings which is majorly defined in AppDelegate) to the place where I am building the sheet. And ideally replacing the string in AppDelegate with enums. Something like this:

AppDelegate:

menu.sheetActions = @[
    action_play,
    action_queue,
];

ViewController:

UIAlertAction *action1 = [UIAlertAction ... handler:^{ [self play] }];
UIAlertAction *action2 = [UIAlertAction ... handler:^{ [self queue] }];

for (actionID in sheetActions) |
    switch (actionID) {
        case action_play:
            [alertCtrl addAction: action1];
            break;
        case action_queue:
            [alertCtrl addAction: action2];
            break;
       default:
           break;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions