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.

155 lines
5.2 KiB

4 years ago
4 years ago
import 'package:dio/dio.dart';
4 years ago
import 'package:flutter/material.dart';
4 years ago
import 'package:flutter_html/flutter_html.dart';
4 years ago
import 'package:flutter_html/image_render.dart';
4 years ago
import 'package:flutter_screenutil/flutter_screenutil.dart';
4 years ago
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';
4 years ago
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
4 years ago
import 'package:share/share.dart';
4 years ago
import 'package:shared_preferences/shared_preferences.dart';
4 years ago
class StoreDetailsPage extends StatefulWidget {
4 years ago
final Map<String, dynamic> arguments;
StoreDetailsPage({this.arguments});
4 years ago
@override
State<StatefulWidget> createState() {
return _StoreDetailsPage();
}
}
class _StoreDetailsPage extends State<StoreDetailsPage> {
4 years ago
4 years ago
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(() {});
}
}
4 years ago
@override
Widget build(BuildContext context) {
return Scaffold(
4 years ago
appBar: MyAppBar(
action: Container(
margin: EdgeInsets.only(right: 15),
child: GestureDetector(
4 years ago
onTap: () {
4 years ago
Share.share('http://share-app.api.lotus-wallet.com/#/share?id=${widget.arguments["activityId"] ?? widget.arguments["articleId"]}');
4 years ago
},
4 years ago
child: Icon(
Icons.share,
size: 24,
color: Colors.black,
),
4 years ago
),
),
4 years ago
background: Color(0xFFF7F7F7),
leadingColor: Colors.black,
4 years ago
title: activity != null ? activity.mainTitle : article != null ? article.mainTitle : "",
4 years ago
titleSize: 18.sp,
titleColor: Colors.black,
4 years ago
),
body: Container(
4 years ago
child: SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: Column(
children: [
Container(
padding: EdgeInsets.all(12),
alignment: Alignment.centerLeft,
child: Text(
4 years ago
activity != null ? activity.mainTitle : article != null ? article.mainTitle : "",
4 years ago
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Color(0xFF353535),
),
),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 12),
child: Row(
children: [
4 years ago
InkWell(
child: Text(
4 years ago
"${activity != null ? activity.storeName : (article != null && article.author != null) ? article.author.name : ""}",
4 years ago
style: TextStyle(
fontWeight: FontWeight.normal,
fontSize: 14.sp,
color: Colors.blue,
),
4 years ago
),
4 years ago
onTap: () {
4 years ago
if(activity != null) {
4 years ago
Navigator.of(context).pushNamed('/router/union_detail_page',
4 years ago
arguments: {"id": activity.storeId});
4 years ago
}
},
4 years ago
),
SizedBox(
width: 10,
),
Text(
4 years ago
activity != null ? activity.createTime : article != null ? article.createTime : "",
4 years ago
style: TextStyle(
fontWeight: FontWeight.normal,
fontSize: 12.sp,
color: Colors.grey,
),
)
],
),
),
4 years ago
Html(
4 years ago
data: activity != null ? activity.content : article != null ? article.content : "",
4 years ago
customImageRenders: {
base64DataUriMatcher(): base64ImageRender(),
assetUriMatcher(): assetImageRender(),
networkSourceMatcher(extension: "svg"): svgNetworkImageRender(),
networkSourceMatcher(): networkImageRender(
loadingWidget: () {
4 years ago
// return Image.asset("assets/image/default_1.png",);
return Container();
4 years ago
}
),
},
),
4 years ago
],
),
4 years ago
),
),
);
}
}