Skip to content

Commit 94db1eb

Browse files
committed
优化桌面端搜索
1 parent 146e4d3 commit 94db1eb

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

lib/widget_system/views/desk_ui/widget_panel/desk_search_bar.dart

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ class _DeskSearchBarState extends State<DeskSearchBar> {
3131
}
3232

3333
void onSelected(WidgetModel model) {
34+
final FocusScopeNode focusScope = FocusScope.of(context);
35+
if (focusScope.hasFocus) {
36+
focusScope.unfocus();
37+
}
38+
_controller.clear();
39+
40+
Navigator.pushNamed(
41+
context,
42+
UnitRouter.widget_detail,
43+
arguments: model,
44+
);
3445
}
3546

3647
Future<Iterable<WidgetModel>> buildOptions(TextEditingValue textEditingValue) async {
@@ -65,7 +76,7 @@ class _DeskSearchBarState extends State<DeskSearchBar> {
6576
itemBuilder: (_,index) {
6677
WidgetModel model = options.elementAt(index);
6778
return InkWell(
68-
onTap: ()=>_toDetaile(model),
79+
onTap: ()=>onSelected(model),
6980
child: Ink(
7081
padding: EdgeInsets.symmetric(vertical: 6, horizontal: 15),
7182
child: Row(children: [
@@ -143,17 +154,4 @@ class _DeskSearchBarState extends State<DeskSearchBar> {
143154
return TextSpan(children: span);
144155
}
145156

146-
void _toDetaile(WidgetModel model) {
147-
final FocusScopeNode focusScope = FocusScope.of(context);
148-
if (focusScope.hasFocus) {
149-
focusScope.unfocus();
150-
}
151-
_controller.clear();
152-
153-
Navigator.pushNamed(
154-
context,
155-
UnitRouter.widget_detail,
156-
arguments: model,
157-
);
158-
}
159157
}

0 commit comments

Comments
 (0)