-
-
Notifications
You must be signed in to change notification settings - Fork 193
/
Copy pathMenuBuilder.php
174 lines (139 loc) · 4.36 KB
/
MenuBuilder.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?php
namespace Native\Laravel\Menu;
use Native\Laravel\Client\Client;
use Native\Laravel\Contracts\MenuItem;
use Native\Laravel\Enums\RolesEnum;
class MenuBuilder
{
public function __construct(protected Client $client) {}
public function make(MenuItem ...$items): Menu
{
$menu = new Menu($this->client);
foreach ($items as $item) {
$menu->add($item);
}
return $menu;
}
public function create(MenuItem ...$items): void
{
$this->make(...$items)
->register();
}
public function default(): void
{
$this->create(
$this->app(),
$this->file(),
$this->edit(),
$this->view(),
$this->window(),
);
}
public function label(string $label, ?string $hotkey = null): Items\Label
{
return new Items\Label($label, $hotkey);
}
public function checkbox(string $label, bool $checked = false, ?string $hotkey = null): Items\Checkbox
{
return new Items\Checkbox($label, $checked, $hotkey);
}
public function radio(string $label, bool $checked = false, ?string $hotkey = null): Items\Radio
{
return new Items\Radio($label, $checked, $hotkey);
}
public function link(string $url, ?string $label = null, ?string $hotkey = null): Items\Link
{
return new Items\Link($url, $label, $hotkey);
}
public function route(string $route, ?string $label = null, ?string $hotkey = null): Items\Link
{
return new Items\Link(route($route), $label, $hotkey);
}
public function app(): Items\Role
{
return new Items\Role(RolesEnum::APP_MENU);
}
public function file(?string $label = null): Items\Role
{
return new Items\Role(RolesEnum::FILE_MENU, $label);
}
public function edit(?string $label = null): Items\Role
{
return new Items\Role(RolesEnum::EDIT_MENU, $label);
}
public function view(?string $label = null): Items\Role
{
return new Items\Role(RolesEnum::VIEW_MENU, $label);
}
public function window(?string $label = null): Items\Role
{
return new Items\Role(RolesEnum::WINDOW_MENU, $label);
}
public function separator(): Items\Separator
{
return new Items\Separator;
}
public function fullscreen(?string $label = null): Items\Role
{
return new Items\Role(RolesEnum::TOGGLE_FULL_SCREEN, $label);
}
public function devTools(?string $label = null): Items\Role
{
return new Items\Role(RolesEnum::TOGGLE_DEV_TOOLS, $label);
}
public function undo(?string $label = null): Items\Role
{
return new Items\Role(RolesEnum::UNDO, $label);
}
public function redo(?string $label = null): Items\Role
{
return new Items\Role(RolesEnum::REDO, $label);
}
public function cut(?string $label = null): Items\Role
{
return new Items\Role(RolesEnum::CUT, $label);
}
public function copy(?string $label = null): Items\Role
{
return new Items\Role(RolesEnum::COPY, $label);
}
public function paste(?string $label = null): Items\Role
{
return new Items\Role(RolesEnum::PASTE, $label);
}
public function pasteAndMatchStyle(?string $label = null): Items\Role
{
return new Items\Role(RolesEnum::PASTE_STYLE, $label);
}
public function reload(?string $label = null): Items\Role
{
return new Items\Role(RolesEnum::RELOAD, $label);
}
public function minimize(?string $label = null): Items\Role
{
return new Items\Role(RolesEnum::MINIMIZE, $label);
}
public function close(?string $label = null): Items\Role
{
return new Items\Role(RolesEnum::CLOSE, $label);
}
public function quit(?string $label = null): Items\Role
{
if (is_null($label)) {
$label = __('Quit').' '.config('app.name');
}
return new Items\Role(RolesEnum::QUIT, $label);
}
public function help(?string $label = null): Items\Role
{
return new Items\Role(RolesEnum::HELP, $label);
}
public function hide(?string $label = null): Items\Role
{
return new Items\Role(RolesEnum::HIDE, $label);
}
public function about(?string $label = null): Items\Role
{
return new Items\Role(RolesEnum::ABOUT, $label);
}
}