diff --git a/lib/pages/orders_page/order_search_page.dart b/lib/pages/orders_page/order_search_page.dart index 363fac3..43aee78 100644 --- a/lib/pages/orders_page/order_search_page.dart +++ b/lib/pages/orders_page/order_search_page.dart @@ -1,7 +1,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:zhiying_comm/zhiying_comm.dart'; import 'package:zhiying_base_widget/widgets/empty/empty_widget.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; // 订单搜索页面 class OrderSearchPage extends StatefulWidget { @@ -18,14 +18,26 @@ class _OrderSearchPageState extends State { super.initState(); } + @override + void dispose() { + _keywordController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { - return Scaffold( - appBar: _createNav(), - body: SafeArea( - child: Container(width: double.infinity, - height: double.infinity, - child: Center(child: EmptyWidget())), + return GestureDetector( + onTap: () { + FocusScope.of(context).requestFocus(FocusNode()); + }, + child: Scaffold( + appBar: _createNav(), + body: SafeArea( + child: Container( + width: double.infinity, + height: double.infinity, + child: Center(child: EmptyWidget())), + ), ), ); } @@ -42,19 +54,19 @@ class _OrderSearchPageState extends State { backgroundColor: Colors.white, leading: Navigator.canPop(context) ? GestureDetector( - child: Container( - padding: EdgeInsets.zero, - child: Icon( - Icons.arrow_back_ios, - size: 20, - ), - ), - onTap: () { - if (Navigator.canPop(context)) { - Navigator.pop(context); - } - }, - ) + child: Container( + padding: EdgeInsets.zero, + child: Icon( + Icons.arrow_back_ios, + size: 20, + ), + ), + onTap: () { + if (Navigator.canPop(context)) { + Navigator.pop(context); + } + }, + ) : Container(), middle: Container( height: 32, @@ -68,6 +80,8 @@ class _OrderSearchPageState extends State { placeholderStyle: TextStyle(color: Color(0xff999999), fontSize: 14), controller: _keywordController, style: TextStyle(fontSize: 14, color: Color(0xff333333)), + textInputAction: TextInputAction.search, + onSubmitted: _search, ), ), trailing: Container( @@ -83,9 +97,14 @@ class _OrderSearchPageState extends State { ), onPressed: () { Logger.debug(_keywordController.text); + _search(_keywordController.text); }, ), ), ); } + + void _search(String keyword) { + FocusScope.of(context).requestFocus(FocusNode()); + } }