mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-31 16:00:13 +08:00
@@ -1,4 +1,3 @@
|
||||
import 'package:PiliPlus/common/skeleton/video_card_h.dart';
|
||||
import 'package:PiliPlus/common/widgets/dialog/dialog.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
@@ -18,7 +17,7 @@ class FavArticlePage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _FavArticlePageState extends State<FavArticlePage>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
with AutomaticKeepAliveClientMixin, GridMixin {
|
||||
final FavArticleController _favArticleController = Get.put(
|
||||
FavArticleController(),
|
||||
);
|
||||
@@ -51,37 +50,27 @@ class _FavArticlePageState extends State<FavArticlePage>
|
||||
|
||||
Widget _buildBody(LoadingState<List<FavArticleItemModel>?> loadingState) {
|
||||
return switch (loadingState) {
|
||||
Loading() => SliverGrid(
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
return const VideoCardHSkeleton();
|
||||
},
|
||||
childCount: 10,
|
||||
),
|
||||
),
|
||||
Loading() => gridSkeleton,
|
||||
Success(:var response) =>
|
||||
response?.isNotEmpty == true
|
||||
? SliverGrid(
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
if (index == response.length - 1) {
|
||||
_favArticleController.onLoadMore();
|
||||
}
|
||||
final item = response[index];
|
||||
return FavArticleItem(
|
||||
item: item,
|
||||
onDelete: () => showConfirmDialog(
|
||||
context: context,
|
||||
title: '确定取消收藏?',
|
||||
onConfirm: () =>
|
||||
_favArticleController.onRemove(index, item.opusId),
|
||||
),
|
||||
);
|
||||
},
|
||||
childCount: response!.length,
|
||||
),
|
||||
? SliverGrid.builder(
|
||||
gridDelegate: gridDelegate,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == response.length - 1) {
|
||||
_favArticleController.onLoadMore();
|
||||
}
|
||||
final item = response[index];
|
||||
return FavArticleItem(
|
||||
item: item,
|
||||
onDelete: () => showConfirmDialog(
|
||||
context: context,
|
||||
title: '确定取消收藏?',
|
||||
onConfirm: () =>
|
||||
_favArticleController.onRemove(index, item.opusId),
|
||||
),
|
||||
);
|
||||
},
|
||||
itemCount: response!.length,
|
||||
)
|
||||
: HttpError(onReload: _favArticleController.onReload),
|
||||
Error(:var errMsg) => HttpError(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'package:PiliPlus/common/widgets/dialog/dialog.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/loading_widget.dart';
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models_new/space/space_cheese/item.dart';
|
||||
@@ -18,7 +17,7 @@ class FavCheesePage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _FavCheesePageState extends State<FavCheesePage>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
with AutomaticKeepAliveClientMixin, GridMixin {
|
||||
final FavCheeseController _controller = Get.put(FavCheeseController());
|
||||
|
||||
@override
|
||||
@@ -53,29 +52,27 @@ class _FavCheesePageState extends State<FavCheesePage>
|
||||
LoadingState<List<SpaceCheeseItem>?> loadingState,
|
||||
) {
|
||||
return switch (loadingState) {
|
||||
Loading() => linearLoading,
|
||||
Loading() => gridSkeleton,
|
||||
Success(:var response) =>
|
||||
response?.isNotEmpty == true
|
||||
? SliverGrid(
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
if (index == response.length - 1) {
|
||||
_controller.onLoadMore();
|
||||
}
|
||||
final item = response[index];
|
||||
return MemberCheeseItem(
|
||||
item: item,
|
||||
onRemove: () => showConfirmDialog(
|
||||
context: context,
|
||||
title: '确定取消收藏该课堂?',
|
||||
onConfirm: () =>
|
||||
_controller.onRemove(index, item.seasonId),
|
||||
),
|
||||
);
|
||||
},
|
||||
childCount: response!.length,
|
||||
),
|
||||
? SliverGrid.builder(
|
||||
gridDelegate: gridDelegate,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == response.length - 1) {
|
||||
_controller.onLoadMore();
|
||||
}
|
||||
final item = response[index];
|
||||
return MemberCheeseItem(
|
||||
item: item,
|
||||
onRemove: () => showConfirmDialog(
|
||||
context: context,
|
||||
title: '确定取消收藏该课堂?',
|
||||
onConfirm: () =>
|
||||
_controller.onRemove(index, item.seasonId),
|
||||
),
|
||||
);
|
||||
},
|
||||
itemCount: response!.length,
|
||||
)
|
||||
: HttpError(onReload: _controller.onReload),
|
||||
Error(:var errMsg) => HttpError(
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:PiliPlus/common/skeleton/video_card_h.dart';
|
||||
import 'package:PiliPlus/common/widgets/button/icon_button.dart';
|
||||
import 'package:PiliPlus/common/widgets/dialog/dialog.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||
@@ -21,7 +20,7 @@ class FavNoteChildPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _FavNoteChildPageState extends State<FavNoteChildPage>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
with AutomaticKeepAliveClientMixin, GridMixin {
|
||||
late final FavNoteController _favNoteController = Get.put(
|
||||
FavNoteController(widget.isPublish),
|
||||
tag: '${widget.isPublish}',
|
||||
@@ -141,33 +140,23 @@ class _FavNoteChildPageState extends State<FavNoteChildPage>
|
||||
|
||||
Widget _buildBody(LoadingState<List<FavNoteItemModel>?> loadingState) {
|
||||
return switch (loadingState) {
|
||||
Loading() => SliverGrid(
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
return const VideoCardHSkeleton();
|
||||
},
|
||||
childCount: 10,
|
||||
),
|
||||
),
|
||||
Loading() => gridSkeleton,
|
||||
Success(:var response) =>
|
||||
response?.isNotEmpty == true
|
||||
? SliverGrid(
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
if (index == response.length - 1) {
|
||||
_favNoteController.onLoadMore();
|
||||
}
|
||||
final item = response[index];
|
||||
return FavNoteItem(
|
||||
item: item,
|
||||
ctr: _favNoteController,
|
||||
onSelect: () => _favNoteController.onSelect(item),
|
||||
);
|
||||
},
|
||||
childCount: response!.length,
|
||||
),
|
||||
? SliverGrid.builder(
|
||||
gridDelegate: gridDelegate,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == response.length - 1) {
|
||||
_favNoteController.onLoadMore();
|
||||
}
|
||||
final item = response[index];
|
||||
return FavNoteItem(
|
||||
item: item,
|
||||
ctr: _favNoteController,
|
||||
onSelect: () => _favNoteController.onSelect(item),
|
||||
);
|
||||
},
|
||||
itemCount: response!.length,
|
||||
)
|
||||
: HttpError(onReload: _favNoteController.onReload),
|
||||
Error(:var errMsg) => HttpError(
|
||||
|
||||
@@ -26,7 +26,7 @@ class FavPgcChildPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _FavPgcChildPageState extends State<FavPgcChildPage>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
with AutomaticKeepAliveClientMixin, GridMixin {
|
||||
late final FavPgcController _favPgcController = Get.put(
|
||||
FavPgcController(widget.type, widget.followStatus),
|
||||
tag: '${widget.type}${widget.followStatus}',
|
||||
@@ -165,52 +165,46 @@ class _FavPgcChildPageState extends State<FavPgcChildPage>
|
||||
|
||||
Widget _buildBody(LoadingState<List<FavPgcItemModel>?> loadingState) {
|
||||
return switch (loadingState) {
|
||||
Loading() => SliverGrid(
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
return const FavPgcItemSkeleton();
|
||||
},
|
||||
childCount: 10,
|
||||
),
|
||||
Loading() => SliverGrid.builder(
|
||||
gridDelegate: gridDelegate,
|
||||
itemBuilder: (context, index) => const FavPgcItemSkeleton(),
|
||||
itemCount: 10,
|
||||
),
|
||||
Success(:var response) =>
|
||||
response?.isNotEmpty == true
|
||||
? SliverGrid(
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
if (index == response.length - 1) {
|
||||
_favPgcController.onLoadMore();
|
||||
}
|
||||
final item = response[index];
|
||||
return FavPgcItem(
|
||||
item: item,
|
||||
ctr: _favPgcController,
|
||||
onSelect: () => _favPgcController.onSelect(item),
|
||||
onUpdateStatus: () => showPgcFollowDialog(
|
||||
context: context,
|
||||
type: widget.type == 0 ? '追番' : '追剧',
|
||||
followStatus: widget.followStatus,
|
||||
onUpdateStatus: (followStatus) {
|
||||
if (followStatus == -1) {
|
||||
_favPgcController.pgcDel(
|
||||
index,
|
||||
item.seasonId,
|
||||
);
|
||||
} else {
|
||||
_favPgcController.onUpdate(
|
||||
index,
|
||||
followStatus,
|
||||
item.seasonId,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
childCount: response!.length,
|
||||
),
|
||||
? SliverGrid.builder(
|
||||
gridDelegate: gridDelegate,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == response.length - 1) {
|
||||
_favPgcController.onLoadMore();
|
||||
}
|
||||
final item = response[index];
|
||||
return FavPgcItem(
|
||||
item: item,
|
||||
ctr: _favPgcController,
|
||||
onSelect: () => _favPgcController.onSelect(item),
|
||||
onUpdateStatus: () => showPgcFollowDialog(
|
||||
context: context,
|
||||
type: widget.type == 0 ? '追番' : '追剧',
|
||||
followStatus: widget.followStatus,
|
||||
onUpdateStatus: (followStatus) {
|
||||
if (followStatus == -1) {
|
||||
_favPgcController.pgcDel(
|
||||
index,
|
||||
item.seasonId,
|
||||
);
|
||||
} else {
|
||||
_favPgcController.onUpdate(
|
||||
index,
|
||||
followStatus,
|
||||
item.seasonId,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
itemCount: response!.length,
|
||||
)
|
||||
: HttpError(onReload: _favPgcController.onReload),
|
||||
Error(:var errMsg) => HttpError(
|
||||
|
||||
@@ -49,6 +49,13 @@ class _FavTopicPageState extends State<FavTopicPage>
|
||||
);
|
||||
}
|
||||
|
||||
late final gridDelegate = SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
mainAxisSpacing: 12,
|
||||
crossAxisSpacing: 12,
|
||||
maxCrossAxisExtent: Grid.smallCardWidth,
|
||||
mainAxisExtent: MediaQuery.textScalerOf(context).scale(30),
|
||||
);
|
||||
|
||||
Widget _buildBody(
|
||||
ThemeData theme,
|
||||
LoadingState<List<FavTopicItem>?> loadingState,
|
||||
@@ -64,61 +71,54 @@ class _FavTopicPageState extends State<FavTopicPage>
|
||||
),
|
||||
Success(:var response) =>
|
||||
response?.isNotEmpty == true
|
||||
? SliverGrid(
|
||||
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
mainAxisSpacing: 12,
|
||||
crossAxisSpacing: 12,
|
||||
maxCrossAxisExtent: Grid.smallCardWidth,
|
||||
mainAxisExtent: MediaQuery.textScalerOf(context).scale(30),
|
||||
),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
if (index == response.length - 1) {
|
||||
_controller.onLoadMore();
|
||||
}
|
||||
final item = response[index];
|
||||
return Material(
|
||||
color: theme.colorScheme.onInverseSurface,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(6)),
|
||||
child: InkWell(
|
||||
onTap: () => Get.toNamed(
|
||||
'/dynTopic',
|
||||
parameters: {
|
||||
'id': item.id!.toString(),
|
||||
'name': item.name!,
|
||||
},
|
||||
? SliverGrid.builder(
|
||||
gridDelegate: gridDelegate,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == response.length - 1) {
|
||||
_controller.onLoadMore();
|
||||
}
|
||||
final item = response[index];
|
||||
return Material(
|
||||
color: theme.colorScheme.onInverseSurface,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(6)),
|
||||
child: InkWell(
|
||||
onTap: () => Get.toNamed(
|
||||
'/dynTopic',
|
||||
parameters: {
|
||||
'id': item.id!.toString(),
|
||||
'name': item.name!,
|
||||
},
|
||||
),
|
||||
onLongPress: () => showConfirmDialog(
|
||||
context: context,
|
||||
title: '确定取消收藏?',
|
||||
onConfirm: () {
|
||||
_controller.onRemove(index, item.id);
|
||||
},
|
||||
),
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(6),
|
||||
),
|
||||
child: Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 11,
|
||||
vertical: 5,
|
||||
),
|
||||
onLongPress: () => showConfirmDialog(
|
||||
context: context,
|
||||
title: '确定取消收藏?',
|
||||
onConfirm: () {
|
||||
_controller.onRemove(index, item.id);
|
||||
},
|
||||
),
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(6),
|
||||
),
|
||||
child: Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 11,
|
||||
vertical: 5,
|
||||
),
|
||||
child: Text(
|
||||
'# ${item.name}',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
child: Text(
|
||||
'# ${item.name}',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
childCount: response!.length,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
itemCount: response!.length,
|
||||
)
|
||||
: HttpError(onReload: _controller.onReload),
|
||||
Error(:var errMsg) => HttpError(
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:PiliPlus/common/skeleton/video_card_h.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
@@ -18,7 +17,7 @@ class FavVideoPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _FavVideoPageState extends State<FavVideoPage>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
with AutomaticKeepAliveClientMixin, GridMixin {
|
||||
final FavController _favController = Get.find<FavController>();
|
||||
|
||||
@override
|
||||
@@ -49,52 +48,40 @@ class _FavVideoPageState extends State<FavVideoPage>
|
||||
|
||||
Widget _buildBody(LoadingState<List<FavFolderInfo>?> loadingState) {
|
||||
return switch (loadingState) {
|
||||
Loading() => SliverGrid(
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) {
|
||||
return const VideoCardHSkeleton();
|
||||
},
|
||||
childCount: 10,
|
||||
),
|
||||
),
|
||||
Loading() => gridSkeleton,
|
||||
Success(:var response) =>
|
||||
response?.isNotEmpty == true
|
||||
? SliverGrid(
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
childCount: response!.length,
|
||||
(BuildContext context, int index) {
|
||||
if (index == response.length - 1) {
|
||||
_favController.onLoadMore();
|
||||
}
|
||||
final item = response[index];
|
||||
String heroTag = Utils.makeHeroTag(item.fid);
|
||||
return FavVideoItem(
|
||||
heroTag: heroTag,
|
||||
item: item,
|
||||
onTap: () async {
|
||||
var res = await Get.toNamed(
|
||||
'/favDetail',
|
||||
arguments: item,
|
||||
parameters: {
|
||||
'heroTag': heroTag,
|
||||
'mediaId': item.id.toString(),
|
||||
},
|
||||
);
|
||||
if (res == true) {
|
||||
_favController.loadingState
|
||||
..value.data!.removeAt(index)
|
||||
..refresh();
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
? SliverGrid.builder(
|
||||
gridDelegate: gridDelegate,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
if (index == response.length - 1) {
|
||||
_favController.onLoadMore();
|
||||
}
|
||||
final item = response[index];
|
||||
String heroTag = Utils.makeHeroTag(item.fid);
|
||||
return FavVideoItem(
|
||||
heroTag: heroTag,
|
||||
item: item,
|
||||
onTap: () async {
|
||||
var res = await Get.toNamed(
|
||||
'/favDetail',
|
||||
arguments: item,
|
||||
parameters: {
|
||||
'heroTag': heroTag,
|
||||
'mediaId': item.id.toString(),
|
||||
},
|
||||
);
|
||||
if (res == true) {
|
||||
_favController.loadingState
|
||||
..value.data!.removeAt(index)
|
||||
..refresh();
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
itemCount: response!.length,
|
||||
)
|
||||
: HttpError(
|
||||
onReload: _favController.onReload,
|
||||
),
|
||||
: HttpError(onReload: _favController.onReload),
|
||||
Error(:var errMsg) => HttpError(
|
||||
errMsg: errMsg,
|
||||
onReload: _favController.onReload,
|
||||
|
||||
Reference in New Issue
Block a user