Compare commits

...

6 Commits

Author SHA1 Message Date
214dd1225d fix:p30兼容 2025-09-24 15:43:35 +08:00
0fac8844dc fix:切换播放问题 2025-09-24 14:43:07 +08:00
96d6ef8f75 fix:切换播放问题 2025-09-24 11:37:15 +08:00
7120208013 fix:首页布局问题 2025-09-24 11:07:31 +08:00
3f710173d3 build.gradle.kts 2025-09-24 09:56:25 +08:00
f53777f26f feat:分类切换优化 2025-09-23 18:29:11 +08:00
8 changed files with 458 additions and 328 deletions

View File

@ -1,9 +1,16 @@
import java.util.Properties
plugins {
id("com.android.application")
id("kotlin-android")
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id("dev.flutter.flutter-gradle-plugin")
}
val signingProperties =
project.rootProject.file("key.properties").takeIf { it.exists() }
?.reader()
?.use { Properties().apply { load(it) } }
?: Properties()
android {
namespace = "com.kinetra.adehok.app"
@ -29,13 +36,44 @@ android {
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
ndk {
abiFilters.clear()
abiFilters.add("armeabi-v7a")
abiFilters.add("arm64-v8a")
}
}
signingConfigs {
create("release") {
storeFile = file(signingProperties["storeFile"].toString())
storePassword = signingProperties["storePassword"].toString()
keyAlias = signingProperties["keyAlias"].toString()
keyPassword = signingProperties["keyPassword"].toString()
}
}
splits {
abi {
isEnable = false
}
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig = signingConfigs.getByName("debug")
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
// 签名配置
signingConfig = signingConfigs.getByName("release")
}
debug {
signingConfig = signingConfigs.getByName("release")
}
}
}

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

@ -1,5 +1,6 @@
import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/material.dart';
import 'package:flutter_kinetra/kt_pages/kt_main_page/view.dart';
import 'package:flutter_kinetra/kt_utils/kt_string_extend.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
@ -28,6 +29,7 @@ class _KtExplorePageState extends State<KtExplorePage>
super.build(context);
return GetBuilder<KtExploreLogic>(
builder: (ctrl) {
if (Get.find<KtMainLogic>().curIndex != 1) return Container();
if (state.loadStatus == KtLoadStatusType.loadNoData ||
state.loadStatus == KtLoadStatusType.loadFailed) {
return KtStatusWidget(
@ -172,6 +174,20 @@ class _KtExplorePageState extends State<KtExplorePage>
),
),
),
if (videoPlayerController.value.isInitialized)
GestureDetector(
onTap: () {
videoPlayerController.value.isPlaying
? videoPlayerController.pause()
: videoPlayerController.play();
setState(() {});
},
child: Container(
width: ScreenUtil().screenWidth,
height: ScreenUtil().screenHeight,
color: Colors.transparent,
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.end,
@ -261,6 +277,7 @@ class _KtExplorePageState extends State<KtExplorePage>
child: Image.asset('ic_play.png'.ktIcon, width: 62.w),
),
),
],
),
),

View File

@ -1,4 +1,5 @@
import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/material.dart';
import 'package:flutter_kinetra/kt_model/kt_home_category_bean.dart';
import 'package:flutter_kinetra/kt_pages/kt_home/state.dart';
import 'package:get/get.dart';
@ -133,6 +134,7 @@ class KtHomeLogic extends GetxController {
}
getCategoryVideoList({bool isRefresh = false}) async {
state.categoryLoadStatus = KtLoadStatusType.loading;
if (isRefresh) {
state.pageIndex = 1;
state.categoryVideoList.clear();
@ -154,6 +156,7 @@ class KtHomeLogic extends GetxController {
easyRefreshController.finishRefresh();
easyRefreshController.finishLoad();
if (res.success) {
state.categoryLoadStatus = KtLoadStatusType.loadSuccess;
List<KtShortVideoBean> list = [
...res.data['list']
.map(
@ -165,6 +168,13 @@ class KtHomeLogic extends GetxController {
easyRefreshController.finishLoad(IndicatorResult.noMore);
}
state.categoryVideoList.addAll(list);
if (state.categoryVideoList.isEmpty) {
state.categoryLoadStatus = KtLoadStatusType.loadNoData;
}
update();
} else {
state.categoryLoadStatus = KtLoadStatusType.loadFailed;
update();
}
}

View File

@ -4,6 +4,7 @@ import '../../kt_widgets/kt_status_widget.dart';
class KtHomeState {
KtLoadStatusType loadStatus = KtLoadStatusType.loading;
KtLoadStatusType categoryLoadStatus = KtLoadStatusType.loading;
List<KtShortVideoBean> topPickList = [];
List<KtShortVideoBean> hotList = [];
List<KtShortVideoBean> arrivalList = [];

View File

@ -19,10 +19,11 @@ class KtHomePage extends StatefulWidget {
}
class _KtHomePageState extends State<KtHomePage>
with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin {
with TickerProviderStateMixin, AutomaticKeepAliveClientMixin {
final logic = Get.put(KtHomeLogic());
final state = Get.find<KtHomeLogic>().state;
late TabController tabCtrl;
TabController? categoryTabCtrl;
@override
Widget build(BuildContext context) {
@ -95,7 +96,7 @@ class _KtHomePageState extends State<KtHomePage>
child: Text(
'Get Hooked in Seconds',
style: TextStyle(
fontSize: 12.sp,
fontSize: 11.sp,
fontWeight: FontWeight.w600,
fontStyle: FontStyle.italic,
color: Colors.white,
@ -132,7 +133,9 @@ class _KtHomePageState extends State<KtHomePage>
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
GestureDetector(
onTap: () => Get.toNamed(KtRoutes.search),
child: Row(
children: [
Stack(
alignment: Alignment.bottomCenter,
@ -151,6 +154,7 @@ class _KtHomePageState extends State<KtHomePage>
Image.asset('ic_right.png'.ktIcon, width: 10.w),
],
),
),
SizedBox(height: 5.w),
Text(
'Everyone\'s Watching',
@ -162,7 +166,7 @@ class _KtHomePageState extends State<KtHomePage>
),
],
),
SizedBox(width: 17.w),
SizedBox(width: 15.w),
Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
@ -180,7 +184,7 @@ class _KtHomePageState extends State<KtHomePage>
child: Row(
children: [
Image.asset('ic_star.png'.ktIcon, width: 14.w),
SizedBox(width: 4.w),
SizedBox(width: 3.w),
SizedBox(
width: 162.w,
child: Text(
@ -253,7 +257,7 @@ class _KtHomePageState extends State<KtHomePage>
SizedBox(width: 4.w),
],
),
SizedBox(height: 9.w),
SizedBox(height: 8.w),
SizedBox(
height: 117.w,
child: ListView.separated(
@ -532,9 +536,10 @@ class _KtHomePageState extends State<KtHomePage>
KtHomeCategoryBean item = state.categoryList[index];
return GestureDetector(
onTap: () {
if (state.selCategoryId == item.categoryId!) return;
state.selCategoryId = item.categoryId!;
categoryTabCtrl?.animateTo(state.categoryList.indexOf(item));
logic.getCategoryVideoList(isRefresh: true);
logic.update(['category-items']);
},
child: Container(
width: (ScreenUtil().screenWidth - 42.w) / 3,
@ -550,8 +555,13 @@ class _KtHomePageState extends State<KtHomePage>
)
: null,
),
child: SizedBox(
width: ((ScreenUtil().screenWidth - 42.w) / 3) - 4.w,
child: Text(
textAlign: TextAlign.center,
item.categoryName ?? '',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xFF1E1E20),
@ -561,6 +571,7 @@ class _KtHomePageState extends State<KtHomePage>
),
),
),
),
);
},
separatorBuilder: (_, __) => SizedBox(width: 6.w),
@ -583,7 +594,21 @@ class _KtHomePageState extends State<KtHomePage>
// return [hotRisingView(), topChartView(), freshDropView()][state.typeList
// .indexOf(state.selType)];
} else {
return categoryVideoView();
categoryTabCtrl ??= TabController(
length: state.categoryList.length,
vsync: this,
);
return Expanded(
child: TabBarView(
controller: categoryTabCtrl,
physics: NeverScrollableScrollPhysics(),
children: List.generate(
state.categoryList.length,
(index) => categoryVideoView(index),
),
),
);
}
}
@ -1011,8 +1036,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(),
@ -1151,7 +1175,6 @@ class _KtHomePageState extends State<KtHomePage>
},
separatorBuilder: (_, __) => SizedBox(height: 10.w),
),
),
],
);
},
@ -1438,11 +1461,12 @@ class _KtHomePageState extends State<KtHomePage>
);
}
Widget categoryVideoView() {
Widget categoryVideoView(int index) {
return GetBuilder<KtHomeLogic>(
id: 'category-list',
key: ValueKey('category-$index'),
builder: (ctrl) {
if (state.categoryVideoList.isEmpty) {
if (state.categoryLoadStatus == KtLoadStatusType.loadNoData) {
return KtStatusWidget(
type: KtErrorStatusType.nothingYet,
onPressed: logic.getCategoryVideoList,
@ -1541,6 +1565,7 @@ class _KtHomePageState extends State<KtHomePage>
@override
void dispose() {
tabCtrl.dispose();
categoryTabCtrl?.dispose();
super.dispose();
}
}

View File

@ -1,11 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_kinetra/kt_pages/kt_actor/kt_actor_page.dart';
import 'package:flutter_kinetra/kt_pages/kt_explore/logic.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_utils/kt_keys.dart';
import '../kt_explore/view.dart';
import '../kt_home/view.dart';
import '../kt_mine/view.dart';
@ -21,11 +21,12 @@ 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'},
{'icon': 'explore', 'title': 'Explore'},
{'icon': 'actor', 'title': 'Actor'},
{'icon': 'actor', 'title': 'Actors'},
{'icon': 'favorite', 'title': 'My List'},
{'icon': 'mine', 'title': 'Profile'},
];
@ -79,12 +80,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),
@ -105,9 +109,15 @@ class _KtMainPageState extends State<KtMainPage>
currentIndex: _currentIndex,
onTap: (index) {
_currentIndex = index;
logic.curIndex = index;
_controller.jumpToPage(index);
if (index == 3) {
final myListLogic = Get.put(MyListLogic());
myListLogic.initData();
} else if (index == 1) {
final exploreLogic = Get.put(KtExploreLogic());
exploreLogic.update();
}
},
items: [
..._tabsTitle.map(
@ -134,6 +144,8 @@ class _KtMainPageState extends State<KtMainPage>
),
],
),
);
},
),
);
}
@ -332,3 +344,7 @@ class _KtMainPageState extends State<KtMainPage>
// EasyThrottle.throttle('restore', Duration(minutes: 5), () => BuyUtils.restorePay(showTips: false));
// }
}
class KtMainLogic extends GetxController {
int curIndex = 0;
}

View File

@ -1,3 +1,4 @@
import 'dart:io';
import 'dart:ui';
import 'package:flutter/material.dart';
@ -8,6 +9,7 @@ import 'package:get/get.dart';
import 'package:video_player/video_player.dart';
import 'package:visibility_detector/visibility_detector.dart';
import '../../kt_model/kt_video_detail_bean.dart';
import '../../kt_widgets/kt_network_image.dart';
import '../../kt_widgets/kt_status_widget.dart';
import '../../kt_widgets/kt_video_progress_bar.dart';
@ -200,7 +202,19 @@ class _VideoPlayPageState extends State<VideoPlayPage>
if (!isAllOver) Center(child: CircularProgressIndicator()),
],
),
if (controller != null && controller.value.isInitialized && !isAllOver)
GestureDetector(
onTap: () {
// if (episode.isLock == true) return;
controller.value.isPlaying ? controller.pause() : controller.play();
setState(() {});
},
child: Container(
width: ScreenUtil().screenWidth,
height: ScreenUtil().screenHeight,
color: Colors.transparent,
),
),
// if (episode.isLock == true)
// Container(
// width: ScreenUtil().screenWidth,
@ -262,18 +276,24 @@ class _VideoPlayPageState extends State<VideoPlayPage>
Positioned(
bottom: 0,
left: 0.w,
child: Container(
child: Platform.isAndroid
? SafeArea(child: bottomView(index))
: bottomView(index),
),
],
);
}
Widget bottomView(int index) {
return Container(
width: ScreenUtil().screenWidth,
padding: EdgeInsets.fromLTRB(15.w, 40.w, 15.w, 40.w),
padding: EdgeInsets.fromLTRB(15.w, 40.w, 15.w, 50.w),
alignment: Alignment.bottomCenter,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Color(0xFF001D1F).withValues(alpha: 0),
Color(0xFF001D1F),
],
colors: [Color(0xFF001D1F).withValues(alpha: 0), Color(0xFF001D1F)],
),
),
child: Column(
@ -319,18 +339,12 @@ class _VideoPlayPageState extends State<VideoPlayPage>
SizedBox(width: 6.w),
Text(
'EP.${index + 1}',
style: TextStyle(
fontSize: 13.sp,
color: Colors.white,
),
style: TextStyle(fontSize: 13.sp, color: Colors.white),
),
const Spacer(),
Text(
'All ${state.video?.shortPlayInfo?.episodeTotal ?? 0} Episodes',
style: TextStyle(
fontSize: 13.sp,
color: Colors.white,
),
style: TextStyle(fontSize: 13.sp, color: Colors.white),
),
],
),
@ -358,9 +372,6 @@ class _VideoPlayPageState extends State<VideoPlayPage>
),
],
),
),
),
],
);
}