feat:安卓一期无支付
This commit is contained in:
parent
82d17e7dd8
commit
0ccd305d72
@ -3,11 +3,13 @@ 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_utils/kt_keys.dart';
|
import '../../kt_utils/kt_keys.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 {
|
||||||
@ -104,13 +106,8 @@ class _KtMainPageState extends State<KtMainPage>
|
|||||||
onTap: (index) {
|
onTap: (index) {
|
||||||
_currentIndex = index;
|
_currentIndex = index;
|
||||||
_controller.jumpToPage(index);
|
_controller.jumpToPage(index);
|
||||||
// final recommendLogic = Get.put(RecommendLogic());
|
final myListLogic = Get.put(MyListLogic());
|
||||||
// if (index != 1) {
|
myListLogic.initData();
|
||||||
// recommendLogic.videoCtrl?.pause();
|
|
||||||
// } else {
|
|
||||||
// recommendLogic.videoCtrl?.play();
|
|
||||||
// }
|
|
||||||
// recommendLogic.update();
|
|
||||||
},
|
},
|
||||||
items: [
|
items: [
|
||||||
..._tabsTitle.map(
|
..._tabsTitle.map(
|
||||||
|
@ -0,0 +1,279 @@
|
|||||||
|
import 'dart:collection';
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:flustars/flustars.dart' hide ScreenUtil;
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_image_compress/flutter_image_compress.dart';
|
||||||
|
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||||
|
import 'package:flutter_kinetra/kt_utils/kt_string_extend.dart';
|
||||||
|
import 'package:flutter_kinetra/kt_utils/kt_utils.dart';
|
||||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:image_picker/image_picker.dart';
|
||||||
|
|
||||||
|
import '../../../dio_cilent/kt_apis.dart';
|
||||||
|
import '../../../kt_utils/kt_keys.dart';
|
||||||
|
import '../../../kt_widgets/kt_status_widget.dart';
|
||||||
|
import '../../../main.dart';
|
||||||
|
import '../../kt_routes.dart';
|
||||||
|
class KtKtHelpCenterDetailPage extends StatefulWidget {
|
||||||
|
const KtKtHelpCenterDetailPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<KtKtHelpCenterDetailPage> createState() => _KtKtHelpCenterDetailScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _KtKtHelpCenterDetailScreenState extends State<KtKtHelpCenterDetailPage> {
|
||||||
|
late String id;
|
||||||
|
|
||||||
|
InAppWebViewController? _webViewController;
|
||||||
|
final ImagePicker _imgPicker = ImagePicker();
|
||||||
|
late Map<String, String> _userData;
|
||||||
|
KtLoadStatusType loadingStatus = KtLoadStatusType.loading;
|
||||||
|
static const String _androidInterfaceJs = """
|
||||||
|
window.AndroidInterface = {
|
||||||
|
getUserInfo: async function () {
|
||||||
|
return window.flutter_inappwebview.callHandler('getUserInfo');
|
||||||
|
},
|
||||||
|
openPhotoPicker: function () {
|
||||||
|
return window.flutter_inappwebview.callHandler('openPhotoPicker');
|
||||||
|
},
|
||||||
|
uploadConvertImage: function () {
|
||||||
|
return window.flutter_inappwebview.callHandler('uploadConvertImage');
|
||||||
|
},
|
||||||
|
};
|
||||||
|
""";
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
id = Get.arguments['id'];
|
||||||
|
super.initState();
|
||||||
|
_initUserData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_webViewController?.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _initUserData() {
|
||||||
|
_userData = {
|
||||||
|
'id': id,
|
||||||
|
'time_zone': KtUtils.getTimeZoneOffset(DateTime.now()),
|
||||||
|
'type': Platform.isAndroid ? 'android' : 'ios',
|
||||||
|
'lang': 'en',
|
||||||
|
'theme': 'theme_2',
|
||||||
|
'token': SpUtil.getString(KtKeys.token) ?? '',
|
||||||
|
'application': 'flutter',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handlePhotoPicker() async {
|
||||||
|
final XFile? image = await _imgPicker.pickImage(source: ImageSource.gallery);
|
||||||
|
if (image == null) return;
|
||||||
|
File imageFile = File(image.path);
|
||||||
|
final File compressedImage = await _compressToTargetSize(imageFile, 1024 * 1024);
|
||||||
|
final bytes = await compressedImage.readAsBytes();
|
||||||
|
final base64Data = base64Encode(bytes);
|
||||||
|
final data = base64Data;
|
||||||
|
final js =
|
||||||
|
'''
|
||||||
|
if (typeof window.onImagePicked === 'function') {
|
||||||
|
window.onImagePicked("$data");
|
||||||
|
}
|
||||||
|
''';
|
||||||
|
_webViewController?.evaluateJavascript(source: js);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<File> _compressToTargetSize(File file, int targetSize) async {
|
||||||
|
int quality = 90;
|
||||||
|
File compressed = file;
|
||||||
|
while ((await compressed.length()) > targetSize && quality > 10) {
|
||||||
|
final result = await FlutterImageCompress.compressWithFile(file.absolute.path, quality: quality);
|
||||||
|
if (result == null) break;
|
||||||
|
compressed = File('${file.parent.path}/compressed_${DateTime.now().millisecondsSinceEpoch}.jpg')
|
||||||
|
..writeAsBytesSync(result);
|
||||||
|
quality -= 10;
|
||||||
|
}
|
||||||
|
return compressed;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handlePhotoUpload(String base64Str) async {
|
||||||
|
debugPrint("收到 base64 图片数据:$base64Str");
|
||||||
|
await _webViewController?.evaluateJavascript(
|
||||||
|
source:
|
||||||
|
'''
|
||||||
|
if (window.uploadConvertImage) {
|
||||||
|
window.uploadConvertImage("$base64Str");
|
||||||
|
} else {
|
||||||
|
console.error("H5 没有定义 window.uploadConvertImage");
|
||||||
|
}
|
||||||
|
''',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildWidget() {
|
||||||
|
switch (loadingStatus) {
|
||||||
|
case KtLoadStatusType.loading:
|
||||||
|
return const Center(child: CircularProgressIndicator());
|
||||||
|
case KtLoadStatusType.loadFailed:
|
||||||
|
return KtStatusWidget(
|
||||||
|
type: KtErrorStatusType.noNetwork,
|
||||||
|
onPressed: () {
|
||||||
|
_webViewController?.loadUrl(urlRequest: URLRequest(url: WebUri(KtApis.WEB_SITE_FEEDBACK_DETAIL)));
|
||||||
|
},
|
||||||
|
);
|
||||||
|
case KtLoadStatusType.loadNoData:
|
||||||
|
return KtStatusWidget(
|
||||||
|
type: KtErrorStatusType.notFound,
|
||||||
|
onPressed: () {
|
||||||
|
_webViewController?.reload();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _registerJsHandlers(InAppWebViewController controller) {
|
||||||
|
controller.addJavaScriptHandler(handlerName: 'getUserInfo', callback: (args) => jsonEncode(_userData));
|
||||||
|
controller.addJavaScriptHandler(handlerName: 'openPhotoPicker', callback: (args) => _handlePhotoPicker());
|
||||||
|
controller.addJavaScriptHandler(
|
||||||
|
handlerName: 'uploadConvertImage',
|
||||||
|
callback: (args) {
|
||||||
|
if (args.isNotEmpty && args[0] is String) {
|
||||||
|
_handlePhotoUpload(args[0] as String);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _registerIosMessageHandlers(InAppWebViewController controller) async {
|
||||||
|
await controller.addWebMessageListener(
|
||||||
|
WebMessageListener(
|
||||||
|
jsObjectName: "openPhotoPicker",
|
||||||
|
allowedOriginRules: {"*"},
|
||||||
|
onPostMessage: (message, origin, isMainFrame, replyProxy) {
|
||||||
|
_handlePhotoPicker();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
extendBodyBehindAppBar: true,
|
||||||
|
body: Container(
|
||||||
|
width: ScreenUtil().screenWidth,
|
||||||
|
height: ScreenUtil().screenHeight,
|
||||||
|
padding: EdgeInsets.only(top: ScreenUtil().statusBarHeight),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
image: DecorationImage(image: AssetImage('bg1.png'.ktIcon), fit: BoxFit.fill),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
_buildAppBar(context),
|
||||||
|
Expanded(
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
InAppWebView(
|
||||||
|
initialSettings: InAppWebViewSettings(
|
||||||
|
javaScriptEnabled: true,
|
||||||
|
mediaPlaybackRequiresUserGesture: false,
|
||||||
|
allowsInlineMediaPlayback: true,
|
||||||
|
cacheEnabled: false,
|
||||||
|
clearCache: true,
|
||||||
|
domStorageEnabled: false,
|
||||||
|
transparentBackground: true,
|
||||||
|
),
|
||||||
|
initialUserScripts: UnmodifiableListView<UserScript>([
|
||||||
|
UserScript(source: _androidInterfaceJs, injectionTime: UserScriptInjectionTime.AT_DOCUMENT_START),
|
||||||
|
]),
|
||||||
|
onWebViewCreated: (controller) async {
|
||||||
|
_webViewController = controller;
|
||||||
|
_registerJsHandlers(controller);
|
||||||
|
if (Platform.isIOS) {
|
||||||
|
await _registerIosMessageHandlers(controller);
|
||||||
|
}
|
||||||
|
await controller.loadUrl(urlRequest: URLRequest(url: WebUri(KtApis.WEB_SITE_FEEDBACK_DETAIL)));
|
||||||
|
},
|
||||||
|
onLoadStop: (controller, url) async {
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
await controller.evaluateJavascript(source: _androidInterfaceJs);
|
||||||
|
} else if (Platform.isIOS) {
|
||||||
|
String userString = jsonEncode(_userData);
|
||||||
|
Future.delayed(const Duration(seconds: 1)).then((_) {
|
||||||
|
controller.evaluateJavascript(
|
||||||
|
source:
|
||||||
|
"""
|
||||||
|
if (typeof window.receiveDataFromNative === 'function') {
|
||||||
|
window.receiveDataFromNative($userString);
|
||||||
|
}
|
||||||
|
""",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
await controller.evaluateJavascript(
|
||||||
|
source: """
|
||||||
|
window.onImagePicked = function(data) {
|
||||||
|
window.flutter_inappwebview.callHandler('uploadConvertImage', data);
|
||||||
|
};
|
||||||
|
""",
|
||||||
|
);
|
||||||
|
loadingStatus = KtLoadStatusType.loadSuccess;
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
onLoadStart: (controller, url) {
|
||||||
|
loadingStatus = KtLoadStatusType.loading;
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
onReceivedError: (controller, request, error) {
|
||||||
|
Future.delayed(const Duration(milliseconds: 500)).then((_) {
|
||||||
|
loadingStatus = KtLoadStatusType.loadFailed;
|
||||||
|
setState(() {});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onPageCommitVisible: (controller, uri) {
|
||||||
|
if (loadingStatus == KtLoadStatusType.loadFailed) {
|
||||||
|
controller.loadData(data: "<html></html>");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
_buildWidget(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildAppBar(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 15.w),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
GestureDetector(
|
||||||
|
child: SizedBox(
|
||||||
|
width: 29.w,
|
||||||
|
child: Center(
|
||||||
|
child: Image.asset('ic_back.png'.ktIcon, width: 10.w),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: () => Navigator.of(context).maybePop(),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Help Center',
|
||||||
|
style: TextStyle(fontSize: 16.sp, fontWeight: FontWeight.w500, color: Colors.black),
|
||||||
|
),
|
||||||
|
Container(width: 24.w),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,254 @@
|
|||||||
|
import 'dart:collection';
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:flustars/flustars.dart' hide ScreenUtil;
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||||
|
import 'package:flutter_kinetra/kt_utils/kt_string_extend.dart';
|
||||||
|
import 'package:flutter_kinetra/kt_utils/kt_utils.dart';
|
||||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
import '../../../dio_cilent/kt_apis.dart';
|
||||||
|
import '../../../kt_utils/kt_keys.dart';
|
||||||
|
import '../../../kt_widgets/kt_status_widget.dart';
|
||||||
|
import '../../../main.dart';
|
||||||
|
import '../../kt_routes.dart';
|
||||||
|
|
||||||
|
class KtHelpCenterListPage extends StatefulWidget {
|
||||||
|
const KtHelpCenterListPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<KtHelpCenterListPage> createState() => _KtHelpCenterListPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _KtHelpCenterListPageState extends State<KtHelpCenterListPage> with RouteAware, AutomaticKeepAliveClientMixin {
|
||||||
|
InAppWebViewController? _webViewController;
|
||||||
|
late Map<String, String> _userData;
|
||||||
|
|
||||||
|
KtLoadStatusType loadingStatus = KtLoadStatusType.loading;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_initUserData();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _initUserData() {
|
||||||
|
_userData = {
|
||||||
|
'time_zone': KtUtils.getTimeZoneOffset(DateTime.now()),
|
||||||
|
'type': Platform.isAndroid ? 'android' : 'ios',
|
||||||
|
'lang': 'en',
|
||||||
|
'theme': 'theme_2',
|
||||||
|
'token': SpUtil.getString(KtKeys.token) ?? '',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeDependencies() {
|
||||||
|
super.didChangeDependencies();
|
||||||
|
routeObserver.subscribe(this, ModalRoute.of(context)! as PageRoute);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didPopNext() {
|
||||||
|
debugPrint('didPopNext');
|
||||||
|
_webViewController?.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
_webViewController?.dispose();
|
||||||
|
routeObserver.unsubscribe(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildWidget() {
|
||||||
|
switch (loadingStatus) {
|
||||||
|
case KtLoadStatusType.loading:
|
||||||
|
return Center(child: CircularProgressIndicator());
|
||||||
|
case KtLoadStatusType.loadFailed:
|
||||||
|
return KtStatusWidget(
|
||||||
|
type: KtErrorStatusType.noNetwork,
|
||||||
|
onPressed: () {
|
||||||
|
_webViewController?.loadUrl(urlRequest: URLRequest(url: WebUri(KtApis.WEB_SITE_FEEDBACK_LIST)));
|
||||||
|
},
|
||||||
|
);
|
||||||
|
case KtLoadStatusType.loadNoData:
|
||||||
|
return KtStatusWidget(
|
||||||
|
type: KtErrorStatusType.notFound,
|
||||||
|
onPressed: () {
|
||||||
|
_webViewController?.reload();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
super.build(context);
|
||||||
|
return Scaffold(
|
||||||
|
extendBodyBehindAppBar: true,
|
||||||
|
body: Container(
|
||||||
|
width: ScreenUtil().screenWidth,
|
||||||
|
height: ScreenUtil().screenHeight,
|
||||||
|
padding: EdgeInsets.only(top: ScreenUtil().statusBarHeight),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
image: DecorationImage(image: AssetImage('bg1.png'.ktIcon), fit: BoxFit.fill),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
_buildAppBar(context),
|
||||||
|
Expanded(
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
InAppWebView(
|
||||||
|
initialSettings: InAppWebViewSettings(
|
||||||
|
javaScriptEnabled: true,
|
||||||
|
mediaPlaybackRequiresUserGesture: false,
|
||||||
|
allowsInlineMediaPlayback: true,
|
||||||
|
cacheEnabled: false,
|
||||||
|
clearCache: true,
|
||||||
|
domStorageEnabled: false,
|
||||||
|
transparentBackground: true, // 允许透明背景
|
||||||
|
),
|
||||||
|
initialUserScripts: UnmodifiableListView<UserScript>([
|
||||||
|
UserScript(
|
||||||
|
source: """
|
||||||
|
window.AndroidInterface = {
|
||||||
|
getUserInfo: async function () {
|
||||||
|
return window.flutter_inappwebview.callHandler('getUserInfo');
|
||||||
|
},
|
||||||
|
openFeedbackDetail: function (id) {
|
||||||
|
return window.flutter_inappwebview.callHandler('openFeedbackDetail',id);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
""",
|
||||||
|
injectionTime: UserScriptInjectionTime.AT_DOCUMENT_START,
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
onWebViewCreated: (controller) async {
|
||||||
|
_webViewController = controller;
|
||||||
|
// Android 获取用户信息
|
||||||
|
_webViewController?.addJavaScriptHandler(
|
||||||
|
handlerName: 'getUserInfo',
|
||||||
|
callback: (args) {
|
||||||
|
return jsonEncode(_userData);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
// Android 去详情页
|
||||||
|
_webViewController?.addJavaScriptHandler(
|
||||||
|
handlerName: 'openFeedbackDetail',
|
||||||
|
callback: (args) {
|
||||||
|
debugPrint('$args');
|
||||||
|
if (args.isNotEmpty && args[0] is String) {
|
||||||
|
final id = args[0] as String;
|
||||||
|
debugPrint('openFeedbackDetail==>$id');
|
||||||
|
Get.toNamed(KtRoutes.helpCenterDetail, arguments: {'id': id});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (Platform.isIOS) {
|
||||||
|
await controller.addWebMessageListener(
|
||||||
|
WebMessageListener(
|
||||||
|
jsObjectName: "openFeedbackDetail",
|
||||||
|
allowedOriginRules: {"*"},
|
||||||
|
onPostMessage: (message, origin, isMainFrame, replyProxy) {
|
||||||
|
if (message == null) return;
|
||||||
|
Get.toNamed(KtRoutes.helpCenterDetail, arguments: {'id': message.data});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
await controller.loadUrl(urlRequest: URLRequest(url: WebUri(KtApis.WEB_SITE_FEEDBACK_LIST)));
|
||||||
|
},
|
||||||
|
onLoadStop: (controller, url) async {
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
await controller.evaluateJavascript(
|
||||||
|
source: """
|
||||||
|
window.AndroidInterface = {
|
||||||
|
getUserInfo: async function () {
|
||||||
|
return window.flutter_inappwebview.callHandler('getUserInfo');
|
||||||
|
},
|
||||||
|
openFeedbackDetail: function (id) {
|
||||||
|
return window.flutter_inappwebview.callHandler('openFeedbackDetail',id);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
""",
|
||||||
|
);
|
||||||
|
} else if (Platform.isIOS) {
|
||||||
|
String userString = jsonEncode(_userData);
|
||||||
|
Future.delayed(const Duration(seconds: 1)).then((_) {
|
||||||
|
controller.evaluateJavascript(
|
||||||
|
source:
|
||||||
|
"""
|
||||||
|
if (typeof window.receiveDataFromNative === 'function') {
|
||||||
|
window.receiveDataFromNative($userString);
|
||||||
|
}
|
||||||
|
""",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
loadingStatus = KtLoadStatusType.loadSuccess;
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
onLoadStart: (controller, url) {
|
||||||
|
loadingStatus = KtLoadStatusType.loading;
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
onReceivedError: (controller, request, error) {
|
||||||
|
Future.delayed(const Duration(milliseconds: 500)).then((_) {
|
||||||
|
loadingStatus = KtLoadStatusType.loadNoData;
|
||||||
|
setState(() {});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onPageCommitVisible: (controller, uri) {
|
||||||
|
if (loadingStatus == KtLoadStatusType.loadFailed) {
|
||||||
|
controller.loadData(data: "<html></html>");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
_buildWidget(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildAppBar(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 15.w),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
GestureDetector(
|
||||||
|
child: SizedBox(
|
||||||
|
width: 24.w,
|
||||||
|
child: Center(
|
||||||
|
child: Image.asset('ic_back.png'.ktIcon, width: 10.w),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: () => Navigator.of(context).maybePop(),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Help Center',
|
||||||
|
style: TextStyle(fontSize: 16.sp, fontWeight: FontWeight.w500, color: Colors.black),
|
||||||
|
),
|
||||||
|
Container(width: 24.w),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get wantKeepAlive => true;
|
||||||
|
}
|
370
lib/kt_pages/kt_mine/kt_help_center/kt_help_center_page.dart
Normal file
370
lib/kt_pages/kt_mine/kt_help_center/kt_help_center_page.dart
Normal file
@ -0,0 +1,370 @@
|
|||||||
|
import 'dart:collection';
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:badges/badges.dart';
|
||||||
|
import 'package:flustars/flustars.dart' hide ScreenUtil;
|
||||||
|
import 'package:flutter/material.dart' hide Badge;
|
||||||
|
import 'package:flutter_image_compress/flutter_image_compress.dart';
|
||||||
|
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||||
|
import 'package:flutter_kinetra/kt_utils/kt_string_extend.dart';
|
||||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:image_picker/image_picker.dart';
|
||||||
|
|
||||||
|
import '../../../dio_cilent/kt_apis.dart';
|
||||||
|
import '../../../dio_cilent/kt_request.dart';
|
||||||
|
import '../../../kt_utils/kt_keys.dart';
|
||||||
|
import '../../../kt_utils/kt_utils.dart';
|
||||||
|
import '../../../kt_widgets/kt_status_widget.dart';
|
||||||
|
import '../../../main.dart';
|
||||||
|
import 'kt_help_center_list_page.dart';
|
||||||
|
|
||||||
|
class KtHelpCenterPage extends StatefulWidget {
|
||||||
|
const KtHelpCenterPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<KtHelpCenterPage> createState() => _KtHelpCenterPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _KtHelpCenterPageState extends State<KtHelpCenterPage> with RouteAware {
|
||||||
|
InAppWebViewController? _webViewController;
|
||||||
|
final ImagePicker _imgPicker = ImagePicker();
|
||||||
|
int _noticeNum = 0;
|
||||||
|
late Map<String, String> _userData;
|
||||||
|
KtLoadStatusType loadingStatus = KtLoadStatusType.loading;
|
||||||
|
static const String _androidInterfaceJs = """
|
||||||
|
window.AndroidInterface = {
|
||||||
|
getUserInfo: async function () {
|
||||||
|
return window.flutter_inappwebview.callHandler('getUserInfo');
|
||||||
|
},
|
||||||
|
openPhotoPicker: function () {
|
||||||
|
return window.flutter_inappwebview.callHandler('openPhotoPicker');
|
||||||
|
},
|
||||||
|
uploadConvertImage: function () {
|
||||||
|
return window.flutter_inappwebview.callHandler('uploadConvertImage');
|
||||||
|
},
|
||||||
|
openFeedbackList: function () {
|
||||||
|
return window.flutter_inappwebview.callHandler('openFeedbackList');
|
||||||
|
},
|
||||||
|
};
|
||||||
|
""";
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_initUserData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeDependencies() {
|
||||||
|
super.didChangeDependencies();
|
||||||
|
routeObserver.subscribe(this, ModalRoute.of(context)! as PageRoute);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didPopNext() {
|
||||||
|
_getNoticeNum();
|
||||||
|
_webViewController?.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_webViewController?.dispose();
|
||||||
|
routeObserver.unsubscribe(this);
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _initUserData() {
|
||||||
|
_userData = {
|
||||||
|
'time_zone': KtUtils.getTimeZoneOffset(DateTime.now()),
|
||||||
|
'type': Platform.isAndroid ? 'android' : 'ios',
|
||||||
|
'lang': 'en',
|
||||||
|
'theme': 'theme_2',
|
||||||
|
'token': SpUtil.getString(KtKeys.token) ?? '',
|
||||||
|
};
|
||||||
|
_getNoticeNum();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _getNoticeNum() async {
|
||||||
|
final res = await KtHttpClient().request(KtApis.getNoticeNum);
|
||||||
|
if (res.success) {
|
||||||
|
_noticeNum =
|
||||||
|
int.tryParse(res.data['feedback_notice_num'].toString()) ?? 0;
|
||||||
|
if (mounted) setState(() {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _pickImage() async {
|
||||||
|
final XFile? image = await _imgPicker.pickImage(
|
||||||
|
source: ImageSource.gallery,
|
||||||
|
);
|
||||||
|
if (image != null) {
|
||||||
|
final compressedImage = await _compressToTargetSize(
|
||||||
|
File(image.path),
|
||||||
|
1024 * 1024,
|
||||||
|
);
|
||||||
|
final bytes = await compressedImage.readAsBytes();
|
||||||
|
final base64Data = base64Encode(bytes);
|
||||||
|
final data = base64Data;
|
||||||
|
final js =
|
||||||
|
'''
|
||||||
|
if (typeof window.onImagePicked === 'function') {
|
||||||
|
window.onImagePicked("$data");
|
||||||
|
}
|
||||||
|
''';
|
||||||
|
_webViewController?.evaluateJavascript(source: js);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<File> _compressToTargetSize(File file, int targetSize) async {
|
||||||
|
int quality = 90;
|
||||||
|
File compressed = file;
|
||||||
|
while ((await compressed.length()) > targetSize && quality > 10) {
|
||||||
|
final result = await FlutterImageCompress.compressWithFile(
|
||||||
|
file.absolute.path,
|
||||||
|
quality: quality,
|
||||||
|
);
|
||||||
|
if (result == null) break;
|
||||||
|
compressed = File(
|
||||||
|
'${file.parent.path}/compressed_${DateTime.now().millisecondsSinceEpoch}.jpg',
|
||||||
|
)..writeAsBytesSync(result);
|
||||||
|
quality -= 10;
|
||||||
|
}
|
||||||
|
return compressed;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _uploadImage(String data) async {
|
||||||
|
await _webViewController?.evaluateJavascript(
|
||||||
|
source:
|
||||||
|
'''
|
||||||
|
if (window.uploadConvertImage) {
|
||||||
|
window.uploadConvertImage("$data");
|
||||||
|
} else {
|
||||||
|
console.error("H5 没有定义 window.uploadConvertImage");
|
||||||
|
}
|
||||||
|
''',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
extendBodyBehindAppBar: true,
|
||||||
|
body: Container(
|
||||||
|
width: ScreenUtil().screenWidth,
|
||||||
|
height: ScreenUtil().screenHeight,
|
||||||
|
padding: EdgeInsets.only(top: ScreenUtil().statusBarHeight),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
image: DecorationImage(
|
||||||
|
image: AssetImage('bg1.png'.ktIcon),
|
||||||
|
fit: BoxFit.fill,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
_buildAppBar(context),
|
||||||
|
Expanded(
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
InAppWebView(
|
||||||
|
initialSettings: InAppWebViewSettings(
|
||||||
|
javaScriptEnabled: true,
|
||||||
|
mediaPlaybackRequiresUserGesture: false,
|
||||||
|
allowsInlineMediaPlayback: true,
|
||||||
|
cacheEnabled: false,
|
||||||
|
clearCache: true,
|
||||||
|
domStorageEnabled: false,
|
||||||
|
transparentBackground: true,
|
||||||
|
),
|
||||||
|
initialUserScripts: UnmodifiableListView<UserScript>([
|
||||||
|
UserScript(
|
||||||
|
source: _androidInterfaceJs,
|
||||||
|
injectionTime:
|
||||||
|
UserScriptInjectionTime.AT_DOCUMENT_START,
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
onWebViewCreated: (controller) async {
|
||||||
|
_webViewController = controller;
|
||||||
|
_registerJsHandlers(controller);
|
||||||
|
if (Platform.isIOS) {
|
||||||
|
await _registerIosMessageHandlers(controller);
|
||||||
|
}
|
||||||
|
await controller.loadUrl(
|
||||||
|
urlRequest: URLRequest(
|
||||||
|
url: WebUri(KtApis.WEB_SITE_FEEDBACK),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onLoadStop: (controller, url) async {
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
await controller.evaluateJavascript(
|
||||||
|
source: _androidInterfaceJs,
|
||||||
|
);
|
||||||
|
} else if (Platform.isIOS) {
|
||||||
|
String userString = jsonEncode(_userData);
|
||||||
|
Future.delayed(const Duration(seconds: 1)).then((_) {
|
||||||
|
controller.evaluateJavascript(
|
||||||
|
source:
|
||||||
|
'''
|
||||||
|
if (typeof window.receiveDataFromNative === 'function') {
|
||||||
|
window.receiveDataFromNative($userString);
|
||||||
|
}
|
||||||
|
''',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
await controller.evaluateJavascript(
|
||||||
|
source: '''
|
||||||
|
window.onImagePicked = function(data) {
|
||||||
|
console.log("📷 接收到来自 Flutter 的图片数据", data);
|
||||||
|
window.flutter_inappwebview.callHandler('uploadConvertImage', data);
|
||||||
|
};
|
||||||
|
''',
|
||||||
|
);
|
||||||
|
loadingStatus = KtLoadStatusType.loadSuccess;
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
onLoadStart: (controller, url) {
|
||||||
|
loadingStatus = KtLoadStatusType.loading;
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
onReceivedError: (controller, request, error) {
|
||||||
|
Future.delayed(const Duration(milliseconds: 500)).then((
|
||||||
|
_,
|
||||||
|
) {
|
||||||
|
loadingStatus = KtLoadStatusType.loadFailed;
|
||||||
|
setState(() {});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onPageCommitVisible: (controller, uri) {
|
||||||
|
if (loadingStatus == KtLoadStatusType.loadFailed) {
|
||||||
|
controller.loadData(data: "<html></html>");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
_buildWidget(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildAppBar(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 15.w),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
GestureDetector(
|
||||||
|
child: SizedBox(
|
||||||
|
width: 29.w,
|
||||||
|
child: Center(
|
||||||
|
child: Image.asset('ic_back.png'.ktIcon, width: 10.w),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: () => Navigator.of(context).maybePop(),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Help Center',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16.sp,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Badge(
|
||||||
|
showBadge: _noticeNum > 0,
|
||||||
|
badgeContent: Text(
|
||||||
|
_noticeNum > 99 ? '99+' : '$_noticeNum',
|
||||||
|
style: const TextStyle(color: Colors.white, fontSize: 10),
|
||||||
|
),
|
||||||
|
badgeStyle: BadgeStyle(badgeColor: Color(0xFFF306B9)),
|
||||||
|
position: BadgePosition.topEnd(top: -5, end: -5),
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () => Get.to(() => KtHelpCenterListPage()),
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.all(5.w),
|
||||||
|
child: Image.asset('ic_help_center.png'.ktIcon, width: 24.w),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _registerJsHandlers(InAppWebViewController controller) {
|
||||||
|
controller.addJavaScriptHandler(
|
||||||
|
handlerName: 'getUserInfo',
|
||||||
|
callback: (args) => jsonEncode(_userData),
|
||||||
|
);
|
||||||
|
controller.addJavaScriptHandler(
|
||||||
|
handlerName: 'openPhotoPicker',
|
||||||
|
callback: (args) => _pickImage(),
|
||||||
|
);
|
||||||
|
controller.addJavaScriptHandler(
|
||||||
|
handlerName: 'uploadConvertImage',
|
||||||
|
callback: (args) {
|
||||||
|
if (args.isNotEmpty && args[0] is String) {
|
||||||
|
_uploadImage(args[0] as String);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
controller.addJavaScriptHandler(
|
||||||
|
handlerName: 'openFeedbackList',
|
||||||
|
callback: (args) => Get.to(() => KtHelpCenterListPage()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _registerIosMessageHandlers(
|
||||||
|
InAppWebViewController controller,
|
||||||
|
) async {
|
||||||
|
await controller.addWebMessageListener(
|
||||||
|
WebMessageListener(
|
||||||
|
jsObjectName: "openPhotoPicker",
|
||||||
|
allowedOriginRules: {"*"},
|
||||||
|
onPostMessage: (message, origin, isMainFrame, replyProxy) {
|
||||||
|
_pickImage();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await controller.addWebMessageListener(
|
||||||
|
WebMessageListener(
|
||||||
|
jsObjectName: "openFeedbackList",
|
||||||
|
allowedOriginRules: {"*"},
|
||||||
|
onPostMessage: (message, origin, isMainFrame, replyProxy) =>
|
||||||
|
Get.to(() => KtHelpCenterListPage()),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildWidget() {
|
||||||
|
debugPrint('----loadStatus:$loadingStatus');
|
||||||
|
switch (loadingStatus) {
|
||||||
|
case KtLoadStatusType.loading:
|
||||||
|
return Center(child: CircularProgressIndicator());
|
||||||
|
case KtLoadStatusType.loadFailed:
|
||||||
|
return KtStatusWidget(
|
||||||
|
type: KtErrorStatusType.noNetwork,
|
||||||
|
onPressed: () {
|
||||||
|
_webViewController?.loadUrl(
|
||||||
|
urlRequest: URLRequest(url: WebUri(KtApis.WEB_SITE_FEEDBACK)),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
case KtLoadStatusType.loadNoData:
|
||||||
|
return KtStatusWidget(
|
||||||
|
type: KtErrorStatusType.notFound,
|
||||||
|
onPressed: () {
|
||||||
|
_webViewController?.reload();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -207,7 +207,7 @@ class _KtMinePageState extends State<KtMinePage> {
|
|||||||
handleItem(
|
handleItem(
|
||||||
'ic_help_center.png',
|
'ic_help_center.png',
|
||||||
'Help Center',
|
'Help Center',
|
||||||
() => Get.toNamed(KtRoutes.search),
|
() => Get.toNamed(KtRoutes.helpCenter),
|
||||||
),
|
),
|
||||||
handleItem(
|
handleItem(
|
||||||
'ic_about_us.png',
|
'ic_about_us.png',
|
||||||
|
@ -125,25 +125,7 @@ class MyListLogic extends GetxController {
|
|||||||
"video_id": video.shortPlayVideoId,
|
"video_id": video.shortPlayVideoId,
|
||||||
};
|
};
|
||||||
if (video.isCollect == 1) {
|
if (video.isCollect == 1) {
|
||||||
Get.dialog(
|
cancelCollect(video.shortPlayId!);
|
||||||
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,
|
||||||
@ -170,7 +152,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)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_kinetra/kt_model/kt_short_video_bean.dart';
|
|
||||||
import 'package:flutter_kinetra/kt_pages/kt_my_list/kt_my_chest_page.dart';
|
import 'package:flutter_kinetra/kt_pages/kt_my_list/kt_my_chest_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_kinetra/kt_widgets/kt_status_widget.dart';
|
import 'package:flutter_kinetra/kt_widgets/kt_status_widget.dart';
|
||||||
@ -27,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 Container();
|
// if (state.loadStatus == KtLoadStatusType.loading) return Center(child: CircularProgressIndicator());
|
||||||
return Container(
|
return Container(
|
||||||
width: ScreenUtil().screenWidth,
|
width: ScreenUtil().screenWidth,
|
||||||
height: ScreenUtil().screenHeight,
|
height: ScreenUtil().screenHeight,
|
||||||
|
@ -4,6 +4,9 @@ import 'package:get/get_navigation/src/routes/get_route.dart';
|
|||||||
import 'kt_main_page/view.dart';
|
import 'kt_main_page/view.dart';
|
||||||
import 'kt_mine/insert_web/wallet_page.dart';
|
import 'kt_mine/insert_web/wallet_page.dart';
|
||||||
import 'kt_mine/kt_about_us_page.dart';
|
import 'kt_mine/kt_about_us_page.dart';
|
||||||
|
import 'kt_mine/kt_help_center/kt_help_center_detail_page.dart';
|
||||||
|
import 'kt_mine/kt_help_center/kt_help_center_list_page.dart';
|
||||||
|
import 'kt_mine/kt_help_center/kt_help_center_page.dart';
|
||||||
import 'kt_mine/kt_store/view.dart';
|
import 'kt_mine/kt_store/view.dart';
|
||||||
import 'kt_short_video/view.dart';
|
import 'kt_short_video/view.dart';
|
||||||
import 'kt_splash_page.dart';
|
import 'kt_splash_page.dart';
|
||||||
@ -38,9 +41,12 @@ class KtRoutes {
|
|||||||
GetPage(name: store, page: () => KtStorePage()),
|
GetPage(name: store, page: () => KtStorePage()),
|
||||||
GetPage(name: wallet, page: () => const WalletPage()),
|
GetPage(name: wallet, page: () => const WalletPage()),
|
||||||
GetPage(name: aboutUs, page: () => const KtAboutUsPage()),
|
GetPage(name: aboutUs, page: () => const KtAboutUsPage()),
|
||||||
// GetPage(name: helpCenter, page: () => const HelpCenterPage()),
|
GetPage(name: helpCenter, page: () => const KtHelpCenterPage()),
|
||||||
// GetPage(name: helpCenterList, page: () => const HelpCenterListPage()),
|
GetPage(name: helpCenterList, page: () => const KtHelpCenterListPage()),
|
||||||
// GetPage(name: helpCenterDetail, page: () => const HelpCenterDetailPage()),
|
GetPage(
|
||||||
|
name: helpCenterDetail,
|
||||||
|
page: () => const KtKtHelpCenterDetailPage(),
|
||||||
|
),
|
||||||
GetPage(
|
GetPage(
|
||||||
name: webView,
|
name: webView,
|
||||||
page: () => const KtWebViewPage(url: 'url'),
|
page: () => const KtWebViewPage(url: 'url'),
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter_kinetra/kt_pages/kt_short_video/state.dart';
|
import 'package:flutter_kinetra/kt_pages/kt_short_video/state.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@ -6,6 +8,7 @@ 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';
|
||||||
|
|
||||||
class VideoPlayLogic extends GetxController {
|
class VideoPlayLogic extends GetxController {
|
||||||
@ -212,7 +215,14 @@ class VideoPlayLogic extends GetxController {
|
|||||||
if (controllers[index] != null) return;
|
if (controllers[index] != null) return;
|
||||||
|
|
||||||
final episode = state.episodeList[index];
|
final episode = state.episodeList[index];
|
||||||
final controller = VideoPlayerController.networkUrl(
|
VideoPlayerController controller =
|
||||||
|
Platform.isAndroid && KtDeviceInfoUtil().osVersion == '10'
|
||||||
|
? VideoPlayerController.networkUrl(
|
||||||
|
Uri.parse(episode.videoUrl!),
|
||||||
|
formatHint: VideoFormat.hls,
|
||||||
|
viewType: VideoViewType.platformView,
|
||||||
|
)
|
||||||
|
: VideoPlayerController.networkUrl(
|
||||||
Uri.parse(episode.videoUrl!),
|
Uri.parse(episode.videoUrl!),
|
||||||
formatHint: VideoFormat.hls,
|
formatHint: VideoFormat.hls,
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user