diff --git a/lib/kt_pages/kt_main_page/logic.dart b/lib/kt_pages/kt_main_page/logic.dart deleted file mode 100644 index e69de29..0000000 diff --git a/lib/kt_pages/kt_main_page/state.dart b/lib/kt_pages/kt_main_page/state.dart deleted file mode 100644 index e69de29..0000000 diff --git a/lib/kt_pages/kt_main_page/view.dart b/lib/kt_pages/kt_main_page/view.dart index 273819c..e621def 100644 --- a/lib/kt_pages/kt_main_page/view.dart +++ b/lib/kt_pages/kt_main_page/view.dart @@ -3,10 +3,12 @@ import 'package:flutter/services.dart'; import 'package:flutter_kinetra/kt_pages/kt_actor/kt_actor_page.dart'; import 'package:flutter_kinetra/kt_utils/kt_string_extend.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; import '../kt_explore/view.dart'; import '../kt_home/view.dart'; import '../kt_mine/view.dart'; +import '../kt_my_list/logic.dart'; import '../kt_my_list/view.dart'; class KtMainPage extends StatefulWidget { @@ -103,13 +105,8 @@ class _KtMainPageState extends State onTap: (index) { _currentIndex = index; _controller.jumpToPage(index); - // final recommendLogic = Get.put(RecommendLogic()); - // if (index != 1) { - // recommendLogic.videoCtrl?.pause(); - // } else { - // recommendLogic.videoCtrl?.play(); - // } - // recommendLogic.update(); + final myListLogic = Get.put(MyListLogic()); + myListLogic.initData(); }, items: [ ..._tabsTitle.map( diff --git a/lib/kt_pages/kt_my_list/logic.dart b/lib/kt_pages/kt_my_list/logic.dart index 160b5f6..2bbbb73 100644 --- a/lib/kt_pages/kt_my_list/logic.dart +++ b/lib/kt_pages/kt_my_list/logic.dart @@ -125,25 +125,7 @@ class MyListLogic extends GetxController { "video_id": video.shortPlayVideoId, }; if (video.isCollect == 1) { - Get.dialog( - KtDialog( - title: 'Remove from your list?', - subTitle: 'This drama will be removed from your saved list.', - rightBtnText: 'Remove', - rightBtnIcon: 'ic_dialog_delete.png', - rightBtnFunc: () async { - ApiResponse res = await KtHttpClient().request( - KtApis.deleteFavoriteVideo, - data: params, - ); - if (res.success) { - video.isCollect = 0; - getCollectList(refresh: true); - update(); - } - }, - ), - ); + cancelCollect(video.shortPlayId!); } else { ApiResponse res = await KtHttpClient().request( KtApis.collectVideo, @@ -170,7 +152,7 @@ class MyListLogic extends GetxController { queryParameters: {'short_play_id': id}, ); if (res.success) { - state.favoriteList.removeWhere((item) => id == item.shortPlayId); + // state.favoriteList.removeWhere((item) => id == item.shortPlayId); state.chestList.removeWhere((item) => id == item.shortPlayId); state.historyList .firstWhereOrNull((item) => id == item.shortPlayId) diff --git a/lib/kt_pages/kt_my_list/view.dart b/lib/kt_pages/kt_my_list/view.dart index fce1d94..99c526a 100644 --- a/lib/kt_pages/kt_my_list/view.dart +++ b/lib/kt_pages/kt_my_list/view.dart @@ -26,7 +26,7 @@ class _KtMyListPageState extends State { Widget build(BuildContext context) { return GetBuilder( builder: (ctrl) { - if (state.loadStatus == KtLoadStatusType.loading) return Container(); + // if (state.loadStatus == KtLoadStatusType.loading) return Center(child: CircularProgressIndicator()); return Container( width: ScreenUtil().screenWidth, height: ScreenUtil().screenHeight, @@ -39,286 +39,286 @@ class _KtMyListPageState extends State { ), child: state.chestList.isEmpty && state.historyList.isEmpty ? KtStatusWidget( - type: KtErrorStatusType.nothingYet, - onPressed: logic.initData, - ) + type: KtErrorStatusType.nothingYet, + onPressed: logic.initData, + ) : SmartRefresher( - controller: logic.refreshCtrl, - enablePullUp: true, - enablePullDown: true, - onRefresh: () => logic.initData(), - onLoading: () => logic.getHistoryList(loadMore: true), - child: Column( - children: [ - if (state.chestList.isNotEmpty) - Container( - width: ScreenUtil().screenWidth - 30.w, - padding: EdgeInsets.fromLTRB(6.w, 53.w, 6.w, 6.w), - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage('collect_bg.png'.ktIcon), - fit: BoxFit.fill, + controller: logic.refreshCtrl, + enablePullUp: true, + enablePullDown: true, + onRefresh: () => logic.initData(), + onLoading: () => logic.getHistoryList(loadMore: true), + child: Column( + children: [ + if (state.chestList.isNotEmpty) + Container( + width: ScreenUtil().screenWidth - 30.w, + padding: EdgeInsets.fromLTRB(6.w, 53.w, 6.w, 6.w), + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('collect_bg.png'.ktIcon), + fit: BoxFit.fill, + ), + ), + child: Column( + children: [ + Row( + children: [ + SizedBox(width: 6.w), + Text( + 'My Treasure Chest', + style: TextStyle( + fontSize: 18.sp, + color: Colors.white, + fontWeight: FontWeight.w800, + fontStyle: FontStyle.italic, + ), ), - ), - child: Column( - children: [ - Row( + const Spacer(), + GestureDetector( + onTap: () => Get.to(KtMyChestPage()), + child: Row( children: [ - SizedBox(width: 6.w), Text( - 'My Treasure Chest', + 'View All', style: TextStyle( - fontSize: 18.sp, - color: Colors.white, - fontWeight: FontWeight.w800, - fontStyle: FontStyle.italic, + fontSize: 12.sp, + color: Color(0xFFD6D6D6), ), ), - const Spacer(), - GestureDetector( - onTap: () => Get.to(KtMyChestPage()), - child: Row( - children: [ - Text( - 'View All', - style: TextStyle( - fontSize: 12.sp, - color: Color(0xFFD6D6D6), - ), - ), - Image.asset( - 'ic_right_white.png'.ktIcon, - width: 10.w, - ), - SizedBox(width: 6.w), - ], - ), + Image.asset( + 'ic_right_white.png'.ktIcon, + width: 10.w, ), + SizedBox(width: 6.w), ], ), - SizedBox(height: 15.w), - Container( - height: 145.w, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(14.w), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - ...state.chestList.map( - (video) => Container( - margin: EdgeInsets.symmetric( - horizontal: 5.w, - ), - child: Stack( - children: [ - GestureDetector( - onTap: () => Get.toNamed( - KtRoutes.shortVideo, - arguments: { - 'shortPlayId': - video.shortPlayId, - 'imageUrl': - video.imageUrl ?? '', - }, - ), - child: KtNetworkImage( - imageUrl: video.imageUrl ?? '', - width: 100.w, - height: 133.w, - borderRadius: - BorderRadius.circular(6.w), - ), - ), - Positioned( - right: 4.w, - top: 4.w, - child: GestureDetector( - onTap: () => - logic.cancelCollect( - video.shortPlayId!, - ), - child: Image.asset( - 'ic_collect_sel.png'.ktIcon, - width: 28.w, - ), - ), - ), - ], - ), - ), - ), - ], - ), - ), - ], - ), + ), + ], ), - SizedBox(height: 15.w), - Expanded( - child: Container( - width: ScreenUtil().screenWidth, - padding: EdgeInsets.all(15.w), + SizedBox(height: 15.w), + Container( + height: 145.w, decoration: BoxDecoration( color: Colors.white, - borderRadius: BorderRadius.vertical( - top: Radius.circular(20.w), - ), + borderRadius: BorderRadius.circular(14.w), ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + child: Row( + mainAxisAlignment: MainAxisAlignment.start, children: [ - Text( - 'Continue Watching', - style: TextStyle( - fontSize: 18.sp, - color: Color(0xFF1E1E20), - fontWeight: FontWeight.w800, - fontStyle: FontStyle.italic, - ), - ), - Expanded( - child: ListView.separated( - padding: EdgeInsets.only(top: 10.w), - // shrinkWrap: true, - // physics: NeverScrollableScrollPhysics(), - itemBuilder: (context, index) { - KtHistoryVideoBean video = - state.historyList[index]; - return GestureDetector( - onTap: () => Get.toNamed( - KtRoutes.shortVideo, - arguments: { - 'shortPlayId': video.shortPlayId, - 'imageUrl': video.imageUrl ?? '', - }, - ), - child: Container( - color: Colors.transparent, - child: Row( - children: [ - KtNetworkImage( - imageUrl: video.imageUrl ?? '', - width: 74.w, - height: 98.w, - borderRadius: - BorderRadius.circular(8.w), - ), - SizedBox(width: 13.w), - SizedBox( - width: 200.w, - height: 98.w, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - Text( - video.name ?? '', - maxLines: 1, - overflow: - TextOverflow.ellipsis, - style: TextStyle( - fontSize: 13.sp, - color: Color(0xFF1E1E20), - fontWeight: - FontWeight.w500, - ), - ), - SizedBox(height: 6.w), - Text( - video.category?.first ?? '', - maxLines: 1, - overflow: - TextOverflow.ellipsis, - style: TextStyle( - fontSize: 10.sp, - color: Color(0xFF79C900), - fontWeight: - FontWeight.w400, - ), - ), - SizedBox(height: 20.w), - Row( - children: [ - SizedBox( - width: 26.w, - height: 26.w, - child: CircularProgressIndicator( - value: - (video.currentEpisode ?? - 0) / - (video.episodeTotal! > - 0 - ? video - .episodeTotal! - : 1), - backgroundColor: - Color(0xFFD9D9D9), - valueColor: - AlwaysStoppedAnimation< - Color - >( - Color( - 0xFFA7F62F, - ), - ), - strokeWidth: 3.w, - ), - ), - SizedBox(width: 5.w), - Text( - "${((video.currentEpisode ?? 0) / (video.episodeTotal! > 0 ? video.episodeTotal! : 1) * 100).toStringAsFixed(0)}%", - style: TextStyle( - fontSize: 12.sp, - color: Color( - 0xFF1E1E20, - ), - fontWeight: - FontWeight.w400, - ), - ), - ], - ), - ], - ), - ), - const Spacer(), - GestureDetector( - onTap: () => - logic.likeVideo(video), - child: Column( - children: [ - Image.asset( - video.isCollect == 1 - ? 'ic_collect_sel.png' - .ktIcon - : 'ic_collect_unsel.png' - .ktIcon, - width: 32.w, - ), - ], - ), - ), - ], + ...state.chestList.map( + (video) => Container( + margin: EdgeInsets.symmetric( + horizontal: 5.w, + ), + child: Stack( + children: [ + GestureDetector( + onTap: () => Get.toNamed( + KtRoutes.shortVideo, + arguments: { + 'shortPlayId': + video.shortPlayId, + 'imageUrl': + video.imageUrl ?? '', + }, + ), + child: KtNetworkImage( + imageUrl: video.imageUrl ?? '', + width: 100.w, + height: 133.w, + borderRadius: + BorderRadius.circular(6.w), ), ), - ); - }, - separatorBuilder: (_, __) => - SizedBox(height: 12.w), - itemCount: state.historyList.length, + Positioned( + right: 4.w, + top: 4.w, + child: GestureDetector( + onTap: () => + logic.cancelCollect( + video.shortPlayId!, + ), + child: Image.asset( + 'ic_collect_sel.png'.ktIcon, + width: 28.w, + ), + ), + ), + ], + ), ), ), ], ), ), + ], + ), + ), + SizedBox(height: 15.w), + Expanded( + child: Container( + width: ScreenUtil().screenWidth, + padding: EdgeInsets.all(15.w), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.vertical( + top: Radius.circular(20.w), ), - ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Continue Watching', + style: TextStyle( + fontSize: 18.sp, + color: Color(0xFF1E1E20), + fontWeight: FontWeight.w800, + fontStyle: FontStyle.italic, + ), + ), + Expanded( + child: ListView.separated( + padding: EdgeInsets.only(top: 10.w), + // shrinkWrap: true, + // physics: NeverScrollableScrollPhysics(), + itemBuilder: (context, index) { + KtHistoryVideoBean video = + state.historyList[index]; + return GestureDetector( + onTap: () => Get.toNamed( + KtRoutes.shortVideo, + arguments: { + 'shortPlayId': video.shortPlayId, + 'imageUrl': video.imageUrl ?? '', + }, + ), + child: Container( + color: Colors.transparent, + child: Row( + children: [ + KtNetworkImage( + imageUrl: video.imageUrl ?? '', + width: 74.w, + height: 98.w, + borderRadius: + BorderRadius.circular(8.w), + ), + SizedBox(width: 13.w), + SizedBox( + width: 200.w, + height: 98.w, + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + Text( + video.name ?? '', + maxLines: 1, + overflow: + TextOverflow.ellipsis, + style: TextStyle( + fontSize: 13.sp, + color: Color(0xFF1E1E20), + fontWeight: + FontWeight.w500, + ), + ), + SizedBox(height: 6.w), + Text( + video.category?.first ?? '', + maxLines: 1, + overflow: + TextOverflow.ellipsis, + style: TextStyle( + fontSize: 10.sp, + color: Color(0xFF79C900), + fontWeight: + FontWeight.w400, + ), + ), + SizedBox(height: 20.w), + Row( + children: [ + SizedBox( + width: 26.w, + height: 26.w, + child: CircularProgressIndicator( + value: + (video.currentEpisode ?? + 0) / + (video.episodeTotal! > + 0 + ? video + .episodeTotal! + : 1), + backgroundColor: + Color(0xFFD9D9D9), + valueColor: + AlwaysStoppedAnimation< + Color + >( + Color( + 0xFFA7F62F, + ), + ), + strokeWidth: 3.w, + ), + ), + SizedBox(width: 5.w), + Text( + "${((video.currentEpisode ?? 0) / (video.episodeTotal! > 0 ? video.episodeTotal! : 1) * 100).toStringAsFixed(0)}%", + style: TextStyle( + fontSize: 12.sp, + color: Color( + 0xFF1E1E20, + ), + fontWeight: + FontWeight.w400, + ), + ), + ], + ), + ], + ), + ), + const Spacer(), + GestureDetector( + onTap: () => + logic.likeVideo(video), + child: Column( + children: [ + Image.asset( + video.isCollect == 1 + ? 'ic_collect_sel.png' + .ktIcon + : 'ic_collect_unsel.png' + .ktIcon, + width: 32.w, + ), + ], + ), + ), + ], + ), + ), + ); + }, + separatorBuilder: (_, __) => + SizedBox(height: 12.w), + itemCount: state.historyList.length, + ), + ), + ], + ), ), ), + ], + ), + ), ); }, ); diff --git a/lib/kt_pages/kt_short_video/logic.dart b/lib/kt_pages/kt_short_video/logic.dart index e4d9752..68b3c93 100644 --- a/lib/kt_pages/kt_short_video/logic.dart +++ b/lib/kt_pages/kt_short_video/logic.dart @@ -1,4 +1,6 @@ import 'package:easy_debounce/easy_throttle.dart'; +import 'dart:io'; + import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_kinetra/kt_pages/kt_mine/logic.dart'; @@ -12,6 +14,7 @@ import 'package:video_player/video_player.dart'; import '../../dio_cilent/kt_apis.dart'; import '../../dio_cilent/kt_request.dart'; import '../../kt_model/kt_video_detail_bean.dart'; +import '../../kt_utils/kt_device_info_utils.dart'; import '../../kt_widgets/kt_status_widget.dart'; import '../../kt_widgets/kt_store_widget.dart'; import '../kt_mine/kt_store/logic.dart'; @@ -222,10 +225,17 @@ class VideoPlayLogic extends GetxController { if (controllers[index] != null) return; final episode = state.episodeList[index]; - final controller = VideoPlayerController.networkUrl( - Uri.parse(episode.videoUrl!), - formatHint: VideoFormat.hls, - ); + VideoPlayerController controller = + Platform.isAndroid && KtDeviceInfoUtil().osVersion == '10' + ? VideoPlayerController.networkUrl( + Uri.parse(episode.videoUrl!), + formatHint: VideoFormat.hls, + viewType: VideoViewType.platformView, + ) + : VideoPlayerController.networkUrl( + Uri.parse(episode.videoUrl!), + formatHint: VideoFormat.hls, + ); controllers[index] = controller;