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_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';
|
||||
import '../kt_my_list/logic.dart';
|
||||
import '../kt_my_list/view.dart';
|
||||
|
||||
class KtMainPage extends StatefulWidget {
|
||||
@ -104,13 +106,8 @@ class _KtMainPageState extends State<KtMainPage>
|
||||
onTap: (index) {
|
||||
_currentIndex = index;
|
||||
_controller.jumpToPage(index);
|
||||
// final recommendLogic = Get.put(RecommendLogic());
|
||||
// if (index != 1) {
|
||||
// recommendLogic.videoCtrl?.pause();
|
||||
// } else {
|
||||
// recommendLogic.videoCtrl?.play();
|
||||
// }
|
||||
// recommendLogic.update();
|
||||
final myListLogic = Get.put(MyListLogic());
|
||||
myListLogic.initData();
|
||||
},
|
||||
items: [
|
||||
..._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(
|
||||
'ic_help_center.png',
|
||||
'Help Center',
|
||||
() => Get.toNamed(KtRoutes.search),
|
||||
() => Get.toNamed(KtRoutes.helpCenter),
|
||||
),
|
||||
handleItem(
|
||||
'ic_about_us.png',
|
||||
|
@ -125,25 +125,7 @@ class MyListLogic extends GetxController {
|
||||
"video_id": video.shortPlayVideoId,
|
||||
};
|
||||
if (video.isCollect == 1) {
|
||||
Get.dialog(
|
||||
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();
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
cancelCollect(video.shortPlayId!);
|
||||
} else {
|
||||
ApiResponse res = await KtHttpClient().request(
|
||||
KtApis.collectVideo,
|
||||
@ -170,7 +152,7 @@ class MyListLogic extends GetxController {
|
||||
queryParameters: {'short_play_id': id},
|
||||
);
|
||||
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.historyList
|
||||
.firstWhereOrNull((item) => id == item.shortPlayId)
|
||||
|
@ -1,5 +1,4 @@
|
||||
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_utils/kt_string_extend.dart';
|
||||
import 'package:flutter_kinetra/kt_widgets/kt_status_widget.dart';
|
||||
@ -27,7 +26,7 @@ class _KtMyListPageState extends State<KtMyListPage> {
|
||||
Widget build(BuildContext context) {
|
||||
return GetBuilder<MyListLogic>(
|
||||
builder: (ctrl) {
|
||||
if (state.loadStatus == KtLoadStatusType.loading) return Container();
|
||||
// if (state.loadStatus == KtLoadStatusType.loading) return Center(child: CircularProgressIndicator());
|
||||
return Container(
|
||||
width: ScreenUtil().screenWidth,
|
||||
height: ScreenUtil().screenHeight,
|
||||
@ -40,286 +39,286 @@ class _KtMyListPageState extends State<KtMyListPage> {
|
||||
),
|
||||
child: state.chestList.isEmpty && state.historyList.isEmpty
|
||||
? KtStatusWidget(
|
||||
type: KtErrorStatusType.nothingYet,
|
||||
onPressed: logic.initData,
|
||||
)
|
||||
type: KtErrorStatusType.nothingYet,
|
||||
onPressed: logic.initData,
|
||||
)
|
||||
: SmartRefresher(
|
||||
controller: logic.refreshCtrl,
|
||||
enablePullUp: true,
|
||||
enablePullDown: true,
|
||||
onRefresh: () => logic.initData(),
|
||||
onLoading: () => logic.getHistoryList(loadMore: true),
|
||||
child: Column(
|
||||
children: [
|
||||
if (state.chestList.isNotEmpty)
|
||||
Container(
|
||||
width: ScreenUtil().screenWidth - 30.w,
|
||||
padding: EdgeInsets.fromLTRB(6.w, 53.w, 6.w, 6.w),
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('collect_bg.png'.ktIcon),
|
||||
fit: BoxFit.fill,
|
||||
controller: logic.refreshCtrl,
|
||||
enablePullUp: true,
|
||||
enablePullDown: true,
|
||||
onRefresh: () => logic.initData(),
|
||||
onLoading: () => logic.getHistoryList(loadMore: true),
|
||||
child: Column(
|
||||
children: [
|
||||
if (state.chestList.isNotEmpty)
|
||||
Container(
|
||||
width: ScreenUtil().screenWidth - 30.w,
|
||||
padding: EdgeInsets.fromLTRB(6.w, 53.w, 6.w, 6.w),
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('collect_bg.png'.ktIcon),
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(width: 6.w),
|
||||
Text(
|
||||
'My Treasure Chest',
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w800,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
const Spacer(),
|
||||
GestureDetector(
|
||||
onTap: () => Get.to(KtMyChestPage()),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 6.w),
|
||||
Text(
|
||||
'My Treasure Chest',
|
||||
'View All',
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w800,
|
||||
fontStyle: FontStyle.italic,
|
||||
fontSize: 12.sp,
|
||||
color: Color(0xFFD6D6D6),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
GestureDetector(
|
||||
onTap: () => Get.to(KtMyChestPage()),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
'View All',
|
||||
style: TextStyle(
|
||||
fontSize: 12.sp,
|
||||
color: Color(0xFFD6D6D6),
|
||||
),
|
||||
),
|
||||
Image.asset(
|
||||
'ic_right_white.png'.ktIcon,
|
||||
width: 10.w,
|
||||
),
|
||||
SizedBox(width: 6.w),
|
||||
],
|
||||
),
|
||||
Image.asset(
|
||||
'ic_right_white.png'.ktIcon,
|
||||
width: 10.w,
|
||||
),
|
||||
SizedBox(width: 6.w),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 15.w),
|
||||
Container(
|
||||
height: 145.w,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(14.w),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
...state.chestList.map(
|
||||
(video) => Container(
|
||||
margin: EdgeInsets.symmetric(
|
||||
horizontal: 5.w,
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () => Get.toNamed(
|
||||
KtRoutes.shortVideo,
|
||||
arguments: {
|
||||
'shortPlayId':
|
||||
video.shortPlayId,
|
||||
'imageUrl':
|
||||
video.imageUrl ?? '',
|
||||
},
|
||||
),
|
||||
child: KtNetworkImage(
|
||||
imageUrl: video.imageUrl ?? '',
|
||||
width: 100.w,
|
||||
height: 133.w,
|
||||
borderRadius:
|
||||
BorderRadius.circular(6.w),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
right: 4.w,
|
||||
top: 4.w,
|
||||
child: GestureDetector(
|
||||
onTap: () =>
|
||||
logic.cancelCollect(
|
||||
video.shortPlayId!,
|
||||
),
|
||||
child: Image.asset(
|
||||
'ic_collect_sel.png'.ktIcon,
|
||||
width: 28.w,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 15.w),
|
||||
Expanded(
|
||||
child: Container(
|
||||
width: ScreenUtil().screenWidth,
|
||||
padding: EdgeInsets.all(15.w),
|
||||
SizedBox(height: 15.w),
|
||||
Container(
|
||||
height: 145.w,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.vertical(
|
||||
top: Radius.circular(20.w),
|
||||
),
|
||||
borderRadius: BorderRadius.circular(14.w),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Continue Watching',
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: Color(0xFF1E1E20),
|
||||
fontWeight: FontWeight.w800,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ListView.separated(
|
||||
padding: EdgeInsets.only(top: 10.w),
|
||||
// shrinkWrap: true,
|
||||
// physics: NeverScrollableScrollPhysics(),
|
||||
itemBuilder: (context, index) {
|
||||
KtHistoryVideoBean video =
|
||||
state.historyList[index];
|
||||
return GestureDetector(
|
||||
onTap: () => Get.toNamed(
|
||||
KtRoutes.shortVideo,
|
||||
arguments: {
|
||||
'shortPlayId': video.shortPlayId,
|
||||
'imageUrl': video.imageUrl ?? '',
|
||||
},
|
||||
),
|
||||
child: Container(
|
||||
color: Colors.transparent,
|
||||
child: Row(
|
||||
children: [
|
||||
KtNetworkImage(
|
||||
imageUrl: video.imageUrl ?? '',
|
||||
width: 74.w,
|
||||
height: 98.w,
|
||||
borderRadius:
|
||||
BorderRadius.circular(8.w),
|
||||
),
|
||||
SizedBox(width: 13.w),
|
||||
SizedBox(
|
||||
width: 200.w,
|
||||
height: 98.w,
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
video.name ?? '',
|
||||
maxLines: 1,
|
||||
overflow:
|
||||
TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 13.sp,
|
||||
color: Color(0xFF1E1E20),
|
||||
fontWeight:
|
||||
FontWeight.w500,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 6.w),
|
||||
Text(
|
||||
video.category?.first ?? '',
|
||||
maxLines: 1,
|
||||
overflow:
|
||||
TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 10.sp,
|
||||
color: Color(0xFF79C900),
|
||||
fontWeight:
|
||||
FontWeight.w400,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20.w),
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 26.w,
|
||||
height: 26.w,
|
||||
child: CircularProgressIndicator(
|
||||
value:
|
||||
(video.currentEpisode ??
|
||||
0) /
|
||||
(video.episodeTotal! >
|
||||
0
|
||||
? video
|
||||
.episodeTotal!
|
||||
: 1),
|
||||
backgroundColor:
|
||||
Color(0xFFD9D9D9),
|
||||
valueColor:
|
||||
AlwaysStoppedAnimation<
|
||||
Color
|
||||
>(
|
||||
Color(
|
||||
0xFFA7F62F,
|
||||
),
|
||||
),
|
||||
strokeWidth: 3.w,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 5.w),
|
||||
Text(
|
||||
"${((video.currentEpisode ?? 0) / (video.episodeTotal! > 0 ? video.episodeTotal! : 1) * 100).toStringAsFixed(0)}%",
|
||||
style: TextStyle(
|
||||
fontSize: 12.sp,
|
||||
color: Color(
|
||||
0xFF1E1E20,
|
||||
),
|
||||
fontWeight:
|
||||
FontWeight.w400,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
GestureDetector(
|
||||
onTap: () =>
|
||||
logic.likeVideo(video),
|
||||
child: Column(
|
||||
children: [
|
||||
Image.asset(
|
||||
video.isCollect == 1
|
||||
? 'ic_collect_sel.png'
|
||||
.ktIcon
|
||||
: 'ic_collect_unsel.png'
|
||||
.ktIcon,
|
||||
width: 32.w,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
...state.chestList.map(
|
||||
(video) => Container(
|
||||
margin: EdgeInsets.symmetric(
|
||||
horizontal: 5.w,
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () => Get.toNamed(
|
||||
KtRoutes.shortVideo,
|
||||
arguments: {
|
||||
'shortPlayId':
|
||||
video.shortPlayId,
|
||||
'imageUrl':
|
||||
video.imageUrl ?? '',
|
||||
},
|
||||
),
|
||||
child: KtNetworkImage(
|
||||
imageUrl: video.imageUrl ?? '',
|
||||
width: 100.w,
|
||||
height: 133.w,
|
||||
borderRadius:
|
||||
BorderRadius.circular(6.w),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (_, __) =>
|
||||
SizedBox(height: 12.w),
|
||||
itemCount: state.historyList.length,
|
||||
Positioned(
|
||||
right: 4.w,
|
||||
top: 4.w,
|
||||
child: GestureDetector(
|
||||
onTap: () =>
|
||||
logic.cancelCollect(
|
||||
video.shortPlayId!,
|
||||
),
|
||||
child: Image.asset(
|
||||
'ic_collect_sel.png'.ktIcon,
|
||||
width: 28.w,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 15.w),
|
||||
Expanded(
|
||||
child: Container(
|
||||
width: ScreenUtil().screenWidth,
|
||||
padding: EdgeInsets.all(15.w),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.vertical(
|
||||
top: Radius.circular(20.w),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Continue Watching',
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: Color(0xFF1E1E20),
|
||||
fontWeight: FontWeight.w800,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ListView.separated(
|
||||
padding: EdgeInsets.only(top: 10.w),
|
||||
// shrinkWrap: true,
|
||||
// physics: NeverScrollableScrollPhysics(),
|
||||
itemBuilder: (context, index) {
|
||||
KtHistoryVideoBean video =
|
||||
state.historyList[index];
|
||||
return GestureDetector(
|
||||
onTap: () => Get.toNamed(
|
||||
KtRoutes.shortVideo,
|
||||
arguments: {
|
||||
'shortPlayId': video.shortPlayId,
|
||||
'imageUrl': video.imageUrl ?? '',
|
||||
},
|
||||
),
|
||||
child: Container(
|
||||
color: Colors.transparent,
|
||||
child: Row(
|
||||
children: [
|
||||
KtNetworkImage(
|
||||
imageUrl: video.imageUrl ?? '',
|
||||
width: 74.w,
|
||||
height: 98.w,
|
||||
borderRadius:
|
||||
BorderRadius.circular(8.w),
|
||||
),
|
||||
SizedBox(width: 13.w),
|
||||
SizedBox(
|
||||
width: 200.w,
|
||||
height: 98.w,
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
video.name ?? '',
|
||||
maxLines: 1,
|
||||
overflow:
|
||||
TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 13.sp,
|
||||
color: Color(0xFF1E1E20),
|
||||
fontWeight:
|
||||
FontWeight.w500,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 6.w),
|
||||
Text(
|
||||
video.category?.first ?? '',
|
||||
maxLines: 1,
|
||||
overflow:
|
||||
TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 10.sp,
|
||||
color: Color(0xFF79C900),
|
||||
fontWeight:
|
||||
FontWeight.w400,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20.w),
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 26.w,
|
||||
height: 26.w,
|
||||
child: CircularProgressIndicator(
|
||||
value:
|
||||
(video.currentEpisode ??
|
||||
0) /
|
||||
(video.episodeTotal! >
|
||||
0
|
||||
? video
|
||||
.episodeTotal!
|
||||
: 1),
|
||||
backgroundColor:
|
||||
Color(0xFFD9D9D9),
|
||||
valueColor:
|
||||
AlwaysStoppedAnimation<
|
||||
Color
|
||||
>(
|
||||
Color(
|
||||
0xFFA7F62F,
|
||||
),
|
||||
),
|
||||
strokeWidth: 3.w,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 5.w),
|
||||
Text(
|
||||
"${((video.currentEpisode ?? 0) / (video.episodeTotal! > 0 ? video.episodeTotal! : 1) * 100).toStringAsFixed(0)}%",
|
||||
style: TextStyle(
|
||||
fontSize: 12.sp,
|
||||
color: Color(
|
||||
0xFF1E1E20,
|
||||
),
|
||||
fontWeight:
|
||||
FontWeight.w400,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
GestureDetector(
|
||||
onTap: () =>
|
||||
logic.likeVideo(video),
|
||||
child: Column(
|
||||
children: [
|
||||
Image.asset(
|
||||
video.isCollect == 1
|
||||
? 'ic_collect_sel.png'
|
||||
.ktIcon
|
||||
: 'ic_collect_unsel.png'
|
||||
.ktIcon,
|
||||
width: 32.w,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (_, __) =>
|
||||
SizedBox(height: 12.w),
|
||||
itemCount: state.historyList.length,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
@ -4,6 +4,9 @@ import 'package:get/get_navigation/src/routes/get_route.dart';
|
||||
import 'kt_main_page/view.dart';
|
||||
import 'kt_mine/insert_web/wallet_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_short_video/view.dart';
|
||||
import 'kt_splash_page.dart';
|
||||
@ -38,9 +41,12 @@ class KtRoutes {
|
||||
GetPage(name: store, page: () => KtStorePage()),
|
||||
GetPage(name: wallet, page: () => const WalletPage()),
|
||||
GetPage(name: aboutUs, page: () => const KtAboutUsPage()),
|
||||
// GetPage(name: helpCenter, page: () => const HelpCenterPage()),
|
||||
// GetPage(name: helpCenterList, page: () => const HelpCenterListPage()),
|
||||
// GetPage(name: helpCenterDetail, page: () => const HelpCenterDetailPage()),
|
||||
GetPage(name: helpCenter, page: () => const KtHelpCenterPage()),
|
||||
GetPage(name: helpCenterList, page: () => const KtHelpCenterListPage()),
|
||||
GetPage(
|
||||
name: helpCenterDetail,
|
||||
page: () => const KtKtHelpCenterDetailPage(),
|
||||
),
|
||||
GetPage(
|
||||
name: webView,
|
||||
page: () => const KtWebViewPage(url: 'url'),
|
||||
|
@ -1,3 +1,5 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_kinetra/kt_pages/kt_short_video/state.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_request.dart';
|
||||
import '../../kt_model/kt_video_detail_bean.dart';
|
||||
import '../../kt_utils/kt_device_info_utils.dart';
|
||||
import '../../kt_widgets/kt_status_widget.dart';
|
||||
|
||||
class VideoPlayLogic extends GetxController {
|
||||
@ -212,10 +215,17 @@ class VideoPlayLogic extends GetxController {
|
||||
if (controllers[index] != null) return;
|
||||
|
||||
final episode = state.episodeList[index];
|
||||
final controller = VideoPlayerController.networkUrl(
|
||||
Uri.parse(episode.videoUrl!),
|
||||
formatHint: VideoFormat.hls,
|
||||
);
|
||||
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!),
|
||||
formatHint: VideoFormat.hls,
|
||||
);
|
||||
|
||||
controllers[index] = controller;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user