You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

231 lines
7.4 KiB

import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_html/image_render.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/retrofit/data/activity.dart';
import 'package:huixiang/retrofit/data/article.dart';
import 'package:huixiang/retrofit/data/base_data.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:huixiang/view_widget/share_dialog.dart';
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';
class StoreDetailsPage extends StatefulWidget {
final Map<String, dynamic> arguments;
StoreDetailsPage({this.arguments});
@override
State<StatefulWidget> createState() {
return _StoreDetailsPage();
}
}
class _StoreDetailsPage extends State<StoreDetailsPage> {
ApiService apiService;
@override
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) {
apiService =
ApiService(Dio(), context: context, token: value.getString("token"));
queryHtml();
});
}
Activity activity;
Article article;
queryHtml() async {
BaseData baseData = await apiService.informationInfo(
widget.arguments["activityId"] ?? widget.arguments["articleId"]);
if (baseData != null && baseData.isSuccess) {
if (widget.arguments.containsKey("activityId")) {
activity = Activity.fromJson(baseData.data);
} else if (widget.arguments.containsKey("articleId")) {
article = Article.fromJson(baseData.data);
}
setState(() {});
}
}
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
? activity.mainTitle
: article != null
? article.mainTitle
: "",
activity != null
? activity.viceTitle
: article != null
? article.viceTitle
: "",
[],
"",
"",
"http://hx.lotus-wallet.com/index.html?id=${widget.arguments["activityId"] ?? widget.arguments["articleId"]}",
"",
"",
"",
"",
SSDKContentTypes.webpage);
SharesdkPlugin.uploadPrivacyPermissionStatus(1, (success) => {
});
showModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
builder: (context) {
return ShareDialog((platform){
if (platform == ShareSDKPlatforms.line) {
params.map["text"] = "${activity != null
? activity.viceTitle
: article != null
? article.viceTitle
: ""} http://hx.lotus-wallet.com/index.html?id=${widget.arguments["activityId"] ?? widget.arguments["articleId"]}";
}
SharesdkPlugin.share(platform, params, (state, userData, contentEntity, error) {
print("share!$state");
print("share!$platform");
print("share!$userData");
print("share!$contentEntity");
print("share!$error");
print("share!");
});
});
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: MyAppBar(
action: Container(
margin: EdgeInsets.only(right: 10),
child: GestureDetector(
onTap: () {
share();
},
child: Icon(
Icons.share,
size: 24,
color: Colors.black,
),
),
),
background: Color(0xFFF7F7F7),
leadingColor: Colors.black,
title: activity != null
? activity.mainTitle
: article != null
? article.mainTitle
: "",
titleSize: 18.sp,
titleColor: Colors.black,
),
body: Container(
child: SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: Column(
children: [
Container(
padding: EdgeInsets.all(12),
alignment: Alignment.centerLeft,
child: Text(
activity != null
? activity.mainTitle
: article != null
? article.mainTitle
: "",
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Color(0xFF353535),
),
),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 12),
child: Row(
children: [
InkWell(
child: Text(
"${activity != null ? activity.storeName : (article != null && article.author != null) ? article.author.name : ""}",
style: TextStyle(
fontWeight: FontWeight.normal,
fontSize: 14.sp,
color: Colors.blue,
),
),
onTap: () {
if (activity != null) {
Navigator.of(context).pushNamed(
'/router/union_detail_page',
arguments: {"id": activity.storeId});
}
},
),
SizedBox(
width: 10,
),
Text(
activity != null
? activity.createTime
: article != null
? article.createTime
: "",
style: TextStyle(
fontWeight: FontWeight.normal,
fontSize: 12.sp,
color: Colors.grey,
),
)
],
),
),
Html(
data: activity != null
? activity.content
: article != null
? article.content
: "",
customImageRenders: {
base64DataUriMatcher(): base64ImageRender(),
assetUriMatcher(): assetImageRender(),
networkSourceMatcher(extension: "svg"):
svgNetworkImageRender(),
networkSourceMatcher(): networkImageRender(loadingWidget: () {
return Container();
}),
},
),
],
),
),
),
);
}
@override
void dispose() {
super.dispose();
}
}