An open-source cross-platform alternative to AirDrop
fix(macos): add missing `setActivationPolicy` (#1760)
Shlomoaa838d7e688d
diff --git a/app/lib/util/native/macos_channel.dart b/app/lib/util/native/macos_channel.dartindex 70b5515c..96024bb3 100644--- a/app/lib/util/native/macos_channel.dart+++ b/app/lib/util/native/macos_channel.dart@@ -3,6 +3,7 @@ import 'dart:async';import 'package:flutter/foundation.dart';import 'package:flutter/services.dart';import 'package:localsend_app/gen/strings.g.dart';+import 'package:localsend_app/util/native/tray_helper.dart';const _methodChannel = MethodChannel('main-delegate-channel');@@ -72,6 +73,9 @@ void setupMethodCallHandler() {case 'onPendingStrings':pendingStringsStreamController.add((call.arguments as List).cast<String>());break;+ case 'showLocalSendFromMenuBar':+ await showFromTray();+ break;}});}diff --git a/app/macos/Runner/AppDelegate.swift b/app/macos/Runner/AppDelegate.swiftindex 5676adb9..88183946 100644--- a/app/macos/Runner/AppDelegate.swift+++ b/app/macos/Runner/AppDelegate.swift@@ -58,7 +58,7 @@ class AppDelegate: FlutterAppDelegate {let menu = NSMenu()let openString = i18n["open"]!- let openItem = NSMenuItem(title: openString, action: #selector(openApp), keyEquivalent: "o")+ let openItem = NSMenuItem(title: openString, action: #selector(showLocalSendFromMenuBar), keyEquivalent: "o")menu.addItem(openItem)let quitString = i18n["quit"]!@@ -80,9 +80,8 @@ class AppDelegate: FlutterAppDelegate {}}- @objc func openApp() {- NSApp.activate(ignoringOtherApps: true)- mainFlutterWindow?.makeKeyAndOrderFront(nil)+ @objc func showLocalSendFromMenuBar() {+ channel?.invokeMethod("showLocalSendFromMenuBar", arguments: nil)}@objc private func quitApp() {@@ -109,7 +108,8 @@ class AppDelegate: FlutterAppDelegate {Defaults[.pendingFiles] = []Defaults[.pendingStrings] = []- openApp()++ channel?.invokeMethod("showLocalSendFromMenuBar", arguments: nil)}// START: handle opened files@@ -126,13 +126,18 @@ class AppDelegate: FlutterAppDelegate {}result(filePaths)+Defaults[.pendingFiles] = []- openApp()++ channel?.invokeMethod("showLocalSendFromMenuBar", arguments: nil)case "getPendingStrings":let pendingStrings = Defaults[.pendingStrings]+result(pendingStrings)+Defaults[.pendingStrings] = []- openApp()++ channel?.invokeMethod("showLocalSendFromMenuBar", arguments: nil)case "setupStatusBar":let i18n = call.arguments as! [String: String]setupStatusBarItem(i18n: i18n)