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

View File

@ -7,24 +7,34 @@ Widget content(item, context, source) {
TextStyle authorStyle = TextStyle authorStyle =
TextStyle(color: Theme.of(context).colorScheme.primary); TextStyle(color: Theme.of(context).colorScheme.primary);
return Container( return Container(
width: double.infinity, width: double.infinity,
padding: const EdgeInsets.fromLTRB(12, 0, 12, 6), padding: const EdgeInsets.fromLTRB(12, 0, 12, 6),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
if (item.modules.moduleDynamic.topic != null) ...[ if (item.modules.moduleDynamic.topic != null) ...[
GestureDetector( GestureDetector(
child: Text( child: Text(
'#${item.modules.moduleDynamic.topic.name}', '#${item.modules.moduleDynamic.topic.name}',
style: authorStyle, 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( WidgetSpan(
alignment: PlaceholderAlignment.middle, alignment: PlaceholderAlignment.middle,
child: GestureDetector( child: GestureDetector(
onTap: () {}, onTap: () {
Get.toNamed(
'/webview',
parameters: {'url': i.origText, 'type': 'url', 'pageTitle': ''},
);
},
child: Text( child: Text(
i.text, i.text,
style: authorStyle, style: authorStyle,
@ -79,7 +84,18 @@ InlineSpan richNode(item, context) {
WidgetSpan( WidgetSpan(
alignment: PlaceholderAlignment.middle, alignment: PlaceholderAlignment.middle,
child: GestureDetector( 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( child: Text(
'投票:${i.text}', '投票:${i.text}',
style: authorStyle, style: authorStyle,

View File

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