mod: show tag on dynamic panel

This commit is contained in:
bggRGjQaUbCoE
2024-09-26 15:37:02 +08:00
parent f73fd8d6a6
commit 381a44de4c
4 changed files with 53 additions and 5 deletions

View File

@@ -85,7 +85,7 @@ class ItemModulesModel {
ModuleDynamicModel? moduleDynamic;
// ModuleInterModel? moduleInter;
ModuleStatModel? moduleStat;
Map? moduleTag;
ModuleTag? moduleTag;
ItemModulesModel.fromJson(Map<String, dynamic> json) {
moduleAuthor = json['module_author'] != null
@@ -98,7 +98,9 @@ class ItemModulesModel {
moduleStat = json['module_stat'] != null
? ModuleStatModel.fromJson(json['module_stat'])
: null;
moduleTag = json['module_tag'];
moduleTag = json['module_tag'] != null
? ModuleTag.fromJson(json['module_tag'])
: null;
}
}
@@ -759,6 +761,18 @@ class DynamicLive2Model {
}
}
class ModuleTag {
ModuleTag({
this.text,
});
String? text;
ModuleTag.fromJson(Map<String, dynamic> json) {
text = json['text'];
}
}
// 动态状态 转发、评论、点赞
class ModuleStatModel {
ModuleStatModel({

View File

@@ -200,7 +200,10 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
return AnimatedOpacity(
opacity: snapshot.data ? 1 : 0,
duration: const Duration(milliseconds: 300),
child: AuthorPanel(item: _dynamicDetailController.item),
child: AuthorPanel(
item: _dynamicDetailController.item,
source: 'detail', //to remove tag
),
);
},
),

View File

@@ -13,7 +13,13 @@ import '../controller.dart';
class AuthorPanel extends StatelessWidget {
final dynamic item;
final Function? addBannedList;
const AuthorPanel({super.key, required this.item, this.addBannedList});
final String? source;
const AuthorPanel({
super.key,
required this.item,
this.addBannedList,
this.source,
});
@override
Widget build(BuildContext context) {
@@ -82,6 +88,31 @@ class AuthorPanel extends StatelessWidget {
],
),
const Spacer(),
if (source != 'detail' && item.modules?.moduleTag?.text != null)
Container(
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 2),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: const BorderRadius.all(Radius.circular(4)),
border: Border.all(
width: 1.25,
color: Theme.of(context).colorScheme.primary,
),
),
child: Text(
item.modules.moduleTag.text,
style: TextStyle(
height: 1,
fontSize: 12,
color: Theme.of(context).colorScheme.primary,
),
strutStyle: const StrutStyle(
leading: 0,
height: 1,
fontSize: 12,
),
),
),
SizedBox(
width: 32,
height: 32,

View File

@@ -42,7 +42,7 @@ class DynamicPanel extends StatelessWidget {
children: [
Padding(
padding: const EdgeInsets.fromLTRB(12, 12, 12, 6),
child: AuthorPanel(item: item),
child: AuthorPanel(item: item, source: source),
),
if (item!.modules!.moduleDynamic!.desc != null ||
item!.modules!.moduleDynamic!.major != null)