添加搜索页面

hmxc
小赖 4 years ago
parent b5f28848db
commit d5601ab5a2

@ -9,3 +9,5 @@ A new Flutter application.
### password ### password
password `1Xpn6hhbxztA6PC0oFiZ` password `1Xpn6hhbxztA6PC0oFiZ`
### 需要重构应用页面

@ -1,5 +1,19 @@
// Flutter imports: // Flutter imports:
import 'package:aku_community_manager/provider/app_provider.dart';
import 'package:aku_community_manager/ui/home/application/applications_page.dart';
import 'package:aku_community_manager/ui/manage_pages/green_manage/green_manage_page.dart';
import 'package:aku_community_manager/ui/manage_pages/inspection_manage/inspection_manage_page.dart';
import 'package:aku_community_manager/ui/sub_pages/activity_manager/activity_manager_page.dart';
import 'package:aku_community_manager/ui/sub_pages/borrow_manager/borrow_manager_page.dart';
import 'package:aku_community_manager/ui/sub_pages/business_and_fix/business_and_fix_page.dart';
import 'package:aku_community_manager/ui/sub_pages/decoration_manager/decoration_manager_page.dart';
import 'package:aku_community_manager/ui/sub_pages/items_outdoor/items_outdoor_page.dart';
import 'package:aku_community_manager/ui/sub_pages/visitor_manager/visitor_manager_page.dart';
import 'package:aku_community_manager/ui/tool_pages/warning/warning_page.dart';
import 'package:aku_ui/common_widgets/aku_material_button.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:provider/provider.dart';
// Package imports: // Package imports:
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -20,9 +34,25 @@ class SearchWorkOrderPage extends StatefulWidget {
class _SearchWorkOrderpageState extends State<SearchWorkOrderPage> { class _SearchWorkOrderpageState extends State<SearchWorkOrderPage> {
TextEditingController _textController; TextEditingController _textController;
List<AppApplication> _wisdomApplications = [
AppApplication('一键报警', R.ASSETS_HOME_IC_POLICE_PNG, WarningPage()),
AppApplication('访客管理', R.ASSETS_HOME_IC_VISITORS_PNG, VisitorManagerPage()),
AppApplication('报事报修', R.ASSETS_HOME_IC_SERVICE_PNG, BusinessAndFixPage()),
AppApplication('物品出户', R.ASSETS_HOME_IC_ARTICLE_PNG, ItemsOutdoorPage()),
AppApplication(
'装修管理', R.ASSETS_HOME_IC_DECORATION_PNG, DecorationManagerPage()),
AppApplication(
'活动管理', R.ASSETS_HOME_IC_ACTIVITY_PNG, ActivityManagerPage()),
AppApplication('借还管理', R.ASSETS_HOME_IC_BORROW_PNG, BorrowManagerPage()),
AppApplication('巡检管理', R.ASSETS_HOME_IC_PATROL_PNG, InspectionManagePage()),
AppApplication('绿化管理', R.ASSETS_HOME_IC_GREENING_PNG, GreenManagePage()),
];
List<AppApplication> _displayApps = [];
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_displayApps = _wisdomApplications;
_textController = TextEditingController(); _textController = TextEditingController();
} }
@ -34,6 +64,7 @@ class _SearchWorkOrderpageState extends State<SearchWorkOrderPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final appProvider = Provider.of<AppProvider>(context);
return AkuScaffold( return AkuScaffold(
appBar: AppBar( appBar: AppBar(
brightness: Brightness.light, brightness: Brightness.light,
@ -57,7 +88,7 @@ class _SearchWorkOrderpageState extends State<SearchWorkOrderPage> {
), ),
AkuBox.w(16), AkuBox.w(16),
Expanded( Expanded(
child: TextFormField( child: TextField(
controller: _textController, controller: _textController,
decoration: InputDecoration( decoration: InputDecoration(
hintText: '搜索工单、手机号', hintText: '搜索工单、手机号',
@ -72,6 +103,12 @@ class _SearchWorkOrderpageState extends State<SearchWorkOrderPage> {
fontSize: 28.sp, fontSize: 28.sp,
), ),
onChanged: (text) { onChanged: (text) {
if (text.isEmpty)
_displayApps = _wisdomApplications;
else
_displayApps = _wisdomApplications
.where((element) => element.name.contains(text))
.toList();
setState(() {}); setState(() {});
}, },
), ),
@ -84,14 +121,37 @@ class _SearchWorkOrderpageState extends State<SearchWorkOrderPage> {
), ),
), ),
), ),
body: Center( body: GridView.builder(
child: _textController.text.isEmpty gridDelegate:
? SizedBox() SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4),
: Text( itemBuilder: (context, index) {
'无结果', final item = _displayApps[index];
style: TextStyle( return AkuMaterialButton(
color: AppStyle.primaryTextColor, fontSize: 36.sp), onPressed: () {
), appProvider.addRecentApp(item);
Get.to(item.page);
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
item.assetPath,
height: 60.w,
width: 60.w,
),
AkuBox.h(8),
Text(
item.name,
style: TextStyle(
color: AppStyle.primaryTextColor,
fontSize: 24.sp,
fontWeight: FontWeight.bold),
),
],
),
);
},
itemCount: _displayApps.length,
), ),
); );
} }

Loading…
Cancel
Save