From 75f569cb79c25c284abdb2d98c6a669c06ab4eb7 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sun, 3 Mar 2024 00:15:16 +0800 Subject: [PATCH] =?UTF-8?q?mod:=20=E5=90=88=E9=9B=86=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/bangumi/widgets/bangumi_panel.dart | 83 +++++++++++------- .../detail/introduction/widgets/page.dart | 84 +++++++++++-------- .../detail/introduction/widgets/season.dart | 68 +++++++++------ 3 files changed, 147 insertions(+), 88 deletions(-) diff --git a/lib/pages/bangumi/widgets/bangumi_panel.dart b/lib/pages/bangumi/widgets/bangumi_panel.dart index 5996d6c8..05889f16 100644 --- a/lib/pages/bangumi/widgets/bangumi_panel.dart +++ b/lib/pages/bangumi/widgets/bangumi_panel.dart @@ -65,6 +65,45 @@ class _BangumiPanelState extends State { super.dispose(); } + Widget buildPageListItem( + EpisodeItem page, + int index, + bool isCurrentIndex, + ) { + Color primary = Theme.of(context).colorScheme.primary; + return ListTile( + onTap: () { + Get.back(); + setState(() { + changeFucCall(page, index); + }); + }, + dense: false, + leading: isCurrentIndex + ? Image.asset( + 'assets/images/live.gif', + color: primary, + height: 12, + ) + : null, + title: Text( + '第${index + 1}话 ${page.longTitle!}', + style: TextStyle( + fontSize: 14, + color: isCurrentIndex + ? primary + : Theme.of(context).colorScheme.onSurface, + ), + ), + trailing: page.badge != null + ? Image.asset( + 'assets/images/big-vip.png', + height: 20, + ) + : const SizedBox(), + ); + } + void showBangumiPanel() { showBottomSheet( context: context, @@ -106,37 +145,21 @@ class _BangumiPanelState extends State { child: Material( child: ScrollablePositionedList.builder( itemCount: widget.pages.length, - itemBuilder: (BuildContext context, int index) => - ListTile( - onTap: () { - setState(() { - changeFucCall(widget.pages[index], index); - }); - }, - dense: false, - leading: index == currentIndex - ? Image.asset( - 'assets/images/live.gif', - color: Theme.of(context).colorScheme.primary, - height: 12, + itemBuilder: (BuildContext context, int index) { + bool isLastItem = index == widget.pages.length - 1; + bool isCurrentIndex = currentIndex == index; + return isLastItem + ? SizedBox( + height: + MediaQuery.of(context).padding.bottom + + 20, ) - : null, - title: Text( - '第${index + 1}话 ${widget.pages[index].longTitle!}', - style: TextStyle( - fontSize: 14, - color: index == currentIndex - ? Theme.of(context).colorScheme.primary - : Theme.of(context).colorScheme.onSurface, - ), - ), - trailing: widget.pages[index].badge != null - ? Image.asset( - 'assets/images/big-vip.png', - height: 20, - ) - : const SizedBox(), - ), + : buildPageListItem( + widget.pages[index], + index, + isCurrentIndex, + ); + }, itemScrollController: itemScrollController, ), ), diff --git a/lib/pages/video/detail/introduction/widgets/page.dart b/lib/pages/video/detail/introduction/widgets/page.dart index 2ba7f507..8d296050 100644 --- a/lib/pages/video/detail/introduction/widgets/page.dart +++ b/lib/pages/video/detail/introduction/widgets/page.dart @@ -56,6 +56,37 @@ class _PagesPanelState extends State { super.dispose(); } + Widget buildEpisodeListItem( + Part episode, + int index, + bool isCurrentIndex, + ) { + Color primary = Theme.of(context).colorScheme.primary; + return ListTile( + onTap: () { + changeFucCall(episode, index); + Get.back(); + }, + dense: false, + leading: isCurrentIndex + ? Image.asset( + 'assets/images/live.gif', + color: primary, + height: 12, + ) + : null, + title: Text( + episode.pagePart!, + style: TextStyle( + fontSize: 14, + color: isCurrentIndex + ? primary + : Theme.of(context).colorScheme.onSurface, + ), + ), + ); + } + @override Widget build(BuildContext context) { return Column( @@ -131,39 +162,25 @@ class _PagesPanelState extends State { child: Material( child: ListView.builder( controller: _scrollController, - itemCount: episodes.length, + itemCount: episodes.length + 1, itemBuilder: (BuildContext context, int index) { - return ListTile( - onTap: () { - changeFucCall( - episodes[index], index); - Get.back(); - }, - dense: false, - leading: index == currentIndex - ? Image.asset( - 'assets/images/live.gif', - color: Theme.of(context) - .colorScheme - .primary, - height: 12, - ) - : null, - title: Text( - episodes[index].pagePart!, - style: TextStyle( - fontSize: 14, - color: index == currentIndex - ? Theme.of(context) - .colorScheme - .primary - : Theme.of(context) - .colorScheme - .onSurface, - ), - ), - ); + bool isLastItem = + index == episodes.length; + bool isCurrentIndex = + currentIndex == index; + return isLastItem + ? SizedBox( + height: MediaQuery.of(context) + .padding + .bottom + + 20, + ) + : buildEpisodeListItem( + episodes[index], + index, + isCurrentIndex, + ); }, ), ), @@ -192,6 +209,7 @@ class _PagesPanelState extends State { itemCount: widget.pages.length, itemExtent: 150, itemBuilder: (BuildContext context, int i) { + bool isCurrentIndex = currentIndex == i; return Container( width: 150, margin: const EdgeInsets.only(right: 10), @@ -206,7 +224,7 @@ class _PagesPanelState extends State { vertical: 8, horizontal: 8), child: Row( children: [ - if (i == currentIndex) ...[ + if (isCurrentIndex) ...[ Image.asset( 'assets/images/live.gif', color: Theme.of(context).colorScheme.primary, @@ -220,7 +238,7 @@ class _PagesPanelState extends State { maxLines: 1, style: TextStyle( fontSize: 13, - color: i == currentIndex + color: isCurrentIndex ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onSurface), overflow: TextOverflow.ellipsis, diff --git a/lib/pages/video/detail/introduction/widgets/season.dart b/lib/pages/video/detail/introduction/widgets/season.dart index 9e5dd34f..c6a94398 100644 --- a/lib/pages/video/detail/introduction/widgets/season.dart +++ b/lib/pages/video/detail/introduction/widgets/season.dart @@ -80,6 +80,34 @@ class _SeasonPanelState extends State { super.dispose(); } + Widget buildEpisodeListItem( + EpisodeItem episode, + int index, + bool isCurrentIndex, + ) { + Color primary = Theme.of(context).colorScheme.primary; + return ListTile( + onTap: () => changeFucCall(episode, index), + dense: false, + leading: isCurrentIndex + ? Image.asset( + 'assets/images/live.gif', + color: primary, + height: 12, + ) + : null, + title: Text( + episode.title!, + style: TextStyle( + fontSize: 14, + color: isCurrentIndex + ? primary + : Theme.of(context).colorScheme.onSurface, + ), + ), + ); + } + @override Widget build(BuildContext context) { return Builder(builder: (BuildContext context) { @@ -134,32 +162,22 @@ class _SeasonPanelState extends State { child: Material( child: ScrollablePositionedList.builder( itemCount: episodes.length, - itemBuilder: (BuildContext context, int index) => - ListTile( - onTap: () => - changeFucCall(episodes[index], index), - dense: false, - leading: index == currentIndex - ? Image.asset( - 'assets/images/live.gif', - color: Theme.of(context) - .colorScheme - .primary, - height: 12, + itemBuilder: (BuildContext context, int index) { + bool isLastItem = index == episodes.length - 1; + bool isCurrentIndex = currentIndex == index; + return isLastItem + ? SizedBox( + height: MediaQuery.of(context) + .padding + .bottom + + 20, ) - : null, - title: Text( - episodes[index].title!, - style: TextStyle( - fontSize: 14, - color: index == currentIndex - ? Theme.of(context).colorScheme.primary - : Theme.of(context) - .colorScheme - .onSurface, - ), - ), - ), + : buildEpisodeListItem( + episodes[index], + index, + isCurrentIndex, + ); + }, itemScrollController: itemScrollController, ), ),