|
|
|
@ -1,3 +1,11 @@
|
|
|
|
|
import 'package:aku_community/base/base_style.dart';
|
|
|
|
|
import 'package:aku_community/constants/api.dart';
|
|
|
|
|
import 'package:aku_community/model/common/img_model.dart';
|
|
|
|
|
import 'package:aku_community/model/community/activity_item_model.dart';
|
|
|
|
|
import 'package:aku_community/model/community/community_topic_model.dart';
|
|
|
|
|
import 'package:aku_community/models/search/search_model.dart';
|
|
|
|
|
import 'package:aku_community/utils/network/base_model.dart';
|
|
|
|
|
import 'package:aku_community/utils/network/net_util.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter_easyrefresh/easy_refresh.dart';
|
|
|
|
@ -7,6 +15,7 @@ import 'package:aku_community/constants/application_objects.dart';
|
|
|
|
|
import 'package:aku_community/utils/headers.dart';
|
|
|
|
|
import 'package:aku_community/utils/login_util.dart';
|
|
|
|
|
import 'package:aku_community/widget/bee_back_button.dart';
|
|
|
|
|
import 'package:velocity_x/velocity_x.dart';
|
|
|
|
|
|
|
|
|
|
class BeeSearch extends StatefulWidget {
|
|
|
|
|
BeeSearch({Key? key}) : super(key: key);
|
|
|
|
@ -16,7 +25,22 @@ class BeeSearch extends StatefulWidget {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _BeeSearchState extends State<BeeSearch> {
|
|
|
|
|
late EasyRefreshController _refreshController;
|
|
|
|
|
TextEditingController _textEditingController = TextEditingController();
|
|
|
|
|
SearchModel _searchModel = SearchModel.init();
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
_refreshController = EasyRefreshController();
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
_refreshController.dispose();
|
|
|
|
|
_textEditingController.dispose();
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<AO> get _searchAppObjects {
|
|
|
|
|
if (_textEditingController.text.isEmpty) return [];
|
|
|
|
|
return appObjects
|
|
|
|
@ -24,6 +48,16 @@ class _BeeSearchState extends State<BeeSearch> {
|
|
|
|
|
.toList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<dynamic> _getNullSafeObjects(dynamic list) {
|
|
|
|
|
List _list = [];
|
|
|
|
|
list.forEach((element) {
|
|
|
|
|
if (element != null) {
|
|
|
|
|
_list.add(element);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return _list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_renderSearchResultBox(String title, {Widget? child, bool visible = true}) {
|
|
|
|
|
if (!visible) return SizedBox().sliverBoxAdapter();
|
|
|
|
|
return Column(
|
|
|
|
@ -59,6 +93,118 @@ class _BeeSearchState extends State<BeeSearch> {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _activityCardButton(ActivityItemModel model) {
|
|
|
|
|
return MaterialButton(
|
|
|
|
|
onPressed: () {},
|
|
|
|
|
shape: StadiumBorder(),
|
|
|
|
|
child: Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 200.w,
|
|
|
|
|
height: 200.w,
|
|
|
|
|
child: ClipRRect(
|
|
|
|
|
clipBehavior: Clip.antiAlias,
|
|
|
|
|
child: FadeInImage.assetNetwork(
|
|
|
|
|
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
|
|
|
|
|
image: API.image(ImgModel.first(model.imgUrls)),
|
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
|
)),
|
|
|
|
|
),
|
|
|
|
|
12.w.widthBox,
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 400.w,
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
model.title!.text
|
|
|
|
|
.size(28.sp)
|
|
|
|
|
.color(ktextPrimary)
|
|
|
|
|
.maxLines(2)
|
|
|
|
|
.overflow(TextOverflow.ellipsis)
|
|
|
|
|
.isIntrinsic
|
|
|
|
|
.bold
|
|
|
|
|
.make()
|
|
|
|
|
.expand(),
|
|
|
|
|
model.statusString.text
|
|
|
|
|
.size(24.sp)
|
|
|
|
|
.color(model.statusColor)
|
|
|
|
|
.make()
|
|
|
|
|
.expand()
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _communityCardButton(CommunityTopicModel model) {
|
|
|
|
|
return MaterialButton(
|
|
|
|
|
onPressed: () {},
|
|
|
|
|
shape: StadiumBorder(),
|
|
|
|
|
child: Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 200.w,
|
|
|
|
|
height: 200.w,
|
|
|
|
|
child: ClipRRect(
|
|
|
|
|
clipBehavior: Clip.antiAlias,
|
|
|
|
|
child: FadeInImage.assetNetwork(
|
|
|
|
|
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
|
|
|
|
|
image: API.image(ImgModel.first(model.imgUrl)),
|
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
|
)),
|
|
|
|
|
),
|
|
|
|
|
12.w.widthBox,
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 400.w,
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
model.title!.text
|
|
|
|
|
.size(28.sp)
|
|
|
|
|
.color(ktextPrimary)
|
|
|
|
|
.maxLines(2)
|
|
|
|
|
.bold.overflow(TextOverflow.ellipsis)
|
|
|
|
|
.isIntrinsic
|
|
|
|
|
.make()
|
|
|
|
|
.expand(),
|
|
|
|
|
model.summary!.text
|
|
|
|
|
.size(28.sp)
|
|
|
|
|
.color(ktextPrimary)
|
|
|
|
|
.maxLines(1)
|
|
|
|
|
.overflow(TextOverflow.ellipsis)
|
|
|
|
|
.make()
|
|
|
|
|
.expand(),
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 100.w,
|
|
|
|
|
child: Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
Image.asset(
|
|
|
|
|
R.ASSETS_ICONS_HOT_FIRE_PNG,
|
|
|
|
|
height: 24.w,
|
|
|
|
|
width: 24.w,
|
|
|
|
|
),
|
|
|
|
|
12.wb,
|
|
|
|
|
'${model.activityNum}'
|
|
|
|
|
.text
|
|
|
|
|
.maxLines(1)
|
|
|
|
|
.size(22.sp)
|
|
|
|
|
.make()
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
@ -77,13 +223,16 @@ class _BeeSearchState extends State<BeeSearch> {
|
|
|
|
|
),
|
|
|
|
|
TextField(
|
|
|
|
|
controller: _textEditingController,
|
|
|
|
|
onChanged: (_) => setState(() {}),
|
|
|
|
|
onChanged: (_) {
|
|
|
|
|
_refreshController.callRefresh();
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
isDense: true,
|
|
|
|
|
contentPadding:
|
|
|
|
|
EdgeInsets.symmetric(vertical: 10.w, horizontal: 10.w),
|
|
|
|
|
border: InputBorder.none,
|
|
|
|
|
hintText: '搜索应用',
|
|
|
|
|
// hintText: '搜索应用',
|
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
|
color: Color(0xFF999999),
|
|
|
|
|
fontSize: 28.sp,
|
|
|
|
@ -100,6 +249,17 @@ class _BeeSearchState extends State<BeeSearch> {
|
|
|
|
|
.make(),
|
|
|
|
|
),
|
|
|
|
|
body: EasyRefresh(
|
|
|
|
|
controller: _refreshController,
|
|
|
|
|
firstRefresh: false,
|
|
|
|
|
header: MaterialHeader(),
|
|
|
|
|
onRefresh: () async {
|
|
|
|
|
BaseModel baseModel = await NetUtil().get(API.search.homeSearch,
|
|
|
|
|
params: {"searchName": _textEditingController.text});
|
|
|
|
|
if (baseModel.status! && baseModel.data != null) {
|
|
|
|
|
_searchModel = SearchModel.fromJson(baseModel.data);
|
|
|
|
|
}
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
child: CustomScrollView(
|
|
|
|
|
slivers: [
|
|
|
|
|
32.hb.sliverBoxAdapter(),
|
|
|
|
@ -114,6 +274,37 @@ class _BeeSearchState extends State<BeeSearch> {
|
|
|
|
|
),
|
|
|
|
|
visible: _searchAppObjects.isNotEmpty,
|
|
|
|
|
),
|
|
|
|
|
32.hb.sliverBoxAdapter(),
|
|
|
|
|
_renderSearchResultBox('社区活动',
|
|
|
|
|
child: GridView.count(
|
|
|
|
|
crossAxisCount: 1,
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
childAspectRatio: 4/1,
|
|
|
|
|
mainAxisSpacing: 20.w,
|
|
|
|
|
physics: NeverScrollableScrollPhysics(),
|
|
|
|
|
children: _getNullSafeObjects(_searchModel.activityVoList)
|
|
|
|
|
.map((e) => _activityCardButton(e))
|
|
|
|
|
.toList(),
|
|
|
|
|
),
|
|
|
|
|
visible: _searchModel.activityVoList.isNotEmpty),
|
|
|
|
|
32.hb.sliverBoxAdapter(),
|
|
|
|
|
_renderSearchResultBox(
|
|
|
|
|
'话题',
|
|
|
|
|
child: GridView.count(
|
|
|
|
|
crossAxisCount: 1,
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
childAspectRatio: 4/1,
|
|
|
|
|
|
|
|
|
|
mainAxisSpacing: 20.w,
|
|
|
|
|
physics: NeverScrollableScrollPhysics(),
|
|
|
|
|
children: [
|
|
|
|
|
..._getNullSafeObjects(_searchModel.gambitVoList)
|
|
|
|
|
.map((e) => _communityCardButton(e))
|
|
|
|
|
.toList()
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
visible: _searchModel.gambitVoList.isNotEmpty,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|