forked from lxm_flutter/FlutterUnit
全局ctrl+f快捷键搜索
This commit is contained in:
27
lib/app/res/keymap/search_key_map.dart
Normal file
27
lib/app/res/keymap/search_key_map.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// create by 张风捷特烈 on 2020/12/22
|
||||
/// contact me by email 1981462002@qq.com
|
||||
/// 说明:
|
||||
|
||||
|
||||
|
||||
class ActionUnit{
|
||||
static SearchAction searchAction = SearchAction();
|
||||
|
||||
}
|
||||
|
||||
class SearchIntent extends Intent {
|
||||
const SearchIntent();
|
||||
}
|
||||
|
||||
class SearchAction extends Action<SearchIntent> {
|
||||
Function() onSearch;
|
||||
|
||||
@override
|
||||
Object invoke(covariant SearchIntent intent) {
|
||||
print('-----SearchAction--------');
|
||||
if(onSearch!=null) onSearch();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_unit_mac/app/res/keymap/search_key_map.dart';
|
||||
import 'package:flutter_unit_mac/app/router.dart';
|
||||
import 'package:flutter_unit_mac/blocs/bloc_exp.dart';
|
||||
import 'package:flutter_unit_mac/views/app/splash/unit_splash.dart';
|
||||
@@ -18,31 +19,25 @@ class FlutterApp extends StatelessWidget {
|
||||
create: (_) => CategoryWidgetBloc(
|
||||
categoryBloc: BlocProvider.of<CategoryBloc>(context)),
|
||||
child: MaterialApp(
|
||||
title: 'Flutter Unit',
|
||||
// shortcuts: <LogicalKeySet, Intent>{
|
||||
// ...WidgetsApp.defaultShortcuts,
|
||||
// LogicalKeySet(LogicalKeyboardKey.keyA, LogicalKeyboardKey.keyS):
|
||||
// const SearchIntent(),
|
||||
// },
|
||||
// actions: <Type, Action<Intent>>{
|
||||
// ...WidgetsApp.defaultActions,
|
||||
// SearchIntent: CallbackAction(
|
||||
// onInvoke: (Intent intent) {
|
||||
// print('-----${intent.runtimeType}--------');
|
||||
// Navigator.of(ctx).pushNamed(UnitRouter.search);
|
||||
// return null;
|
||||
// },
|
||||
// ),
|
||||
// },
|
||||
debugShowCheckedModeBanner: false,
|
||||
onGenerateRoute: UnitRouter.generateRoute,
|
||||
theme: ThemeData(
|
||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||
primarySwatch: state.themeColor,
|
||||
fontFamily: state.fontFamily,
|
||||
),
|
||||
home: UnitSplash(),
|
||||
),
|
||||
title: 'Flutter Unit',
|
||||
shortcuts: <LogicalKeySet, Intent>{
|
||||
...WidgetsApp.defaultShortcuts,
|
||||
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.keyF):
|
||||
const SearchIntent(),
|
||||
},
|
||||
actions: <Type, Action<Intent>>{
|
||||
...WidgetsApp.defaultActions,
|
||||
SearchIntent: ActionUnit.searchAction,
|
||||
},
|
||||
debugShowCheckedModeBanner: false,
|
||||
onGenerateRoute: UnitRouter.generateRoute,
|
||||
theme: ThemeData(
|
||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||
primarySwatch: state.themeColor,
|
||||
fontFamily: state.fontFamily,
|
||||
),
|
||||
home: UnitSplash(),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_unit_mac/app/res/cons.dart';
|
||||
import 'package:flutter_unit_mac/app/res/keymap/search_key_map.dart';
|
||||
import 'package:flutter_unit_mac/app/router.dart';
|
||||
import 'package:flutter_unit_mac/app/res/toly_icon.dart';
|
||||
import 'package:flutter_unit_mac/blocs/bloc_exp.dart';
|
||||
@@ -17,6 +18,8 @@ import 'package:flutter_unit_mac/views/pages/unit_todo/layout_unit_page.dart';
|
||||
import 'package:flutter_unit_mac/views/pages/unit_todo/paint_unit_page.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../flutter_app.dart';
|
||||
|
||||
class UnitNavigation extends StatefulWidget {
|
||||
@override
|
||||
_UnitNavigationState createState() => _UnitNavigationState();
|
||||
@@ -27,8 +30,12 @@ class _UnitNavigationState extends State<UnitNavigation> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_controller = PageController();
|
||||
super.initState();
|
||||
_controller = PageController();
|
||||
|
||||
ActionUnit.searchAction.onSearch = () {
|
||||
Navigator.of(context).pushNamed(UnitRouter.search);
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -249,8 +256,9 @@ class _RightNavBarState extends State<RightNavBar> {
|
||||
borderRadius: BorderRadius.only(
|
||||
topRight: Radius.circular(20),
|
||||
bottomRight: Radius.circular(20))),
|
||||
width:
|
||||
active ? widget.itemSize.width*0.95 : widget.itemSize.width * 0.85,
|
||||
width: active
|
||||
? widget.itemSize.width * 0.95
|
||||
: widget.itemSize.width * 0.85,
|
||||
height: widget.itemSize.height,
|
||||
child: Wrap(
|
||||
spacing: 10,
|
||||
@@ -259,12 +267,12 @@ class _RightNavBarState extends State<RightNavBar> {
|
||||
Icon(
|
||||
widget.itemData[info[i]],
|
||||
size: active ? 24 : 20,
|
||||
color: active ? Colors.white:Colors.white70,
|
||||
color: active ? Colors.white : Colors.white70,
|
||||
),
|
||||
Text(
|
||||
info[i],
|
||||
style: TextStyle(
|
||||
color: active ? Colors.white:Colors.white70,
|
||||
color: active ? Colors.white : Colors.white70,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1098,8 +1098,8 @@ class WidgetsMap {
|
||||
return [
|
||||
CustomListView(),
|
||||
HorizontalListView(),
|
||||
BuilderListView(),
|
||||
SeparatedListView(),
|
||||
BuilderListView(),
|
||||
];
|
||||
case "GridView":
|
||||
return [
|
||||
|
||||
@@ -17,7 +17,7 @@ PODS:
|
||||
- FlutterMacOS
|
||||
|
||||
DEPENDENCIES:
|
||||
- FlutterMacOS (from `Flutter/ephemeral/.symlinks/flutter/darwin-x64-release`)
|
||||
- FlutterMacOS (from `Flutter/ephemeral/.symlinks/flutter/darwin-x64`)
|
||||
- path_provider (from `Flutter/ephemeral/.symlinks/plugins/path_provider/macos`)
|
||||
- path_provider_macos (from `Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos`)
|
||||
- shared_preferences (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences/macos`)
|
||||
@@ -32,7 +32,7 @@ SPEC REPOS:
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
FlutterMacOS:
|
||||
:path: Flutter/ephemeral/.symlinks/flutter/darwin-x64-release
|
||||
:path: Flutter/ephemeral/.symlinks/flutter/darwin-x64
|
||||
path_provider:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/path_provider/macos
|
||||
path_provider_macos:
|
||||
|
||||
Reference in New Issue
Block a user