mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
implement separated entities for auth pop-up
This commit is contained in:
parent
51e62ece26
commit
1d81089d87
3 changed files with 182 additions and 91 deletions
96
src/Entity/Browser/Container/Page/Auth/Option/Identity.php
Normal file
96
src/Entity/Browser/Container/Page/Auth/Option/Identity.php
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yggverse\Yoda\Entity\Browser\Container\Page\Auth\Option;
|
||||
|
||||
use \GtkRadioButton;
|
||||
|
||||
use \Yggverse\Yoda\Entity\Browser\Container\Page\Auth;
|
||||
|
||||
use \Yggverse\Yoda\Model\Identity\Gemini;
|
||||
|
||||
class Identity
|
||||
{
|
||||
// GTK
|
||||
public GtkRadioButton $gtk;
|
||||
|
||||
// Dependencies
|
||||
public Auth $auth;
|
||||
|
||||
// Requirements
|
||||
public ?Identity\Name $name = null;
|
||||
|
||||
// Defaults
|
||||
public const MARGIN = 12;
|
||||
public const LABEL_DEFAULT = '#%d (%s)';
|
||||
public const LABEL_NO_NAME = '#%d (no name)';
|
||||
|
||||
public function __construct(
|
||||
Auth $auth
|
||||
) {
|
||||
// Init dependencies
|
||||
$this->auth = $auth;
|
||||
|
||||
// Init GTK
|
||||
$this->gtk = new GtkRadioButton;
|
||||
|
||||
$this->gtk->set_margin_top(
|
||||
$this::MARGIN
|
||||
);
|
||||
|
||||
$this->gtk->set_margin_start(
|
||||
$this::MARGIN
|
||||
);
|
||||
|
||||
$this->gtk->set_margin_end(
|
||||
$this::MARGIN
|
||||
);
|
||||
|
||||
$this->gtk->show();
|
||||
|
||||
// Connect events
|
||||
$this->gtk->connect(
|
||||
'toggled',
|
||||
function(): void
|
||||
{
|
||||
$this->auth->refresh();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function setGroup(
|
||||
Identity $identity
|
||||
): void
|
||||
{
|
||||
$this->gtk->join_group(
|
||||
$identity->gtk
|
||||
);
|
||||
}
|
||||
|
||||
public function setLabel(
|
||||
int $id,
|
||||
?string $label = null
|
||||
): void
|
||||
{
|
||||
$this->gtk->set_label(
|
||||
$label ? sprintf(
|
||||
$this::LABEL_DEFAULT,
|
||||
$id,
|
||||
$label
|
||||
) : sprintf(
|
||||
$this::LABEL_NO_NAME,
|
||||
$id
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function setName(
|
||||
string $label
|
||||
): void
|
||||
{
|
||||
$this->name = new Identity\Name(
|
||||
$this
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue