Compare commits

..

No commits in common. "f22c893932f9befe41a790221dffd3fd13999f42" and "bd65038cfc9184b0cdc5c049676e039c3f2cbcd9" have entirely different histories.

6 changed files with 280 additions and 269 deletions

View File

View File

View File

@ -3,12 +3,10 @@ import 'package:flutter/services.dart';
import 'package:flutter_kinetra/kt_pages/kt_actor/kt_actor_page.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_kinetra/kt_utils/kt_string_extend.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import '../kt_explore/view.dart'; import '../kt_explore/view.dart';
import '../kt_home/view.dart'; import '../kt_home/view.dart';
import '../kt_mine/view.dart'; import '../kt_mine/view.dart';
import '../kt_my_list/logic.dart';
import '../kt_my_list/view.dart'; import '../kt_my_list/view.dart';
class KtMainPage extends StatefulWidget { class KtMainPage extends StatefulWidget {
@ -105,8 +103,13 @@ class _KtMainPageState extends State<KtMainPage>
onTap: (index) { onTap: (index) {
_currentIndex = index; _currentIndex = index;
_controller.jumpToPage(index); _controller.jumpToPage(index);
final myListLogic = Get.put(MyListLogic()); // final recommendLogic = Get.put(RecommendLogic());
myListLogic.initData(); // if (index != 1) {
// recommendLogic.videoCtrl?.pause();
// } else {
// recommendLogic.videoCtrl?.play();
// }
// recommendLogic.update();
}, },
items: [ items: [
..._tabsTitle.map( ..._tabsTitle.map(

View File

@ -125,7 +125,25 @@ class MyListLogic extends GetxController {
"video_id": video.shortPlayVideoId, "video_id": video.shortPlayVideoId,
}; };
if (video.isCollect == 1) { if (video.isCollect == 1) {
cancelCollect(video.shortPlayId!); 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();
}
},
),
);
} else { } else {
ApiResponse res = await KtHttpClient().request( ApiResponse res = await KtHttpClient().request(
KtApis.collectVideo, KtApis.collectVideo,
@ -152,7 +170,7 @@ class MyListLogic extends GetxController {
queryParameters: {'short_play_id': id}, queryParameters: {'short_play_id': id},
); );
if (res.success) { 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.chestList.removeWhere((item) => id == item.shortPlayId);
state.historyList state.historyList
.firstWhereOrNull((item) => id == item.shortPlayId) .firstWhereOrNull((item) => id == item.shortPlayId)

View File

@ -26,7 +26,7 @@ class _KtMyListPageState extends State<KtMyListPage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GetBuilder<MyListLogic>( return GetBuilder<MyListLogic>(
builder: (ctrl) { builder: (ctrl) {
// if (state.loadStatus == KtLoadStatusType.loading) return Center(child: CircularProgressIndicator()); if (state.loadStatus == KtLoadStatusType.loading) return Container();
return Container( return Container(
width: ScreenUtil().screenWidth, width: ScreenUtil().screenWidth,
height: ScreenUtil().screenHeight, height: ScreenUtil().screenHeight,
@ -39,286 +39,286 @@ class _KtMyListPageState extends State<KtMyListPage> {
), ),
child: state.chestList.isEmpty && state.historyList.isEmpty child: state.chestList.isEmpty && state.historyList.isEmpty
? KtStatusWidget( ? KtStatusWidget(
type: KtErrorStatusType.nothingYet, type: KtErrorStatusType.nothingYet,
onPressed: logic.initData, onPressed: logic.initData,
) )
: SmartRefresher( : SmartRefresher(
controller: logic.refreshCtrl, controller: logic.refreshCtrl,
enablePullUp: true, enablePullUp: true,
enablePullDown: true, enablePullDown: true,
onRefresh: () => logic.initData(), onRefresh: () => logic.initData(),
onLoading: () => logic.getHistoryList(loadMore: true), onLoading: () => logic.getHistoryList(loadMore: true),
child: Column( child: Column(
children: [ children: [
if (state.chestList.isNotEmpty) if (state.chestList.isNotEmpty)
Container( Container(
width: ScreenUtil().screenWidth - 30.w, width: ScreenUtil().screenWidth - 30.w,
padding: EdgeInsets.fromLTRB(6.w, 53.w, 6.w, 6.w), padding: EdgeInsets.fromLTRB(6.w, 53.w, 6.w, 6.w),
decoration: BoxDecoration( decoration: BoxDecoration(
image: DecorationImage( image: DecorationImage(
image: AssetImage('collect_bg.png'.ktIcon), image: AssetImage('collect_bg.png'.ktIcon),
fit: BoxFit.fill, 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,
),
), ),
const Spacer(), ),
GestureDetector( child: Column(
onTap: () => Get.to(KtMyChestPage()), children: [
child: Row( Row(
children: [ children: [
SizedBox(width: 6.w),
Text( Text(
'View All', 'My Treasure Chest',
style: TextStyle( style: TextStyle(
fontSize: 12.sp, fontSize: 18.sp,
color: Color(0xFFD6D6D6), color: Colors.white,
fontWeight: FontWeight.w800,
fontStyle: FontStyle.italic,
), ),
), ),
Image.asset( const Spacer(),
'ic_right_white.png'.ktIcon, GestureDetector(
width: 10.w, onTap: () => Get.to(KtMyChestPage()),
), child: Row(
SizedBox(width: 6.w), children: [
], Text(
), 'View All',
), style: TextStyle(
], fontSize: 12.sp,
), color: Color(0xFFD6D6D6),
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,
), ),
), ),
), 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(
SizedBox(height: 15.w), width: ScreenUtil().screenWidth,
Expanded( padding: EdgeInsets.all(15.w),
child: Container( decoration: BoxDecoration(
width: ScreenUtil().screenWidth, color: Colors.white,
padding: EdgeInsets.all(15.w), borderRadius: BorderRadius.vertical(
decoration: BoxDecoration( top: Radius.circular(20.w),
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,
), ),
), child: Column(
Expanded( crossAxisAlignment: CrossAxisAlignment.start,
child: ListView.separated( children: [
padding: EdgeInsets.only(top: 10.w), Text(
// shrinkWrap: true, 'Continue Watching',
// physics: NeverScrollableScrollPhysics(), style: TextStyle(
itemBuilder: (context, index) { fontSize: 18.sp,
KtHistoryVideoBean video = color: Color(0xFF1E1E20),
state.historyList[index]; fontWeight: FontWeight.w800,
return GestureDetector( fontStyle: FontStyle.italic,
onTap: () => Get.toNamed(
KtRoutes.shortVideo,
arguments: {
'shortPlayId': video.shortPlayId,
'imageUrl': video.imageUrl ?? '',
},
), ),
child: Container( ),
color: Colors.transparent, Expanded(
child: Row( child: ListView.separated(
children: [ padding: EdgeInsets.only(top: 10.w),
KtNetworkImage( // shrinkWrap: true,
imageUrl: video.imageUrl ?? '', // physics: NeverScrollableScrollPhysics(),
width: 74.w, itemBuilder: (context, index) {
height: 98.w, KtHistoryVideoBean video =
borderRadius: state.historyList[index];
BorderRadius.circular(8.w), return GestureDetector(
onTap: () => Get.toNamed(
KtRoutes.shortVideo,
arguments: {
'shortPlayId': video.shortPlayId,
'imageUrl': video.imageUrl ?? '',
},
), ),
SizedBox(width: 13.w), child: Container(
SizedBox( color: Colors.transparent,
width: 200.w, child: Row(
height: 98.w,
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment.start,
children: [ children: [
Text( KtNetworkImage(
video.name ?? '', imageUrl: video.imageUrl ?? '',
maxLines: 1, width: 74.w,
overflow: height: 98.w,
TextOverflow.ellipsis, borderRadius:
style: TextStyle( BorderRadius.circular(8.w),
fontSize: 13.sp,
color: Color(0xFF1E1E20),
fontWeight:
FontWeight.w500,
),
), ),
SizedBox(height: 6.w), SizedBox(width: 13.w),
Text( SizedBox(
video.category?.first ?? '', width: 200.w,
maxLines: 1, height: 98.w,
overflow: child: Column(
TextOverflow.ellipsis, crossAxisAlignment:
style: TextStyle( CrossAxisAlignment.start,
fontSize: 10.sp, mainAxisAlignment:
color: Color(0xFF79C900), MainAxisAlignment.start,
fontWeight: children: [
FontWeight.w400, Text(
), video.name ?? '',
), maxLines: 1,
SizedBox(height: 20.w), overflow:
Row( TextOverflow.ellipsis,
children: [ style: TextStyle(
SizedBox( fontSize: 13.sp,
width: 26.w, color: Color(0xFF1E1E20),
height: 26.w, fontWeight:
child: CircularProgressIndicator( FontWeight.w500,
value: ),
(video.currentEpisode ?? ),
0) / SizedBox(height: 6.w),
(video.episodeTotal! > Text(
0 video.category?.first ?? '',
? video maxLines: 1,
.episodeTotal! overflow:
: 1), TextOverflow.ellipsis,
backgroundColor: style: TextStyle(
Color(0xFFD9D9D9), fontSize: 10.sp,
valueColor: color: Color(0xFF79C900),
AlwaysStoppedAnimation< fontWeight:
Color FontWeight.w400,
>( ),
Color( ),
0xFFA7F62F, 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),
strokeWidth: 3.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,
),
),
],
), ),
), ],
SizedBox(width: 5.w), ),
Text( ),
"${((video.currentEpisode ?? 0) / (video.episodeTotal! > 0 ? video.episodeTotal! : 1) * 100).toStringAsFixed(0)}%", const Spacer(),
style: TextStyle( GestureDetector(
fontSize: 12.sp, onTap: () =>
color: Color( logic.likeVideo(video),
0xFF1E1E20, child: Column(
), children: [
fontWeight: Image.asset(
FontWeight.w400, video.isCollect == 1
? 'ic_collect_sel.png'
.ktIcon
: 'ic_collect_unsel.png'
.ktIcon,
width: 32.w,
), ),
), ],
], ),
), ),
], ],
), ),
), ),
const Spacer(), );
GestureDetector( },
onTap: () => separatorBuilder: (_, __) =>
logic.likeVideo(video), SizedBox(height: 12.w),
child: Column( itemCount: state.historyList.length,
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,
), ),
), ),
], ),
), ],
), ),
), ),
],
),
),
); );
}, },
); );

View File

@ -1,6 +1,4 @@
import 'package:easy_debounce/easy_throttle.dart'; import 'package:easy_debounce/easy_throttle.dart';
import 'dart:io';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_kinetra/kt_pages/kt_mine/logic.dart'; import 'package:flutter_kinetra/kt_pages/kt_mine/logic.dart';
@ -14,7 +12,6 @@ import 'package:video_player/video_player.dart';
import '../../dio_cilent/kt_apis.dart'; import '../../dio_cilent/kt_apis.dart';
import '../../dio_cilent/kt_request.dart'; import '../../dio_cilent/kt_request.dart';
import '../../kt_model/kt_video_detail_bean.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_status_widget.dart';
import '../../kt_widgets/kt_store_widget.dart'; import '../../kt_widgets/kt_store_widget.dart';
import '../kt_mine/kt_store/logic.dart'; import '../kt_mine/kt_store/logic.dart';
@ -225,17 +222,10 @@ class VideoPlayLogic extends GetxController {
if (controllers[index] != null) return; if (controllers[index] != null) return;
final episode = state.episodeList[index]; final episode = state.episodeList[index];
VideoPlayerController controller = final controller = VideoPlayerController.networkUrl(
Platform.isAndroid && KtDeviceInfoUtil().osVersion == '10' Uri.parse(episode.videoUrl!),
? VideoPlayerController.networkUrl( formatHint: VideoFormat.hls,
Uri.parse(episode.videoUrl!), );
formatHint: VideoFormat.hls,
viewType: VideoViewType.platformView,
)
: VideoPlayerController.networkUrl(
Uri.parse(episode.videoUrl!),
formatHint: VideoFormat.hls,
);
controllers[index] = controller; controllers[index] = controller;