mwbrooks/cordova-plugin-menu

Add support for toolbar label

Closed this issue · 6 comments

Currently, there is no support for a toolbar title on iOS

From JavaScript, we should be able to update the toolbar title with:

PhoneGap.exec("NativeControls2.updateToolBar", { 'label': data['label'] });

This is problematic because a UIToolbar is just a button container, and to put a centred label we would have to put a UILabel in the middle, surrounded by spacers to centre it. And once you put in other buttons after, it won't be centred anymore of course.

Only UINavigationBar has the concept of a title in the middle, but then it is designed to only have two buttons - one on the left of the title, and one on the right of the title.

Thoughts?

I think the toolbar title is important, so we may need to go with the UINavigationBar. The first button inserted into the menu can be rendered on the right. If a back button is inserted into the menu, then it will be rendered on the left. The problem is what to do about additional buttons.

Two options that come to mind are:

  • Ignore additional buttons. Not a very ideal solution.
  • Render a UIToolbar underneath the UINavigationBar. Would this be the normal solution for an iOS interface?

We could also combine the above two options into an explicit solution. The main toolbar can have a max of one button and an optional back button. Additional buttons would be ignored. To add more buttons, the user would create a sub-menu inside of the toolbar.

<menu type="toolbar">
    <command accesskey="back">Back</command>
    <command>Settings</command>
    <menu type="toolbar">
        <command accesskey="search">Search</command>
        <command accesskey="search">Update</command>
    </menu>
</menu>

<menu type="context">
    <command>Inbox</command>
    <command>Sent</command>
    <command>Draft</command>
    <command>Trash</command>
</menu>    

I'm sort of leaning on just ignore additional buttons. We could enforce this on all platforms to add consistency.

If IE.com needs additional menu buttons, then we can reevaluate the toolbar. However, it seems like few mobile application use multiple toolbar buttons, likely due to screen real-estate.

Ignore additional would be best, and not have an additional toolbar because... what if the user does not want the NavigationBar, but a Toolbar? I would say this would be a different type of "toolbar", but UINavigationBar would be the one we use for now.

Sounds good to me.

For now, let's enforce one button max (right aligned) and optional back button (left aligned) if the command has 'acesskey="back"'. In the future, perhaps, we can allow a different button to be left aligned - but not for now.

Michael

On 2011-07-01, at 11:07 AM, shazronreply@reply.github.com wrote:

Ignore additional would be best, and not have an additional toolbar because... what if the user does not want the NavigationBar, but a Toolbar? I would say this would be a different type of "menu", but UINavigationBar would be the one we use for now.

Reply to this email directly or view it on GitHub:
https://github.com/nitobi/phonegap-plugin-menu/issues/1#issuecomment-1485180