From da2e00484f3b0d34780aadbc124a67f8fe8a44ec Mon Sep 17 00:00:00 2001 From: laiiihz Date: Mon, 8 Feb 2021 09:29:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=90=9C=E7=B4=A2=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/personal/personal_page.dart | 3 +- lib/ui/home/application/all_application.dart | 5 +- lib/ui/search/bee_search.dart | 115 +++++++++++++++++++ 3 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 lib/ui/search/bee_search.dart diff --git a/lib/pages/personal/personal_page.dart b/lib/pages/personal/personal_page.dart index d7d51abf..eac0fbfc 100644 --- a/lib/pages/personal/personal_page.dart +++ b/lib/pages/personal/personal_page.dart @@ -143,7 +143,8 @@ class _PersonalIndexState extends State margin: EdgeInsets.only(left: 16.w), child: userProvider.isLogin ? Text( - userProvider.userInfoModel.nickName, + userProvider.userInfoModel?.nickName ?? + '', style: TextStyle( fontSize: 32.sp, color: Color(0xffad8940), diff --git a/lib/ui/home/application/all_application.dart b/lib/ui/home/application/all_application.dart index a98cc59e..5c1d9d47 100644 --- a/lib/ui/home/application/all_application.dart +++ b/lib/ui/home/application/all_application.dart @@ -1,4 +1,5 @@ // Flutter imports: +import 'package:akuCommunity/ui/search/bee_search.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -234,7 +235,9 @@ class _AllApplicationPageState extends State { elevation: 0, minWidth: double.infinity, color: Color(0xFFF3F3F3), - onPressed: () {}, + onPressed: () { + Get.to(BeeSearch()); + }, child: Row( children: [ Icon( diff --git a/lib/ui/search/bee_search.dart b/lib/ui/search/bee_search.dart new file mode 100644 index 00000000..98efe233 --- /dev/null +++ b/lib/ui/search/bee_search.dart @@ -0,0 +1,115 @@ +import 'package:akuCommunity/constants/application_objects.dart'; +import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/widget/bee_back_button.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:get/get.dart'; + +class BeeSearch extends StatefulWidget { + BeeSearch({Key key}) : super(key: key); + + @override + _BeeSearchState createState() => _BeeSearchState(); +} + +class _BeeSearchState extends State { + TextEditingController _textEditingController = TextEditingController(); + List get _searchAppObjects { + if (_textEditingController.text.isEmpty) return []; + return appObjects + .where((element) => element.title.contains(_textEditingController.text)) + .toList(); + } + + _renderSearchResultBox(String title, {Widget child, bool visible = true}) { + if (!visible) return SizedBox().sliverBoxAdapter(); + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + title.text.size(28.sp).make(), + Divider(), + child, + ], + ).p(32.w).material(color: Colors.white).sliverBoxAdapter(); + } + + Widget _buildColumnIcon(AO e) { + return MaterialButton( + onPressed: () => Get.to(e.page), + shape: StadiumBorder(), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset( + e.path, + height: 75.w, + width: 75.w, + ), + 8.hb, + e.title.text.size(24.sp).make(), + ], + ), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Color(0xFFF2F2F2), + appBar: AppBar( + backgroundColor: Colors.white, + leading: BeeBackButton(), + elevation: 0, + title: Row( + children: [ + 40.wb, + Icon( + Icons.search, + size: 32.w, + color: Color(0xFF666666), + ), + TextField( + controller: _textEditingController, + onChanged: (_) => setState(() {}), + decoration: InputDecoration( + isDense: true, + contentPadding: + EdgeInsets.symmetric(vertical: 10.w, horizontal: 10.w), + border: InputBorder.none, + hintText: '搜索商品、活动、帖子、应用', + hintStyle: TextStyle( + color: Color(0xFF999999), + fontSize: 28.sp, + ), + ), + ).expand(), + ], + ) + .box + .color(Color(0xFFF3F3F3)) + .withRounded(value: 36.w) + .height(72.w) + .alignment(Alignment.center) + .make(), + ), + body: EasyRefresh( + child: CustomScrollView( + slivers: [ + 32.hb.sliverBoxAdapter(), + _renderSearchResultBox( + '应用', + child: GridView.count( + crossAxisCount: 4, + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + children: + _searchAppObjects.map((e) => _buildColumnIcon(e)).toList(), + ), + visible: _searchAppObjects.isNotEmpty, + ), + ], + ), + ), + ); + } +}