fix:首页布局问题

This commit is contained in:
zengyi 2025-09-24 11:07:31 +08:00
parent 3f710173d3
commit 7120208013
2 changed files with 144 additions and 136 deletions

View File

@ -1,3 +1,5 @@
import 'dart:io';
import 'package:flutter_kinetra/kt_pages/kt_explore/state.dart';
import 'package:get/get.dart';
import 'package:easy_refresh/easy_refresh.dart';
@ -7,6 +9,7 @@ import 'package:video_player/video_player.dart';
import '../../dio_cilent/kt_apis.dart';
import '../../dio_cilent/kt_request.dart';
import '../../kt_model/kt_short_video_bean.dart';
import '../../kt_utils/kt_device_info_utils.dart';
import '../../kt_widgets/kt_status_widget.dart';
class KtExploreLogic extends GetxController {
@ -145,10 +148,17 @@ class KtExploreLogic extends GetxController {
if (index < 0 || index >= state.videoList.length) return;
if (state.controllers[index] != null) return;
final episode = state.videoList[index];
final controller = VideoPlayerController.networkUrl(
Uri.parse(episode.videoInfo!.videoUrl!),
formatHint: VideoFormat.hls,
);
VideoPlayerController controller =
Platform.isAndroid && KtDeviceInfoUtil().osVersion == '10'
? VideoPlayerController.networkUrl(
Uri.parse(episode.videoInfo!.videoUrl!),
formatHint: VideoFormat.hls,
viewType: VideoViewType.platformView,
)
: VideoPlayerController.networkUrl(
Uri.parse(episode.videoInfo!.videoUrl!),
formatHint: VideoFormat.hls,
);
state.controllers[index] = controller;

View File

@ -1030,146 +1030,144 @@ class _KtHomePageState extends State<KtHomePage>
),
SizedBox(height: 10.w),
if (state.topPickList.length > 3)
Expanded(
child: ListView.separated(
padding: EdgeInsets.zero,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: state.topPickList.length - 3,
itemBuilder: (BuildContext context, int index) {
KtShortVideoBean video = state.topPickList[index + 3];
return GestureDetector(
onTap: () => Get.toNamed(
KtRoutes.shortVideo,
arguments: {
'shortPlayId': video.shortPlayId,
'imageUrl': video.imageUrl ?? '',
},
ListView.separated(
padding: EdgeInsets.zero,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: state.topPickList.length - 3,
itemBuilder: (BuildContext context, int index) {
KtShortVideoBean video = state.topPickList[index + 3];
return GestureDetector(
onTap: () => Get.toNamed(
KtRoutes.shortVideo,
arguments: {
'shortPlayId': video.shortPlayId,
'imageUrl': video.imageUrl ?? '',
},
),
child: Container(
width: ScreenUtil().screenWidth - 30.w,
padding: EdgeInsets.all(10.w),
decoration: BoxDecoration(
color: Color(0xFFF5F5F5),
borderRadius: BorderRadius.circular(14.w),
),
child: Container(
width: ScreenUtil().screenWidth - 30.w,
padding: EdgeInsets.all(10.w),
decoration: BoxDecoration(
color: Color(0xFFF5F5F5),
borderRadius: BorderRadius.circular(14.w),
),
child: Row(
children: [
Stack(
clipBehavior: Clip.none,
alignment: Alignment.topLeft,
children: [
KtNetworkImage(
imageUrl: video.imageUrl ?? '',
width: 100.w,
height: 127.w,
borderRadius: BorderRadius.circular(12.w),
child: Row(
children: [
Stack(
clipBehavior: Clip.none,
alignment: Alignment.topLeft,
children: [
KtNetworkImage(
imageUrl: video.imageUrl ?? '',
width: 100.w,
height: 127.w,
borderRadius: BorderRadius.circular(12.w),
),
Container(
width: 24.w,
height: 24.w,
alignment: Alignment.center,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('top_other.png'.ktIcon),
fit: BoxFit.fill,
),
),
Container(
width: 24.w,
height: 24.w,
alignment: Alignment.center,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('top_other.png'.ktIcon),
fit: BoxFit.fill,
),
child: Text(
'${index + 4}',
style: TextStyle(
fontSize: 12.sp,
color: Colors.black,
fontWeight: FontWeight.w800,
fontStyle: FontStyle.italic,
),
child: Text(
'${index + 4}',
style: TextStyle(
fontSize: 12.sp,
color: Colors.black,
fontWeight: FontWeight.w800,
fontStyle: FontStyle.italic,
),
),
),
],
),
SizedBox(width: 12.w),
SizedBox(
width: 200.w,
height: 127.w,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
video.name ?? '',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14.sp,
fontWeight: FontWeight.w500,
color: Color(0xFF1E1E20),
),
),
Text(
video.categoryList?.first.name ?? '',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 12.sp,
fontWeight: FontWeight.w400,
color: Color(0xFF79C900),
),
),
Text(
video.description ?? '',
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 10.sp,
fontWeight: FontWeight.w400,
color: Color(0xFF5E5E5E),
),
),
Row(
children: [
Container(
padding: EdgeInsets.symmetric(
horizontal: 14.w,
vertical: 7.w,
),
decoration: BoxDecoration(
color: Color(0xFF1E1E20),
borderRadius: BorderRadius.circular(
100,
),
),
child: Row(
children: [
Image.asset(
'ic_top_play.png'.ktIcon,
width: 16.w,
),
SizedBox(width: 4.w),
Text(
'Play',
style: TextStyle(
fontSize: 12.sp,
fontWeight: FontWeight.w500,
color: Color(0xFFA7F62F),
),
),
],
),
),
],
),
],
),
SizedBox(width: 12.w),
SizedBox(
width: 200.w,
height: 127.w,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
video.name ?? '',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14.sp,
fontWeight: FontWeight.w500,
color: Color(0xFF1E1E20),
),
),
Text(
video.categoryList?.first.name ?? '',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 12.sp,
fontWeight: FontWeight.w400,
color: Color(0xFF79C900),
),
),
Text(
video.description ?? '',
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 10.sp,
fontWeight: FontWeight.w400,
color: Color(0xFF5E5E5E),
),
),
Row(
children: [
Container(
padding: EdgeInsets.symmetric(
horizontal: 14.w,
vertical: 7.w,
),
decoration: BoxDecoration(
color: Color(0xFF1E1E20),
borderRadius: BorderRadius.circular(
100,
),
),
child: Row(
children: [
Image.asset(
'ic_top_play.png'.ktIcon,
width: 16.w,
),
SizedBox(width: 4.w),
Text(
'Play',
style: TextStyle(
fontSize: 12.sp,
fontWeight: FontWeight.w500,
color: Color(0xFFA7F62F),
),
),
],
),
),
],
),
],
),
),
],
),
),
],
),
);
},
separatorBuilder: (_, __) => SizedBox(height: 10.w),
),
),
);
},
separatorBuilder: (_, __) => SizedBox(height: 10.w),
),
],
);