mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-31 16:18:22 +08:00
handle sub url
Closes #995 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -8,55 +8,39 @@ import 'package:get/get.dart';
|
||||
|
||||
class SubDetailController
|
||||
extends CommonListController<SubDetailData, SubDetailItemModel> {
|
||||
late SubItemModel subInfo;
|
||||
|
||||
late int id;
|
||||
late String heroTag;
|
||||
|
||||
late final RxInt mediaCount;
|
||||
late final RxInt playCount;
|
||||
String? heroTag;
|
||||
SubItemModel? subInfo;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
subInfo = Get.arguments;
|
||||
mediaCount = (subInfo.mediaCount ?? 0).obs;
|
||||
playCount = (subInfo.viewCount ?? 0).obs;
|
||||
id = int.parse(Get.parameters['id']!);
|
||||
heroTag = Get.parameters['heroTag']!;
|
||||
final args = Get.arguments;
|
||||
id = args['id'];
|
||||
subInfo = args['subInfo'];
|
||||
heroTag = args['heroTag'];
|
||||
|
||||
queryData();
|
||||
}
|
||||
|
||||
@override
|
||||
List<SubDetailItemModel>? getDataList(SubDetailData response) {
|
||||
mediaCount.value = response.info!.mediaCount!;
|
||||
if (subInfo.type == 11) {
|
||||
playCount.value = response.info!.cntInfo!.play!;
|
||||
}
|
||||
subInfo = response.info;
|
||||
return response.medias;
|
||||
}
|
||||
|
||||
@override
|
||||
void checkIsEnd(int length) {
|
||||
if (length >= mediaCount.value) {
|
||||
final count = subInfo?.mediaCount;
|
||||
if (count != null && length >= count) {
|
||||
isEnd = true;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LoadingState<SubDetailData>> customGetData() {
|
||||
if (subInfo.type == 11) {
|
||||
return FavHttp.favResourceList(
|
||||
id: id,
|
||||
ps: 20,
|
||||
pn: page,
|
||||
);
|
||||
} else {
|
||||
return FavHttp.favSeasonList(
|
||||
id: id,
|
||||
ps: 20,
|
||||
pn: page,
|
||||
);
|
||||
}
|
||||
}
|
||||
Future<LoadingState<SubDetailData>> customGetData() => FavHttp.favSeasonList(
|
||||
id: id,
|
||||
ps: 20,
|
||||
pn: page,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:PiliPlus/common/widgets/image/network_img_layer.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';
|
||||
import 'package:PiliPlus/models_new/sub/sub/list.dart';
|
||||
import 'package:PiliPlus/models_new/sub/sub_detail/media.dart';
|
||||
import 'package:PiliPlus/pages/subscription_detail/controller.dart';
|
||||
import 'package:PiliPlus/pages/subscription_detail/widget/sub_video_card.dart';
|
||||
@@ -17,6 +18,21 @@ class SubDetailPage extends StatefulWidget {
|
||||
|
||||
@override
|
||||
State<SubDetailPage> createState() => _SubDetailPageState();
|
||||
|
||||
static void toSubDetailPage(
|
||||
int id, {
|
||||
String? heroTag,
|
||||
SubItemModel? subInfo,
|
||||
}) {
|
||||
Get.toNamed(
|
||||
'/subDetail',
|
||||
arguments: {
|
||||
'id': id,
|
||||
'subInfo': subInfo,
|
||||
'heroTag': heroTag,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SubDetailPageState extends State<SubDetailPage> {
|
||||
@@ -39,7 +55,7 @@ class _SubDetailPageState extends State<SubDetailPage> {
|
||||
controller: _subDetailController.scrollController,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
_buildAppBar(theme, padding),
|
||||
_appBar(theme, padding),
|
||||
SliverPadding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 7,
|
||||
@@ -91,11 +107,37 @@ class _SubDetailPageState extends State<SubDetailPage> {
|
||||
};
|
||||
}
|
||||
|
||||
Widget _buildAppBar(ThemeData theme, EdgeInsets padding) {
|
||||
Widget _appBar(ThemeData theme, EdgeInsets padding) {
|
||||
final info = _subDetailController.subInfo;
|
||||
if (info != null) return _buildAppBar(theme, padding, info);
|
||||
return Obx(() {
|
||||
return switch (_subDetailController.loadingState.value) {
|
||||
Loading() || Error() => const SliverAppBar(),
|
||||
Success() => _buildAppBar(
|
||||
theme,
|
||||
padding,
|
||||
_subDetailController.subInfo!,
|
||||
),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildAppBar(ThemeData theme, EdgeInsets padding, SubItemModel info) {
|
||||
final style = TextStyle(
|
||||
fontSize: 12.5,
|
||||
color: theme.colorScheme.outline,
|
||||
);
|
||||
Widget cover = NetworkImgLayer(
|
||||
width: 176,
|
||||
height: 110,
|
||||
src: info.cover,
|
||||
);
|
||||
if (_subDetailController.heroTag != null) {
|
||||
cover = Hero(
|
||||
tag: _subDetailController.heroTag!,
|
||||
child: cover,
|
||||
);
|
||||
}
|
||||
return SliverAppBar.medium(
|
||||
expandedHeight: kToolbarHeight + 132,
|
||||
pinned: true,
|
||||
@@ -103,16 +145,14 @@ class _SubDetailPageState extends State<SubDetailPage> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
_subDetailController.subInfo.title!,
|
||||
info.title!,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: theme.textTheme.titleMedium,
|
||||
),
|
||||
Obx(
|
||||
() => Text(
|
||||
'共${_subDetailController.mediaCount.value}条视频',
|
||||
style: theme.textTheme.labelMedium,
|
||||
),
|
||||
Text(
|
||||
'共${info.mediaCount}条视频',
|
||||
style: theme.textTheme.labelMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -135,21 +175,14 @@ class _SubDetailPageState extends State<SubDetailPage> {
|
||||
spacing: 12,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Hero(
|
||||
tag: _subDetailController.heroTag,
|
||||
child: NetworkImgLayer(
|
||||
width: 176,
|
||||
height: 110,
|
||||
src: _subDetailController.subInfo.cover,
|
||||
),
|
||||
),
|
||||
cover,
|
||||
Expanded(
|
||||
child: Column(
|
||||
spacing: 4,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
_subDetailController.subInfo.title!,
|
||||
info.title!,
|
||||
style: TextStyle(
|
||||
fontSize: theme.textTheme.titleMedium!.fontSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -158,32 +191,19 @@ class _SubDetailPageState extends State<SubDetailPage> {
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Get.toNamed(
|
||||
'/member?mid=${_subDetailController.subInfo.upper!.mid}',
|
||||
'/member?mid=${info.upper!.mid}',
|
||||
);
|
||||
},
|
||||
child: Text(
|
||||
_subDetailController.subInfo.upper!.name!,
|
||||
info.upper!.name!,
|
||||
style: TextStyle(color: theme.colorScheme.primary),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Obx(
|
||||
() {
|
||||
final mediaCount =
|
||||
_subDetailController.mediaCount.value;
|
||||
return mediaCount == 0
|
||||
? const SizedBox.shrink()
|
||||
: Text(
|
||||
'共$mediaCount条视频',
|
||||
style: style,
|
||||
);
|
||||
},
|
||||
),
|
||||
Obx(
|
||||
() => Text(
|
||||
'${NumUtil.numFormat(_subDetailController.playCount.value)}次播放',
|
||||
style: style,
|
||||
),
|
||||
Text('共${info.mediaCount}条视频', style: style),
|
||||
Text(
|
||||
'${NumUtil.numFormat(info.viewCount ?? info.cntInfo?.play)}次播放',
|
||||
style: style,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user