fix:首页布局问题

This commit is contained in:
zengyi 2025-09-24 11:34:52 +08:00
parent 311e4fe06c
commit ab042840b9
5 changed files with 380 additions and 358 deletions

View File

@ -1,3 +1,5 @@
import java.util.Properties
plugins {
id("com.android.application")
id("kotlin-android")

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,7 +9,9 @@ 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';
import '../kt_main_page/view.dart';
class KtExploreLogic extends GetxController {
final state = KtExploreState();
@ -145,7 +149,14 @@ 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(
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,
);
@ -155,7 +166,8 @@ class KtExploreLogic extends GetxController {
try {
await controller.initialize();
if (index == state.currentPage) {
controller.play();
final mainLogic = Get.find<KtMainLogic>();
if(mainLogic.curIndex == 1) controller.play();
update();
}
controller.addListener(() {

View File

@ -11,7 +11,6 @@ import '../../kt_widgets/kt_status_widget.dart';
class KtHomeLogic extends GetxController {
final state = KtHomeState();
late TabController categoryTabCtrl;
final EasyRefreshController easyRefreshController = EasyRefreshController(
controlFinishRefresh: true,

View File

@ -1030,8 +1030,7 @@ class _KtHomePageState extends State<KtHomePage>
),
SizedBox(height: 10.w),
if (state.topPickList.length > 3)
Expanded(
child: ListView.separated(
ListView.separated(
padding: EdgeInsets.zero,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
@ -1170,7 +1169,6 @@ class _KtHomePageState extends State<KtHomePage>
},
separatorBuilder: (_, __) => SizedBox(height: 10.w),
),
),
],
);
},

View File

@ -20,6 +20,7 @@ class KtMainPage extends StatefulWidget {
class _KtMainPageState extends State<KtMainPage>
with RouteAware, WidgetsBindingObserver {
final logic = Get.put(KtMainLogic());
final PageController _controller = PageController();
static const List _tabsTitle = [
{'icon': 'home', 'title': 'Home'},
@ -78,12 +79,15 @@ class _KtMainPageState extends State<KtMainPage>
}
}
},
child: Scaffold(
child: GetBuilder<KtMainLogic>(
builder: (ctrl) {
return Scaffold(
body: PageView.builder(
controller: _controller,
physics: const NeverScrollableScrollPhysics(),
onPageChanged: (index) {
_currentIndex = index;
logic.curIndex = index;
setState(() {});
},
itemBuilder: (context, index) => _getTab(index),
@ -104,6 +108,7 @@ class _KtMainPageState extends State<KtMainPage>
currentIndex: _currentIndex,
onTap: (index) {
_currentIndex = index;
logic.curIndex = index;
_controller.jumpToPage(index);
final myListLogic = Get.put(MyListLogic());
myListLogic.initData();
@ -133,6 +138,8 @@ class _KtMainPageState extends State<KtMainPage>
),
],
),
);
}
),
);
}
@ -331,3 +338,7 @@ class _KtMainPageState extends State<KtMainPage>
// EasyThrottle.throttle('restore', Duration(minutes: 5), () => BuyUtils.restorePay(showTips: false));
// }
}
class KtMainLogic extends GetxController{
int curIndex = 0;
}