mod: 动态页面长按复制、链接跳转、样式

This commit is contained in:
guozhigq
2023-07-18 18:11:06 +08:00
parent 9eb52933c4
commit 70a35deefc
4 changed files with 133 additions and 91 deletions

View File

@ -23,7 +23,7 @@ Widget addWidget(item, context, type, {floor = 1}) {
onTap: () {},
child: Container(
padding:
const EdgeInsets.only(left: 15, top: 10, right: 15, bottom: 8),
const EdgeInsets.only(left: 12, top: 8, right: 12, bottom: 8),
color: bgColor,
child: Row(
children: [
@ -60,90 +60,104 @@ Widget addWidget(item, context, type, {floor = 1}) {
),
);
case 'ADDITIONAL_TYPE_RESERVE':
return InkWell(
onTap: () {},
child: Container(
margin: const EdgeInsets.only(top: 8),
padding:
const EdgeInsets.only(left: 15, top: 12, right: 15, bottom: 10),
color: bgColor,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(dynamicProperty[type].title),
Text.rich(TextSpan(
style: TextStyle(
color: Theme.of(context).colorScheme.outline,
fontSize: Theme.of(context)
.textTheme
.labelMedium!
.fontSize),
children: [
TextSpan(text: dynamicProperty[type].desc1['text']),
TextSpan(text: dynamicProperty[type].desc2['text']),
]))
],
),
// TextButton(onPressed: () {}, child: Text('123'))
],
return Padding(
padding: const EdgeInsets.only(top: 8),
child: InkWell(
onTap: () {},
child: Container(
width: double.infinity,
padding:
const EdgeInsets.only(left: 12, top: 10, right: 12, bottom: 10),
color: bgColor,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
dynamicProperty[type].title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 1),
Text.rich(
TextSpan(
style: TextStyle(
color: Theme.of(context).colorScheme.outline,
fontSize:
Theme.of(context).textTheme.labelMedium!.fontSize),
children: [
TextSpan(text: dynamicProperty[type].desc1['text']),
const TextSpan(text: ' '),
TextSpan(text: dynamicProperty[type].desc2['text']),
],
),
)
],
),
// TextButton(onPressed: () {}, child: Text('123'))
),
),
);
case 'ADDITIONAL_TYPE_GOODS':
return Container(
margin: const EdgeInsets.only(top: 6),
padding: const EdgeInsets.only(left: 15, top: 10, right: 15, bottom: 8),
decoration: BoxDecoration(
color: bgColor,
borderRadius: BorderRadius.all(Radius.circular(6)),
),
child: Row(
children: [
NetworkImgLayer(
width: 75,
height: 75,
src: dynamicProperty[type].items.first.cover,
),
const SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
return Padding(
padding: const EdgeInsets.only(top: 6),
child: InkWell(
onTap: () {},
child: Container(
padding:
const EdgeInsets.only(left: 12, top: 8, right: 12, bottom: 8),
decoration: BoxDecoration(
color: bgColor,
borderRadius: const BorderRadius.all(Radius.circular(6)),
),
child: Row(
children: [
Text(
dynamicProperty[type].items.first.name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
NetworkImgLayer(
width: 75,
height: 75,
src: dynamicProperty[type].items.first.cover,
),
Text(
dynamicProperty[type].items.first.brief,
maxLines: 1,
style: TextStyle(
color: Theme.of(context).colorScheme.outline,
fontSize:
Theme.of(context).textTheme.labelMedium!.fontSize,
),
),
const SizedBox(height: 2),
Text(
dynamicProperty[type].items.first.price,
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
const SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
dynamicProperty[type].items.first.name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Text(
dynamicProperty[type].items.first.brief,
maxLines: 1,
style: TextStyle(
color: Theme.of(context).colorScheme.outline,
fontSize: Theme.of(context)
.textTheme
.labelMedium!
.fontSize,
),
),
const SizedBox(height: 2),
Text(
dynamicProperty[type].items.first.price,
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
),
),
],
),
),
],
),
),
],
),
);
));
case 'ADDITIONAL_TYPE_MATCH':
return SizedBox();
case 'ADDITIONAL_TYPE_COMMON':
return SizedBox();
case 'ADDITIONAL_TYPE_VOTE':
return SizedBox();
default:
return Text('11');
}

View File

@ -7,24 +7,34 @@ Widget content(item, context, source) {
TextStyle authorStyle =
TextStyle(color: Theme.of(context).colorScheme.primary);
return Container(
width: double.infinity,
padding: const EdgeInsets.fromLTRB(12, 0, 12, 6),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (item.modules.moduleDynamic.topic != null) ...[
GestureDetector(
child: Text(
'#${item.modules.moduleDynamic.topic.name}',
style: authorStyle,
),
width: double.infinity,
padding: const EdgeInsets.fromLTRB(12, 0, 12, 6),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (item.modules.moduleDynamic.topic != null) ...[
GestureDetector(
child: Text(
'#${item.modules.moduleDynamic.topic.name}',
style: authorStyle,
),
],
Text.rich(
richNode(item, context),
maxLines: source == 'detail' ? 999 : 3,
overflow: TextOverflow.ellipsis,
),
],
));
IgnorePointer(
// 禁用SelectableRegion的触摸交互功能
ignoring: source == 'detail' ? false : true,
child: SelectableRegion(
magnifierConfiguration: const TextMagnifierConfiguration(),
focusNode: FocusNode(),
selectionControls: MaterialTextSelectionControls(),
child: Text.rich(
richNode(item, context),
maxLines: source == 'detail' ? 999 : 3,
overflow: TextOverflow.ellipsis,
),
),
),
],
),
);
}

View File

@ -64,7 +64,12 @@ InlineSpan richNode(item, context) {
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: GestureDetector(
onTap: () {},
onTap: () {
Get.toNamed(
'/webview',
parameters: {'url': i.origText, 'type': 'url', 'pageTitle': ''},
);
},
child: Text(
i.text,
style: authorStyle,
@ -79,7 +84,18 @@ InlineSpan richNode(item, context) {
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: GestureDetector(
onTap: () {},
onTap: () {
String dynamicId = item.basic['comment_id_str'];
Get.toNamed(
'/webview',
parameters: {
'url':
'https://t.bilibili.com/vote/h5/index/#/result?vote_id=${i.rid}&dynamic_id=${dynamicId}&isWeb=1',
'type': 'vote',
'pageTitle': '投票'
},
);
},
child: Text(
'投票:${i.text}',
style: authorStyle,

View File

@ -92,8 +92,10 @@ class _UpPanelState extends State<UpPanel> {
child: Center(
child: Text(
'全部',
style:
TextStyle(color: Theme.of(context).primaryColor),
style: TextStyle(
color: Theme.of(context)
.colorScheme
.onSecondaryContainer),
),
),
),