SteveEdson / bitbar-php

PHP formatter for BitBar plugins
MIT License
67 stars 7 forks source link

submenu example does not work #14

Open gingerbeardman opened 6 years ago

gingerbeardman commented 6 years ago
// Create BitBar formatter
$bb = new BitBar();

// Create the first line
$line = $bb->newLine();

// Set the text and formatting
$mainMenu = $line
    ->setText("Servers")
    ->setColour("yellow");

$mainMenu = $mainMenu->addSubMenu()
    ->newLine()
    ->setText("Server 1")
    ->setUrl('http://server1.com');

$mainMenu = $mainMenu->addSubMenu()
    ->newLine()
    ->setText("Server 2")
    ->setUrl('http://server2.com');

$mainMenu->show();

I see screen shot 2018-06-19 at 12 58 20

gingerbeardman commented 6 years ago

Also, how to recreate this?

https://github.com/matryer/bitbar-plugins/blob/master/Tutorial/submenus.sh

SteveEdson commented 6 years ago

Good question, most of it can be recreated like so:

$bb = new BitBar();

$places = $bb->newLine()
    ->setText("Places");

$placesData = ['London', 'Paris', 'Tokyo'];

foreach($placesData as $place) {
    $places = $places->addSubMenu()
       ->newLine()
       ->setText($place);
}

$places->show();

However, there isn't any support for nested submenus just yet.

This would need to change from the $withinSubMenu approach currently implemented, to something like $depth. I've taken a quick stab at this on the branch feature/nested-submenus, but there's more work required to get this working. (If you run the test example, you'll see that its increasing the depth for every item at the moment).

It'd be a big help if you could open a PR and continue this work, otherwise I'll try to find some more time to look into this later.

Cheers!

gingerbeardman commented 6 years ago

I'll try to find some time, cheers for work done so far

JonLaliberte commented 4 years ago

@gingerbeardman Ever get to the bottom of the submenu issue? I'm seeing the same thing.

gingerbeardman commented 4 years ago

@JonLaliberte no, and sadly no idea what the current state of affairs is with BitBar - sorry