mod: dyn author panel

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-01-27 21:46:44 +08:00
parent c5877b7c5e
commit 7f3f7f6bdd
2 changed files with 182 additions and 159 deletions

View File

@@ -143,6 +143,7 @@ class ModuleAuthorModel {
String? type; String? type;
Map? vip; Map? vip;
Map? decorate; Map? decorate;
// Map? pendant;
ModuleAuthorModel.fromJson(Map<String, dynamic> json) { ModuleAuthorModel.fromJson(Map<String, dynamic> json) {
face = json['face']; face = json['face'];
@@ -156,7 +157,10 @@ class ModuleAuthorModel {
pubTs = json['pub_ts'] == 0 ? null : json['pub_ts']; pubTs = json['pub_ts'] == 0 ? null : json['pub_ts'];
type = json['type']; type = json['type'];
vip = json['vip']; vip = json['vip'];
if (showDynDecorate) decorate = json['decorate']; if (showDynDecorate) {
decorate = json['decorate'];
// pendant = json['pendant'];
}
} }
static bool showDynDecorate = GStorage.showDynDecorate; static bool showDynDecorate = GStorage.showDynDecorate;

View File

@@ -3,6 +3,7 @@ import 'package:PiliPlus/http/index.dart';
import 'package:PiliPlus/models/dynamics/result.dart'; import 'package:PiliPlus/models/dynamics/result.dart';
import 'package:PiliPlus/utils/extension.dart'; import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/storage.dart'; import 'package:PiliPlus/utils/storage.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@@ -32,175 +33,193 @@ class AuthorPanel extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
String heroTag = Utils.makeHeroTag(item.modules.moduleAuthor.mid); return Stack(
return Row( alignment: Alignment.center,
children: [ children: [
GestureDetector( Align(
onTap: () { alignment: Alignment.centerLeft,
// 番剧 child: Row(
if (item.modules.moduleAuthor.type == 'AUTHOR_TYPE_PGC' || mainAxisSize: MainAxisSize.min,
item.modules.moduleAuthor.type == 'AUTHOR_TYPE_UGC_SEASON') { children: [
return; GestureDetector(
} onTap: () {
feedBack(); // 番剧
Get.toNamed( if (item.modules.moduleAuthor.type == 'AUTHOR_TYPE_PGC' ||
'/member?mid=${item.modules.moduleAuthor.mid}', item.modules.moduleAuthor.type ==
arguments: { 'AUTHOR_TYPE_UGC_SEASON') {
'face': item.modules.moduleAuthor.face, return;
'heroTag': heroTag
},
);
},
child: Hero(
tag: heroTag,
child: NetworkImgLayer(
width: 40,
height: 40,
type: 'avatar',
src: item.modules.moduleAuthor.face,
),
),
),
const SizedBox(width: 10),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text(
item.modules.moduleAuthor.name,
// semanticsLabel: "UP主${item.modules.moduleAuthor.name}",
style: TextStyle(
color: item.modules.moduleAuthor!.vip != null &&
item.modules.moduleAuthor!.vip['status'] > 0 &&
item.modules.moduleAuthor!.vip['type'] == 2
? context.vipColor
: Theme.of(context).colorScheme.onSurface,
fontSize: Theme.of(context).textTheme.titleSmall!.fontSize,
),
),
],
),
DefaultTextStyle.merge(
style: TextStyle(
color: Theme.of(context).colorScheme.outline,
fontSize: Theme.of(context).textTheme.labelSmall!.fontSize,
),
child: Row(
children: [
Text(item is ItemOrigModel
? Utils.dateFormat(item.modules.moduleAuthor.pubTs)
: item.modules.moduleAuthor.pubTime),
if (item.modules.moduleAuthor.pubTime != '' &&
item.modules.moduleAuthor.pubAction != '')
const Text(' '),
Text(item.modules.moduleAuthor.pubAction),
],
),
)
],
),
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,
),
),
),
if (item.modules.moduleAuthor.decorate != null)
GestureDetector(
onTap: item.modules.moduleAuthor.decorate['jump_url'] != null
? () {
Get.toNamed(
'/webview',
parameters: {
'url':
'${item.modules.moduleAuthor.decorate['jump_url']}'
},
);
} }
: null, feedBack();
child: Stack( Get.toNamed(
clipBehavior: Clip.none, '/member?mid=${item.modules.moduleAuthor.mid}',
alignment: Alignment.centerRight, arguments: {
children: [ 'face': item.modules.moduleAuthor.face,
Image.network( },
height: 32, );
item.modules.moduleAuthor.decorate['card_url'], },
child: NetworkImgLayer(
width: 40,
height: 40,
type: 'avatar',
src: item.modules.moduleAuthor.face,
), ),
if ((item.modules.moduleAuthor.decorate?['fan']?['num_str'] ),
as String?) const SizedBox(width: 10),
?.isNotEmpty == Column(
true) crossAxisAlignment: CrossAxisAlignment.start,
Padding( children: [
padding: const EdgeInsets.only(right: 32), Text(
child: Text( item.modules.moduleAuthor.name,
'${item.modules.moduleAuthor.decorate['fan']['num_str']}', // semanticsLabel: "UP主${item.modules.moduleAuthor.name}",
style: TextStyle( style: TextStyle(
fontSize: 11, color: item.modules.moduleAuthor!.vip != null &&
fontFamily: 'digital_id_num', item.modules.moduleAuthor!.vip['status'] > 0 &&
color: (item.modules.moduleAuthor.decorate?['fan'] item.modules.moduleAuthor!.vip['type'] == 2
?['color'] as String?) ? context.vipColor
?.startsWith('#') == : Theme.of(context).colorScheme.onSurface,
true fontSize:
? Color( Theme.of(context).textTheme.titleSmall!.fontSize,
int.parse(
item.modules.moduleAuthor
.decorate['fan']['color']
.replaceFirst('#', '0xFF'),
),
)
: null,
),
), ),
), ),
], DefaultTextStyle.merge(
), style: TextStyle(
), color: Theme.of(context).colorScheme.outline,
SizedBox( fontSize:
width: 32, Theme.of(context).textTheme.labelSmall!.fontSize,
height: 32, ),
child: IconButton( child: Row(
tooltip: '更多', children: [
style: ButtonStyle( Text(item is ItemOrigModel
padding: WidgetStateProperty.all(EdgeInsets.zero), ? Utils.dateFormat(item.modules.moduleAuthor.pubTs)
), : item.modules.moduleAuthor.pubTime),
onPressed: () { if (item.modules.moduleAuthor.pubTime != '' &&
showModalBottomSheet( item.modules.moduleAuthor.pubAction != '')
context: context, const Text(' '),
useRootNavigator: true, Text(item.modules.moduleAuthor.pubAction),
isScrollControlled: true, ],
builder: (context) { ),
return morePanel(context); )
}, ],
); ),
}, // const Spacer(),
icon: const Icon(Icons.more_vert_outlined, size: 18), // 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,
// ),
// ),
// ),
],
), ),
), ),
Align(
alignment: Alignment.centerRight,
child: item.modules.moduleAuthor.decorate != null
? Row(
mainAxisSize: MainAxisSize.min,
children: [
GestureDetector(
onTap:
item.modules.moduleAuthor.decorate['jump_url'] != null
? () {
Get.toNamed(
'/webview',
parameters: {
'url':
'${item.modules.moduleAuthor.decorate['jump_url']}'
},
);
}
: null,
child: Stack(
clipBehavior: Clip.none,
alignment: Alignment.centerRight,
children: [
CachedNetworkImage(
height: 32,
imageUrl:
item.modules.moduleAuthor.decorate['card_url'],
),
if ((item.modules.moduleAuthor.decorate?['fan']
?['num_str'] as String?)
?.isNotEmpty ==
true)
Padding(
padding: const EdgeInsets.only(right: 32),
child: Text(
'${item.modules.moduleAuthor.decorate['fan']['num_str']}',
style: TextStyle(
fontSize: 11,
fontFamily: 'digital_id_num',
color: (item.modules.moduleAuthor
.decorate?['fan']
?['color'] as String?)
?.startsWith('#') ==
true
? Color(
int.parse(
item.modules.moduleAuthor
.decorate['fan']['color']
.replaceFirst('#', '0xFF'),
),
)
: null,
),
),
),
],
),
),
_moreWidget(context),
],
)
: _moreWidget(context),
)
], ],
); );
} }
Widget _moreWidget(context) => SizedBox(
width: 32,
height: 32,
child: IconButton(
tooltip: '更多',
style: ButtonStyle(
padding: WidgetStateProperty.all(EdgeInsets.zero),
),
onPressed: () {
showModalBottomSheet(
context: context,
useRootNavigator: true,
isScrollControlled: true,
builder: (context) {
return morePanel(context);
},
);
},
icon: const Icon(Icons.more_vert_outlined, size: 18),
),
);
Widget morePanel(context) { Widget morePanel(context) {
return Container( return Container(
padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom), padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),