diff --git a/lib/pages/bangumi/widgets/bangumi_panel.dart b/lib/pages/bangumi/widgets/bangumi_panel.dart index 17bc4b30..04a21030 100644 --- a/lib/pages/bangumi/widgets/bangumi_panel.dart +++ b/lib/pages/bangumi/widgets/bangumi_panel.dart @@ -65,6 +65,47 @@ 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.png', + color: primary, + height: 12, + semanticLabel: "正在播放:", + ) + : 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, + semanticLabel: "大会员", + ) + : const SizedBox(), + ); + } + void showBangumiPanel() { showBottomSheet( context: context, @@ -107,39 +148,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.png', - color: Theme.of(context).colorScheme.primary, - height: 12, - semanticLabel: "正在播放:", + 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, - semanticLabel: "大会员", - ) - : 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 295395f2..beabd5d3 100644 --- a/lib/pages/video/detail/introduction/widgets/page.dart +++ b/lib/pages/video/detail/introduction/widgets/page.dart @@ -56,6 +56,38 @@ 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.png', + color: primary, + height: 12, + semanticLabel: "正在播放:", + ) + : null, + title: Text( + episode.pagePart!, + style: TextStyle( + fontSize: 14, + color: isCurrentIndex + ? primary + : Theme.of(context).colorScheme.onSurface, + ), + ), + ); + } + @override Widget build(BuildContext context) { return Column( @@ -132,40 +164,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.png', - color: Theme.of(context) - .colorScheme - .primary, - height: 12, - semanticLabel: "正在播放:", - ) - : 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, + ); }, ), ), @@ -194,6 +211,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), @@ -208,7 +226,7 @@ class _PagesPanelState extends State { vertical: 8, horizontal: 8), child: Row( children: [ - if (i == currentIndex) ...[ + if (isCurrentIndex) ...[ Image.asset( 'assets/images/live.png', color: Theme.of(context).colorScheme.primary, @@ -223,7 +241,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 6e657411..f15f62a1 100644 --- a/lib/pages/video/detail/introduction/widgets/season.dart +++ b/lib/pages/video/detail/introduction/widgets/season.dart @@ -84,6 +84,35 @@ 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.png', + color: primary, + height: 12, + semanticLabel: "正在播放:", + ) + : null, + title: Text( + episode.title!, + style: TextStyle( + fontSize: 14, + color: isCurrentIndex + ? primary + : Theme.of(context).colorScheme.onSurface, + ), + ), + ); + } + @override Widget build(BuildContext context) { if (episodes == null) { @@ -144,34 +173,23 @@ class _SeasonPanelState extends State { bottom: MediaQuery.of(context).padding.bottom), 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.png', - color: Theme.of(context) - .colorScheme - .primary, - height: 12, - semanticLabel: "正在播放:", + itemCount: episodes.length, + 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, ), ),