feat:反馈
This commit is contained in:
parent
ab2e1a49f9
commit
8932eefb14
@ -9,6 +9,7 @@
|
|||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
002E1F1EA059FEE73E55E03C /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D1AEBA8280B01EA417C5A4C5 /* Pods_Runner.framework */; };
|
002E1F1EA059FEE73E55E03C /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D1AEBA8280B01EA417C5A4C5 /* Pods_Runner.framework */; };
|
||||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
|
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
|
||||||
|
2E31D4A42E82814000481906 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2E31D4A32E82814000481906 /* StoreKit.framework */; };
|
||||||
2F3E2165998010C253A6A3AB /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 31F0B6F62A10C414CCB11B56 /* Pods_RunnerTests.framework */; };
|
2F3E2165998010C253A6A3AB /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 31F0B6F62A10C414CCB11B56 /* Pods_RunnerTests.framework */; };
|
||||||
331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; };
|
331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; };
|
||||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
||||||
@ -44,6 +45,7 @@
|
|||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
|
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
|
||||||
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
|
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
|
||||||
|
2E31D4A32E82814000481906 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; };
|
||||||
31F0B6F62A10C414CCB11B56 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
31F0B6F62A10C414CCB11B56 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = "<group>"; };
|
331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = "<group>"; };
|
||||||
331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
@ -73,6 +75,7 @@
|
|||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
002E1F1EA059FEE73E55E03C /* Pods_Runner.framework in Frameworks */,
|
002E1F1EA059FEE73E55E03C /* Pods_Runner.framework in Frameworks */,
|
||||||
|
2E31D4A42E82814000481906 /* StoreKit.framework in Frameworks */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@ -145,6 +148,7 @@
|
|||||||
A643DB2437D6E4CE3EFAE3C0 /* Frameworks */ = {
|
A643DB2437D6E4CE3EFAE3C0 /* Frameworks */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
2E31D4A32E82814000481906 /* StoreKit.framework */,
|
||||||
D1AEBA8280B01EA417C5A4C5 /* Pods_Runner.framework */,
|
D1AEBA8280B01EA417C5A4C5 /* Pods_Runner.framework */,
|
||||||
31F0B6F62A10C414CCB11B56 /* Pods_RunnerTests.framework */,
|
31F0B6F62A10C414CCB11B56 /* Pods_RunnerTests.framework */,
|
||||||
);
|
);
|
||||||
@ -331,10 +335,14 @@
|
|||||||
inputFileListPaths = (
|
inputFileListPaths = (
|
||||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
|
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
|
||||||
);
|
);
|
||||||
|
inputPaths = (
|
||||||
|
);
|
||||||
name = "[CP] Embed Pods Frameworks";
|
name = "[CP] Embed Pods Frameworks";
|
||||||
outputFileListPaths = (
|
outputFileListPaths = (
|
||||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
|
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
|
||||||
);
|
);
|
||||||
|
outputPaths = (
|
||||||
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
shellPath = /bin/sh;
|
shellPath = /bin/sh;
|
||||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
|
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
|
||||||
@ -370,10 +378,14 @@
|
|||||||
inputFileListPaths = (
|
inputFileListPaths = (
|
||||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
|
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
|
||||||
);
|
);
|
||||||
|
inputPaths = (
|
||||||
|
);
|
||||||
name = "[CP] Copy Pods Resources";
|
name = "[CP] Copy Pods Resources";
|
||||||
outputFileListPaths = (
|
outputFileListPaths = (
|
||||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
|
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
|
||||||
);
|
);
|
||||||
|
outputPaths = (
|
||||||
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
shellPath = /bin/sh;
|
shellPath = /bin/sh;
|
||||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
|
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
|
||||||
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -64,7 +64,9 @@ class _KtMinePageState extends State<KtMinePage> {
|
|||||||
padding: EdgeInsets.fromLTRB(6.w, 13.w, 6.w, 6.w),
|
padding: EdgeInsets.fromLTRB(6.w, 13.w, 6.w, 6.w),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
image: DecorationImage(
|
image: DecorationImage(
|
||||||
image: AssetImage('ic_mine_top_bg.png'.ktIcon),
|
image: AssetImage(
|
||||||
|
'ic_mine_top_bg.png'.ktIcon,
|
||||||
|
),
|
||||||
fit: BoxFit.fill,
|
fit: BoxFit.fill,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -101,7 +103,9 @@ class _KtMinePageState extends State<KtMinePage> {
|
|||||||
margin: EdgeInsets.symmetric(
|
margin: EdgeInsets.symmetric(
|
||||||
horizontal: 15.w,
|
horizontal: 15.w,
|
||||||
),
|
),
|
||||||
color: Colors.white.withValues(alpha: .3),
|
color: Colors.white.withValues(
|
||||||
|
alpha: .3,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'Donate',
|
'Donate',
|
||||||
@ -163,7 +167,9 @@ class _KtMinePageState extends State<KtMinePage> {
|
|||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
KtUtils.isEmpty(
|
KtUtils.isEmpty(
|
||||||
state.userInfo.familyName,
|
state
|
||||||
|
.userInfo
|
||||||
|
.familyName,
|
||||||
)
|
)
|
||||||
? 'Visitor'
|
? 'Visitor'
|
||||||
: state
|
: state
|
||||||
@ -174,7 +180,8 @@ class _KtMinePageState extends State<KtMinePage> {
|
|||||||
fontFamily: 'PingFang SC',
|
fontFamily: 'PingFang SC',
|
||||||
fontSize: 18.sp,
|
fontSize: 18.sp,
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight:
|
||||||
|
FontWeight.w500,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -200,7 +207,12 @@ class _KtMinePageState extends State<KtMinePage> {
|
|||||||
Positioned(
|
Positioned(
|
||||||
right: 0,
|
right: 0,
|
||||||
top: -28.w,
|
top: -28.w,
|
||||||
child: Image.asset('ic_mine_ip.png'.ktIcon,width: 80.w,height: 84.w))
|
child: Image.asset(
|
||||||
|
'ic_mine_ip.png'.ktIcon,
|
||||||
|
width: 80.w,
|
||||||
|
height: 84.w,
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(height: 15.w),
|
SizedBox(height: 15.w),
|
||||||
@ -366,11 +378,9 @@ class _KtMinePageState extends State<KtMinePage> {
|
|||||||
handleItem(
|
handleItem(
|
||||||
'ic_order_record.png',
|
'ic_order_record.png',
|
||||||
'Order Record',
|
'Order Record',
|
||||||
() => Get.to(
|
() => Get.to(() => KtOrderRecordPage()),
|
||||||
() => KtOrderRecordPage(
|
|
||||||
),
|
),
|
||||||
),
|
handleItem(
|
||||||
), handleItem(
|
|
||||||
'ic_privacy.png',
|
'ic_privacy.png',
|
||||||
'Privacy Policy',
|
'Privacy Policy',
|
||||||
() => Get.to(
|
() => Get.to(
|
||||||
@ -393,7 +403,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',
|
||||||
|
@ -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/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 KtOrderRecordPage()),
|
GetPage(name: wallet, page: () => const KtOrderRecordPage()),
|
||||||
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'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user