|
|
|
@ -1,3 +1,6 @@
|
|
|
|
|
import 'dart:io'; |
|
|
|
|
|
|
|
|
|
import 'package:chewie_audio/chewie_audio.dart'; |
|
|
|
|
import 'package:dio/dio.dart'; |
|
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
|
import 'package:flutter_html/flutter_html.dart'; |
|
|
|
@ -13,6 +16,12 @@ import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
|
import 'package:sharesdk_plugin/sharesdk_defines.dart'; |
|
|
|
|
import 'package:sharesdk_plugin/sharesdk_interface.dart'; |
|
|
|
|
import 'package:sharesdk_plugin/sharesdk_map.dart'; |
|
|
|
|
import 'package:video_player/video_player.dart'; |
|
|
|
|
import 'package:webview_flutter/webview_flutter.dart'; |
|
|
|
|
import 'package:flutter_html/src/replaced_element.dart'; |
|
|
|
|
import 'package:flutter/cupertino.dart'; |
|
|
|
|
import 'package:chewie/src/chewie_progress_colors.dart' as chewie; |
|
|
|
|
import 'package:chewie/chewie.dart'; |
|
|
|
|
|
|
|
|
|
class StoreDetailsPage extends StatefulWidget { |
|
|
|
|
final Map<String, dynamic> arguments; |
|
|
|
@ -33,6 +42,8 @@ class _StoreDetailsPage extends State<StoreDetailsPage> {
|
|
|
|
|
void initState() { |
|
|
|
|
super.initState(); |
|
|
|
|
|
|
|
|
|
if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView(); |
|
|
|
|
|
|
|
|
|
SharedPreferences.getInstance().then((value) { |
|
|
|
|
apiService = |
|
|
|
|
ApiService(Dio(), context: context, token: value.getString("token")); |
|
|
|
@ -58,11 +69,6 @@ class _StoreDetailsPage extends State<StoreDetailsPage> {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
share() async { |
|
|
|
|
// await registerWxApi(appId: "wx3b269e795ed23e5f", doOnAndroid: true, universalLink: "https://hx.lotus-wallet.com/app/"); |
|
|
|
|
// shareToWeChat(WeChatShareWebPageModel( |
|
|
|
|
// "http://hx.lotus-wallet.com/index.html?id=${widget.arguments["activityId"] ?? widget.arguments["articleId"]}", |
|
|
|
|
// scene: WeChatScene.SESSION)); |
|
|
|
|
// SharesdkPlugin.showMenu(); |
|
|
|
|
SSDKMap params = SSDKMap() |
|
|
|
|
..setGeneral( |
|
|
|
|
activity != null |
|
|
|
@ -152,14 +158,14 @@ class _StoreDetailsPage extends State<StoreDetailsPage> {
|
|
|
|
|
? article.mainTitle |
|
|
|
|
: "", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 16, |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
color: Color(0xFF353535), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Container( |
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12), |
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w), |
|
|
|
|
child: Row( |
|
|
|
|
children: [ |
|
|
|
|
InkWell( |
|
|
|
@ -212,6 +218,29 @@ class _StoreDetailsPage extends State<StoreDetailsPage> {
|
|
|
|
|
return Container(); |
|
|
|
|
}), |
|
|
|
|
}, |
|
|
|
|
customRender: { |
|
|
|
|
"video" : (context, parsedChild, attributes, element) { |
|
|
|
|
print("video attributes: ${element.attributes}"); |
|
|
|
|
print("video attributes: ${element.attributeSpans}"); |
|
|
|
|
print("video attributes: ${element.children.first.attributes["src"]}"); |
|
|
|
|
print("video attributes: ${parsedChild}"); |
|
|
|
|
return videoWidget(double.tryParse(attributes['width'] ?? ""), double.tryParse(element.attributes['height'] ?? ""), element.children.first.attributes["src"], element.attributes["sandbox"]); |
|
|
|
|
}, |
|
|
|
|
"iframe" : (context, parsedChild, attributes, element) { |
|
|
|
|
print("iframe attributes: ${element.toString()}"); |
|
|
|
|
print("iframe attributes: ${parsedChild}"); |
|
|
|
|
return videoWidget(double.tryParse(attributes['width'] ?? ""), double.tryParse(element.attributes['height'] ?? ""), element.children.first.attributes["src"], element.attributes["sandbox"]); |
|
|
|
|
}, |
|
|
|
|
"audio" : (context, parsedChild, attributes, element) { |
|
|
|
|
final sources = <String>[ |
|
|
|
|
if (element.attributes['src'] != null) element.attributes['src'], |
|
|
|
|
]; |
|
|
|
|
if (sources == null || sources.isEmpty || sources.first == null) { |
|
|
|
|
return EmptyContentElement(); |
|
|
|
|
} |
|
|
|
|
return audioWidget(attributes['controls'] != null, attributes['loop'] != null, attributes['autoplay'] != null, sources, context.style.width ?? 300.w); |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
@ -220,10 +249,65 @@ class _StoreDetailsPage extends State<StoreDetailsPage> {
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
VideoPlayerController videoPlayerController; |
|
|
|
|
ChewieController chewieAudioController; |
|
|
|
|
Chewie chewies; |
|
|
|
|
|
|
|
|
|
Widget videoWidget(double width, double height, src, sandboxMode) { |
|
|
|
|
print("src : $src"); |
|
|
|
|
return Container( |
|
|
|
|
width: MediaQuery.of(context).size.width, |
|
|
|
|
height: (MediaQuery.of(context).size.width) / (width / height), |
|
|
|
|
child: chewies = Chewie( |
|
|
|
|
controller: chewieAudioController = ChewieController( |
|
|
|
|
videoPlayerController: videoPlayerController = VideoPlayerController.network( |
|
|
|
|
src, |
|
|
|
|
), |
|
|
|
|
aspectRatio: width / height, |
|
|
|
|
//宽高比 |
|
|
|
|
autoPlay: !true, |
|
|
|
|
//自动播放 |
|
|
|
|
looping: false, |
|
|
|
|
//循环播放 |
|
|
|
|
// 拖动条样式颜色 |
|
|
|
|
materialProgressColors: chewie.ChewieProgressColors( |
|
|
|
|
playedColor: Colors.white, |
|
|
|
|
handleColor: Colors.white, |
|
|
|
|
backgroundColor: Colors.grey, |
|
|
|
|
bufferedColor: Colors.transparent, |
|
|
|
|
), |
|
|
|
|
autoInitialize: true, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Widget audioWidget(showControls, loop, autoplay, src, width) { |
|
|
|
|
return Container( |
|
|
|
|
width: width, |
|
|
|
|
child: chewies = Chewie( |
|
|
|
|
controller: chewieAudioController = ChewieController( |
|
|
|
|
videoPlayerController: VideoPlayerController.network( |
|
|
|
|
src.first ?? "", |
|
|
|
|
), |
|
|
|
|
autoPlay: autoplay, |
|
|
|
|
looping: loop, |
|
|
|
|
showControls: showControls, |
|
|
|
|
autoInitialize: true, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
void dispose() { |
|
|
|
|
super.dispose(); |
|
|
|
|
if (chewieAudioController != null) |
|
|
|
|
chewieAudioController.dispose(); |
|
|
|
|
|
|
|
|
|
if (videoPlayerController != null) |
|
|
|
|
videoPlayerController.dispose(); |
|
|
|
|
|
|
|
|
|
super.dispose(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|