mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-08-04 06:50:23 +00:00

* feat: implement folder indexer * feat: sqlite search views using fts5 * feat: add view indexing to user manager * feat: implement folder indexer * feat: add sqlite search documents * feat: add document indexing to user manager * feat: add document indexing to folder indexer * chore: update collab rev * feat: search frontend integration * refactor: search index * test: add event test * chore: fix ci * feat: initial command palette overlay impl (#4619) * chore: test search engine * chore: initial structure * chore: replace old search request * chore: enable log for lib-dispatch * chore: move search manager to core * feat: move traits and responsibility to search crate * feat: move search to search crate * feat: replace sqlite with tantivy * feat: deserialize tantivy documents * chore: fixes after rebase * chore: clean code * feat: fetch and sort results * fix: code review + cleaning * feat: support custom icons * feat: support view layout icons * feat: rename bloc and fix indexing * fix: prettify dialog * feat: score results * chore: update collab rev * feat: add recent view history to command palette * test: add integration_tests * fix: clippy changes * fix: focus traversal in cmd palette * fix: remove file after merging main * chore: code review and panic-safe * feat: index all views if index does not exist * chore: improve logic with conditional * chore: add is_empty check * chore: abstract logic from folder manager init * chore: update collab rev * chore: code review * chore: fixes after merge + update lock file * chore: revert cargo lock * fix: set icon type when removing icon * fix: code review + dependency inversion * fix: remove icon fix for not persisting icon type * test: simple tests manipulating views * test: create 100 views * fix: tauri build * chore: create 1000 views * chore: create util methods * chore: test * chore: test * chore: remove logs * chore: fix build.rs * chore: export models * chore: enable clear cache on Rust-CI * fix: navigate to newly created views * fix: force disable setting workspace listener on rebuilds * fix: remove late final * fix: missing returns * fix: localization and minor fixes * test: add index assert to large test * fix: missing section param after merging main * chore: try fix unzip file error * chore: lower the test * feat: show hint when result is in trash * feat: one index_writer per index * fix: minor changes after merge * fix: make create_log_filter public after merge * chore: fix test * chore: fix test * chore: flutter analyze * chore: flutter analyze * chore: fix tauri build --------- Co-authored-by: nathan <nathan@appflowy.io> Co-authored-by: Lucas.Xu <lucas.xu@appflowy.io> Co-authored-by: Nathan.fooo <86001920+appflowy@users.noreply.github.com>
125 lines
3.7 KiB
Dart
125 lines
3.7 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:appflowy/startup/startup.dart';
|
|
import 'package:appflowy/workspace/application/home/home_setting_bloc.dart';
|
|
import 'package:appflowy/workspace/application/settings/appearance/appearance_cubit.dart';
|
|
import 'package:appflowy/workspace/application/sidebar/rename_view/rename_view_bloc.dart';
|
|
import 'package:appflowy/workspace/application/tabs/tabs_bloc.dart';
|
|
import 'package:appflowy/workspace/presentation/home/menu/sidebar/sidebar_setting.dart';
|
|
import 'package:hotkey_manager/hotkey_manager.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
typedef KeyDownHandler = void Function(HotKey hotKey);
|
|
|
|
/// Helper class that utilizes the global [HotKeyManager] to easily
|
|
/// add a [HotKey] with different handlers.
|
|
///
|
|
/// Makes registration of a [HotKey] simple and easy to read, and makes
|
|
/// sure the [KeyDownHandler], and other handlers, are grouped with the
|
|
/// relevant [HotKey].
|
|
///
|
|
class HotKeyItem {
|
|
HotKeyItem({
|
|
required this.hotKey,
|
|
this.keyDownHandler,
|
|
});
|
|
|
|
final HotKey hotKey;
|
|
final KeyDownHandler? keyDownHandler;
|
|
|
|
void register() =>
|
|
hotKeyManager.register(hotKey, keyDownHandler: keyDownHandler);
|
|
}
|
|
|
|
class HomeHotKeys extends StatelessWidget {
|
|
const HomeHotKeys({required this.child, super.key});
|
|
|
|
final Widget child;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// Collapse sidebar menu
|
|
HotKeyItem(
|
|
hotKey: HotKey(
|
|
Platform.isMacOS ? KeyCode.period : KeyCode.backslash,
|
|
modifiers: [Platform.isMacOS ? KeyModifier.meta : KeyModifier.control],
|
|
// Set hotkey scope (default is HotKeyScope.system)
|
|
scope: HotKeyScope.inapp, // Set as inapp-wide hotkey.
|
|
),
|
|
keyDownHandler: (_) => context
|
|
.read<HomeSettingBloc>()
|
|
.add(const HomeSettingEvent.collapseMenu()),
|
|
).register();
|
|
|
|
// Toggle theme mode light/dark
|
|
HotKeyItem(
|
|
hotKey: HotKey(
|
|
KeyCode.keyL,
|
|
modifiers: [
|
|
Platform.isMacOS ? KeyModifier.meta : KeyModifier.control,
|
|
KeyModifier.shift,
|
|
],
|
|
scope: HotKeyScope.inapp,
|
|
),
|
|
keyDownHandler: (_) =>
|
|
context.read<AppearanceSettingsCubit>().toggleThemeMode(),
|
|
).register();
|
|
|
|
// Close current tab
|
|
HotKeyItem(
|
|
hotKey: HotKey(
|
|
KeyCode.keyW,
|
|
modifiers: [Platform.isMacOS ? KeyModifier.meta : KeyModifier.control],
|
|
scope: HotKeyScope.inapp,
|
|
),
|
|
keyDownHandler: (_) =>
|
|
context.read<TabsBloc>().add(const TabsEvent.closeCurrentTab()),
|
|
).register();
|
|
|
|
// Go to previous tab
|
|
HotKeyItem(
|
|
hotKey: HotKey(
|
|
KeyCode.pageUp,
|
|
modifiers: [Platform.isMacOS ? KeyModifier.meta : KeyModifier.control],
|
|
scope: HotKeyScope.inapp,
|
|
),
|
|
keyDownHandler: (_) => _selectTab(context, -1),
|
|
).register();
|
|
|
|
// Go to next tab
|
|
HotKeyItem(
|
|
hotKey: HotKey(
|
|
KeyCode.pageDown,
|
|
modifiers: [Platform.isMacOS ? KeyModifier.meta : KeyModifier.control],
|
|
scope: HotKeyScope.inapp,
|
|
),
|
|
keyDownHandler: (_) => _selectTab(context, 1),
|
|
).register();
|
|
|
|
// Rename current view
|
|
HotKeyItem(
|
|
hotKey: HotKey(
|
|
KeyCode.f2,
|
|
scope: HotKeyScope.inapp,
|
|
),
|
|
keyDownHandler: (_) =>
|
|
getIt<RenameViewBloc>().add(const RenameViewEvent.open()),
|
|
).register();
|
|
|
|
_asyncRegistration(context);
|
|
|
|
return child;
|
|
}
|
|
|
|
Future<void> _asyncRegistration(BuildContext context) async {
|
|
(await openSettingsHotKey(context))?.register();
|
|
}
|
|
|
|
void _selectTab(BuildContext context, int change) {
|
|
final bloc = context.read<TabsBloc>();
|
|
bloc.add(TabsEvent.selectTab(bloc.state.currentIndex + change));
|
|
}
|
|
}
|