Skip to content

Commit

Permalink
support setting the iconSize on macOS (#60)
Browse files Browse the repository at this point in the history
Co-authored-by: tariq <[email protected]>
  • Loading branch information
alkebuware and tariq authored Dec 12, 2024
1 parent 61115ad commit 115ea6e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/tray_manager/lib/src/tray_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class TrayManager {
String iconPath, {
bool isTemplate = false, // macOS only
TrayIconPositon iconPosition = TrayIconPositon.left, // macOS only
int iconSize = 18, // macOS only
}) async {
final Map<String, dynamic> arguments = {
'id': shortid.generate(),
Expand All @@ -117,6 +118,7 @@ class TrayManager {
]),
'isTemplate': isTemplate,
'iconPosition': iconPosition.name,
'iconSize': iconSize,
};

switch (defaultTargetPlatform) {
Expand Down
3 changes: 2 additions & 1 deletion packages/tray_manager/macos/Classes/TrayManagerPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,11 @@ public class TrayManagerPlugin: NSObject, FlutterPlugin, NSMenuDelegate {
let base64Icon: String = args["base64Icon"] as! String;
let isTemplate: Bool = args["isTemplate"] as! Bool;
let iconPosition: String = args["iconPosition"] as! String;
let iconSize: Int = args["iconSize"] as! Int;

let imageData = Data(base64Encoded: base64Icon, options: .ignoreUnknownCharacters)
let image = NSImage(data: imageData!)
image!.size = NSSize(width: 18, height: 18)
image!.size = NSSize(width: iconSize, height: iconSize)
image!.isTemplate = isTemplate

if (trayIcon == nil) {
Expand Down

0 comments on commit 115ea6e

Please sign in to comment.