分类页面更新

hmxc
小赖 4 years ago
parent a93b2b43d9
commit 4768dc0d67

@ -258,6 +258,9 @@ class _Community {
class _Market {
String get category => '/user/shop/findAllCategory';
///appid
String get list => '/user/shop/findGoodsByCategoryId';
}
class _Upload {

@ -1,7 +1,9 @@
import 'package:aku_community/constants/api.dart';
import 'package:aku_community/model/common/img_model.dart';
import 'package:aku_community/models/market/display_category_model.dart';
import 'package:aku_community/models/market/market_category_model.dart';
import 'package:aku_community/ui/market/goods/goods_list_view.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:aku_community/utils/headers.dart';
@ -33,13 +35,15 @@ class CategoryCard extends StatelessWidget {
Spacer(),
],
),
onPressed: () {
Get.to(
() => GoodsListView(
model: model,
subModels: [],
),
);
onPressed: () async {
final cancel = BotToast.showLoading();
List<MarketCategoryModel> models =
await DisplayCategoryModel.fetchCategory(model.id);
cancel();
Get.to(() => GoodsListView(
model: model,
subModels: models,
));
},
);
}

@ -2,6 +2,7 @@ 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/models/market/market_category_model.dart';
import 'package:aku_community/ui/market/goods/goods_tab_list_view.dart';
import 'package:aku_community/ui/market/search/search_goods_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -91,8 +92,9 @@ class _GoodsListViewState extends State<GoodsListView>
preferredSize: Size.fromHeight(220.w),
),
body: TabBarView(
children: widget.subModels.map((e) => Text(e.name)).toList(),
children: widget.subModels.map((e) => GoodsTabListView(model: e)).toList(),
controller: _tabController,
physics: NeverScrollableScrollPhysics(),
),
);
}

@ -0,0 +1,46 @@
import 'package:aku_community/constants/api.dart';
import 'package:aku_community/models/market/goods_item.dart';
import 'package:aku_community/models/market/market_category_model.dart';
import 'package:aku_community/pages/things_page/widget/bee_list_view.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:waterfall_flow/waterfall_flow.dart';
class GoodsTabListView extends StatefulWidget {
final MarketCategoryModel model;
GoodsTabListView({Key? key, required this.model}) : super(key: key);
@override
_GoodsTabListViewState createState() => _GoodsTabListViewState();
}
class _GoodsTabListViewState extends State<GoodsTabListView>
with AutomaticKeepAliveClientMixin {
EasyRefreshController _refreshController = EasyRefreshController();
@override
Widget build(BuildContext context) {
super.build(context);
return BeeListView<GoodsItem>(
path: API.market.list,
controller: _refreshController,
extraParams: {'categoryId': widget.model.id},
convert: (model) =>
model.tableList?.map((e) => GoodsItem.fromJson(e)).toList() ?? [],
builder: (items) {
return WaterfallFlow.builder(
gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
),
itemBuilder: (context, index) {
final GoodsItem item = items[index];
return Text(item.title);
},
itemCount: items.length,
);
},
);
}
@override
bool get wantKeepAlive => true;
}
Loading…
Cancel
Save