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 { plugins {
id("com.android.application") id("com.android.application")
id("kotlin-android") id("kotlin-android")

View File

@ -1,3 +1,5 @@
import 'dart:io';
import 'package:flutter_kinetra/kt_pages/kt_explore/state.dart'; import 'package:flutter_kinetra/kt_pages/kt_explore/state.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:easy_refresh/easy_refresh.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_apis.dart';
import '../../dio_cilent/kt_request.dart'; import '../../dio_cilent/kt_request.dart';
import '../../kt_model/kt_short_video_bean.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_widgets/kt_status_widget.dart';
import '../kt_main_page/view.dart';
class KtExploreLogic extends GetxController { class KtExploreLogic extends GetxController {
final state = KtExploreState(); final state = KtExploreState();
@ -145,7 +149,14 @@ class KtExploreLogic extends GetxController {
if (index < 0 || index >= state.videoList.length) return; if (index < 0 || index >= state.videoList.length) return;
if (state.controllers[index] != null) return; if (state.controllers[index] != null) return;
final episode = state.videoList[index]; 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!), Uri.parse(episode.videoInfo!.videoUrl!),
formatHint: VideoFormat.hls, formatHint: VideoFormat.hls,
); );
@ -155,7 +166,8 @@ class KtExploreLogic extends GetxController {
try { try {
await controller.initialize(); await controller.initialize();
if (index == state.currentPage) { if (index == state.currentPage) {
controller.play(); final mainLogic = Get.find<KtMainLogic>();
if(mainLogic.curIndex == 1) controller.play();
update(); update();
} }
controller.addListener(() { controller.addListener(() {

View File

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

View File

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

View File

@ -20,6 +20,7 @@ class KtMainPage extends StatefulWidget {
class _KtMainPageState extends State<KtMainPage> class _KtMainPageState extends State<KtMainPage>
with RouteAware, WidgetsBindingObserver { with RouteAware, WidgetsBindingObserver {
final logic = Get.put(KtMainLogic());
final PageController _controller = PageController(); final PageController _controller = PageController();
static const List _tabsTitle = [ static const List _tabsTitle = [
{'icon': 'home', 'title': 'Home'}, {'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( body: PageView.builder(
controller: _controller, controller: _controller,
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
onPageChanged: (index) { onPageChanged: (index) {
_currentIndex = index; _currentIndex = index;
logic.curIndex = index;
setState(() {}); setState(() {});
}, },
itemBuilder: (context, index) => _getTab(index), itemBuilder: (context, index) => _getTab(index),
@ -104,6 +108,7 @@ class _KtMainPageState extends State<KtMainPage>
currentIndex: _currentIndex, currentIndex: _currentIndex,
onTap: (index) { onTap: (index) {
_currentIndex = index; _currentIndex = index;
logic.curIndex = index;
_controller.jumpToPage(index); _controller.jumpToPage(index);
final myListLogic = Get.put(MyListLogic()); final myListLogic = Get.put(MyListLogic());
myListLogic.initData(); 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)); // EasyThrottle.throttle('restore', Duration(minutes: 5), () => BuyUtils.restorePay(showTips: false));
// } // }
} }
class KtMainLogic extends GetxController{
int curIndex = 0;
}