mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 11:08:03 +08:00
opt: get theme color
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'package:PiliPlus/models/dynamics/result.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -6,33 +7,36 @@ import 'package:PiliPlus/common/widgets/network_img_layer.dart';
|
||||
import 'package:PiliPlus/http/search.dart';
|
||||
|
||||
/// TODO 点击跳转
|
||||
Widget addWidget(item, context, type, {floor = 1}) {
|
||||
Widget addWidget(
|
||||
ThemeData theme, DynamicItemModel item, BuildContext context, type,
|
||||
{floor = 1}) {
|
||||
Map<dynamic, dynamic> dynamicProperty = {
|
||||
'ADDITIONAL_TYPE_UGC': item.modules.moduleDynamic.additional.ugc,
|
||||
'ADDITIONAL_TYPE_UGC': item.modules.moduleDynamic!.additional!.ugc,
|
||||
// 直播预约
|
||||
'ADDITIONAL_TYPE_RESERVE': item.modules.moduleDynamic.additional.reserve,
|
||||
'ADDITIONAL_TYPE_RESERVE': item.modules.moduleDynamic!.additional!.reserve,
|
||||
// 商品
|
||||
'ADDITIONAL_TYPE_GOODS': item.modules.moduleDynamic.additional.goods,
|
||||
'ADDITIONAL_TYPE_GOODS': item.modules.moduleDynamic!.additional!.goods,
|
||||
// 比赛信息
|
||||
'ADDITIONAL_TYPE_MATCH': item.modules.moduleDynamic.additional.match,
|
||||
'ADDITIONAL_TYPE_MATCH': item.modules.moduleDynamic!.additional!.match,
|
||||
// 游戏信息
|
||||
'ADDITIONAL_TYPE_COMMON': item.modules.moduleDynamic.additional.common,
|
||||
'ADDITIONAL_TYPE_COMMON': item.modules.moduleDynamic!.additional!.common,
|
||||
};
|
||||
dynamic content = dynamicProperty[type];
|
||||
Color bgColor = floor == 1
|
||||
? Theme.of(context).dividerColor.withOpacity(0.08)
|
||||
: Theme.of(context).colorScheme.surface;
|
||||
? theme.dividerColor.withOpacity(0.08)
|
||||
: theme.colorScheme.surface;
|
||||
switch (type) {
|
||||
case 'ADDITIONAL_TYPE_UGC':
|
||||
// 转发的投稿
|
||||
return InkWell(
|
||||
onTap: () async {
|
||||
String text = dynamicProperty[type].jumpUrl;
|
||||
String text = content.jumpUrl;
|
||||
RegExp bvRegex = RegExp(r'BV[0-9A-Za-z]{10}', caseSensitive: false);
|
||||
Iterable<Match> matches = bvRegex.allMatches(text);
|
||||
if (matches.isNotEmpty) {
|
||||
Match match = matches.first;
|
||||
String bvid = match.group(0)!;
|
||||
String cover = dynamicProperty[type].cover;
|
||||
String cover = content.cover;
|
||||
try {
|
||||
int cid = await SearchHttp.ab2c(bvid: bvid);
|
||||
PageUtils.toVideoPage(
|
||||
@@ -58,7 +62,7 @@ Widget addWidget(item, context, type, {floor = 1}) {
|
||||
NetworkImgLayer(
|
||||
width: 120,
|
||||
height: 75,
|
||||
src: dynamicProperty[type].cover,
|
||||
src: content.cover,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
@@ -67,17 +71,16 @@ Widget addWidget(item, context, type, {floor = 1}) {
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
dynamicProperty[type].title,
|
||||
content.title,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
dynamicProperty[type].descSecond,
|
||||
content.descSecond,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
fontSize:
|
||||
Theme.of(context).textTheme.labelMedium!.fontSize,
|
||||
color: theme.colorScheme.outline,
|
||||
fontSize: theme.textTheme.labelMedium!.fontSize,
|
||||
),
|
||||
)
|
||||
],
|
||||
@@ -88,22 +91,22 @@ Widget addWidget(item, context, type, {floor = 1}) {
|
||||
),
|
||||
);
|
||||
case 'ADDITIONAL_TYPE_RESERVE':
|
||||
return dynamicProperty[type].state != -1
|
||||
? dynamicProperty[type].title != null
|
||||
return content.state != -1
|
||||
? content.title != null
|
||||
? 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),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12, vertical: 10),
|
||||
color: bgColor,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
dynamicProperty[type].title,
|
||||
content.title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
@@ -111,21 +114,15 @@ Widget addWidget(item, context, type, {floor = 1}) {
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
.labelMedium!
|
||||
.fontSize),
|
||||
color: theme.colorScheme.outline,
|
||||
fontSize: theme.textTheme.labelMedium!.fontSize,
|
||||
),
|
||||
children: [
|
||||
if (dynamicProperty[type].desc1 != null)
|
||||
TextSpan(
|
||||
text:
|
||||
dynamicProperty[type].desc1['text']),
|
||||
if (content.desc1 != null)
|
||||
TextSpan(text: content.desc1['text']),
|
||||
const TextSpan(text: ' '),
|
||||
if (dynamicProperty[type].desc2 != null)
|
||||
TextSpan(
|
||||
text:
|
||||
dynamicProperty[type].desc2['text']),
|
||||
if (content.desc2 != null)
|
||||
TextSpan(text: content.desc2['text']),
|
||||
],
|
||||
),
|
||||
)
|
||||
@@ -146,6 +143,6 @@ Widget addWidget(item, context, type, {floor = 1}) {
|
||||
case 'ADDITIONAL_TYPE_VOTE':
|
||||
return const SizedBox.shrink();
|
||||
default:
|
||||
return const Text('11');
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user