Skip to content

Commit

Permalink
chore: Add hotkey_manager_macos package
Browse files Browse the repository at this point in the history
  • Loading branch information
lijy91 committed Feb 4, 2024
1 parent a4cc20c commit d9f75c4
Show file tree
Hide file tree
Showing 29 changed files with 499 additions and 1,180 deletions.
4 changes: 2 additions & 2 deletions packages/hotkey_manager/example/lib/pages/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ class _HomePageState extends State<HomePage> {
List<HotKey> _registeredHotKeyList = [];

void _keyDownHandler(HotKey hotKey) {
String log = 'keyDown ${hotKey.keyCode.name} (${hotKey.scope})';
String log = 'keyDown ${hotKey.physicalKey.debugName} (${hotKey.scope})';
BotToast.showText(text: log);
if (kDebugMode) {
print(log);
}
}

void _keyUpHandler(HotKey hotKey) {
String log = 'keyUp ${hotKey.keyCode.name} (${hotKey.scope})';
String log = 'keyUp ${hotKey.physicalKey.debugName} (${hotKey.scope})';
if (kDebugMode) {
print(log);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart';
import 'package:hotkey_manager/hotkey_manager.dart';

Expand All @@ -16,10 +17,22 @@ class RecordHotKeyDialog extends StatefulWidget {
class _RecordHotKeyDialogState extends State<RecordHotKeyDialog> {
HotKey? _hotKey;

void _handleSetAsInappWideChanged(bool newValue) {
if (_hotKey == null) {
BotToast.showText(text: 'Please record a hotkey first.');
return;
}
_hotKey = HotKey(
key: _hotKey!.key,
modifiers: _hotKey?.modifiers,
scope: newValue ? HotKeyScope.inapp : HotKeyScope.system,
);
setState(() {});
}

@override
Widget build(BuildContext context) {
return AlertDialog(
// title: Text('Rewind and remember'),
content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
Expand All @@ -45,20 +58,25 @@ class _RecordHotKeyDialogState extends State<RecordHotKeyDialog> {
],
),
),
Row(
children: [
Checkbox(
value: _hotKey?.scope == HotKeyScope.inapp,
onChanged: (newValue) {
_hotKey?.scope =
newValue! ? HotKeyScope.inapp : HotKeyScope.system;
setState(() {});
},
),
const Text(
'Set as inapp-wide hotkey. (default is system-wide)',
),
],
GestureDetector(
onTap: () {
_handleSetAsInappWideChanged(
_hotKey?.scope != HotKeyScope.inapp,
);
},
child: Row(
children: [
Checkbox(
value: _hotKey?.scope == HotKeyScope.inapp,
onChanged: (newValue) {
_handleSetAsInappWideChanged(newValue!);
},
),
const Text(
'Set as inapp-wide hotkey. (default is system-wide)',
),
],
),
),
],
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import FlutterMacOS
import Foundation

import hotkey_manager
import hotkey_manager_macos

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
HotkeyManagerPlugin.register(with: registry.registrar(forPlugin: "HotkeyManagerPlugin"))
HotkeyManagerMacosPlugin.register(with: registry.registrar(forPlugin: "HotkeyManagerMacosPlugin"))
}
14 changes: 7 additions & 7 deletions packages/hotkey_manager/example/macos/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
PODS:
- FlutterMacOS (1.0.0)
- HotKey (0.1.2)
- hotkey_manager (0.0.1):
- HotKey (0.2.0)
- hotkey_manager_macos (0.0.1):
- FlutterMacOS
- HotKey

DEPENDENCIES:
- FlutterMacOS (from `Flutter/ephemeral`)
- hotkey_manager (from `Flutter/ephemeral/.symlinks/plugins/hotkey_manager/macos`)
- hotkey_manager_macos (from `Flutter/ephemeral/.symlinks/plugins/hotkey_manager_macos/macos`)

SPEC REPOS:
trunk:
Expand All @@ -16,13 +16,13 @@ SPEC REPOS:
EXTERNAL SOURCES:
FlutterMacOS:
:path: Flutter/ephemeral
hotkey_manager:
:path: Flutter/ephemeral/.symlinks/plugins/hotkey_manager/macos
hotkey_manager_macos:
:path: Flutter/ephemeral/.symlinks/plugins/hotkey_manager_macos/macos

SPEC CHECKSUMS:
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
HotKey: ad59450195936c10992438c4210f673de5aee43e
hotkey_manager: c32bf0bfe8f934b7bc17ab4ad5c4c142960b023c
HotKey: e96d8a2ddbf4591131e2bb3f54e69554d90cdca6
hotkey_manager_macos: 1e2edb0c7ae4fe67108af44a9d3445de41404160

PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7

Expand Down
4 changes: 1 addition & 3 deletions packages/hotkey_manager/lib/hotkey_manager.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
export './src/enums/key_code.dart';
export './src/enums/key_modifier.dart';
export './src/hotkey.dart';
export 'package:hotkey_manager_platform_interface/hotkey_manager_platform_interface.dart';
export './src/hotkey_manager.dart';
export './src/widgets/hotkey_recorder.dart';
export './src/widgets/hotkey_virtual_view.dart';
Loading

0 comments on commit d9f75c4

Please sign in to comment.