mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
refa: opus (#762)
* feat: opus * fix * fix * fix * fix * . * fix * remove * wbi sign * fix * opus content null check Co-authored-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
committed by
GitHub
parent
3722ff1f33
commit
bd3c76ef43
@@ -3,14 +3,17 @@ import 'package:PiliPlus/http/dynamics.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/user.dart';
|
||||
import 'package:PiliPlus/http/video.dart';
|
||||
import 'package:PiliPlus/models/dynamics/article_view/data.dart';
|
||||
import 'package:PiliPlus/models/dynamics/opus_detail/data.dart';
|
||||
import 'package:PiliPlus/models/dynamics/opus_detail/favorite.dart';
|
||||
import 'package:PiliPlus/models/dynamics/article_content_model.dart'
|
||||
show ArticleContentModel;
|
||||
import 'package:PiliPlus/models/dynamics/result.dart';
|
||||
import 'package:PiliPlus/models/model_owner.dart';
|
||||
import 'package:PiliPlus/models/space_article/item.dart';
|
||||
import 'package:PiliPlus/models/space_article/stats.dart';
|
||||
import 'package:PiliPlus/pages/common/reply_controller.dart';
|
||||
import 'package:PiliPlus/pages/mine/controller.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/url_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:PiliPlus/http/reply.dart';
|
||||
@@ -20,9 +23,10 @@ class ArticleController extends ReplyController<MainListReply> {
|
||||
late String id;
|
||||
late String type;
|
||||
|
||||
late final String url;
|
||||
late String url;
|
||||
late int commentType;
|
||||
dynamic commentId;
|
||||
late int commentId;
|
||||
final summary = Summary();
|
||||
|
||||
RxBool showTitle = false.obs;
|
||||
|
||||
@@ -30,14 +34,15 @@ class ArticleController extends ReplyController<MainListReply> {
|
||||
late final showDynActionBar = GStorage.showDynActionBar;
|
||||
|
||||
@override
|
||||
dynamic get sourceId => id;
|
||||
dynamic get sourceId => commentType == 12 ? 'cv$commentId' : id;
|
||||
|
||||
RxBool isLoaded = false.obs;
|
||||
late ArticleData articleData;
|
||||
late OpusData opusData;
|
||||
final RxBool isLoaded = false.obs;
|
||||
DynamicItemModel? opusData; // 采用opus信息作为动态信息, 标题信息从summary获取
|
||||
Item? articleData;
|
||||
final Rx<ModuleStatModel?> stats = Rx<ModuleStatModel?>(null);
|
||||
|
||||
late final Rx<DynamicItemModel> item = DynamicItemModel().obs;
|
||||
late final RxMap favStat = <dynamic, dynamic>{'status': false}.obs;
|
||||
List<ArticleContentModel>? get opus =>
|
||||
opusData?.modules.moduleContent ?? articleData?.opus?.content;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@@ -45,6 +50,13 @@ class ArticleController extends ReplyController<MainListReply> {
|
||||
id = Get.parameters['id']!;
|
||||
type = Get.parameters['type']!;
|
||||
|
||||
if (Get.arguments?['item'] is DynamicItemModel) {
|
||||
opusData = Get.arguments['item'];
|
||||
if (opusData!.modules.moduleStat != null) {
|
||||
stats.value = opusData!.modules.moduleStat!;
|
||||
}
|
||||
}
|
||||
|
||||
// to opus
|
||||
if (type == 'read') {
|
||||
UrlUtils.parseRedirectUrl('https://www.bilibili.com/read/cv$id/')
|
||||
@@ -60,101 +72,92 @@ class ArticleController extends ReplyController<MainListReply> {
|
||||
}
|
||||
}
|
||||
|
||||
init() {
|
||||
setUrl() {
|
||||
url = type == 'read'
|
||||
? 'https://www.bilibili.com/read/cv$id'
|
||||
: 'https://www.bilibili.com/opus/$id';
|
||||
}
|
||||
|
||||
init() {
|
||||
setUrl();
|
||||
commentType = type == 'picture' ? 11 : 12;
|
||||
|
||||
if (Get.arguments?['item'] is DynamicItemModel) {
|
||||
item.value = Get.arguments['item'];
|
||||
}
|
||||
|
||||
_queryDynItem();
|
||||
_queryContent();
|
||||
}
|
||||
|
||||
_queryDynItem() async {
|
||||
if (showDynActionBar) {
|
||||
if (type == 'read') {
|
||||
if (item.value.idStr == null) {
|
||||
UrlUtils.parseRedirectUrl('https://www.bilibili.com/read/cv$id/')
|
||||
.then((url) {
|
||||
if (url != null) {
|
||||
_queryDyn(url.split('/').last);
|
||||
}
|
||||
});
|
||||
}
|
||||
_queryInfo();
|
||||
} else {
|
||||
_queryDyn(id);
|
||||
Future<bool> queryOpus(opusId) async {
|
||||
final res = await DynamicsHttp.opusDetail(opusId: opusId);
|
||||
if (res is Success) {
|
||||
opusData = (res as Success<DynamicItemModel>).response;
|
||||
//fallback
|
||||
if (opusData?.fallback?.id != null) {
|
||||
id = opusData!.fallback!.id!;
|
||||
type = 'read';
|
||||
setUrl();
|
||||
_queryContent();
|
||||
return false;
|
||||
}
|
||||
commentType = opusData!.basic!.commentType!;
|
||||
commentId = int.parse(opusData!.basic!.commentIdStr!);
|
||||
if (showDynActionBar && opusData!.modules.moduleStat != null) {
|
||||
stats.value = opusData!.modules.moduleStat!;
|
||||
}
|
||||
summary
|
||||
..author ??= opusData!.modules.moduleAuthor
|
||||
..title ??= opusData!.modules.moduleTag?.text;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
_queryInfo() {
|
||||
DynamicsHttp.articleInfo(cvId: id).then((res) {
|
||||
if (res['status']) {
|
||||
favStat.addAll({
|
||||
'status': true,
|
||||
'isFav': res['data']?['favorite'] ?? false,
|
||||
'favNum': res['data']?['stats']?['favorite'] ?? 0,
|
||||
'data': res['data'],
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
Future<bool> queryRead(cvid) async {
|
||||
final res = await DynamicsHttp.articleView(cvId: cvid);
|
||||
if (res is Success) {
|
||||
articleData = (res as Success<Item>).response;
|
||||
summary
|
||||
..author ??= articleData!.author
|
||||
..title ??= articleData!.title
|
||||
..cover ??= articleData!.originImageUrls?.firstOrNull;
|
||||
|
||||
_queryDyn(id) {
|
||||
if (item.value.idStr != null) {
|
||||
return;
|
||||
}
|
||||
DynamicsHttp.dynamicDetail(id: id).then((res) {
|
||||
if (res['status']) {
|
||||
item.value = res['data'];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future _queryContent() async {
|
||||
final res = type == 'read'
|
||||
? await DynamicsHttp.articleView(cvId: id)
|
||||
: await DynamicsHttp.opusDetail(opusId: id);
|
||||
if (res['status']) {
|
||||
if (type == 'read') {
|
||||
articleData = res['data'];
|
||||
commentId = int.parse(id);
|
||||
} else {
|
||||
opusData = res['data'];
|
||||
// fallback
|
||||
if (opusData.fallback?.id != null) {
|
||||
id = opusData.fallback!.id!;
|
||||
type = 'read';
|
||||
commentType = 12;
|
||||
_queryInfo();
|
||||
_queryContent();
|
||||
return;
|
||||
if (showDynActionBar && opusData?.modules.moduleStat == null) {
|
||||
final dynId = articleData!.dynIdStr;
|
||||
if (dynId != null) {
|
||||
_queryReadAsDyn(dynId);
|
||||
} else {
|
||||
commentType = opusData.item?.basic?.commentType ??
|
||||
(type == 'picture' ? 11 : 12);
|
||||
commentId = int.parse(opusData.item!.basic!.commentIdStr!);
|
||||
Favorite? favorite =
|
||||
opusData.item?.modules?.lastOrNull?.moduleStat?.favorite;
|
||||
favStat.addAll({
|
||||
'status': true,
|
||||
'isFav': favorite?.status ?? false,
|
||||
'favNum': favorite?.count ?? 0,
|
||||
});
|
||||
debugPrint('cvid2opus failed: $id');
|
||||
}
|
||||
_statsToModuleStat(articleData!.stats!);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
isLoaded.value = true;
|
||||
_queryReadAsDyn(id) async {
|
||||
// 仅用于获取moduleStat
|
||||
final res = await DynamicsHttp.dynamicDetail(id: id);
|
||||
if (res['status']) {
|
||||
opusData = res['data'] as DynamicItemModel;
|
||||
if (opusData!.modules.moduleStat != null) {
|
||||
stats.value = opusData!.modules.moduleStat!;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 请求动态内容
|
||||
Future _queryContent() async {
|
||||
if (type != 'read') {
|
||||
isLoaded.value = await queryOpus(id);
|
||||
} else {
|
||||
commentId = int.parse(id);
|
||||
commentType = 12;
|
||||
isLoaded.value = await queryRead(commentId);
|
||||
}
|
||||
if (isLoaded.value) {
|
||||
queryData();
|
||||
if (isLogin && !MineController.anonymity.value) {
|
||||
VideoHttp.historyReport(aid: commentId, type: 5);
|
||||
}
|
||||
|
||||
queryData();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,22 +180,48 @@ class ArticleController extends ReplyController<MainListReply> {
|
||||
}
|
||||
|
||||
Future onFav() async {
|
||||
bool isFav = favStat['isFav'] == true;
|
||||
bool isFav = stats.value?.favorite?.status == true;
|
||||
final res = type == 'read'
|
||||
? isFav
|
||||
? await UserHttp.delFavArticle(id: id)
|
||||
: await UserHttp.addFavArticle(id: id)
|
||||
? await UserHttp.delFavArticle(id: commentId)
|
||||
: await UserHttp.addFavArticle(id: commentId)
|
||||
: await UserHttp.communityAction(opusId: id, action: isFav ? 4 : 3);
|
||||
if (res['status']) {
|
||||
favStat['isFav'] = !isFav;
|
||||
stats.value?.favorite?.status = !isFav;
|
||||
var count = stats.value?.favorite?.count ?? 0;
|
||||
if (isFav) {
|
||||
favStat['favNum'] -= 1;
|
||||
stats.value?.favorite?.count = count - 1;
|
||||
} else {
|
||||
favStat['favNum'] += 1;
|
||||
stats.value?.favorite?.count = count + 1;
|
||||
}
|
||||
stats.refresh();
|
||||
SmartDialog.showToast('${isFav ? '取消' : ''}收藏成功');
|
||||
} else {
|
||||
SmartDialog.showToast(res['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
void _statsToModuleStat(Stats dynStats) {
|
||||
if (stats.value == null) {
|
||||
stats.value = ModuleStatModel(
|
||||
comment: _setCount(dynStats.reply),
|
||||
forward: _setCount(dynStats.dyn),
|
||||
like: _setCount(dynStats.like),
|
||||
favorite: _setCount(dynStats.favorite),
|
||||
);
|
||||
} else {
|
||||
// 动态类无收藏数据
|
||||
stats.value!.favorite ??= _setCount(dynStats.favorite);
|
||||
}
|
||||
}
|
||||
|
||||
DynamicStat _setCount(int? count) => DynamicStat(count: count);
|
||||
}
|
||||
|
||||
class Summary {
|
||||
Owner? author;
|
||||
String? title;
|
||||
String? cover;
|
||||
|
||||
Summary({this.author, this.title, this.cover});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:PiliPlus/common/widgets/network_img_layer.dart';
|
||||
import 'package:PiliPlus/models/dynamics/result.dart' show DynamicStat;
|
||||
import 'package:PiliPlus/pages/article/widgets/opus_content.dart';
|
||||
import 'package:PiliPlus/pages/article/widgets/html_render.dart';
|
||||
import 'package:PiliPlus/common/widgets/http_error.dart';
|
||||
@@ -338,101 +339,98 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
sliver: Obx(
|
||||
() {
|
||||
if (_articleCtr.isLoaded.value) {
|
||||
if (_articleCtr.type == 'read') {
|
||||
late final res = parser.parse(_articleCtr.articleData.content);
|
||||
return SliverMainAxisGroup(
|
||||
slivers: [
|
||||
if (_articleCtr.articleData.title != null)
|
||||
SliverToBoxAdapter(
|
||||
child: Text(
|
||||
_articleCtr.articleData.title!,
|
||||
style: TextStyle(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
Get.toNamed(
|
||||
'/member?mid=${_articleCtr.articleData.author?.mid}');
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
width: 40,
|
||||
height: 40,
|
||||
type: 'avatar',
|
||||
src: _articleCtr.articleData.author?.face,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
_articleCtr.articleData.author?.name ?? "",
|
||||
style: TextStyle(
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
.titleSmall!
|
||||
.fontSize,
|
||||
),
|
||||
),
|
||||
if (_articleCtr.articleData.publishTime !=
|
||||
null)
|
||||
Text(
|
||||
Utils.dateFormat(
|
||||
_articleCtr.articleData.publishTime),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline,
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
.labelSmall!
|
||||
.fontSize,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
_articleCtr.articleData.modules?.isNotEmpty == true
|
||||
? opusContent(
|
||||
context: context,
|
||||
modules: _articleCtr.articleData.modules,
|
||||
callback: _getImageCallback,
|
||||
maxWidth: maxWidth,
|
||||
)
|
||||
: SliverList.separated(
|
||||
itemCount: res.body!.children.length,
|
||||
itemBuilder: (context, index) {
|
||||
return htmlRender(
|
||||
context: context,
|
||||
element: res.body!.children[index],
|
||||
maxWidth: maxWidth,
|
||||
callback: _getImageCallback,
|
||||
);
|
||||
},
|
||||
separatorBuilder: (context, index) =>
|
||||
const SizedBox(height: 10),
|
||||
),
|
||||
],
|
||||
late Widget content;
|
||||
if (_articleCtr.opus == null) {
|
||||
debugPrint('html page');
|
||||
final res = parser.parse(_articleCtr.articleData!.content!);
|
||||
content = SliverList.separated(
|
||||
itemCount: res.body!.children.length,
|
||||
itemBuilder: (context, index) {
|
||||
return htmlRender(
|
||||
context: context,
|
||||
element: res.body!.children[index],
|
||||
maxWidth: maxWidth,
|
||||
callback: _getImageCallback,
|
||||
);
|
||||
},
|
||||
separatorBuilder: (context, index) =>
|
||||
const SizedBox(height: 10),
|
||||
);
|
||||
} else {
|
||||
return opusContent(
|
||||
debugPrint('json page');
|
||||
content = opusContent(
|
||||
context: context,
|
||||
modules: _articleCtr.opusData.item?.modules,
|
||||
opus: _articleCtr.opus!,
|
||||
callback: _getImageCallback,
|
||||
maxWidth: maxWidth,
|
||||
);
|
||||
}
|
||||
|
||||
int? pubTime =
|
||||
_articleCtr.opusData?.modules.moduleAuthor?.pubTs ??
|
||||
_articleCtr.articleData?.publishTime;
|
||||
return SliverMainAxisGroup(
|
||||
slivers: [
|
||||
if (_articleCtr.summary.title != null)
|
||||
SliverToBoxAdapter(
|
||||
child: Text(
|
||||
_articleCtr.summary.title!,
|
||||
style: TextStyle(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: GestureDetector(
|
||||
onTap: () => Get.toNamed(
|
||||
'/member?mid=${_articleCtr.summary.author?.mid}'),
|
||||
child: Row(
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
// TODO Avatar
|
||||
width: 40,
|
||||
height: 40,
|
||||
type: 'avatar',
|
||||
src: _articleCtr.summary.author?.face,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
_articleCtr.summary.author?.name ?? '',
|
||||
style: TextStyle(
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
.titleSmall!
|
||||
.fontSize,
|
||||
),
|
||||
),
|
||||
if (pubTime != null)
|
||||
Text(
|
||||
Utils.dateFormat(pubTime),
|
||||
style: TextStyle(
|
||||
color:
|
||||
Theme.of(context).colorScheme.outline,
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
.labelSmall!
|
||||
.fontSize,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
content,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return const SliverToBoxAdapter();
|
||||
@@ -543,11 +541,7 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
PreferredSizeWidget get _buildAppBar => AppBar(
|
||||
title: Obx(() {
|
||||
if (_articleCtr.isLoaded.value && _articleCtr.showTitle.value) {
|
||||
return Text(_articleCtr.type == 'read'
|
||||
? _articleCtr.articleData.title ?? ''
|
||||
: _articleCtr.opusData.item?.modules?.firstOrNull?.moduleTitle
|
||||
?.text ??
|
||||
'');
|
||||
return Text(_articleCtr.summary.title ?? '');
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
}),
|
||||
@@ -628,23 +622,21 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
],
|
||||
),
|
||||
),
|
||||
if (_articleCtr.type == 'read' && _articleCtr.favStat['status'])
|
||||
if (_articleCtr.commentType == 12 &&
|
||||
_articleCtr.stats.value != null)
|
||||
PopupMenuItem(
|
||||
onTap: () {
|
||||
try {
|
||||
PageUtils.pmShare(
|
||||
content: {
|
||||
"id": _articleCtr.id,
|
||||
"id": _articleCtr.commentId,
|
||||
"title": "- 哔哩哔哩专栏",
|
||||
"headline": _articleCtr.favStat['data']['title'],
|
||||
"headline": _articleCtr.summary.title!, // throw
|
||||
"source": 6,
|
||||
"thumb": (_articleCtr.favStat['data']
|
||||
['origin_image_urls'] as List?)
|
||||
?.firstOrNull ??
|
||||
'',
|
||||
"author": _articleCtr.favStat['data']['author_name'],
|
||||
"thumb": _articleCtr.summary.cover!,
|
||||
"author": _articleCtr.summary.author!.name,
|
||||
"author_id":
|
||||
_articleCtr.favStat['data']['mid'].toString(),
|
||||
_articleCtr.summary.author!.mid.toString(),
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
@@ -704,8 +696,38 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
child: button(),
|
||||
),
|
||||
)
|
||||
: Obx(
|
||||
() => Column(
|
||||
: Obx(() {
|
||||
Widget textIconButton({
|
||||
required IconData icon,
|
||||
required String text,
|
||||
required DynamicStat? stat,
|
||||
required VoidCallback callback,
|
||||
IconData? activitedIcon,
|
||||
}) {
|
||||
final show = stat?.status == true;
|
||||
final color = show
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: Theme.of(context).colorScheme.outline;
|
||||
return TextButton.icon(
|
||||
onPressed: callback,
|
||||
icon: Icon(
|
||||
stat?.status == true ? activitedIcon : icon,
|
||||
size: 16,
|
||||
color: color,
|
||||
semanticLabel: text,
|
||||
),
|
||||
style: TextButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||
foregroundColor:
|
||||
Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
label: Text(stat?.count != null
|
||||
? Utils.numFormat(stat!.count)
|
||||
: text),
|
||||
);
|
||||
}
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
@@ -713,13 +735,13 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
padding: EdgeInsets.only(
|
||||
right: 14,
|
||||
bottom: 14 +
|
||||
(_articleCtr.favStat['status']
|
||||
(_articleCtr.stats.value != null
|
||||
? 0
|
||||
: MediaQuery.of(context).padding.bottom),
|
||||
),
|
||||
child: button(),
|
||||
),
|
||||
_articleCtr.favStat['status']
|
||||
_articleCtr.stats.value != null
|
||||
? Container(
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
@@ -743,34 +765,36 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
Expanded(
|
||||
child: Builder(
|
||||
builder: (btnContext) =>
|
||||
TextButton.icon(
|
||||
onPressed: () {
|
||||
textIconButton(
|
||||
text: '转发',
|
||||
icon: FontAwesomeIcons
|
||||
.shareFromSquare,
|
||||
stat: _articleCtr
|
||||
.stats.value?.forward,
|
||||
callback: () {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
useSafeArea: true,
|
||||
builder: (context) =>
|
||||
RepostPanel(
|
||||
item: _articleCtr.item.value,
|
||||
item: _articleCtr.opusData,
|
||||
pic:
|
||||
_articleCtr.summary.cover,
|
||||
title:
|
||||
_articleCtr.summary.title,
|
||||
callback: () {
|
||||
int count = int.tryParse(
|
||||
_articleCtr
|
||||
.item
|
||||
.value
|
||||
.modules
|
||||
?.moduleStat
|
||||
?.forward
|
||||
?.count ??
|
||||
'0') ??
|
||||
int count = _articleCtr
|
||||
.stats
|
||||
.value
|
||||
?.forward
|
||||
?.count ??
|
||||
0;
|
||||
_articleCtr
|
||||
.item
|
||||
.value
|
||||
.modules
|
||||
?.moduleStat
|
||||
?.forward!
|
||||
.count =
|
||||
(count + 1).toString();
|
||||
.stats
|
||||
.value
|
||||
?.forward
|
||||
?.count = count + 1;
|
||||
if (btnContext.mounted) {
|
||||
(btnContext as Element?)
|
||||
?.markNeedsBuild();
|
||||
@@ -779,108 +803,34 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
),
|
||||
);
|
||||
},
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.shareFromSquare,
|
||||
size: 16,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline,
|
||||
semanticLabel: "转发",
|
||||
),
|
||||
style: TextButton.styleFrom(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(
|
||||
15, 0, 15, 0),
|
||||
foregroundColor: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline,
|
||||
),
|
||||
label: Text(
|
||||
_articleCtr
|
||||
.item
|
||||
.value
|
||||
.modules
|
||||
?.moduleStat
|
||||
?.forward!
|
||||
.count !=
|
||||
null
|
||||
? Utils.numFormat(_articleCtr
|
||||
.item
|
||||
.value
|
||||
.modules
|
||||
?.moduleStat
|
||||
?.forward!
|
||||
.count)
|
||||
: '转发',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: TextButton.icon(
|
||||
onPressed: () {
|
||||
Utils.shareText(_articleCtr.url);
|
||||
},
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.shareNodes,
|
||||
size: 16,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline,
|
||||
semanticLabel: "分享",
|
||||
),
|
||||
style: TextButton.styleFrom(
|
||||
padding: const EdgeInsets.fromLTRB(
|
||||
15, 0, 15, 0),
|
||||
foregroundColor: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline,
|
||||
),
|
||||
label: const Text('分享'),
|
||||
),
|
||||
),
|
||||
if (_articleCtr.favStat['status'])
|
||||
child: textIconButton(
|
||||
text: '分享',
|
||||
icon: FontAwesomeIcons.shareNodes,
|
||||
stat: null,
|
||||
callback: () =>
|
||||
Utils.shareText(_articleCtr.url),
|
||||
)),
|
||||
if (_articleCtr.stats.value != null)
|
||||
Expanded(
|
||||
child: TextButton.icon(
|
||||
onPressed: () {
|
||||
_articleCtr.onFav();
|
||||
},
|
||||
icon: Icon(
|
||||
_articleCtr.favStat['isFav'] ==
|
||||
true
|
||||
? FontAwesomeIcons.solidStar
|
||||
: FontAwesomeIcons.star,
|
||||
size: 16,
|
||||
color: _articleCtr
|
||||
.favStat['isFav'] ==
|
||||
true
|
||||
? Theme.of(context)
|
||||
.colorScheme
|
||||
.primary
|
||||
: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline,
|
||||
semanticLabel: "收藏",
|
||||
),
|
||||
style: TextButton.styleFrom(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(
|
||||
15, 0, 15, 0),
|
||||
foregroundColor: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline,
|
||||
),
|
||||
label: Text(_articleCtr
|
||||
.favStat['favNum']
|
||||
.toString()),
|
||||
),
|
||||
),
|
||||
child: textIconButton(
|
||||
icon: FontAwesomeIcons.star,
|
||||
activitedIcon:
|
||||
FontAwesomeIcons.solidStar,
|
||||
text: '收藏',
|
||||
stat:
|
||||
_articleCtr.stats.value!.favorite,
|
||||
callback: _articleCtr.onFav,
|
||||
)),
|
||||
Expanded(
|
||||
child: Builder(
|
||||
builder: (context) => TextButton.icon(
|
||||
onPressed: () =>
|
||||
RequestUtils.onLikeDynamic(
|
||||
_articleCtr.item.value,
|
||||
_articleCtr.opusData!,
|
||||
() {
|
||||
if (context.mounted) {
|
||||
(context as Element?)
|
||||
@@ -889,25 +839,15 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
},
|
||||
),
|
||||
icon: Icon(
|
||||
_articleCtr
|
||||
.item
|
||||
.value
|
||||
.modules
|
||||
?.moduleStat
|
||||
?.like
|
||||
_articleCtr.stats.value?.like
|
||||
?.status ==
|
||||
true
|
||||
? FontAwesomeIcons
|
||||
.solidThumbsUp
|
||||
: FontAwesomeIcons.thumbsUp,
|
||||
size: 16,
|
||||
color: _articleCtr
|
||||
.item
|
||||
.value
|
||||
.modules
|
||||
?.moduleStat
|
||||
?.like
|
||||
?.status ==
|
||||
color: _articleCtr.stats.value
|
||||
?.like?.status ==
|
||||
true
|
||||
? Theme.of(context)
|
||||
.colorScheme
|
||||
@@ -916,10 +856,8 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
.colorScheme
|
||||
.outline,
|
||||
semanticLabel: _articleCtr
|
||||
.item
|
||||
.stats
|
||||
.value
|
||||
.modules
|
||||
?.moduleStat
|
||||
?.like
|
||||
?.status ==
|
||||
true
|
||||
@@ -928,8 +866,8 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
),
|
||||
style: TextButton.styleFrom(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(
|
||||
15, 0, 15, 0),
|
||||
const EdgeInsets.symmetric(
|
||||
horizontal: 15),
|
||||
foregroundColor: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline,
|
||||
@@ -944,31 +882,16 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
child: child);
|
||||
},
|
||||
child: Text(
|
||||
_articleCtr
|
||||
.item
|
||||
.value
|
||||
.modules
|
||||
?.moduleStat
|
||||
?.like
|
||||
_articleCtr.stats.value?.like
|
||||
?.count !=
|
||||
null
|
||||
? Utils.numFormat(
|
||||
_articleCtr
|
||||
.item
|
||||
.value
|
||||
.modules!
|
||||
.moduleStat!
|
||||
.like!
|
||||
.count)
|
||||
_articleCtr.stats.value!
|
||||
.like!.count)
|
||||
: '点赞',
|
||||
style: TextStyle(
|
||||
color: _articleCtr
|
||||
.item
|
||||
.value
|
||||
.modules
|
||||
?.moduleStat
|
||||
?.like
|
||||
?.status ==
|
||||
color: _articleCtr.stats.value
|
||||
?.like?.status ==
|
||||
true
|
||||
? Theme.of(context)
|
||||
.colorScheme
|
||||
@@ -987,8 +910,8 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
],
|
||||
),
|
||||
);
|
||||
);
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
@@ -70,6 +70,7 @@ Widget htmlRender({
|
||||
),
|
||||
);
|
||||
} catch (err) {
|
||||
debugPrint('错误的HTML: $element');
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
},
|
||||
|
||||
@@ -2,14 +2,14 @@ import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart'
|
||||
show SourceModel;
|
||||
import 'package:PiliPlus/common/widgets/network_img_layer.dart';
|
||||
import 'package:PiliPlus/models/dynamics/opus_detail/module.dart';
|
||||
import 'package:PiliPlus/models/dynamics/article_content_model.dart'
|
||||
show ArticleContentModel;
|
||||
import 'package:PiliPlus/utils/app_scheme.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||
import 'package:re_highlight/languages/all.dart';
|
||||
import 'package:re_highlight/re_highlight.dart';
|
||||
@@ -17,339 +17,257 @@ import 'package:re_highlight/styles/all.dart';
|
||||
|
||||
Widget opusContent({
|
||||
required BuildContext context,
|
||||
required List<OpusModule>? modules,
|
||||
required List<ArticleContentModel> opus,
|
||||
Function(List<String>, int)? callback,
|
||||
required double maxWidth,
|
||||
}) {
|
||||
debugPrint('opusContent');
|
||||
|
||||
if (modules.isNullOrEmpty) {
|
||||
if (opus.isEmpty) {
|
||||
return const SliverToBoxAdapter();
|
||||
}
|
||||
|
||||
return SliverMainAxisGroup(
|
||||
slivers: modules!.map<Widget>((item) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
return SliverList.separated(
|
||||
itemCount: opus.length,
|
||||
itemBuilder: (context, index) {
|
||||
final element = opus[index];
|
||||
try {
|
||||
return switch (item.moduleType) {
|
||||
//
|
||||
'MODULE_TYPE_TITLE' => SliverToBoxAdapter(
|
||||
child: Text(
|
||||
item.moduleTitle!.text!,
|
||||
style: TextStyle(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.bold,
|
||||
switch (element.paraType) {
|
||||
case 1 || 4:
|
||||
return SelectableText.rich(
|
||||
textAlign: element.align == 1 ? TextAlign.center : null,
|
||||
TextSpan(
|
||||
children: element.text?.nodes?.map<TextSpan>((item) {
|
||||
if (item.rich != null) {
|
||||
return TextSpan(
|
||||
text: '\u{1F517}${item.rich?.text}',
|
||||
style: TextStyle(
|
||||
decoration: item.rich?.style?.strikethrough == true
|
||||
? TextDecoration.lineThrough
|
||||
: null,
|
||||
fontStyle: item.rich?.style?.italic == true
|
||||
? FontStyle.italic
|
||||
: null,
|
||||
fontWeight: item.rich?.style?.bold == true
|
||||
? FontWeight.bold
|
||||
: null,
|
||||
color: colorScheme.primary,
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
if (item.rich?.jumpUrl != null) {
|
||||
PiliScheme.routePushFromUrl(item.rich!.jumpUrl!);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
return TextSpan(
|
||||
text: item.word?.words,
|
||||
style: TextStyle(
|
||||
decoration: item.word?.style?.strikethrough == true
|
||||
? TextDecoration.lineThrough
|
||||
: null,
|
||||
fontStyle: item.word?.style?.italic == true
|
||||
? FontStyle.italic
|
||||
: null,
|
||||
fontWeight:
|
||||
item.word?.style?.bold == true ? FontWeight.bold : null,
|
||||
color: item.word?.color != null
|
||||
? Color(item.word!.color!)
|
||||
: null,
|
||||
fontSize: item.word?.fontSize,
|
||||
),
|
||||
);
|
||||
}).toList()),
|
||||
);
|
||||
case 2 when (element.pic != null):
|
||||
element.pic!.pics!.first.onCalHeight(maxWidth);
|
||||
return Hero(
|
||||
tag: element.pic!.pics!.first.url!,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
if (callback != null) {
|
||||
callback([element.pic!.pics!.first.url!], 0);
|
||||
} else {
|
||||
context.imageView(
|
||||
initialPage: 0,
|
||||
imgList: [
|
||||
SourceModel(url: element.pic!.pics!.first.url!)
|
||||
],
|
||||
);
|
||||
}
|
||||
},
|
||||
child: NetworkImgLayer(
|
||||
width: maxWidth,
|
||||
height: element.pic!.pics!.first.calHeight,
|
||||
src: element.pic!.pics!.first.url!,
|
||||
quality: 60,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
//
|
||||
'MODULE_TYPE_AUTHOR' => SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
Get.toNamed('/member?mid=${item.moduleAuthor?.mid}');
|
||||
},
|
||||
);
|
||||
case 3 when (element.line != null):
|
||||
return CachedNetworkImage(
|
||||
width: maxWidth,
|
||||
fit: BoxFit.contain,
|
||||
height: element.line?.pic?.height?.toDouble(),
|
||||
imageUrl: Utils.thumbnailImgUrl(element.line!.pic!.url!),
|
||||
);
|
||||
case 5 when (element.list != null):
|
||||
return SelectableText.rich(
|
||||
TextSpan(
|
||||
children: element.list!.items?.asMap().entries.map((entry) {
|
||||
return TextSpan(
|
||||
children: [
|
||||
WidgetSpan(
|
||||
child: Icon(MdiIcons.circleMedium),
|
||||
alignment: PlaceholderAlignment.middle,
|
||||
),
|
||||
...entry.value.nodes!.map((item) {
|
||||
return TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: item.word?.words,
|
||||
style: TextStyle(
|
||||
decoration:
|
||||
item.word?.style?.strikethrough == true
|
||||
? TextDecoration.lineThrough
|
||||
: null,
|
||||
fontStyle: item.word?.style?.italic == true
|
||||
? FontStyle.italic
|
||||
: null,
|
||||
fontWeight: item.word?.style?.bold == true
|
||||
? FontWeight.bold
|
||||
: null,
|
||||
color: item.word?.color != null
|
||||
? Color(item.word!.color!)
|
||||
: null,
|
||||
fontSize: item.word?.fontSize,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
if (entry.key < element.list!.items!.length - 1)
|
||||
const TextSpan(text: '\n'),
|
||||
],
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
case 6 when (element.linkCard?.card?.ugc != null):
|
||||
return Material(
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||
),
|
||||
color: colorScheme.onInverseSurface,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
try {
|
||||
PiliScheme.videoPush(
|
||||
int.parse(element.linkCard!.card!.oid!),
|
||||
null,
|
||||
);
|
||||
} catch (_) {}
|
||||
},
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Row(
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
width: 40,
|
||||
height: 40,
|
||||
type: 'avatar',
|
||||
src: item.moduleAuthor?.face,
|
||||
radius: 6,
|
||||
width: 65 * StyleString.aspectRatio,
|
||||
height: 65,
|
||||
src: element.linkCard!.card!.ugc!.cover,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.moduleAuthor!.name!,
|
||||
style: TextStyle(
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
.titleSmall!
|
||||
.fontSize,
|
||||
),
|
||||
),
|
||||
if (item.moduleAuthor?.pubTime != null)
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(element.linkCard!.card!.ugc!.title!),
|
||||
Text(
|
||||
item.moduleAuthor!.pubTime!,
|
||||
element.linkCard!.card!.ugc!.descSecond!,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
.labelSmall!
|
||||
.fontSize,
|
||||
fontSize: 13,
|
||||
color: colorScheme.outline,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
//
|
||||
'MODULE_TYPE_CONTENT' => SliverList.separated(
|
||||
itemCount: item.moduleContent!.paragraphs!.length,
|
||||
itemBuilder: (context, index) {
|
||||
final element = item.moduleContent!.paragraphs![index];
|
||||
|
||||
if (element.paraType == 1 || element.paraType == 4) {
|
||||
return SelectableText.rich(
|
||||
textAlign: element.align == 1 ? TextAlign.center : null,
|
||||
TextSpan(
|
||||
children: element.text?.nodes?.map<TextSpan>((item) {
|
||||
if (item.rich != null) {
|
||||
return TextSpan(
|
||||
text: '\u{1F517}${item.rich?.text}',
|
||||
style: TextStyle(
|
||||
decoration: item.rich?.style?.strikethrough == true
|
||||
? TextDecoration.lineThrough
|
||||
: null,
|
||||
fontStyle: item.rich?.style?.italic == true
|
||||
? FontStyle.italic
|
||||
: null,
|
||||
fontWeight: item.rich?.style?.bold == true
|
||||
? FontWeight.bold
|
||||
: null,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
if (item.rich?.jumpUrl != null) {
|
||||
PiliScheme.routePushFromUrl(
|
||||
item.rich!.jumpUrl!);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
return TextSpan(
|
||||
text: item.word?.words,
|
||||
style: TextStyle(
|
||||
decoration: item.word?.style?.strikethrough == true
|
||||
? TextDecoration.lineThrough
|
||||
: null,
|
||||
fontStyle: item.word?.style?.italic == true
|
||||
? FontStyle.italic
|
||||
: null,
|
||||
fontWeight: item.word?.style?.bold == true
|
||||
? FontWeight.bold
|
||||
: null,
|
||||
color: item.word?.color != null
|
||||
? Color(item.word!.color!)
|
||||
: null,
|
||||
fontSize: item.word?.fontSize,
|
||||
),
|
||||
);
|
||||
}).toList()),
|
||||
);
|
||||
}
|
||||
|
||||
if (element.paraType == 2) {
|
||||
element.pic!.pics!.first.onCalHeight(maxWidth);
|
||||
return Hero(
|
||||
tag: element.pic!.pics!.first.url!,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
if (callback != null) {
|
||||
callback([element.pic!.pics!.first.url!], 0);
|
||||
} else {
|
||||
context.imageView(
|
||||
initialPage: 0,
|
||||
imgList: [
|
||||
SourceModel(url: element.pic!.pics!.first.url!)
|
||||
],
|
||||
);
|
||||
}
|
||||
},
|
||||
child: NetworkImgLayer(
|
||||
width: maxWidth,
|
||||
height: element.pic!.pics!.first.calHeight,
|
||||
src: element.pic!.pics!.first.url!,
|
||||
quality: 60,
|
||||
),
|
||||
);
|
||||
case 7 when (element.code != null):
|
||||
final Highlight highlight = Highlight()
|
||||
..registerLanguages(builtinAllLanguages);
|
||||
final HighlightResult result = highlight.highlightAuto(
|
||||
element.code!.content!,
|
||||
element.code!.lang == 'language-clike'
|
||||
? const ['c', 'java']
|
||||
: [
|
||||
element.code!.lang!
|
||||
.replaceAll('language-', '')
|
||||
.replaceAll('like', ''),
|
||||
]);
|
||||
final TextSpanRenderer renderer = TextSpanRenderer(
|
||||
const TextStyle(), builtinAllThemes['github']!);
|
||||
result.render(renderer);
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
color: colorScheme.onInverseSurface,
|
||||
),
|
||||
width: double.infinity,
|
||||
child: SelectableText.rich(renderer.span!),
|
||||
);
|
||||
default:
|
||||
debugPrint('unknown type ${element.paraType}');
|
||||
if (element.text?.nodes?.isNotEmpty == true) {
|
||||
return SelectableText.rich(
|
||||
textAlign: element.align == 1 ? TextAlign.center : null,
|
||||
TextSpan(
|
||||
children: element.text!.nodes!.map<TextSpan>((item) {
|
||||
return TextSpan(
|
||||
text: item.word?.words,
|
||||
style: TextStyle(
|
||||
decoration: item.word?.style?.strikethrough == true
|
||||
? TextDecoration.lineThrough
|
||||
: null,
|
||||
fontStyle: item.word?.style?.italic == true
|
||||
? FontStyle.italic
|
||||
: null,
|
||||
fontWeight: item.word?.style?.bold == true
|
||||
? FontWeight.bold
|
||||
: null,
|
||||
color: item.word?.color != null
|
||||
? Color(item.word!.color!)
|
||||
: null,
|
||||
fontSize: item.word?.fontSize,
|
||||
),
|
||||
);
|
||||
}
|
||||
}).toList()),
|
||||
);
|
||||
}
|
||||
|
||||
if (element.paraType == 3) {
|
||||
return CachedNetworkImage(
|
||||
width: maxWidth,
|
||||
fit: BoxFit.contain,
|
||||
height: element.line?.pic?.height,
|
||||
imageUrl: Utils.thumbnailImgUrl(element.line!.pic!.url!),
|
||||
);
|
||||
}
|
||||
|
||||
if (element.paraType == 5) {
|
||||
return SelectableText.rich(
|
||||
TextSpan(
|
||||
children:
|
||||
element.list?.items?.asMap().entries.map((entry) {
|
||||
return TextSpan(
|
||||
children: [
|
||||
WidgetSpan(
|
||||
child: Icon(MdiIcons.circleMedium),
|
||||
alignment: PlaceholderAlignment.middle,
|
||||
),
|
||||
...entry.value.nodes!.map((item) {
|
||||
return TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: item.word?.words,
|
||||
style: TextStyle(
|
||||
decoration:
|
||||
item.word?.style?.strikethrough ==
|
||||
true
|
||||
? TextDecoration.lineThrough
|
||||
: null,
|
||||
fontStyle:
|
||||
item.word?.style?.italic == true
|
||||
? FontStyle.italic
|
||||
: null,
|
||||
fontWeight: item.word?.style?.bold == true
|
||||
? FontWeight.bold
|
||||
: null,
|
||||
color: item.word?.color != null
|
||||
? Color(item.word!.color!)
|
||||
: null,
|
||||
fontSize: item.word?.fontSize,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
if (entry.key < element.list!.items!.length - 1)
|
||||
TextSpan(text: '\n'),
|
||||
],
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (element.paraType == 6) {
|
||||
if (element.linkCard?.card?.ugc != null) {
|
||||
return Material(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(8)),
|
||||
),
|
||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
try {
|
||||
PiliScheme.videoPush(
|
||||
int.parse(element.linkCard!.card!.oid!),
|
||||
null,
|
||||
);
|
||||
} catch (_) {}
|
||||
},
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(8)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Row(
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
radius: 6,
|
||||
width: 65 * StyleString.aspectRatio,
|
||||
height: 65,
|
||||
src: element.linkCard!.card!.ugc!.cover,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(element.linkCard!.card!.ugc!.title!),
|
||||
Text(
|
||||
element.linkCard!.card!.ugc!.descSecond!,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (element.paraType == 7) {
|
||||
final Highlight highlight = Highlight()
|
||||
..registerLanguages(builtinAllLanguages);
|
||||
final HighlightResult result = highlight.highlightAuto(
|
||||
element.code!.content!,
|
||||
element.code!.lang == 'language-clike'
|
||||
? ['c', 'java']
|
||||
: [
|
||||
element.code!.lang!
|
||||
.replaceAll('language-', '')
|
||||
.replaceAll('like', ''),
|
||||
]);
|
||||
final TextSpanRenderer renderer = TextSpanRenderer(
|
||||
const TextStyle(), builtinAllThemes['github']!);
|
||||
result.render(renderer);
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
||||
),
|
||||
width: double.infinity,
|
||||
child: SelectableText.rich(renderer.span!),
|
||||
);
|
||||
}
|
||||
|
||||
if (element.text?.nodes?.isNotEmpty == true) {
|
||||
return SelectableText.rich(
|
||||
textAlign: element.align == 1 ? TextAlign.center : null,
|
||||
TextSpan(
|
||||
children: element.text!.nodes!.map<TextSpan>((item) {
|
||||
return TextSpan(
|
||||
text: item.word?.words,
|
||||
style: TextStyle(
|
||||
decoration: item.word?.style?.strikethrough == true
|
||||
? TextDecoration.lineThrough
|
||||
: null,
|
||||
fontStyle: item.word?.style?.italic == true
|
||||
? FontStyle.italic
|
||||
: null,
|
||||
fontWeight: item.word?.style?.bold == true
|
||||
? FontWeight.bold
|
||||
: null,
|
||||
color: item.word?.color != null
|
||||
? Color(item.word!.color!)
|
||||
: null,
|
||||
fontSize: item.word?.fontSize,
|
||||
),
|
||||
);
|
||||
}).toList()),
|
||||
);
|
||||
}
|
||||
|
||||
return const SizedBox.shrink();
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) =>
|
||||
const SizedBox(height: 10),
|
||||
),
|
||||
|
||||
//
|
||||
_ => const SliverToBoxAdapter(),
|
||||
};
|
||||
return SelectableText('不支持的类型 (${element.paraType})',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.red,
|
||||
));
|
||||
}
|
||||
} catch (e) {
|
||||
return SliverToBoxAdapter(child: Text(e.toString()));
|
||||
return SelectableText('错误的类型 $e',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.red,
|
||||
));
|
||||
}
|
||||
}).toList(),
|
||||
},
|
||||
separatorBuilder: (context, index) => const SizedBox(height: 10),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'package:PiliPlus/grpc/app/main/community/reply/v1/reply.pb.dart';
|
||||
import 'package:PiliPlus/http/dynamics.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/common/reply_type.dart';
|
||||
import 'package:PiliPlus/models/dynamics/opus_detail/data.dart';
|
||||
import 'package:PiliPlus/models/dynamics/result.dart';
|
||||
import 'package:PiliPlus/pages/common/reply_controller.dart';
|
||||
import 'package:PiliPlus/utils/id_utils.dart';
|
||||
@@ -31,7 +30,7 @@ class DynamicDetailController extends ReplyController<MainListReply> {
|
||||
item = Get.arguments['item'];
|
||||
floor = Get.arguments['floor'];
|
||||
if (floor == 1) {
|
||||
count.value = int.parse(item.modules!.moduleStat!.comment!.count ?? '0');
|
||||
count.value = item.modules.moduleStat?.comment?.count ?? 0;
|
||||
}
|
||||
|
||||
if (oid != 0) {
|
||||
@@ -41,10 +40,10 @@ class DynamicDetailController extends ReplyController<MainListReply> {
|
||||
|
||||
getCommentParams(int id) async {
|
||||
var res = await DynamicsHttp.opusDetail(opusId: id);
|
||||
if (res['status']) {
|
||||
OpusData data = res['data'];
|
||||
type = data.item!.basic!.commentType!;
|
||||
oid = int.parse(data.item!.basic!.commentIdStr!);
|
||||
if (res is Success) {
|
||||
final data = (res as Success<DynamicItemModel>).response;
|
||||
type = data.basic!.commentType!;
|
||||
oid = int.parse(data.basic!.commentIdStr!);
|
||||
queryData();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,14 +118,15 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
// 楼层
|
||||
int floor = args['floor'];
|
||||
// 评论类型
|
||||
int commentType = args['item'].basic!['comment_type'] ?? 11;
|
||||
final item = args['item'] as DynamicItemModel;
|
||||
int commentType = item.basic?.commentType ?? 11;
|
||||
replyType = (commentType == 0) ? 11 : commentType;
|
||||
|
||||
if (floor == 1) {
|
||||
oid = int.parse(args['item'].basic!['comment_id_str']);
|
||||
oid = int.parse(item.basic!.commentIdStr!);
|
||||
} else {
|
||||
try {
|
||||
ModuleDynamicModel moduleDynamic = args['item'].modules.moduleDynamic;
|
||||
final moduleDynamic = item.modules.moduleDynamic!;
|
||||
String majorType = moduleDynamic.major!.type!;
|
||||
|
||||
if (majorType == 'MAJOR_TYPE_OPUS') {
|
||||
@@ -528,32 +529,31 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
item: _dynamicDetailController
|
||||
.item,
|
||||
callback: () {
|
||||
int count = int.tryParse(
|
||||
_dynamicDetailController
|
||||
.item
|
||||
.modules
|
||||
?.moduleStat
|
||||
?.forward
|
||||
?.count ??
|
||||
'0') ??
|
||||
0;
|
||||
int count =
|
||||
_dynamicDetailController
|
||||
.item
|
||||
.modules
|
||||
.moduleStat
|
||||
?.forward
|
||||
?.count ??
|
||||
0;
|
||||
_dynamicDetailController
|
||||
.item
|
||||
.modules
|
||||
?.moduleStat ??=
|
||||
.moduleStat ??=
|
||||
ModuleStatModel();
|
||||
_dynamicDetailController
|
||||
.item
|
||||
.modules!
|
||||
.moduleStat
|
||||
?.forward ??= ForWard();
|
||||
_dynamicDetailController
|
||||
.item
|
||||
.modules!
|
||||
.moduleStat!
|
||||
.forward!
|
||||
.count =
|
||||
(count + 1).toString();
|
||||
.modules
|
||||
.moduleStat
|
||||
?.forward ??=
|
||||
DynamicStat();
|
||||
_dynamicDetailController
|
||||
.item
|
||||
.modules
|
||||
.moduleStat!
|
||||
.forward!
|
||||
.count = count + 1;
|
||||
if (btnContext.mounted) {
|
||||
(btnContext as Element?)
|
||||
?.markNeedsBuild();
|
||||
@@ -581,14 +581,14 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
_dynamicDetailController
|
||||
.item
|
||||
.modules
|
||||
?.moduleStat
|
||||
.moduleStat
|
||||
?.forward
|
||||
?.count !=
|
||||
null
|
||||
? Utils.numFormat(
|
||||
_dynamicDetailController
|
||||
.item
|
||||
.modules!
|
||||
.modules
|
||||
.moduleStat!
|
||||
.forward!
|
||||
.count)
|
||||
@@ -638,7 +638,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
_dynamicDetailController
|
||||
.item
|
||||
.modules
|
||||
?.moduleStat
|
||||
.moduleStat
|
||||
?.like
|
||||
?.status ==
|
||||
true
|
||||
@@ -648,7 +648,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
color: _dynamicDetailController
|
||||
.item
|
||||
.modules
|
||||
?.moduleStat
|
||||
.moduleStat
|
||||
?.like
|
||||
?.status ==
|
||||
true
|
||||
@@ -662,7 +662,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
_dynamicDetailController
|
||||
.item
|
||||
.modules
|
||||
?.moduleStat
|
||||
.moduleStat
|
||||
?.like
|
||||
?.status ==
|
||||
true
|
||||
@@ -689,14 +689,14 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
_dynamicDetailController
|
||||
.item
|
||||
.modules
|
||||
?.moduleStat
|
||||
.moduleStat
|
||||
?.like
|
||||
?.count !=
|
||||
null
|
||||
? Utils.numFormat(
|
||||
_dynamicDetailController
|
||||
.item
|
||||
.modules!
|
||||
.modules
|
||||
.moduleStat!
|
||||
.like!
|
||||
.count)
|
||||
@@ -705,7 +705,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
color: _dynamicDetailController
|
||||
.item
|
||||
.modules
|
||||
?.moduleStat
|
||||
.moduleStat
|
||||
?.like
|
||||
?.status ==
|
||||
true
|
||||
|
||||
@@ -34,7 +34,7 @@ class RepostPanel extends CommonPublishPage {
|
||||
final String? uname;
|
||||
final bool? isMax;
|
||||
|
||||
final dynamic item;
|
||||
final DynamicItemModel? item;
|
||||
final VoidCallback? callback;
|
||||
|
||||
@override
|
||||
@@ -44,53 +44,19 @@ class RepostPanel extends CommonPublishPage {
|
||||
class _RepostPanelState extends CommonPublishPageState<RepostPanel> {
|
||||
late bool _isMax = widget.isMax ?? false;
|
||||
|
||||
late final dynamic _pic = widget.pic ??
|
||||
(widget.item as DynamicItemModel?)
|
||||
?.modules
|
||||
?.moduleDynamic
|
||||
?.major
|
||||
?.archive
|
||||
?.cover ??
|
||||
(widget.item as DynamicItemModel?)
|
||||
?.modules
|
||||
?.moduleDynamic
|
||||
?.major
|
||||
?.pgc
|
||||
?.cover ??
|
||||
(widget.item as DynamicItemModel?)
|
||||
?.modules
|
||||
?.moduleDynamic
|
||||
?.major
|
||||
?.opus
|
||||
?.pics
|
||||
?.firstOrNull
|
||||
?.url;
|
||||
late final _pic = widget.pic ??
|
||||
widget.item?.modules.moduleDynamic?.major?.archive?.cover ??
|
||||
widget.item?.modules.moduleDynamic?.major?.pgc?.cover ??
|
||||
widget.item?.modules.moduleDynamic?.major?.opus?.pics?.firstOrNull?.url;
|
||||
|
||||
late final _text = widget.title ??
|
||||
(widget.item as DynamicItemModel?)
|
||||
?.modules
|
||||
?.moduleDynamic
|
||||
?.major
|
||||
?.opus
|
||||
?.summary
|
||||
?.text ??
|
||||
(widget.item as DynamicItemModel?)?.modules?.moduleDynamic?.desc?.text ??
|
||||
(widget.item as DynamicItemModel?)
|
||||
?.modules
|
||||
?.moduleDynamic
|
||||
?.major
|
||||
?.archive
|
||||
?.title ??
|
||||
(widget.item as DynamicItemModel?)
|
||||
?.modules
|
||||
?.moduleDynamic
|
||||
?.major
|
||||
?.pgc
|
||||
?.title ??
|
||||
widget.item?.modules.moduleDynamic?.major?.opus?.summary?.text ??
|
||||
widget.item?.modules.moduleDynamic?.desc?.text ??
|
||||
widget.item?.modules.moduleDynamic?.major?.archive?.title ??
|
||||
widget.item?.modules.moduleDynamic?.major?.pgc?.title ??
|
||||
'';
|
||||
|
||||
late final _uname = widget.uname ??
|
||||
(widget.item as DynamicItemModel?)?.modules?.moduleAuthor?.name;
|
||||
late final _uname = widget.uname ?? widget.item?.modules.moduleAuthor?.name;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
|
||||
@@ -162,7 +162,7 @@ class _DynamicsTabPageState
|
||||
] else ...[
|
||||
for (var i in loadingState.response!)
|
||||
if (!dynamicsController.tempBannedList
|
||||
.contains(i.modules?.moduleAuthor?.mid))
|
||||
.contains(i.modules.moduleAuthor?.mid))
|
||||
DynamicPanel(
|
||||
item: i,
|
||||
onRemove: controller.onRemove,
|
||||
@@ -185,7 +185,7 @@ class _DynamicsTabPageState
|
||||
4 &&
|
||||
dynamicsController.mid.value != -1) ||
|
||||
!dynamicsController.tempBannedList.contains(
|
||||
item.modules?.moduleAuthor?.mid)) {
|
||||
item.modules.moduleAuthor?.mid)) {
|
||||
return DynamicPanel(
|
||||
item: item,
|
||||
onRemove: controller.onRemove,
|
||||
|
||||
@@ -12,9 +12,9 @@ import 'package:PiliPlus/utils/feed_back.dart';
|
||||
class ActionPanel extends StatefulWidget {
|
||||
const ActionPanel({
|
||||
super.key,
|
||||
this.item,
|
||||
required this.item,
|
||||
});
|
||||
final dynamic item;
|
||||
final DynamicItemModel item;
|
||||
|
||||
@override
|
||||
State<ActionPanel> createState() => _ActionPanelState();
|
||||
@@ -33,26 +33,22 @@ class _ActionPanelState extends State<ActionPanel> {
|
||||
// 动态点赞
|
||||
Future onLikeDynamic() async {
|
||||
feedBack();
|
||||
var item = widget.item!;
|
||||
final item = widget.item;
|
||||
String dynamicId = item.idStr!;
|
||||
// 1 已点赞 2 不喜欢 0 未操作
|
||||
Like like = item.modules.moduleStat.like;
|
||||
int count = like.count == '点赞' ? 0 : int.parse(like.count ?? '0');
|
||||
bool status = like.status!;
|
||||
DynamicStat? like = item.modules.moduleStat?.like;
|
||||
int count = like?.count ?? 0;
|
||||
bool status = like?.status == true;
|
||||
int up = status ? 2 : 1;
|
||||
var res = await DynamicsHttp.likeDynamic(dynamicId: dynamicId, up: up);
|
||||
if (res['status']) {
|
||||
SmartDialog.showToast(!status ? '点赞成功' : '取消赞');
|
||||
if (up == 1) {
|
||||
item.modules.moduleStat.like.count = (count + 1).toString();
|
||||
item.modules.moduleStat.like.status = true;
|
||||
item.modules.moduleStat?.like?.count = count + 1;
|
||||
item.modules.moduleStat?.like?.status = true;
|
||||
} else {
|
||||
if (count == 1) {
|
||||
item.modules.moduleStat.like.count = '点赞';
|
||||
} else {
|
||||
item.modules.moduleStat.like.count = (count - 1).toString();
|
||||
}
|
||||
item.modules.moduleStat.like.status = false;
|
||||
item.modules.moduleStat?.like?.count = count - 1;
|
||||
item.modules.moduleStat?.like?.status = false;
|
||||
}
|
||||
setState(() {});
|
||||
} else {
|
||||
@@ -78,12 +74,9 @@ class _ActionPanelState extends State<ActionPanel> {
|
||||
builder: (context) => RepostPanel(
|
||||
item: widget.item,
|
||||
callback: () {
|
||||
int count = int.tryParse(
|
||||
widget.item!.modules.moduleStat.forward?.count ??
|
||||
'0') ??
|
||||
0;
|
||||
widget.item!.modules.moduleStat.forward!.count =
|
||||
(count + 1).toString();
|
||||
int count =
|
||||
widget.item.modules.moduleStat?.forward?.count ?? 0;
|
||||
widget.item.modules.moduleStat!.forward!.count = count + 1;
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
@@ -100,9 +93,9 @@ class _ActionPanelState extends State<ActionPanel> {
|
||||
foregroundColor: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
label: Text(
|
||||
widget.item!.modules.moduleStat.forward!.count != null
|
||||
widget.item.modules.moduleStat!.forward!.count != null
|
||||
? Utils.numFormat(
|
||||
widget.item!.modules.moduleStat.forward!.count)
|
||||
widget.item.modules.moduleStat!.forward!.count)
|
||||
: '转发',
|
||||
),
|
||||
),
|
||||
@@ -123,9 +116,9 @@ class _ActionPanelState extends State<ActionPanel> {
|
||||
foregroundColor: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
label: Text(
|
||||
widget.item!.modules.moduleStat.comment!.count != null
|
||||
widget.item.modules.moduleStat!.comment!.count != null
|
||||
? Utils.numFormat(
|
||||
widget.item!.modules.moduleStat.comment!.count)
|
||||
widget.item.modules.moduleStat!.comment!.count)
|
||||
: '评论',
|
||||
),
|
||||
),
|
||||
@@ -135,15 +128,15 @@ class _ActionPanelState extends State<ActionPanel> {
|
||||
child: TextButton.icon(
|
||||
onPressed: () => handleState(onLikeDynamic),
|
||||
icon: Icon(
|
||||
widget.item!.modules.moduleStat.like!.status!
|
||||
widget.item.modules.moduleStat!.like!.status!
|
||||
? FontAwesomeIcons.solidThumbsUp
|
||||
: FontAwesomeIcons.thumbsUp,
|
||||
size: 16,
|
||||
color: widget.item!.modules.moduleStat.like!.status!
|
||||
color: widget.item.modules.moduleStat!.like!.status!
|
||||
? primary
|
||||
: color,
|
||||
semanticLabel:
|
||||
widget.item!.modules.moduleStat.like!.status! ? "已赞" : "点赞",
|
||||
widget.item.modules.moduleStat!.like!.status! ? "已赞" : "点赞",
|
||||
),
|
||||
style: TextButton.styleFrom(
|
||||
padding: const EdgeInsets.fromLTRB(15, 0, 15, 0),
|
||||
@@ -155,14 +148,15 @@ class _ActionPanelState extends State<ActionPanel> {
|
||||
return ScaleTransition(scale: animation, child: child);
|
||||
},
|
||||
child: Text(
|
||||
widget.item!.modules.moduleStat.like!.count != null
|
||||
widget.item.modules.moduleStat!.like!.count != null
|
||||
? Utils.numFormat(
|
||||
widget.item!.modules.moduleStat.like!.count)
|
||||
widget.item.modules.moduleStat!.like!.count)
|
||||
: '点赞',
|
||||
key: ValueKey<String>(
|
||||
widget.item!.modules.moduleStat.like!.count ?? '点赞'),
|
||||
widget.item.modules.moduleStat!.like!.count?.toString() ??
|
||||
'点赞'),
|
||||
style: TextStyle(
|
||||
color: widget.item!.modules.moduleStat.like!.status!
|
||||
color: widget.item.modules.moduleStat!.like!.status!
|
||||
? primary
|
||||
: color,
|
||||
),
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:PiliPlus/common/widgets/avatar.dart';
|
||||
import 'package:PiliPlus/common/widgets/report.dart';
|
||||
import 'package:PiliPlus/common/widgets/save_panel.dart';
|
||||
import 'package:PiliPlus/http/video.dart';
|
||||
import 'package:PiliPlus/models/dynamics/result.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:PiliPlus/utils/request_utils.dart';
|
||||
@@ -20,7 +21,7 @@ import '../../../http/constants.dart';
|
||||
import '../controller.dart';
|
||||
|
||||
class AuthorPanel extends StatelessWidget {
|
||||
final dynamic item;
|
||||
final DynamicItemModel item;
|
||||
final Function? addBannedList;
|
||||
final String? source;
|
||||
final Function? onRemove;
|
||||
@@ -40,7 +41,7 @@ class AuthorPanel extends StatelessWidget {
|
||||
Widget _buildAvatar() {
|
||||
String? pendant = item.modules.moduleAuthor?.pendant?['image'];
|
||||
Widget avatar = Avatar(
|
||||
avatar: item.modules.moduleAuthor.face,
|
||||
avatar: item.modules.moduleAuthor?.face ?? '',
|
||||
size: pendant.isNullOrEmpty ? 40 : 34,
|
||||
isVip: null, // item.modules.moduleAuthor!.vip['status'] > 0
|
||||
officialType: null, // 已被注释
|
||||
@@ -55,14 +56,14 @@ class AuthorPanel extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
String? pubTime = item.modules.moduleAuthor.pubTs != null
|
||||
final pubTime = item.modules.moduleAuthor?.pubTs != null
|
||||
? isSave
|
||||
? DateTime.fromMillisecondsSinceEpoch(
|
||||
item.modules.moduleAuthor.pubTs * 1000)
|
||||
item.modules.moduleAuthor!.pubTs! * 1000)
|
||||
.toString()
|
||||
.substring(0, 19)
|
||||
: Utils.dateFormat(item.modules.moduleAuthor.pubTs)
|
||||
: item.modules.moduleAuthor.pubTime;
|
||||
: Utils.dateFormat(item.modules.moduleAuthor!.pubTs)
|
||||
: item.modules.moduleAuthor?.pubTime;
|
||||
return Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
@@ -71,17 +72,17 @@ class AuthorPanel extends StatelessWidget {
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
(item.modules.moduleAuthor.type == 'AUTHOR_TYPE_PGC' ||
|
||||
item.modules.moduleAuthor.type ==
|
||||
(item.modules.moduleAuthor!.type == 'AUTHOR_TYPE_PGC' ||
|
||||
item.modules.moduleAuthor!.type ==
|
||||
'AUTHOR_TYPE_UGC_SEASON')
|
||||
? _buildAvatar() // 番剧
|
||||
: GestureDetector(
|
||||
onTap: () {
|
||||
feedBack();
|
||||
Get.toNamed(
|
||||
'/member?mid=${item.modules.moduleAuthor.mid}',
|
||||
'/member?mid=${item.modules.moduleAuthor!.mid}',
|
||||
arguments: {
|
||||
'face': item.modules.moduleAuthor.face,
|
||||
'face': item.modules.moduleAuthor!.face,
|
||||
},
|
||||
);
|
||||
},
|
||||
@@ -92,11 +93,11 @@ class AuthorPanel extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.modules.moduleAuthor.name,
|
||||
item.modules.moduleAuthor?.name ?? '',
|
||||
style: TextStyle(
|
||||
color: item.modules.moduleAuthor!.vip != null &&
|
||||
item.modules.moduleAuthor!.vip['status'] > 0 &&
|
||||
item.modules.moduleAuthor!.vip['type'] == 2
|
||||
item.modules.moduleAuthor!.vip!['status'] > 0 &&
|
||||
item.modules.moduleAuthor!.vip!['type'] == 2
|
||||
? context.vipColor
|
||||
: theme.colorScheme.onSurface,
|
||||
fontSize: theme.textTheme.titleSmall!.fontSize,
|
||||
@@ -104,7 +105,7 @@ class AuthorPanel extends StatelessWidget {
|
||||
),
|
||||
if (pubTime != null)
|
||||
Text(
|
||||
'$pubTime${item.modules.moduleAuthor.pubAction != null ? ' ${item.modules.moduleAuthor.pubAction}' : ''}',
|
||||
'$pubTime${item.modules.moduleAuthor?.pubAction != null ? ' ${item.modules.moduleAuthor!.pubAction}' : ''}',
|
||||
style: TextStyle(
|
||||
color: theme.colorScheme.outline,
|
||||
fontSize: theme.textTheme.labelSmall!.fontSize,
|
||||
@@ -117,7 +118,7 @@ class AuthorPanel extends StatelessWidget {
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: source != 'detail' && item.modules?.moduleTag?.text != null
|
||||
child: source != 'detail' && item.modules.moduleTag?.text != null
|
||||
? Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
@@ -133,7 +134,7 @@ class AuthorPanel extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
item.modules.moduleTag.text,
|
||||
item.modules.moduleTag!.text!,
|
||||
style: TextStyle(
|
||||
height: 1,
|
||||
fontSize: 12,
|
||||
@@ -149,7 +150,7 @@ class AuthorPanel extends StatelessWidget {
|
||||
_moreWidget(context),
|
||||
],
|
||||
)
|
||||
: item.modules.moduleAuthor.decorate != null
|
||||
: item.modules.moduleAuthor!.decorate != null
|
||||
? Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
@@ -159,31 +160,31 @@ class AuthorPanel extends StatelessWidget {
|
||||
children: [
|
||||
CachedNetworkImage(
|
||||
height: 32,
|
||||
imageUrl: (item.modules.moduleAuthor
|
||||
.decorate['card_url'] as String)
|
||||
imageUrl: (item.modules.moduleAuthor!
|
||||
.decorate!['card_url'] as String)
|
||||
.http2https,
|
||||
),
|
||||
if ((item.modules.moduleAuthor.decorate?['fan']
|
||||
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']}',
|
||||
'${item.modules.moduleAuthor!.decorate!['fan']['num_str']}',
|
||||
style: TextStyle(
|
||||
height: 1,
|
||||
fontSize: 11,
|
||||
fontFamily: 'digital_id_num',
|
||||
color: (item.modules.moduleAuthor
|
||||
.decorate?['fan']
|
||||
?['color'] as String?)
|
||||
color: (item.modules.moduleAuthor!
|
||||
.decorate!['fan']
|
||||
['color'] as String?)
|
||||
?.startsWith('#') ==
|
||||
true
|
||||
? Color(
|
||||
int.parse(
|
||||
item.modules.moduleAuthor
|
||||
.decorate['fan']['color']
|
||||
item.modules.moduleAuthor!
|
||||
.decorate!['fan']['color']
|
||||
.replaceFirst('#', '0xFF'),
|
||||
),
|
||||
)
|
||||
@@ -220,15 +221,15 @@ class AuthorPanel extends StatelessWidget {
|
||||
void morePanel(BuildContext context) {
|
||||
String? bvid;
|
||||
try {
|
||||
getBvid(String? type, dynamic major) => switch (type) {
|
||||
getBvid(String? type, DynamicMajorModel? major) => switch (type) {
|
||||
'DYNAMIC_TYPE_AV' => major?.archive?.bvid,
|
||||
'DYNAMIC_TYPE_UGC_SEASON' => major?.ugcSeason?.bvid,
|
||||
_ => null,
|
||||
};
|
||||
bvid = getBvid(item.type, item.modules?.moduleDynamic?.major);
|
||||
bvid = getBvid(item.type, item.modules.moduleDynamic?.major);
|
||||
if (bvid == null && item.orig != null) {
|
||||
bvid =
|
||||
getBvid(item.orig.type, item.orig?.modules?.moduleDynamic?.major);
|
||||
getBvid(item.orig!.type, item.orig?.modules.moduleDynamic?.major);
|
||||
}
|
||||
} catch (_) {}
|
||||
|
||||
@@ -308,8 +309,8 @@ class AuthorPanel extends StatelessWidget {
|
||||
},
|
||||
minLeadingWidth: 0,
|
||||
),
|
||||
if (item.basic['comment_type'] == 17 ||
|
||||
item.basic['comment_type'] == 11)
|
||||
if (item.basic!.commentType == 17 ||
|
||||
item.basic!.commentType == 11)
|
||||
ListTile(
|
||||
title: Text(
|
||||
'分享至消息',
|
||||
@@ -319,23 +320,23 @@ class AuthorPanel extends StatelessWidget {
|
||||
onTap: () {
|
||||
Get.back();
|
||||
try {
|
||||
bool isDyn = item.basic['comment_type'] == 17;
|
||||
String id = isDyn ? item.idStr : item.basic['rid_str'];
|
||||
bool isDyn = item.basic!.commentType == 17;
|
||||
String id = isDyn ? item.idStr : item.basic!.ridStr!;
|
||||
int source = isDyn ? 11 : 2;
|
||||
String title;
|
||||
if (item.modules.moduleDynamic.desc != null) {
|
||||
title = item.modules.moduleDynamic.desc.text;
|
||||
} else if (item.modules.moduleDynamic.major != null) {
|
||||
title =
|
||||
item.modules.moduleDynamic.major.opus.summary.text;
|
||||
if (item.modules.moduleDynamic?.desc != null) {
|
||||
title = item.modules.moduleDynamic!.desc!.text!;
|
||||
} else if (item.modules.moduleDynamic?.major != null) {
|
||||
title = item
|
||||
.modules.moduleDynamic!.major!.opus!.summary!.text!;
|
||||
} else {
|
||||
throw UnsupportedError(
|
||||
'error getting title: {"type": ${item.basic['comment_type']}, "id": $id}');
|
||||
'error getting title: {"type": ${item.basic!.commentType}, "id": $id}');
|
||||
}
|
||||
String thumb = isDyn
|
||||
? item.modules.moduleAuthor.face
|
||||
: item
|
||||
.modules.moduleDynamic.major.opus.pics.first.url;
|
||||
? item.modules.moduleAuthor!.face!
|
||||
: item.modules.moduleDynamic!.major!.opus!.pics!.first
|
||||
.url!;
|
||||
PageUtils.pmShare(
|
||||
content: {
|
||||
"id": id,
|
||||
@@ -344,8 +345,8 @@ class AuthorPanel extends StatelessWidget {
|
||||
"source": source,
|
||||
"extra": {},
|
||||
"thumb": thumb,
|
||||
"author": item.modules.moduleAuthor.name,
|
||||
"author_id": item.modules.moduleAuthor.mid.toString()
|
||||
"author": item.modules.moduleAuthor!.name,
|
||||
"author_id": item.modules.moduleAuthor!.mid.toString()
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
@@ -356,7 +357,7 @@ class AuthorPanel extends StatelessWidget {
|
||||
),
|
||||
ListTile(
|
||||
title: Text(
|
||||
'临时屏蔽:${item.modules?.moduleAuthor?.name}',
|
||||
'临时屏蔽:${item.modules.moduleAuthor?.name}',
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
),
|
||||
leading: const Icon(Icons.visibility_off_outlined, size: 19),
|
||||
@@ -364,13 +365,13 @@ class AuthorPanel extends StatelessWidget {
|
||||
Get.back();
|
||||
Get.find<DynamicsController>()
|
||||
.tempBannedList
|
||||
.add(item.modules.moduleAuthor.mid);
|
||||
.add(item.modules.moduleAuthor!.mid!);
|
||||
SmartDialog.showToast(
|
||||
'已临时屏蔽${item.modules?.moduleAuthor?.name}(${item.modules.moduleAuthor.mid}),重启恢复');
|
||||
'已临时屏蔽${item.modules.moduleAuthor?.name}(${item.modules.moduleAuthor!.mid}),重启恢复');
|
||||
},
|
||||
minLeadingWidth: 0,
|
||||
),
|
||||
if (item.modules?.moduleAuthor?.mid == Accounts.main.mid) ...[
|
||||
if (item.modules.moduleAuthor?.mid == Accounts.main.mid) ...[
|
||||
ListTile(
|
||||
onTap: () {
|
||||
Get.back();
|
||||
@@ -393,12 +394,12 @@ class AuthorPanel extends StatelessWidget {
|
||||
onTap: () {
|
||||
Get.back();
|
||||
onSetTop!(
|
||||
item.modules?.moduleTag?.text != null, item.idStr);
|
||||
item.modules.moduleTag?.text != null, item.idStr);
|
||||
},
|
||||
minLeadingWidth: 0,
|
||||
leading: const Icon(Icons.vertical_align_top, size: 19),
|
||||
title: Text(
|
||||
'${item.modules?.moduleTag?.text != null ? '取消' : ''}置顶',
|
||||
'${item.modules.moduleTag?.text != null ? '取消' : ''}置顶',
|
||||
style: Theme.of(context).textTheme.titleSmall!),
|
||||
),
|
||||
if (onRemove != null)
|
||||
@@ -459,13 +460,13 @@ class AuthorPanel extends StatelessWidget {
|
||||
(reasonType, reasonDesc, banUid) {
|
||||
if (banUid) {
|
||||
VideoHttp.relationMod(
|
||||
mid: item.modules!.moduleAuthor!.mid!,
|
||||
mid: item.modules.moduleAuthor!.mid!,
|
||||
act: 5,
|
||||
reSrc: 11,
|
||||
);
|
||||
}
|
||||
return UserHttp.dynamicReport(
|
||||
mid: item.modules!.moduleAuthor!.mid,
|
||||
mid: item.modules.moduleAuthor!.mid,
|
||||
dynId: item.idStr,
|
||||
reasonType: reasonType,
|
||||
);
|
||||
|
||||
@@ -74,8 +74,8 @@ class DynamicPanel extends StatelessWidget {
|
||||
padding: const EdgeInsets.fromLTRB(12, 12, 12, 6),
|
||||
child: authorWidget,
|
||||
),
|
||||
if (item.modules!.moduleDynamic!.desc != null ||
|
||||
item.modules!.moduleDynamic!.major != null)
|
||||
if (item.modules.moduleDynamic!.desc != null ||
|
||||
item.modules.moduleDynamic!.major != null)
|
||||
content(isSave, context, item, source, callback),
|
||||
forWard(isSave, item, context, source, callback),
|
||||
const SizedBox(height: 2),
|
||||
@@ -94,7 +94,7 @@ class DynamicPanel extends StatelessWidget {
|
||||
) {
|
||||
late String? title;
|
||||
late String? cover;
|
||||
late final major = item.modules?.moduleDynamic?.major;
|
||||
late final major = item.modules.moduleDynamic?.major;
|
||||
switch (item.type) {
|
||||
case 'DYNAMIC_TYPE_AV':
|
||||
title = major?.archive?.title;
|
||||
|
||||
@@ -143,7 +143,7 @@ Widget forWard(bool isSave, item, BuildContext context, source, callback,
|
||||
item.modules.moduleDynamic.additional.type,
|
||||
floor: floor,
|
||||
),
|
||||
if (item?.modules?.moduleDynamic?.major?.blocked != null)
|
||||
if (item?.modules.moduleDynamic?.major?.blocked != null)
|
||||
_blockedItem(context, item, source),
|
||||
],
|
||||
);
|
||||
@@ -155,27 +155,27 @@ Widget forWard(bool isSave, item, BuildContext context, source, callback,
|
||||
return switch (item) {
|
||||
DynamicItemModel() => item.isForwarded == true
|
||||
? articlePanel(source, item, context, callback, floor: floor)
|
||||
: item.modules?.moduleDynamic?.major?.blocked != null
|
||||
: item.modules.moduleDynamic?.major?.blocked != null
|
||||
? Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (item.modules?.moduleDynamic?.major
|
||||
if (item.modules.moduleDynamic?.major
|
||||
?.blocked?['title'] !=
|
||||
null)
|
||||
Text(
|
||||
'${item.modules?.moduleDynamic?.major?.blocked!['title']}',
|
||||
'${item.modules.moduleDynamic?.major?.blocked!['title']}',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
),
|
||||
if (item.modules?.moduleDynamic?.major
|
||||
if (item.modules.moduleDynamic?.major
|
||||
?.blocked?['hint_message'] !=
|
||||
null)
|
||||
Text(
|
||||
'${item.modules?.moduleDynamic?.major?.blocked!['hint_message']}',
|
||||
'${item.modules.moduleDynamic?.major?.blocked!['hint_message']}',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
@@ -304,7 +304,7 @@ Widget forWard(bool isSave, item, BuildContext context, source, callback,
|
||||
item.modules.moduleDynamic.additional.type,
|
||||
floor: floor,
|
||||
)
|
||||
: item?.modules?.moduleDynamic?.major?.blocked != null
|
||||
: item?.modules.moduleDynamic?.major?.blocked != null
|
||||
? _blockedItem(context, item, source)
|
||||
: const SizedBox(height: 0);
|
||||
case 'DYNAMIC_TYPE_PGC':
|
||||
|
||||
@@ -72,13 +72,13 @@ class MemberDynamicsController
|
||||
var res = await DynamicsHttp.setTop(dynamicId: dynamicId);
|
||||
if (res['status']) {
|
||||
List<DynamicItemModel> list = (loadingState.value as Success).response;
|
||||
list[0].modules?.moduleTag = null;
|
||||
list[0].modules.moduleTag = null;
|
||||
if (isTop) {
|
||||
loadingState.refresh();
|
||||
SmartDialog.showToast('取消置顶成功');
|
||||
} else {
|
||||
final item = list.firstWhere((item) => item.idStr == dynamicId);
|
||||
item.modules?.moduleTag = ModuleTag(text: '置顶');
|
||||
item.modules.moduleTag = ModuleTag(text: '置顶');
|
||||
list.remove(item);
|
||||
list.insert(0, item);
|
||||
loadingState.refresh();
|
||||
|
||||
Reference in New Issue
Block a user