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

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

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

@ -61,6 +61,13 @@ class _ElectronicCommercDetailPageState extends State<ElectronicCommercDetailPag
: ListView(
padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 32.w),
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
.size(32.sp)
.color(ktextPrimary)

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

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