Skip to content

Commit

Permalink
fix(plugin): clear icons on hot restart
Browse files Browse the repository at this point in the history
  • Loading branch information
benthillerkus committed Apr 6, 2022
1 parent ffe1bdf commit bc9484d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions lib/src/plugin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class BetrayalPlugin {
static const MethodChannel _channel = MethodChannel('betrayal');

BetrayalPlugin._internal() {
_channel.invokeMethod('init');
_channel.setMethodCallHandler(_handleMethod);
}

Expand Down
20 changes: 12 additions & 8 deletions windows/betrayal_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,43 +96,47 @@ namespace Betrayal
const flutter::MethodCall<flutter::EncodableValue> &method_call,
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result)
{
if (method_call.method_name().compare("addTray") == 0)
auto method = method_call.method_name();
if (method.compare("init") == 0) {
icons.clear_all();
}
else if (method.compare("addTray") == 0)
{
WITH_ARGS;
WITH_HWND;
WITH_ID;
AddTray(hWnd, id, std::move(result));
}
else if (method_call.method_name().compare("disposeTray") == 0)
else if (method.compare("disposeTray") == 0)
{
WITH_ARGS;
WITH_HWND;
WITH_ID;
DisposeTray(hWnd, id, std::move(result));
}
else if (method_call.method_name().compare("hideIcon") == 0)
else if (method.compare("hideIcon") == 0)
{
WITH_ARGS;
WITH_HWND;
WITH_ID;
HideIcon(hWnd, id, std::move(result));
}
else if (method_call.method_name().compare("showIcon") == 0)
else if (method.compare("showIcon") == 0)
{
WITH_ARGS;
WITH_HWND;
WITH_ID;
ShowIcon(hWnd, id, std::move(result));
}
else if (method_call.method_name().compare("setTooltip") == 0)
else if (method.compare("setTooltip") == 0)
{
WITH_ARGS;
WITH_HWND;
WITH_ID;
auto tooltip = std::get<std::string>(args.at(flutter::EncodableValue("tooltip")));
SetTooltip(hWnd, id, tooltip, std::move(result));
}
else if (method_call.method_name().compare("setIconFromPath") == 0)
else if (method.compare("setIconFromPath") == 0)
{
WITH_ARGS;
WITH_HWND;
Expand All @@ -141,15 +145,15 @@ namespace Betrayal
auto is_shared = std::get<bool>(args.at(flutter::EncodableValue("isShared")));
SetIconFromPath(hWnd, id, path, is_shared, std::move(result));
}
else if (method_call.method_name().compare("setIconAsWinIcon") == 0)
else if (method.compare("setIconAsWinIcon") == 0)
{
WITH_ARGS;
WITH_HWND;
WITH_ID;
auto resource_id = std::get<int>(args.at(flutter::EncodableValue("resourceId")));
SetIconAsWinIcon(hWnd, id, resource_id, std::move(result));
}
else if (method_call.method_name().compare("setIconFromPixels") == 0)
else if (method.compare("setIconFromPixels") == 0)
{
WITH_ARGS;
WITH_HWND;
Expand Down

0 comments on commit bc9484d

Please sign in to comment.