mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: item
chore: clean up widgets Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -22,13 +22,15 @@ class MemberSearchController extends GetxController
|
||||
int archivePn = 1;
|
||||
RxInt archiveCount = (-1).obs;
|
||||
bool isEndArchive = false;
|
||||
Rx<LoadingState> archiveState = LoadingState.loading().obs;
|
||||
Rx<LoadingState<List<VListItemModel>?>> archiveState =
|
||||
LoadingState<List<VListItemModel>?>.loading().obs;
|
||||
|
||||
String offset = '';
|
||||
int dynamicPn = 1;
|
||||
RxInt dynamicCount = (-1).obs;
|
||||
bool isEndDynamic = false;
|
||||
Rx<LoadingState> dynamicState = LoadingState.loading().obs;
|
||||
Rx<LoadingState<List<DynamicItemModel>?>> dynamicState =
|
||||
LoadingState<List<DynamicItemModel>?>.loading().obs;
|
||||
|
||||
dynamic wwebid;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:PiliPlus/common/widgets/loading_widget.dart';
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/common/widgets/video_card_h.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/member/archive.dart';
|
||||
import 'package:PiliPlus/pages/member_search/controller.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
import 'package:easy_debounce/easy_throttle.dart';
|
||||
@@ -29,10 +30,11 @@ class _SearchArchiveState extends State<SearchArchive>
|
||||
return Obx(() => _buildBody(context, widget.ctr.archiveState.value));
|
||||
}
|
||||
|
||||
Widget _buildBody(BuildContext context, LoadingState loadingState) {
|
||||
Widget _buildBody(
|
||||
BuildContext context, LoadingState<List<VListItemModel>?> loadingState) {
|
||||
return switch (loadingState) {
|
||||
Loading() => loadingWidget,
|
||||
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||
Success() => loadingState.response?.isNotEmpty == true
|
||||
? refreshIndicator(
|
||||
onRefresh: () async {
|
||||
await widget.ctr.refreshArchive();
|
||||
@@ -46,24 +48,20 @@ class _SearchArchiveState extends State<SearchArchive>
|
||||
bottom: MediaQuery.paddingOf(context).bottom + 80,
|
||||
),
|
||||
sliver: SliverGrid(
|
||||
gridDelegate: SliverGridDelegateWithExtentAndRatio(
|
||||
mainAxisSpacing: 2,
|
||||
maxCrossAxisExtent: Grid.mediumCardWidth * 2,
|
||||
childAspectRatio: StyleString.aspectRatio * 2.2,
|
||||
),
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
if (index == loadingState.response.length - 1) {
|
||||
if (index == loadingState.response!.length - 1) {
|
||||
EasyThrottle.throttle('searchArchives',
|
||||
const Duration(milliseconds: 500), () {
|
||||
widget.ctr.searchArchives(false);
|
||||
});
|
||||
}
|
||||
return VideoCardH(
|
||||
videoItem: loadingState.response[index],
|
||||
videoItem: loadingState.response![index],
|
||||
);
|
||||
},
|
||||
childCount: loadingState.response.length,
|
||||
childCount: loadingState.response!.length,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget.dart';
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/dynamics/result.dart';
|
||||
import 'package:PiliPlus/pages/dynamics/widgets/dynamic_panel.dart';
|
||||
import 'package:PiliPlus/pages/member_search/controller.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
@@ -31,12 +32,13 @@ class _SearchDynamicState extends State<SearchDynamic>
|
||||
return Obx(() => _buildBody(context, widget.ctr.dynamicState.value));
|
||||
}
|
||||
|
||||
Widget _buildBody(BuildContext context, LoadingState loadingState) {
|
||||
Widget _buildBody(BuildContext context,
|
||||
LoadingState<List<DynamicItemModel>?> loadingState) {
|
||||
bool dynamicsWaterfallFlow = GStorage.setting
|
||||
.get(SettingBoxKey.dynamicsWaterfallFlow, defaultValue: true);
|
||||
return switch (loadingState) {
|
||||
Loading() => loadingWidget,
|
||||
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||
Success() => loadingState.response?.isNotEmpty == true
|
||||
? refreshIndicator(
|
||||
onRefresh: () async {
|
||||
await widget.ctr.refreshDynamic();
|
||||
@@ -54,13 +56,13 @@ class _SearchDynamicState extends State<SearchDynamic>
|
||||
crossAxisSpacing: StyleString.safeSpace,
|
||||
mainAxisSpacing: StyleString.safeSpace,
|
||||
lastChildLayoutTypeBuilder: (index) {
|
||||
if (index == loadingState.response.length - 1) {
|
||||
if (index == loadingState.response!.length - 1) {
|
||||
EasyThrottle.throttle('member_dynamics',
|
||||
const Duration(milliseconds: 1000), () {
|
||||
widget.ctr.searchDynamic(false);
|
||||
});
|
||||
}
|
||||
return index == loadingState.response.length
|
||||
return index == loadingState.response!.length
|
||||
? LastChildLayoutType.foot
|
||||
: LastChildLayoutType.none;
|
||||
},
|
||||
@@ -77,7 +79,7 @@ class _SearchDynamicState extends State<SearchDynamic>
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
if (index ==
|
||||
loadingState.response.length - 1) {
|
||||
loadingState.response!.length - 1) {
|
||||
EasyThrottle.throttle('member_dynamics',
|
||||
const Duration(milliseconds: 1000),
|
||||
() {
|
||||
@@ -85,10 +87,10 @@ class _SearchDynamicState extends State<SearchDynamic>
|
||||
});
|
||||
}
|
||||
return DynamicPanel(
|
||||
item: loadingState.response[index],
|
||||
item: loadingState.response![index],
|
||||
);
|
||||
},
|
||||
childCount: loadingState.response.length,
|
||||
childCount: loadingState.response!.length,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user