opt: medialist page

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-02 16:31:50 +08:00
parent 9bbd934f8e
commit 2abf01362c
6 changed files with 154 additions and 150 deletions

View File

@@ -13,6 +13,7 @@ class PBadge extends StatelessWidget {
final String? semanticsLabel; final String? semanticsLabel;
final bool bold; final bool bold;
final double? textScaleFactor; final double? textScaleFactor;
final EdgeInsets? padding;
const PBadge({ const PBadge({
super.key, super.key,
@@ -28,6 +29,7 @@ class PBadge extends StatelessWidget {
this.semanticsLabel, this.semanticsLabel,
this.bold = true, this.bold = true,
this.textScaleFactor, this.textScaleFactor,
this.padding,
}); });
@override @override
@@ -54,7 +56,7 @@ class PBadge extends StatelessWidget {
color = t.onError; color = t.onError;
} }
EdgeInsets paddingStyle = late EdgeInsets paddingStyle =
const EdgeInsets.symmetric(vertical: 2, horizontal: 3); const EdgeInsets.symmetric(vertical: 2, horizontal: 3);
double fontSize = 11; double fontSize = 11;
BorderRadius br = BorderRadius.circular(4); BorderRadius br = BorderRadius.circular(4);
@@ -66,7 +68,7 @@ class PBadge extends StatelessWidget {
} }
Widget content = Container( Widget content = Container(
padding: paddingStyle, padding: padding ?? paddingStyle,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: br, borderRadius: br,
color: bgColor, color: bgColor,

View File

@@ -107,7 +107,6 @@ class _EpisodePanelState extends CommonSlidePageState<EpisodePanel>
late bool _isInit = true; late bool _isInit = true;
late final Color primary = Theme.of(context).colorScheme.primary; late final Color primary = Theme.of(context).colorScheme.primary;
final height = 120 / StyleString.aspectRatio + 10;
void listener() { void listener() {
_currentTabIndex.value = _tabController.index; _currentTabIndex.value = _tabController.index;
@@ -248,9 +247,9 @@ class _EpisodePanelState extends CommonSlidePageState<EpisodePanel>
Widget _buildBody(int index, episodes) { Widget _buildBody(int index, episodes) {
return KeepAliveWrapper( return KeepAliveWrapper(
builder: (context) => ScrollablePositionedList.builder( builder: (context) => ScrollablePositionedList.separated(
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: 5, top: 7,
bottom: MediaQuery.of(context).padding.bottom + 80, bottom: MediaQuery.of(context).padding.bottom + 80,
), ),
reverse: _isReversed[index], reverse: _isReversed[index],
@@ -306,6 +305,7 @@ class _EpisodePanelState extends CommonSlidePageState<EpisodePanel>
); );
}, },
itemScrollController: _itemScrollController[index], itemScrollController: _itemScrollController[index],
separatorBuilder: (context, index) => const SizedBox(height: 2),
), ),
); );
} }
@@ -356,7 +356,7 @@ class _EpisodePanelState extends CommonSlidePageState<EpisodePanel>
return Material( return Material(
color: Colors.transparent, color: Colors.transparent,
child: SizedBox( child: SizedBox(
height: height, height: 98,
child: InkWell( child: InkWell(
onTap: () { onTap: () {
if (episode.badge != null && episode.badge == "会员") { if (episode.badge != null && episode.badge == "会员") {

View File

@@ -70,6 +70,11 @@ class FavPgcItem extends StatelessWidget {
right: 4, right: 4,
top: 4, top: 4,
text: item.badge, text: item.badge,
fs: 10,
padding: const EdgeInsets.symmetric(
horizontal: 2,
vertical: 1,
),
), ),
Positioned.fill( Positioned.fill(
child: IgnorePointer( child: IgnorePointer(

View File

@@ -1,4 +1,3 @@
import 'package:PiliPlus/common/constants.dart';
import 'package:PiliPlus/common/widgets/loading_widget.dart'; import 'package:PiliPlus/common/widgets/loading_widget.dart';
import 'package:PiliPlus/common/widgets/refresh_indicator.dart'; import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/http/loading_state.dart';
@@ -79,7 +78,6 @@ class _MemberFavoriteState extends State<MemberFavorite>
} }
_buildItem(Datum data, bool isFirst) { _buildItem(Datum data, bool isFirst) {
final height = 120 / StyleString.aspectRatio + 10;
return Theme( return Theme(
data: Theme.of(context).copyWith( data: Theme.of(context).copyWith(
dividerColor: Colors.transparent, dividerColor: Colors.transparent,
@@ -108,7 +106,7 @@ class _MemberFavoriteState extends State<MemberFavorite>
children: [ children: [
...(data.mediaListResponse?.list as List<FavList>).map( ...(data.mediaListResponse?.list as List<FavList>).map(
(item) => SizedBox( (item) => SizedBox(
height: height, height: 98,
child: MemberFavItem( child: MemberFavItem(
item: item, item: item,
callback: (res) { callback: (res) {

View File

@@ -90,7 +90,7 @@ class _MemberHomeState extends State<MemberHome>
), ),
SliverToBoxAdapter( SliverToBoxAdapter(
child: SizedBox( child: SizedBox(
height: 120 / StyleString.aspectRatio + 10, height: 98,
child: MemberFavItem( child: MemberFavItem(
item: loadingState.response.favourite2.item.first, item: loadingState.response.favourite2.item.first,
), ),

View File

@@ -1,9 +1,9 @@
import 'package:PiliPlus/common/widgets/dialog.dart'; import 'package:PiliPlus/common/widgets/dialog.dart';
import 'package:PiliPlus/common/widgets/icon_button.dart'; import 'package:PiliPlus/common/widgets/icon_button.dart';
import 'package:PiliPlus/common/widgets/image_save.dart';
import 'package:PiliPlus/common/widgets/refresh_indicator.dart'; import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
import 'package:PiliPlus/common/widgets/stat/stat.dart'; import 'package:PiliPlus/common/widgets/stat/stat.dart';
import 'package:PiliPlus/pages/common/common_collapse_slide_page.dart'; import 'package:PiliPlus/pages/common/common_collapse_slide_page.dart';
import 'package:PiliPlus/pages/common/common_slide_page.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@@ -46,7 +46,8 @@ class MediaListPanel extends CommonCollapseSlidePage {
State<MediaListPanel> createState() => _MediaListPanelState(); State<MediaListPanel> createState() => _MediaListPanelState();
} }
class _MediaListPanelState extends CommonSlidePageState<MediaListPanel> { class _MediaListPanelState
extends CommonCollapseSlidePageState<MediaListPanel> {
final _scrollController = ItemScrollController(); final _scrollController = ItemScrollController();
late RxBool desc; late RxBool desc;
@@ -97,6 +98,10 @@ class _MediaListPanelState extends CommonSlidePageState<MediaListPanel> {
const SizedBox(width: 14), const SizedBox(width: 14),
], ],
), ),
Divider(
height: 1,
color: Theme.of(context).colorScheme.outline.withOpacity(0.1),
),
Expanded( Expanded(
child: enableSlide ? slideList() : buildList, child: enableSlide ? slideList() : buildList,
), ),
@@ -119,11 +124,12 @@ class _MediaListPanelState extends CommonSlidePageState<MediaListPanel> {
() { () {
final showDelBtn = final showDelBtn =
widget.onDelete != null && widget.mediaList.length > 1; widget.onDelete != null && widget.mediaList.length > 1;
return ScrollablePositionedList.builder( return ScrollablePositionedList.separated(
itemScrollController: _scrollController, itemScrollController: _scrollController,
physics: const AlwaysScrollableScrollPhysics(), physics: const AlwaysScrollableScrollPhysics(),
itemCount: widget.mediaList.length, itemCount: widget.mediaList.length,
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: 7,
bottom: MediaQuery.paddingOf(context).bottom + 80, bottom: MediaQuery.paddingOf(context).bottom + 80,
), ),
itemBuilder: ((context, index) { itemBuilder: ((context, index) {
@@ -133,7 +139,9 @@ class _MediaListPanelState extends CommonSlidePageState<MediaListPanel> {
widget.mediaList.length < widget.count!)) { widget.mediaList.length < widget.count!)) {
widget.loadMoreMedia(); widget.loadMoreMedia();
} }
return InkWell( return SizedBox(
height: 98,
child: InkWell(
onTap: () async { onTap: () async {
if (item.type != 2) { if (item.type != 2) {
SmartDialog.showToast('不支持播放该类型视频'); SmartDialog.showToast('不支持播放该类型视频');
@@ -147,6 +155,13 @@ class _MediaListPanelState extends CommonSlidePageState<MediaListPanel> {
item.cid ?? await SearchHttp.ab2c(aid: aid, bvid: bvid); item.cid ?? await SearchHttp.ab2c(aid: aid, bvid: bvid);
widget.changeMediaList?.call(bvid, cid, aid, cover); widget.changeMediaList?.call(bvid, cid, aid, cover);
}, },
onLongPress: () {
imageSaveDialog(
context: context,
title: item.title,
cover: item.cover,
);
},
child: Stack( child: Stack(
children: [ children: [
Padding( Padding(
@@ -154,35 +169,23 @@ class _MediaListPanelState extends CommonSlidePageState<MediaListPanel> {
horizontal: 12, horizontal: 12,
vertical: 5, vertical: 5,
), ),
child: LayoutBuilder(
builder: (context, boxConstraints) {
const double width = 120;
return Container(
constraints: const BoxConstraints(minHeight: 88),
height: width / StyleString.aspectRatio,
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: [
AspectRatio( AspectRatio(
aspectRatio: StyleString.aspectRatio, aspectRatio: StyleString.aspectRatio,
child: LayoutBuilder( child: LayoutBuilder(
builder: (BuildContext context, builder: (context, boxConstraints) {
BoxConstraints boxConstraints) {
final double maxWidth =
boxConstraints.maxWidth;
final double maxHeight =
boxConstraints.maxHeight;
return Stack( return Stack(
children: [ children: [
NetworkImgLayer( NetworkImgLayer(
src: item.cover ?? '', src: item.cover,
width: maxWidth, width: boxConstraints.maxWidth,
height: maxHeight, height: boxConstraints.maxHeight,
), ),
PBadge( PBadge(
text: Utils.timeFormat( text: Utils.timeFormat(item.duration!),
item.duration!),
right: 6.0, right: 6.0,
bottom: 6.0, bottom: 6.0,
type: 'gray', type: 'gray',
@@ -195,17 +198,15 @@ class _MediaListPanelState extends CommonSlidePageState<MediaListPanel> {
const SizedBox(width: 10), const SizedBox(width: 10),
Expanded( Expanded(
child: Column( child: Column(
crossAxisAlignment: crossAxisAlignment: CrossAxisAlignment.start,
CrossAxisAlignment.start,
children: [ children: [
Text( Text(
item.title as String, item.title!,
textAlign: TextAlign.start, textAlign: TextAlign.start,
maxLines: 2, maxLines: 2,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
fontWeight: fontWeight: item.bvid == widget.getBvId()
item.bvid == widget.getBvId()
? FontWeight.bold ? FontWeight.bold
: null, : null,
color: item.bvid == widget.getBvId() color: item.bvid == widget.getBvId()
@@ -217,15 +218,14 @@ class _MediaListPanelState extends CommonSlidePageState<MediaListPanel> {
), ),
const Spacer(), const Spacer(),
Text( Text(
item.upper?.name as String, item.upper!.name!,
style: TextStyle( style: TextStyle(
fontSize: Theme.of(context) fontSize: Theme.of(context)
.textTheme .textTheme
.labelMedium! .labelMedium!
.fontSize, .fontSize,
color: Theme.of(context) color:
.colorScheme Theme.of(context).colorScheme.outline,
.outline,
), ),
), ),
const SizedBox(height: 2), const SizedBox(height: 2),
@@ -251,9 +251,6 @@ class _MediaListPanelState extends CommonSlidePageState<MediaListPanel> {
), ),
], ],
), ),
);
},
),
), ),
if (showDelBtn && item.bvid != widget.getBvId()) if (showDelBtn && item.bvid != widget.getBvId())
Positioned( Positioned(
@@ -283,8 +280,10 @@ class _MediaListPanelState extends CommonSlidePageState<MediaListPanel> {
), ),
], ],
), ),
),
); );
}), }),
separatorBuilder: (context, index) => const SizedBox(height: 2),
); );
}, },
); );