mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
129
lib/pages/pgc/controller.dart
Normal file
129
lib/pages/pgc/controller.dart
Normal file
@@ -0,0 +1,129 @@
|
||||
import 'package:PiliPlus/http/fav.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/pgc.dart';
|
||||
import 'package:PiliPlus/models/common/home_tab_type.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_pgc/data.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_pgc/list.dart';
|
||||
import 'package:PiliPlus/models_new/pgc/pgc_index_result/list.dart';
|
||||
import 'package:PiliPlus/models_new/pgc/pgc_timeline/result.dart';
|
||||
import 'package:PiliPlus/pages/common/common_list_controller.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class PgcController
|
||||
extends CommonListController<List<PgcIndexItem>?, PgcIndexItem> {
|
||||
PgcController({required this.tabType});
|
||||
final HomeTabType tabType;
|
||||
|
||||
int? mid;
|
||||
late final RxBool isLogin;
|
||||
late final showPgcTimeline =
|
||||
tabType == HomeTabType.bangumi && GStorage.showPgcTimeline;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
mid = Accounts.main.mid;
|
||||
isLogin = (mid != 0).obs;
|
||||
|
||||
queryData();
|
||||
queryPgcFollow();
|
||||
if (showPgcTimeline) {
|
||||
queryPgcTimeline();
|
||||
}
|
||||
if (isLogin.value) {
|
||||
followController = ScrollController();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onRefresh() {
|
||||
if (isLogin.value) {
|
||||
followPage = 1;
|
||||
followEnd = false;
|
||||
}
|
||||
queryPgcFollow();
|
||||
if (showPgcTimeline) {
|
||||
queryPgcTimeline();
|
||||
}
|
||||
return super.onRefresh();
|
||||
}
|
||||
|
||||
// follow
|
||||
late int followPage = 1;
|
||||
late RxInt followCount = (-1).obs;
|
||||
late bool followLoading = false;
|
||||
late bool followEnd = false;
|
||||
late Rx<LoadingState<List<FavPgcItemModel>?>> followState =
|
||||
LoadingState<List<FavPgcItemModel>?>.loading().obs;
|
||||
ScrollController? followController;
|
||||
|
||||
// timeline
|
||||
late Rx<LoadingState<List<Result>?>> timelineState =
|
||||
LoadingState<List<Result>?>.loading().obs;
|
||||
|
||||
Future<void> queryPgcTimeline() async {
|
||||
final res = await PgcHttp.pgcTimeline(types: 1, before: 6, after: 6);
|
||||
timelineState.value = res;
|
||||
}
|
||||
|
||||
// 我的订阅
|
||||
Future<void> queryPgcFollow([bool isRefresh = true]) async {
|
||||
if (!isLogin.value || followLoading || (!isRefresh && followEnd)) {
|
||||
return;
|
||||
}
|
||||
followLoading = true;
|
||||
var res = await FavHttp.favPgc(
|
||||
mid: mid,
|
||||
type: tabType == HomeTabType.bangumi ? 1 : 2,
|
||||
pn: followPage,
|
||||
);
|
||||
|
||||
if (res.isSuccess) {
|
||||
FavPgcData data = res.data;
|
||||
List<FavPgcItemModel>? list = data.list;
|
||||
followCount.value = data.total ?? -1;
|
||||
|
||||
if (list.isNullOrEmpty) {
|
||||
followEnd = true;
|
||||
if (isRefresh) {
|
||||
followState.value = Success(list);
|
||||
}
|
||||
followLoading = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (isRefresh) {
|
||||
if (list!.length >= followCount.value) {
|
||||
followEnd = true;
|
||||
}
|
||||
followState.value = Success(list);
|
||||
followController?.animToTop();
|
||||
} else if (followState.value.isSuccess) {
|
||||
final currentList = followState.value.data!..addAll(list!);
|
||||
if (currentList.length >= followCount.value) {
|
||||
followEnd = true;
|
||||
}
|
||||
followState.refresh();
|
||||
}
|
||||
followPage++;
|
||||
} else if (isRefresh) {
|
||||
followState.value = res as Error;
|
||||
}
|
||||
followLoading = false;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LoadingState<List<PgcIndexItem>?>> customGetData() => PgcHttp.pgcIndex(
|
||||
page: page,
|
||||
indexType: tabType == HomeTabType.cinema ? 102 : null,
|
||||
);
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
followController?.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
459
lib/pages/pgc/view.dart
Normal file
459
lib/pages/pgc/view.dart
Normal file
@@ -0,0 +1,459 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:PiliPlus/common/constants.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/common/widgets/scroll_physics.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/common/fav_type.dart';
|
||||
import 'package:PiliPlus/models/common/home_tab_type.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_pgc/list.dart';
|
||||
import 'package:PiliPlus/models_new/pgc/pgc_index_result/list.dart';
|
||||
import 'package:PiliPlus/models_new/pgc/pgc_timeline/result.dart';
|
||||
import 'package:PiliPlus/pages/common/common_page.dart';
|
||||
import 'package:PiliPlus/pages/pgc/controller.dart';
|
||||
import 'package:PiliPlus/pages/pgc/widgets/pgc_card_v.dart';
|
||||
import 'package:PiliPlus/pages/pgc/widgets/pgc_card_v_timeline.dart';
|
||||
import 'package:PiliPlus/pages/pgc_index/controller.dart';
|
||||
import 'package:PiliPlus/pages/pgc_index/view.dart';
|
||||
import 'package:PiliPlus/pages/pgc_index/widgets/pgc_card_v_pgc_index.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class PgcPage extends CommonPage {
|
||||
const PgcPage({
|
||||
super.key,
|
||||
required this.tabType,
|
||||
});
|
||||
|
||||
final HomeTabType tabType;
|
||||
|
||||
@override
|
||||
State<PgcPage> createState() => _PgcPageState();
|
||||
}
|
||||
|
||||
class _PgcPageState extends CommonPageState<PgcPage, PgcController>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
@override
|
||||
late PgcController controller = Get.put(
|
||||
PgcController(tabType: widget.tabType),
|
||||
tag: widget.tabType.name,
|
||||
);
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
final ThemeData theme = Theme.of(context);
|
||||
return refreshIndicator(
|
||||
onRefresh: controller.onRefresh,
|
||||
child: CustomScrollView(
|
||||
controller: controller.scrollController,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
_buildFollow(theme),
|
||||
if (controller.showPgcTimeline)
|
||||
SliverToBoxAdapter(
|
||||
child: SizedBox(
|
||||
height: Grid.smallCardWidth / 2 / 0.75 +
|
||||
MediaQuery.textScalerOf(context).scale(96),
|
||||
child: Obx(() =>
|
||||
_buildTimeline(theme, controller.timelineState.value)),
|
||||
),
|
||||
),
|
||||
..._buildRcmd(theme),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTimeline(
|
||||
ThemeData theme, LoadingState<List<Result>?> loadingState) =>
|
||||
switch (loadingState) {
|
||||
Loading() => loadingWidget,
|
||||
Success(:var response) => response?.isNotEmpty == true
|
||||
? Builder(builder: (context) {
|
||||
final initialIndex =
|
||||
max(0, response!.indexWhere((item) => item.isToday == 1));
|
||||
return DefaultTabController(
|
||||
initialIndex: initialIndex,
|
||||
length: response.length,
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const SizedBox(width: 16),
|
||||
Text(
|
||||
'追番时间表',
|
||||
style: theme.textTheme.titleMedium,
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: TabBar(
|
||||
isScrollable: true,
|
||||
tabAlignment: TabAlignment.start,
|
||||
dividerHeight: 0,
|
||||
overlayColor:
|
||||
WidgetStateProperty.all(Colors.transparent),
|
||||
splashFactory: NoSplash.splashFactory,
|
||||
padding: const EdgeInsets.only(right: 10),
|
||||
indicatorPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 4,
|
||||
vertical: 10,
|
||||
),
|
||||
indicator: BoxDecoration(
|
||||
color: theme.colorScheme.secondaryContainer,
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(20)),
|
||||
),
|
||||
indicatorSize: TabBarIndicatorSize.tab,
|
||||
labelColor:
|
||||
theme.colorScheme.onSecondaryContainer,
|
||||
labelStyle: TabBarTheme.of(context)
|
||||
.labelStyle
|
||||
?.copyWith(fontSize: 14) ??
|
||||
const TextStyle(fontSize: 14),
|
||||
dividerColor: Colors.transparent,
|
||||
tabs: response.map(
|
||||
(item) {
|
||||
return Tab(
|
||||
text:
|
||||
'${item.date} ${item.isToday == 1 ? '今天' : '周${const [
|
||||
'一',
|
||||
'二',
|
||||
'三',
|
||||
'四',
|
||||
'五',
|
||||
'六',
|
||||
'日',
|
||||
][item.dayOfWeek! - 1]}'}',
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
children: response.map((item) {
|
||||
if (item.episodes!.isNullOrEmpty) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return ListView.builder(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: item.episodes!.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Container(
|
||||
width: Grid.smallCardWidth / 2,
|
||||
margin: EdgeInsets.only(
|
||||
left: StyleString.safeSpace,
|
||||
right: index == item.episodes!.length - 1
|
||||
? StyleString.safeSpace
|
||||
: 0,
|
||||
),
|
||||
child: PgcCardVTimeline(
|
||||
item: item.episodes![index],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}).toList()),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
})
|
||||
: const SizedBox.shrink(),
|
||||
Error(:var errMsg) => GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: controller.queryPgcTimeline,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
errMsg ?? '',
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
};
|
||||
|
||||
List<Widget> _buildRcmd(ThemeData theme) => [
|
||||
_buildRcmdTitle(theme),
|
||||
SliverPadding(
|
||||
padding: EdgeInsets.only(
|
||||
left: StyleString.safeSpace,
|
||||
right: StyleString.safeSpace,
|
||||
bottom: MediaQuery.paddingOf(context).bottom + 80,
|
||||
),
|
||||
sliver: Obx(
|
||||
() => _buildRcmdBody(controller.loadingState.value),
|
||||
),
|
||||
),
|
||||
];
|
||||
|
||||
Widget _buildRcmdTitle(ThemeData theme) => SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 10,
|
||||
bottom: 10,
|
||||
left: 16,
|
||||
right: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'推荐',
|
||||
style: theme.textTheme.titleMedium,
|
||||
),
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
if (widget.tabType == HomeTabType.bangumi) {
|
||||
Get.to(const PgcIndexPage());
|
||||
} else {
|
||||
List<String> titles = const [
|
||||
'全部',
|
||||
'电影',
|
||||
'电视剧',
|
||||
'纪录片',
|
||||
'综艺',
|
||||
];
|
||||
List<int> types = const [102, 2, 5, 3, 7];
|
||||
Get.to(
|
||||
Scaffold(
|
||||
appBar: AppBar(title: const Text('索引')),
|
||||
body: DefaultTabController(
|
||||
length: types.length,
|
||||
child: Builder(builder: (context) {
|
||||
return Column(
|
||||
children: [
|
||||
SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: TabBar(
|
||||
tabs: titles
|
||||
.map((title) => Tab(text: title))
|
||||
.toList(),
|
||||
onTap: (index) {
|
||||
try {
|
||||
if (!DefaultTabController.of(context)
|
||||
.indexIsChanging) {
|
||||
Get.find<PgcIndexController>(
|
||||
tag: types[index].toString())
|
||||
.animateToTop();
|
||||
}
|
||||
} catch (_) {}
|
||||
},
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: tabBarView(
|
||||
children: types
|
||||
.map((type) =>
|
||||
PgcIndexPage(indexType: type))
|
||||
.toList()),
|
||||
)
|
||||
],
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 2),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'查看更多',
|
||||
strutStyle: const StrutStyle(leading: 0, height: 1),
|
||||
style: TextStyle(
|
||||
height: 1,
|
||||
color: theme.colorScheme.secondary,
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
Icons.chevron_right,
|
||||
color: theme.colorScheme.secondary,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Widget _buildRcmdBody(LoadingState<List<PgcIndexItem>?> loadingState) {
|
||||
return switch (loadingState) {
|
||||
Loading() => const SliverToBoxAdapter(),
|
||||
Success(:var response) => response?.isNotEmpty == true
|
||||
? SliverGrid(
|
||||
gridDelegate: SliverGridDelegateWithExtentAndRatio(
|
||||
// 行间距
|
||||
mainAxisSpacing: StyleString.cardSpace,
|
||||
// 列间距
|
||||
crossAxisSpacing: StyleString.cardSpace,
|
||||
// 最大宽度
|
||||
maxCrossAxisExtent: Grid.smallCardWidth / 3 * 2,
|
||||
childAspectRatio: 0.75,
|
||||
mainAxisExtent: MediaQuery.textScalerOf(context).scale(50),
|
||||
),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) {
|
||||
if (index == response.length - 1) {
|
||||
controller.onLoadMore();
|
||||
}
|
||||
return PgcCardVPgcIndex(item: response[index]);
|
||||
},
|
||||
childCount: response!.length,
|
||||
),
|
||||
)
|
||||
: HttpError(
|
||||
onReload: controller.onReload,
|
||||
),
|
||||
Error(:var errMsg) => HttpError(
|
||||
errMsg: errMsg,
|
||||
onReload: controller.onReload,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
Widget _buildFollow(ThemeData theme) => SliverToBoxAdapter(
|
||||
child: Obx(
|
||||
() => controller.isLogin.value
|
||||
? Column(
|
||||
children: [
|
||||
_buildFollowTitle(theme),
|
||||
SizedBox(
|
||||
height: Grid.smallCardWidth / 2 / 0.75 +
|
||||
MediaQuery.textScalerOf(context).scale(50),
|
||||
child: Obx(
|
||||
() => _buildFollowBody(controller.followState.value),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
),
|
||||
);
|
||||
|
||||
Widget _buildFollowTitle(ThemeData theme) => Padding(
|
||||
padding: const EdgeInsets.only(left: 16),
|
||||
child: Row(
|
||||
children: [
|
||||
Obx(
|
||||
() => Text(
|
||||
'最近${widget.tabType == HomeTabType.bangumi ? '追番' : '追剧'}${controller.followCount.value == -1 ? '' : ' ${controller.followCount.value}'}',
|
||||
style: theme.textTheme.titleMedium,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
tooltip: '刷新',
|
||||
onPressed: () => controller
|
||||
..followPage = 1
|
||||
..followEnd = false
|
||||
..queryPgcFollow(),
|
||||
icon: const Icon(
|
||||
Icons.refresh,
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
Obx(
|
||||
() => controller.isLogin.value
|
||||
? Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () => Get.toNamed(
|
||||
'/fav',
|
||||
arguments: widget.tabType == HomeTabType.bangumi
|
||||
? FavTabType.bangumi.index
|
||||
: FavTabType.cinema.index,
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'查看全部',
|
||||
strutStyle:
|
||||
const StrutStyle(leading: 0, height: 1),
|
||||
style: TextStyle(
|
||||
height: 1,
|
||||
color: theme.colorScheme.secondary,
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
Icons.chevron_right,
|
||||
color: theme.colorScheme.secondary,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Widget _buildFollowBody(LoadingState<List<FavPgcItemModel>?> loadingState) {
|
||||
return switch (loadingState) {
|
||||
Loading() => loadingWidget,
|
||||
Success(:var response) => response?.isNotEmpty == true
|
||||
? ListView.builder(
|
||||
controller: controller.followController,
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: response!.length,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == response.length - 1) {
|
||||
controller.queryPgcFollow(false);
|
||||
}
|
||||
return Container(
|
||||
width: Grid.smallCardWidth / 2,
|
||||
margin: EdgeInsets.only(
|
||||
left: StyleString.safeSpace,
|
||||
right: index == response.length - 1
|
||||
? StyleString.safeSpace
|
||||
: 0,
|
||||
),
|
||||
child: PgcCardV(
|
||||
item: response[index],
|
||||
),
|
||||
);
|
||||
},
|
||||
)
|
||||
: Center(
|
||||
child: Text(
|
||||
'还没有${widget.tabType == HomeTabType.bangumi ? '追番' : '追剧'}')),
|
||||
Error(:var errMsg) => Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
errMsg ?? '',
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
};
|
||||
}
|
||||
}
|
||||
109
lib/pages/pgc/widgets/pgc_card_v.dart
Normal file
109
lib/pages/pgc/widgets/pgc_card_v.dart
Normal file
@@ -0,0 +1,109 @@
|
||||
import 'package:PiliPlus/common/widgets/badge.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/image_save.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/models/common/badge_type.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_pgc/list.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
// 视频卡片 - 垂直布局
|
||||
class PgcCardV extends StatelessWidget {
|
||||
const PgcCardV({
|
||||
super.key,
|
||||
required this.item,
|
||||
});
|
||||
|
||||
final FavPgcItemModel item;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
String heroTag = Utils.makeHeroTag(item.mediaId);
|
||||
return Card(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
margin: EdgeInsets.zero,
|
||||
child: InkWell(
|
||||
onLongPress: () => imageSaveDialog(
|
||||
title: item.title,
|
||||
cover: item.cover,
|
||||
),
|
||||
onTap: () => PageUtils.viewPgc(seasonId: item.seasonId),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
AspectRatio(
|
||||
aspectRatio: 0.75,
|
||||
child: LayoutBuilder(builder: (context, boxConstraints) {
|
||||
final double maxWidth = boxConstraints.maxWidth;
|
||||
final double maxHeight = boxConstraints.maxHeight;
|
||||
return Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Hero(
|
||||
tag: heroTag,
|
||||
child: NetworkImgLayer(
|
||||
src: item.cover,
|
||||
width: maxWidth,
|
||||
height: maxHeight,
|
||||
),
|
||||
),
|
||||
PBadge(
|
||||
text: item.badge,
|
||||
top: 6,
|
||||
right: 6,
|
||||
bottom: null,
|
||||
left: null,
|
||||
),
|
||||
if (item.isFinish == 0 &&
|
||||
item.renewalTime?.isNotEmpty == true)
|
||||
PBadge(
|
||||
text: item.renewalTime,
|
||||
bottom: 6,
|
||||
left: 6,
|
||||
type: PBadgeType.gray,
|
||||
)
|
||||
],
|
||||
);
|
||||
}),
|
||||
),
|
||||
bagumiContent(context)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget bagumiContent(context) {
|
||||
final theme = Theme.of(context);
|
||||
final style = TextStyle(
|
||||
fontSize: theme.textTheme.labelMedium!.fontSize,
|
||||
color: theme.colorScheme.outline,
|
||||
);
|
||||
return Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(4, 5, 0, 3),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.title!,
|
||||
textAlign: TextAlign.start,
|
||||
style: const TextStyle(
|
||||
letterSpacing: 0.3,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 1),
|
||||
if (item.progress != null)
|
||||
Text(
|
||||
item.progress!,
|
||||
maxLines: 1,
|
||||
style: style,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
99
lib/pages/pgc/widgets/pgc_card_v_timeline.dart
Normal file
99
lib/pages/pgc/widgets/pgc_card_v_timeline.dart
Normal file
@@ -0,0 +1,99 @@
|
||||
import 'package:PiliPlus/common/widgets/badge.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/image_save.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/models/common/badge_type.dart';
|
||||
import 'package:PiliPlus/models_new/pgc/pgc_timeline/episode.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
// 视频卡片 - 垂直布局
|
||||
class PgcCardVTimeline extends StatelessWidget {
|
||||
const PgcCardVTimeline({
|
||||
super.key,
|
||||
required this.item,
|
||||
});
|
||||
|
||||
final Episode item;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
margin: EdgeInsets.zero,
|
||||
child: InkWell(
|
||||
onLongPress: () => imageSaveDialog(
|
||||
title: item.title,
|
||||
cover: item.cover,
|
||||
),
|
||||
onTap: () =>
|
||||
PageUtils.viewPgc(seasonId: item.seasonId, epId: item.episodeId),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
AspectRatio(
|
||||
aspectRatio: 0.75,
|
||||
child: LayoutBuilder(builder: (context, boxConstraints) {
|
||||
final double maxWidth = boxConstraints.maxWidth;
|
||||
final double maxHeight = boxConstraints.maxHeight;
|
||||
return Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
src: item.cover,
|
||||
width: maxWidth,
|
||||
height: maxHeight,
|
||||
),
|
||||
if (item.follow == 1)
|
||||
const PBadge(
|
||||
text: '已追番',
|
||||
right: 6,
|
||||
top: 6,
|
||||
),
|
||||
PBadge(
|
||||
text: '${item.pubTime}',
|
||||
left: 6,
|
||||
bottom: 6,
|
||||
type: PBadgeType.gray,
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
),
|
||||
bagumiContent(context)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget bagumiContent(context) {
|
||||
final theme = Theme.of(context);
|
||||
return Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(4, 5, 0, 3),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.title ?? '',
|
||||
textAlign: TextAlign.start,
|
||||
style: const TextStyle(
|
||||
letterSpacing: 0.3,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
Text(
|
||||
item.pubIndex ?? '',
|
||||
maxLines: 1,
|
||||
style: TextStyle(
|
||||
fontSize: theme.textTheme.labelMedium!.fontSize,
|
||||
color: theme.colorScheme.outline,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user