diff --git a/lib/kt_pages/kt_explore/logic.dart b/lib/kt_pages/kt_explore/logic.dart index bcb051f..e341150 100644 --- a/lib/kt_pages/kt_explore/logic.dart +++ b/lib/kt_pages/kt_explore/logic.dart @@ -21,6 +21,7 @@ class KtExploreLogic extends GetxController { final PageController pageController = PageController(viewportFraction: .95); final int preloadRange = 1; bool isRefresh = false; + final mainLogic = Get.find(); @override void onReady() { @@ -123,10 +124,10 @@ class KtExploreLogic extends GetxController { }); } if (state.controllers[index] != null) { - state.controllers[index]?.play(); + if (mainLogic.curIndex == 1) state.controllers[index]?.play(); } else { if (!isToggle) await _initializeController(index); - state.controllers[index]?.play(); + if (mainLogic.curIndex == 1) state.controllers[index]?.play(); } // 预加载新的相邻视频,并释放多余控制器 _preloadAdjacentVideos(); @@ -165,13 +166,16 @@ class KtExploreLogic extends GetxController { try { await controller.initialize(); - final mainLogic = Get.find(); if (index == state.currentPage && mainLogic.curIndex == 1) { controller.play(); update(); } controller.addListener(() { - if (state.currentPage == index && mainLogic.curIndex == 1) update(); + if (state.currentPage == index && mainLogic.curIndex == 1) { + update(); + } else { + controller.pause(); + } if (controller.value.isCompleted && !controller.value.isBuffering) { onPageChanged(index + 1, isToggle: true); diff --git a/lib/kt_pages/kt_explore/view.dart b/lib/kt_pages/kt_explore/view.dart index 45c9725..a7a9138 100644 --- a/lib/kt_pages/kt_explore/view.dart +++ b/lib/kt_pages/kt_explore/view.dart @@ -29,7 +29,7 @@ class _KtExplorePageState extends State super.build(context); return GetBuilder( builder: (ctrl) { - if(Get.find().curIndex != 1) return Container(); + if (Get.find().curIndex != 1) return Container(); if (state.loadStatus == KtLoadStatusType.loadNoData || state.loadStatus == KtLoadStatusType.loadFailed) { return KtStatusWidget( @@ -174,6 +174,20 @@ class _KtExplorePageState extends State ), ), ), + if (videoPlayerController.value.isInitialized) + GestureDetector( + onTap: () { + videoPlayerController.value.isPlaying + ? videoPlayerController.pause() + : videoPlayerController.play(); + setState(() {}); + }, + child: Container( + width: ScreenUtil().screenWidth, + height: ScreenUtil().screenHeight, + color: Colors.transparent, + ), + ), Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.end, @@ -263,6 +277,7 @@ class _KtExplorePageState extends State child: Image.asset('ic_play.png'.ktIcon, width: 62.w), ), ), + ], ), ), diff --git a/lib/kt_pages/kt_home/view.dart b/lib/kt_pages/kt_home/view.dart index 9b382f1..dff0739 100644 --- a/lib/kt_pages/kt_home/view.dart +++ b/lib/kt_pages/kt_home/view.dart @@ -96,7 +96,7 @@ class _KtHomePageState extends State child: Text( 'Get Hooked in Seconds', style: TextStyle( - fontSize: 12.sp, + fontSize: 11.sp, fontWeight: FontWeight.w600, fontStyle: FontStyle.italic, color: Colors.white, @@ -166,7 +166,7 @@ class _KtHomePageState extends State ), ], ), - SizedBox(width: 17.w), + SizedBox(width: 15.w), Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -184,7 +184,7 @@ class _KtHomePageState extends State child: Row( children: [ Image.asset('ic_star.png'.ktIcon, width: 14.w), - SizedBox(width: 4.w), + SizedBox(width: 3.w), SizedBox( width: 162.w, child: Text( @@ -257,7 +257,7 @@ class _KtHomePageState extends State SizedBox(width: 4.w), ], ), - SizedBox(height: 9.w), + SizedBox(height: 8.w), SizedBox( height: 117.w, child: ListView.separated( @@ -555,14 +555,20 @@ class _KtHomePageState extends State ) : null, ), - child: Text( - item.categoryName ?? '', - style: TextStyle( - fontSize: 14.sp, - color: Color(0xFF1E1E20), - fontWeight: state.selCategoryId == item.categoryId - ? FontWeight.w600 - : FontWeight.w400, + child: SizedBox( + width: ((ScreenUtil().screenWidth - 42.w) / 3) - 4.w, + child: Text( + textAlign: TextAlign.center, + item.categoryName ?? '', + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 14.sp, + color: Color(0xFF1E1E20), + fontWeight: state.selCategoryId == item.categoryId + ? FontWeight.w600 + : FontWeight.w400, + ), ), ), ), diff --git a/lib/kt_pages/kt_short_video/view.dart b/lib/kt_pages/kt_short_video/view.dart index d5ce617..c840f57 100644 --- a/lib/kt_pages/kt_short_video/view.dart +++ b/lib/kt_pages/kt_short_video/view.dart @@ -1,3 +1,4 @@ +import 'dart:io'; import 'dart:ui'; import 'package:easy_debounce/easy_throttle.dart'; @@ -9,6 +10,7 @@ import 'package:get/get.dart'; import 'package:video_player/video_player.dart'; import 'package:visibility_detector/visibility_detector.dart'; +import '../../kt_model/kt_video_detail_bean.dart'; import '../../kt_utils/kt_toast_utils.dart'; import '../../kt_widgets/kt_network_image.dart'; import '../../kt_widgets/kt_status_widget.dart'; @@ -201,7 +203,20 @@ class _VideoPlayPageState extends State if (!isAllOver) Center(child: CircularProgressIndicator()), ], ), - + GestureDetector( + onTap: () { + if (episode.isLock == true) return; + (controller?.value.isPlaying ?? true) + ? controller?.pause() + : controller?.play(); + setState(() {}); + }, + child: Container( + width: ScreenUtil().screenWidth, + height: ScreenUtil().screenHeight, + color: Colors.transparent, + ), + ), if (episode.isLock == true) Stack( children: [ @@ -261,7 +276,6 @@ class _VideoPlayPageState extends State ), ), Image.asset('ic_coin.png'.ktIcon, width: 18.7.w), - ], ), ), @@ -277,7 +291,6 @@ class _VideoPlayPageState extends State ), ), Image.asset('ic_coin.png'.ktIcon, width: 11.2.w), - ], ), ],