修复包裹管理列表显示错误的问题,

实现公共资讯详情中,嵌入超链接,可以点击跳转浏览器
hmxc
张萌 4 years ago
parent 7eed5f3780
commit 7bd49900cb

@ -13,8 +13,7 @@ import 'package:aku_community/const/resource.dart';
class ElectronicCommercCard extends StatefulWidget { class ElectronicCommercCard extends StatefulWidget {
final ElectronicCommercListModel model; final ElectronicCommercListModel model;
ElectronicCommercCard({Key? key, required this.model}) ElectronicCommercCard({Key? key, required this.model}) : super(key: key);
: super(key: key);
@override @override
_ElectronicCommercCardState createState() => _ElectronicCommercCardState(); _ElectronicCommercCardState createState() => _ElectronicCommercCardState();

@ -61,6 +61,13 @@ class _ElectronicCommercDetailPageState extends State<ElectronicCommercDetailPag
: ListView( : ListView(
padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 32.w), padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 32.w),
children: [ children: [
// SizedBox(
// width: double.infinity,
// child: FadeInImage.assetNetwork(
// placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
// image: API.image(ImgModel.first(_detailModel.imgList))),
// ),
// 24.w.heightBox,
_detailModel.title.text _detailModel.title.text
.size(32.sp) .size(32.sp)
.color(ktextPrimary) .color(ktextPrimary)

@ -31,13 +31,12 @@ class _ExpressPackageViewState extends State<ExpressPackageView> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// return ListView(
// padding: EdgeInsets.symmetric(vertical: 16.w, horizontal: 32.w),
// children: [ExpressPackageCard(index: widget.index)],
// );
return BeeListView( return BeeListView(
path: API.manager.expressPackageList, path: API.manager.expressPackageList,
controller: _refreshController, controller: _refreshController,
extraParams: {
"packageCollectionStatus": widget.index + 1,
},
convert: (models) { convert: (models) {
return models.tableList return models.tableList
?.map((e) => ExpressPackageListModel.fromJson(e)) ?.map((e) => ExpressPackageListModel.fromJson(e))

@ -1,13 +1,16 @@
import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/base/base_style.dart';
import 'package:aku_community/constants/api.dart'; import 'package:aku_community/constants/api.dart';
import 'package:aku_community/models/news/news_detail_model.dart'; import 'package:aku_community/models/news/news_detail_model.dart';
import 'package:aku_community/utils/link_text_parase.dart';
import 'package:aku_community/utils/network/base_model.dart'; import 'package:aku_community/utils/network/base_model.dart';
import 'package:aku_community/utils/network/net_util.dart'; import 'package:aku_community/utils/network/net_util.dart';
import 'package:aku_community/widget/bee_scaffold.dart'; import 'package:aku_community/widget/bee_scaffold.dart';
import 'package:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
import 'package:flustars/flustars.dart'; import 'package:flustars/flustars.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:velocity_x/velocity_x.dart'; import 'package:velocity_x/velocity_x.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -25,15 +28,19 @@ class _PublicInformationDetailPageState
late EasyRefreshController _easyRefreshController; late EasyRefreshController _easyRefreshController;
bool _onload = true; bool _onload = true;
late NewsDetailModel _detailModel; late NewsDetailModel _detailModel;
late List<String> _parasedText;
late TapGestureRecognizer _tapLinkUrlLancher; //
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_easyRefreshController = EasyRefreshController(); _easyRefreshController = EasyRefreshController();
_tapLinkUrlLancher = TapGestureRecognizer();
} }
@override @override
void dispose() { void dispose() {
_easyRefreshController.dispose(); _easyRefreshController.dispose();
_tapLinkUrlLancher.dispose(); //
super.dispose(); super.dispose();
} }
@ -52,6 +59,7 @@ class _PublicInformationDetailPageState
}); });
if (baseModel.status! && baseModel.data != null) { if (baseModel.status! && baseModel.data != null) {
_detailModel = NewsDetailModel.fromJson(baseModel.data); _detailModel = NewsDetailModel.fromJson(baseModel.data);
_parasedText = LinkTextParase.stringParase(_detailModel.content);
} else { } else {
BotToast.showText(text: '无法获取信息'); BotToast.showText(text: '无法获取信息');
} }
@ -72,10 +80,29 @@ class _PublicInformationDetailPageState
24.w.heightBox, 24.w.heightBox,
SizedBox( SizedBox(
width: double.infinity, width: double.infinity,
child: _detailModel.content.text child: RichText(
.size(28.sp) text: TextSpan(
.color(ktextPrimary) children: List.generate(_parasedText.length, (index) {
.make(), if (index.isEven) {
return TextSpan(
text: _parasedText[index],
style:
TextStyle(fontSize: 28.sp, color: ktextPrimary),
);
} else {
return TextSpan(
text: _parasedText[index],
style: TextStyle(
fontSize: 28.sp,
color: Colors.lightBlue,
),
recognizer: _tapLinkUrlLancher
..onTap = () {
launch(_parasedText[index]);
});
}
})),
),
), ),
40.w.heightBox, 40.w.heightBox,
Row( Row(

@ -0,0 +1,23 @@
class LinkTextParase {
static List<String> stringParase(String text, {Pattern? pattern}) {
List<String> _listString = [];
List<String> _urls = []; //url
//使urlurl
Pattern _pattern = pattern ??
RegExp(
r"(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]"); //url
_listString = text.split(_pattern);
var _matches = _pattern.allMatches(text);
for (var item in _matches) {
_urls.add(item[0]!);
print(item[0]);
}
//url
for (var i = 0; i < _urls.length; i++) {
_listString.insert(2 * i + 1, _urls[i]);
}
return _listString;
}
}
Loading…
Cancel
Save