feat:分类切换优化
This commit is contained in:
parent
f22c893932
commit
5c00e4efef
@ -133,6 +133,7 @@ class KtHomeLogic extends GetxController {
|
||||
}
|
||||
|
||||
getCategoryVideoList({bool isRefresh = false}) async {
|
||||
state.categoryLoadStatus = KtLoadStatusType.loading;
|
||||
if (isRefresh) {
|
||||
state.pageIndex = 1;
|
||||
state.categoryVideoList.clear();
|
||||
@ -154,6 +155,7 @@ class KtHomeLogic extends GetxController {
|
||||
easyRefreshController.finishRefresh();
|
||||
easyRefreshController.finishLoad();
|
||||
if (res.success) {
|
||||
state.categoryLoadStatus = KtLoadStatusType.loadSuccess;
|
||||
List<KtShortVideoBean> list = [
|
||||
...res.data['list']
|
||||
.map(
|
||||
@ -165,6 +167,13 @@ class KtHomeLogic extends GetxController {
|
||||
easyRefreshController.finishLoad(IndicatorResult.noMore);
|
||||
}
|
||||
state.categoryVideoList.addAll(list);
|
||||
if (state.categoryVideoList.isEmpty) {
|
||||
state.categoryLoadStatus = KtLoadStatusType.loadNoData;
|
||||
}
|
||||
|
||||
update();
|
||||
} else {
|
||||
state.categoryLoadStatus = KtLoadStatusType.loadFailed;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import '../../kt_widgets/kt_status_widget.dart';
|
||||
|
||||
class KtHomeState {
|
||||
KtLoadStatusType loadStatus = KtLoadStatusType.loading;
|
||||
KtLoadStatusType categoryLoadStatus = KtLoadStatusType.loading;
|
||||
List<KtShortVideoBean> topPickList = [];
|
||||
List<KtShortVideoBean> hotList = [];
|
||||
List<KtShortVideoBean> arrivalList = [];
|
||||
|
@ -535,9 +535,9 @@ class _KtHomePageState extends State<KtHomePage>
|
||||
KtHomeCategoryBean item = state.categoryList[index];
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
if( state.selCategoryId == item.categoryId!) return;
|
||||
state.selCategoryId = item.categoryId!;
|
||||
logic.getCategoryVideoList(isRefresh: true);
|
||||
logic.update(['category-items']);
|
||||
},
|
||||
child: Container(
|
||||
width: (ScreenUtil().screenWidth - 42.w) / 3,
|
||||
@ -1445,7 +1445,7 @@ class _KtHomePageState extends State<KtHomePage>
|
||||
return GetBuilder<KtHomeLogic>(
|
||||
id: 'category-list',
|
||||
builder: (ctrl) {
|
||||
if (state.categoryVideoList.isEmpty) {
|
||||
if (state.categoryLoadStatus == KtLoadStatusType.loadNoData) {
|
||||
return KtStatusWidget(
|
||||
type: KtErrorStatusType.nothingYet,
|
||||
onPressed: logic.getCategoryVideoList,
|
||||
|
Loading…
x
Reference in New Issue
Block a user