diff --git a/lib/pages/video/detail/introduction/widgets/page.dart b/lib/pages/video/detail/introduction/widgets/page.dart index b3f1f7a0..e1fdaf09 100644 --- a/lib/pages/video/detail/introduction/widgets/page.dart +++ b/lib/pages/video/detail/introduction/widgets/page.dart @@ -27,6 +27,7 @@ class _PagesPanelState extends State { late int currentIndex; String heroTag = Get.arguments['heroTag']; late VideoDetailController _videoDetailController; + final ScrollController _scrollController = ScrollController(); @override void initState() { @@ -50,6 +51,12 @@ class _PagesPanelState extends State { setState(() {}); } + @override + void dispose() { + _scrollController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { return Column( @@ -80,73 +87,92 @@ class _PagesPanelState extends State { onPressed: () { showBottomSheet( context: context, - builder: (_) => Container( - height: widget.sheetHeight, - color: Theme.of(context).colorScheme.background, - child: Column( - children: [ - Container( - height: 45, - padding: - const EdgeInsets.only(left: 14, right: 14), - child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Text( - '合集(${episodes.length})', - style: - Theme.of(context).textTheme.titleMedium, + builder: (BuildContext context) { + return StatefulBuilder(builder: + (BuildContext context, StateSetter setState) { + WidgetsBinding.instance + .addPostFrameCallback((_) async { + await Future.delayed( + const Duration(milliseconds: 200)); + _scrollController.jumpTo(currentIndex * 56); + }); + return Container( + height: widget.sheetHeight, + color: Theme.of(context).colorScheme.background, + child: Column( + children: [ + Container( + height: 45, + padding: const EdgeInsets.only( + left: 14, right: 14), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + '合集(${episodes.length})', + style: Theme.of(context) + .textTheme + .titleMedium, + ), + IconButton( + icon: const Icon(Icons.close), + onPressed: () => Navigator.pop(context), + ), + ], ), - IconButton( - icon: const Icon(Icons.close), - onPressed: () => Navigator.pop(context), - ), - ], - ), - ), - Divider( - height: 1, - color: Theme.of(context) - .dividerColor - .withOpacity(0.1), - ), - Expanded( - child: Material( - child: ListView.builder( - itemCount: episodes.length, - itemBuilder: (context, index) { - return InkWell( - onTap: () { - changeFucCall(episodes[index], index); - Get.back(); - }, - child: Padding( - padding: const EdgeInsets.only( - top: 10, - bottom: 10, - left: 15, - right: 15), - child: Text( - episodes[index].pagePart!, - style: TextStyle( + ), + Divider( + height: 1, + color: Theme.of(context) + .dividerColor + .withOpacity(0.1), + ), + Expanded( + child: Material( + child: ListView.builder( + controller: _scrollController, + itemCount: episodes.length, + itemBuilder: (context, 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), - ), - ), - ); - }, + .onSurface, + ), + ), + ); + }, + ), + ), ), - ), + ], ), - ], - ), - ), + ); + }); + }, ); }, child: Text( diff --git a/lib/pages/video/detail/introduction/widgets/season.dart b/lib/pages/video/detail/introduction/widgets/season.dart index 611b9d70..4b075c66 100644 --- a/lib/pages/video/detail/introduction/widgets/season.dart +++ b/lib/pages/video/detail/introduction/widgets/season.dart @@ -28,6 +28,7 @@ class _SeasonPanelState extends State { late int currentIndex; String heroTag = Get.arguments['heroTag']; late VideoDetailController _videoDetailController; + final ScrollController _scrollController = ScrollController(); @override void initState() { @@ -73,6 +74,12 @@ class _SeasonPanelState extends State { setState(() {}); } + @override + void dispose() { + _scrollController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { return Builder(builder: (context) { @@ -90,63 +97,82 @@ class _SeasonPanelState extends State { child: InkWell( onTap: () => showBottomSheet( context: context, - builder: (_) => Container( - height: widget.sheetHeight, - color: Theme.of(context).colorScheme.background, - child: Column( - children: [ - Container( - height: 45, - padding: const EdgeInsets.only(left: 14, right: 14), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - '合集(${episodes.length})', - style: Theme.of(context).textTheme.titleMedium, + builder: (BuildContext context) { + return StatefulBuilder( + builder: (BuildContext context, StateSetter setState) { + WidgetsBinding.instance.addPostFrameCallback((_) async { + await Future.delayed(const Duration(milliseconds: 200)); + _scrollController.jumpTo(currentIndex * 56); + }); + return Container( + height: widget.sheetHeight, + color: Theme.of(context).colorScheme.background, + child: Column( + children: [ + Container( + height: 45, + padding: const EdgeInsets.only(left: 14, right: 14), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + '合集(${episodes.length})', + style: Theme.of(context).textTheme.titleMedium, + ), + IconButton( + icon: const Icon(Icons.close), + onPressed: () => Navigator.pop(context), + ), + ], ), - IconButton( - icon: const Icon(Icons.close), - onPressed: () => Navigator.pop(context), - ), - ], - ), - ), - Divider( - height: 1, - color: Theme.of(context).dividerColor.withOpacity(0.1), - ), - Expanded( - child: Material( - child: ListView.builder( - itemCount: episodes.length, - itemBuilder: (context, index) { - return InkWell( - onTap: () => - changeFucCall(episodes[index], index), - child: Padding( - padding: const EdgeInsets.only( - top: 10, bottom: 10, left: 15, right: 15), - child: Text( - episodes[index].title!, - style: TextStyle( + ), + Divider( + height: 1, + color: + Theme.of(context).dividerColor.withOpacity(0.1), + ), + Expanded( + child: Material( + child: ListView.builder( + controller: _scrollController, + itemCount: episodes.length, + itemBuilder: (context, index) { + return 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, + ) + : null, + title: Text( + episodes[index].title!, + style: TextStyle( + fontSize: 14, color: index == currentIndex ? Theme.of(context) .colorScheme .primary : Theme.of(context) .colorScheme - .onSurface), - ), - ), - ); - }, + .onSurface, + ), + ), + ); + }, + ), + ), ), - ), + ], ), - ], - ), - ), + ); + }); + }, ), child: Padding( padding: const EdgeInsets.fromLTRB(8, 12, 8, 12),