2022-08-08 16:36:26 +08:00
|
|
|
import 'dart:io';
|
|
|
|
|
2022-11-26 21:28:08 +08:00
|
|
|
import 'package:app_flowy/workspace/application/home/home_setting_bloc.dart';
|
2022-08-08 16:36:26 +08:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:hotkey_manager/hotkey_manager.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
class HomeHotKeys extends StatelessWidget {
|
|
|
|
final Widget child;
|
2022-08-08 17:12:27 +08:00
|
|
|
const HomeHotKeys({required this.child, Key? key}) : super(key: key);
|
2022-08-08 16:36:26 +08:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-08-31 09:19:31 +08:00
|
|
|
HotKey hotKey = HotKey(
|
2022-08-08 16:36:26 +08:00
|
|
|
KeyCode.backslash,
|
|
|
|
modifiers: [Platform.isMacOS ? KeyModifier.meta : KeyModifier.control],
|
|
|
|
// Set hotkey scope (default is HotKeyScope.system)
|
|
|
|
scope: HotKeyScope.inapp, // Set as inapp-wide hotkey.
|
|
|
|
);
|
|
|
|
hotKeyManager.register(
|
2022-08-31 09:19:31 +08:00
|
|
|
hotKey,
|
2022-08-08 16:36:26 +08:00
|
|
|
keyDownHandler: (hotKey) {
|
2022-11-26 21:28:08 +08:00
|
|
|
context
|
|
|
|
.read<HomeSettingBloc>()
|
|
|
|
.add(const HomeSettingEvent.collapseMenu());
|
2022-08-08 16:36:26 +08:00
|
|
|
},
|
|
|
|
);
|
|
|
|
return child;
|
|
|
|
}
|
|
|
|
}
|