Reserve global shortcuts for chat selection and search
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import '../../core/api_gateway.dart';
|
||||
import '../../shell/shell_bar.dart';
|
||||
import '../../shell/shell_search_focus.dart';
|
||||
import '../../ui/adaptive/host.dart';
|
||||
import '../../ui/adaptive/segmented_bar.dart';
|
||||
import 'data/search_repository.dart';
|
||||
@@ -44,6 +45,7 @@ class SearchScreen extends StatefulWidget {
|
||||
class _SearchScreenState extends State<SearchScreen> {
|
||||
late final OmniSearchController _controller;
|
||||
late final TextEditingController _text;
|
||||
final FocusNode _focus = FocusNode(debugLabel: 'omni-search');
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -76,11 +78,15 @@ class _SearchScreenState extends State<SearchScreen> {
|
||||
_controller.removeListener(_onState);
|
||||
_controller.dispose();
|
||||
_text.dispose();
|
||||
_focus.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget build(BuildContext context) =>
|
||||
ShellSearchShortcut(onFocus: _focus.requestFocus, child: _build(context));
|
||||
|
||||
Widget _build(BuildContext context) {
|
||||
// Follow the actual host app class: Cupertino only under an explicit
|
||||
// Cupertino host, Material on every platform otherwise.
|
||||
final cupertino = widget.cupertino ?? usesCupertinoHost(context);
|
||||
@@ -112,6 +118,7 @@ class _SearchScreenState extends State<SearchScreen> {
|
||||
}
|
||||
|
||||
Widget _controls(bool cupertino) => SearchBarControls(
|
||||
focusNode: _focus,
|
||||
cupertino: cupertino,
|
||||
text: _text,
|
||||
kind: _controller.parsed.kind,
|
||||
|
||||
@@ -29,6 +29,7 @@ class SearchBarControls extends StatelessWidget {
|
||||
required this.onCleared,
|
||||
required this.onKind,
|
||||
this.autofocus = true,
|
||||
this.focusNode,
|
||||
});
|
||||
|
||||
final bool cupertino;
|
||||
@@ -39,6 +40,7 @@ class SearchBarControls extends StatelessWidget {
|
||||
final VoidCallback onCleared;
|
||||
final ValueChanged<SearchKind> onKind;
|
||||
final bool autofocus;
|
||||
final FocusNode? focusNode;
|
||||
|
||||
@override
|
||||
// The pill grows with the bar, so the field and the results share both
|
||||
@@ -55,6 +57,7 @@ class SearchBarControls extends StatelessWidget {
|
||||
clearKey: const ValueKey('search.clear'),
|
||||
controller: text,
|
||||
autofocus: autofocus,
|
||||
focusNode: focusNode,
|
||||
inBar: true,
|
||||
cupertino: cupertino,
|
||||
placeholder: 'Search pipelines, runs, artifacts and chats',
|
||||
|
||||
Reference in New Issue
Block a user