mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: share origin img & lazy to opus (#768)
* opt: type * opt: share origin img * opt: lazy to opus
This commit is contained in:
committed by
GitHub
parent
a831b41623
commit
7f93b42a1b
@@ -786,6 +786,4 @@ class Api {
|
||||
static const String articleView = '/x/article/view';
|
||||
|
||||
static const String opusDetail = '/x/polymer/web-dynamic/v1/opus/detail';
|
||||
|
||||
static const String feedInfoWeb = '${HttpString.tUrl}/x/im/feed/infoweb';
|
||||
}
|
||||
|
||||
@@ -570,26 +570,4 @@ class MsgHttp {
|
||||
static String getDevId() {
|
||||
return Uuid().v4();
|
||||
}
|
||||
|
||||
static Future feedInfoWeb({
|
||||
List? aids,
|
||||
List? epIds,
|
||||
List? articleIds,
|
||||
}) async {
|
||||
var res = await Request().get(
|
||||
Api.feedInfoWeb,
|
||||
queryParameters: {
|
||||
if (aids != null) 'aids': aids.join(','),
|
||||
if (epIds != null) 'ep_ids': epIds.join(','),
|
||||
if (articleIds != null) 'article_ids': articleIds.join(','),
|
||||
'build': 0,
|
||||
'mobi_app': 'web',
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true, 'data': res.data['data']};
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,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/http/msg.dart';
|
||||
import 'package:PiliPlus/http/user.dart';
|
||||
import 'package:PiliPlus/http/video.dart';
|
||||
import 'package:PiliPlus/models/dynamics/article_content_model.dart'
|
||||
@@ -12,7 +11,6 @@ import 'package:PiliPlus/models/space_article/item.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';
|
||||
@@ -23,7 +21,9 @@ class ArticleController extends ReplyController<MainListReply> {
|
||||
late String id;
|
||||
late String type;
|
||||
|
||||
late String url;
|
||||
late String url = type == 'read'
|
||||
? 'https://www.bilibili.com/read/cv$id'
|
||||
: 'https://www.bilibili.com/opus/$id';
|
||||
late int commentType;
|
||||
late int commentId;
|
||||
final summary = Summary();
|
||||
@@ -37,7 +37,7 @@ class ArticleController extends ReplyController<MainListReply> {
|
||||
dynamic get sourceId => commentType == 12 ? 'cv$commentId' : id;
|
||||
|
||||
final RxBool isLoaded = false.obs;
|
||||
DynamicItemModel? opusData; // 采用opus信息作为动态信息, 标题信息从summary获取
|
||||
DynamicItemModel? opusData; // 标题信息从summary获取, 动态没有favorite
|
||||
Item? articleData;
|
||||
final Rx<ModuleStatModel?> stats = Rx<ModuleStatModel?>(null);
|
||||
|
||||
@@ -50,52 +50,23 @@ 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/')
|
||||
.then((url) {
|
||||
if (url != null) {
|
||||
id = url.split('/').last;
|
||||
type = 'opus';
|
||||
}
|
||||
init();
|
||||
});
|
||||
} else {
|
||||
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;
|
||||
|
||||
_queryContent();
|
||||
_queryContent(); // lazy to opus
|
||||
}
|
||||
|
||||
Future<bool> queryOpus(opusId) async {
|
||||
Future<void> _queryOpus(opusId) async {
|
||||
final res = await DynamicsHttp.opusDetail(opusId: opusId);
|
||||
if (res is Success) {
|
||||
final opusData = (res as Success<DynamicItemModel>).response;
|
||||
if (res.isSuccess) {
|
||||
final opusData = res.data;
|
||||
//fallback
|
||||
if (opusData.fallback?.id != null) {
|
||||
id = opusData.fallback!.id!;
|
||||
type = 'read';
|
||||
setUrl();
|
||||
_queryContent();
|
||||
return false;
|
||||
if (articleData?.content == null) {
|
||||
await _queryRead(id, false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
this.opusData = opusData;
|
||||
commentType = opusData.basic!.commentType!;
|
||||
@@ -106,44 +77,45 @@ class ArticleController extends ReplyController<MainListReply> {
|
||||
summary
|
||||
..author ??= opusData.modules.moduleAuthor
|
||||
..title ??= opusData.modules.moduleTag?.text;
|
||||
return true;
|
||||
isLoaded.value = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Future<bool> queryRead(cvid) async {
|
||||
final res = await DynamicsHttp.articleView(cvId: cvid);
|
||||
if (res is Success) {
|
||||
articleData = (res as Success<Item>).response;
|
||||
Future<void> _queryRead(cvId, [bool toOpus = false]) async {
|
||||
final res = await DynamicsHttp.articleView(cvId: cvId);
|
||||
if (res.isSuccess) {
|
||||
articleData = res.data;
|
||||
summary
|
||||
..author ??= articleData!.author
|
||||
..title ??= articleData!.title
|
||||
..cover ??= articleData!.originImageUrls?.firstOrNull;
|
||||
isLoaded.value = true;
|
||||
|
||||
if (showDynActionBar) {
|
||||
_queryReadAsDyn(articleData!.dynIdStr);
|
||||
_getArticleInfo();
|
||||
if (toOpus &&
|
||||
articleData!.dynIdStr != null &&
|
||||
articleData?.opus?.content?.isNotEmpty != true) {
|
||||
await _queryOpus(articleData!.dynIdStr);
|
||||
if (opusData != null) {
|
||||
id = articleData!.dynIdStr!;
|
||||
type = 'opus';
|
||||
isLoaded.refresh();
|
||||
}
|
||||
}
|
||||
if (showDynActionBar && stats.value == null) {
|
||||
// _queryReadAsDyn(articleData!.dynIdStr);
|
||||
getArticleInfo();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// data for forward
|
||||
Future _queryReadAsDyn(id) async {
|
||||
if (opusData != null) {
|
||||
return;
|
||||
}
|
||||
final res = await DynamicsHttp.dynamicDetail(id: id);
|
||||
if (res['status']) {
|
||||
opusData = res['data'];
|
||||
}
|
||||
}
|
||||
|
||||
// stats
|
||||
Future _getArticleInfo() async {
|
||||
Future<bool> getArticleInfo() async {
|
||||
final res = await DynamicsHttp.articleInfo(cvId: commentId);
|
||||
if (res['status']) {
|
||||
summary
|
||||
..cover ??= (res['data']?['origin_image_urls'] as List?)?.firstOrNull
|
||||
..title ??= res['data']?['title'];
|
||||
|
||||
stats.value = ModuleStatModel(
|
||||
comment: DynamicStat(count: res['data']?['stats']?['reply']),
|
||||
forward: DynamicStat(count: res['data']?['stats']?['share']),
|
||||
@@ -156,17 +128,20 @@ class ArticleController extends ReplyController<MainListReply> {
|
||||
status: res['data']?['favorite'],
|
||||
),
|
||||
);
|
||||
return true;
|
||||
}
|
||||
SmartDialog.showToast(res['msg']);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 请求动态内容
|
||||
Future _queryContent() async {
|
||||
if (type != 'read') {
|
||||
isLoaded.value = await queryOpus(id);
|
||||
await _queryOpus(id);
|
||||
} else {
|
||||
commentId = int.parse(id);
|
||||
commentType = 12;
|
||||
isLoaded.value = await queryRead(commentId);
|
||||
await _queryRead(commentId, true);
|
||||
}
|
||||
if (isLoaded.value) {
|
||||
queryData();
|
||||
@@ -219,7 +194,8 @@ class ArticleController extends ReplyController<MainListReply> {
|
||||
Future onLike(VoidCallback callback) async {
|
||||
bool isLike = stats.value?.like?.status == true;
|
||||
final res = await DynamicsHttp.likeDynamic(
|
||||
dynamicId: opusData?.idStr, up: isLike ? 2 : 1);
|
||||
dynamicId: opusData?.idStr ?? articleData?.dynIdStr,
|
||||
up: isLike ? 2 : 1);
|
||||
if (res['status']) {
|
||||
stats.value?.like?.status = !isLike;
|
||||
int count = stats.value?.like?.count ?? 0;
|
||||
@@ -234,19 +210,6 @@ class ArticleController extends ReplyController<MainListReply> {
|
||||
SmartDialog.showToast(res['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
Future getArticleCover() async {
|
||||
final res = await MsgHttp.feedInfoWeb(articleIds: [commentId]);
|
||||
if (res['status']) {
|
||||
summary.cover = ((res['data']?['article'] as List?)
|
||||
?.firstOrNull?['image_urls'] as List?)
|
||||
?.firstOrNull;
|
||||
// debugPrint('cover: ${summary.cover}');
|
||||
return summary.cover != null;
|
||||
} else {
|
||||
SmartDialog.showToast(res['msg']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Summary {
|
||||
|
||||
@@ -626,8 +626,7 @@ class _ArticlePageState extends State<ArticlePage>
|
||||
onTap: () async {
|
||||
try {
|
||||
if (_articleCtr.summary.cover == null) {
|
||||
final res = await _articleCtr.getArticleCover();
|
||||
if (res != true) {
|
||||
if (!await _articleCtr.getArticleInfo()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ InlineSpan picsNodes(List<OpusPicsModel> pics, callback) {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _blockedItem(BuildContext context, item, source) {
|
||||
Widget _blockedItem(BuildContext context, DynamicItemModel item, source) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.only(
|
||||
@@ -49,16 +49,16 @@ Widget _blockedItem(BuildContext context, item, source) {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (item.modules.moduleDynamic.major.blocked['title'] != null)
|
||||
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.blocked['hint_message'] != null)
|
||||
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,
|
||||
@@ -69,14 +69,14 @@ Widget _blockedItem(BuildContext context, item, source) {
|
||||
);
|
||||
}
|
||||
|
||||
Widget forWard(bool isSave, item, BuildContext context, source, callback,
|
||||
Widget forWard(
|
||||
bool isSave, DynamicItemModel item, BuildContext context, source, callback,
|
||||
{floor = 1}) {
|
||||
switch (item.type) {
|
||||
// 图文
|
||||
case 'DYNAMIC_TYPE_DRAW':
|
||||
bool hasPics = item.modules.moduleDynamic.major != null &&
|
||||
item.modules.moduleDynamic.major.opus != null &&
|
||||
item.modules.moduleDynamic.major.opus.pics.isNotEmpty;
|
||||
bool hasPics =
|
||||
item.modules.moduleDynamic?.major?.opus?.pics?.isNotEmpty == true;
|
||||
|
||||
InlineSpan? richNodes = richNode(item, context);
|
||||
return Column(
|
||||
@@ -87,17 +87,17 @@ Widget forWard(bool isSave, item, BuildContext context, source, callback,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () => Get.toNamed(
|
||||
'/member?mid=${item.modules.moduleAuthor.mid}',
|
||||
arguments: {'face': item.modules.moduleAuthor.face}),
|
||||
'/member?mid=${item.modules.moduleAuthor!.mid}',
|
||||
arguments: {'face': item.modules.moduleAuthor!.face}),
|
||||
child: Text(
|
||||
'@${item.modules.moduleAuthor.name}',
|
||||
'@${item.modules.moduleAuthor!.name}',
|
||||
style:
|
||||
TextStyle(color: Theme.of(context).colorScheme.primary),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
Utils.dateFormat(item.modules.moduleAuthor.pubTs),
|
||||
Utils.dateFormat(item.modules.moduleAuthor!.pubTs),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
fontSize:
|
||||
@@ -123,7 +123,8 @@ Widget forWard(bool isSave, item, BuildContext context, source, callback,
|
||||
),
|
||||
if (hasPics) ...[
|
||||
Text.rich(
|
||||
picsNodes(item.modules.moduleDynamic.major.opus.pics, callback),
|
||||
picsNodes(
|
||||
item.modules.moduleDynamic!.major!.opus!.pics!, callback),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 4),
|
||||
@@ -136,14 +137,14 @@ Widget forWard(bool isSave, item, BuildContext context, source, callback,
|
||||
),
|
||||
|
||||
/// 附加内容 商品信息、直播预约等等
|
||||
if (item.modules.moduleDynamic.additional != null)
|
||||
if (item.modules.moduleDynamic?.additional != null)
|
||||
addWidget(
|
||||
item,
|
||||
context,
|
||||
item.modules.moduleDynamic.additional.type,
|
||||
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),
|
||||
],
|
||||
);
|
||||
@@ -152,93 +153,87 @@ Widget forWard(bool isSave, item, BuildContext context, source, callback,
|
||||
return videoSeasonWidget(source, item, context, 'archive', floor: floor);
|
||||
// 文章
|
||||
case 'DYNAMIC_TYPE_ARTICLE':
|
||||
return switch (item) {
|
||||
DynamicItemModel() => item.isForwarded == true
|
||||
? articlePanel(source, item, context, callback, floor: floor)
|
||||
: 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
|
||||
?.blocked?['title'] !=
|
||||
null)
|
||||
Text(
|
||||
'${item.modules.moduleDynamic?.major?.blocked!['title']}',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
return item.isForwarded == true
|
||||
? articlePanel(source, item, context, callback, floor: floor)
|
||||
: 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
|
||||
?.blocked?['title'] !=
|
||||
null)
|
||||
Text(
|
||||
item.modules.moduleDynamic!.major!.blocked!['title'],
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
if (item.modules.moduleDynamic?.major
|
||||
?.blocked?['hint_message'] !=
|
||||
null)
|
||||
Text(
|
||||
'${item.modules.moduleDynamic?.major?.blocked!['hint_message']}',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
_ => const SizedBox.shrink(),
|
||||
};
|
||||
),
|
||||
if (item.modules.moduleDynamic?.major
|
||||
?.blocked?['hint_message'] !=
|
||||
null)
|
||||
Text(
|
||||
item.modules.moduleDynamic!.major!
|
||||
.blocked!['hint_message'],
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
: const SizedBox.shrink();
|
||||
// 转发
|
||||
case 'DYNAMIC_TYPE_FORWARD':
|
||||
final isNoneMajor =
|
||||
item.orig?.modules.moduleDynamic?.major?.type == 'MAJOR_TYPE_NONE';
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
if (item.orig.modules.moduleDynamic.major?.type ==
|
||||
'MAJOR_TYPE_NONE') {
|
||||
return;
|
||||
}
|
||||
PageUtils.pushDynDetail(item.orig, floor + 1);
|
||||
},
|
||||
onLongPress: () {
|
||||
if (item.orig.modules.moduleDynamic.major?.type ==
|
||||
'MAJOR_TYPE_NONE') {
|
||||
return;
|
||||
}
|
||||
if (item.orig.type == 'DYNAMIC_TYPE_AV') {
|
||||
imageSaveDialog(
|
||||
context: context,
|
||||
title: item.orig.modules.moduleDynamic.major.archive.title,
|
||||
cover: item.orig.modules.moduleDynamic.major.archive.cover,
|
||||
);
|
||||
} else if (item.orig.type == 'DYNAMIC_TYPE_UGC_SEASON') {
|
||||
imageSaveDialog(
|
||||
context: context,
|
||||
title: item.orig.modules.moduleDynamic.major.ugcSeason.title,
|
||||
cover: item.orig.modules.moduleDynamic.major.ugcSeason.cover,
|
||||
);
|
||||
} else if (item.orig.type == 'DYNAMIC_TYPE_PGC' ||
|
||||
item.orig.type == 'DYNAMIC_TYPE_PGC_UNION') {
|
||||
imageSaveDialog(
|
||||
context: context,
|
||||
title: item.orig.modules.moduleDynamic.major.pgc.title,
|
||||
cover: item.orig.modules.moduleDynamic.major.pgc.cover,
|
||||
);
|
||||
} else if (item.type == 'DYNAMIC_TYPE_LIVE_RCMD') {
|
||||
imageSaveDialog(
|
||||
context: context,
|
||||
title: item.modules.moduleDynamic.major.liveRcmd.title,
|
||||
cover: item.modules.moduleDynamic.major.liveRcmd.cover,
|
||||
);
|
||||
} else if (item.type == 'DYNAMIC_TYPE_LIVE') {
|
||||
imageSaveDialog(
|
||||
context: context,
|
||||
title: item.modules.moduleDynamic.major.live.title,
|
||||
cover: item.modules.moduleDynamic.major.live.cover,
|
||||
);
|
||||
}
|
||||
},
|
||||
onTap: isNoneMajor
|
||||
? null
|
||||
: () => PageUtils.pushDynDetail(item.orig!, floor + 1),
|
||||
onLongPress: isNoneMajor
|
||||
? null
|
||||
: () {
|
||||
late String? title, cover;
|
||||
late var origMajor = item.orig?.modules.moduleDynamic?.major;
|
||||
late var major = item.modules.moduleDynamic?.major;
|
||||
switch (item.orig?.type) {
|
||||
case 'DYNAMIC_TYPE_AV':
|
||||
title = origMajor?.archive?.title;
|
||||
cover = origMajor?.archive?.cover;
|
||||
break;
|
||||
case 'DYNAMIC_TYPE_UGC_SEASON':
|
||||
title = origMajor?.ugcSeason?.title;
|
||||
cover = origMajor?.ugcSeason?.cover;
|
||||
break;
|
||||
case 'DYNAMIC_TYPE_PGC' || 'DYNAMIC_TYPE_PGC_UNION':
|
||||
title = origMajor?.pgc?.title;
|
||||
cover = origMajor?.pgc?.cover;
|
||||
break;
|
||||
case 'DYNAMIC_TYPE_LIVE_RCMD':
|
||||
title = major?.liveRcmd?.title;
|
||||
cover = major?.liveRcmd?.cover;
|
||||
break;
|
||||
case 'DYNAMIC_TYPE_LIVE':
|
||||
title = major?.live?.title;
|
||||
cover = major?.live?.cover;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
imageSaveDialog(
|
||||
context: context,
|
||||
title: title,
|
||||
cover: cover,
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 8),
|
||||
color: Theme.of(context).dividerColor.withOpacity(0.08),
|
||||
child: forWard(isSave, item.orig, context, source, callback,
|
||||
child: forWard(isSave, item.orig!, context, source, callback,
|
||||
floor: floor + 1),
|
||||
),
|
||||
);
|
||||
@@ -261,17 +256,17 @@ Widget forWard(bool isSave, item, BuildContext context, source, callback,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () => Get.toNamed(
|
||||
'/member?mid=${item.modules.moduleAuthor.mid}',
|
||||
arguments: {'face': item.modules.moduleAuthor.face}),
|
||||
'/member?mid=${item.modules.moduleAuthor?.mid}',
|
||||
arguments: {'face': item.modules.moduleAuthor?.face}),
|
||||
child: Text(
|
||||
'@${item.modules.moduleAuthor.name}',
|
||||
'@${item.modules.moduleAuthor?.name}',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.primary),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
Utils.dateFormat(item.modules.moduleAuthor.pubTs),
|
||||
Utils.dateFormat(item.modules.moduleAuthor?.pubTs),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
fontSize:
|
||||
@@ -297,14 +292,14 @@ Widget forWard(bool isSave, item, BuildContext context, source, callback,
|
||||
),
|
||||
],
|
||||
)
|
||||
: item.modules.moduleDynamic.additional != null
|
||||
: item.modules.moduleDynamic?.additional != null
|
||||
? addWidget(
|
||||
item,
|
||||
context,
|
||||
item.modules.moduleDynamic.additional.type,
|
||||
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':
|
||||
@@ -320,7 +315,7 @@ Widget forWard(bool isSave, item, BuildContext context, source, callback,
|
||||
size: 14,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(item.modules.moduleDynamic.major.none.tips)
|
||||
Text(item.modules.moduleDynamic!.major!.none!.tips!)
|
||||
],
|
||||
);
|
||||
// 课堂
|
||||
@@ -329,7 +324,7 @@ Widget forWard(bool isSave, item, BuildContext context, source, callback,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"课堂💪:${item.modules.moduleDynamic.major.courses['title']}",
|
||||
"课堂💪:${item.modules.moduleDynamic!.major!.courses!['title']}",
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
@@ -341,7 +336,7 @@ Widget forWard(bool isSave, item, BuildContext context, source, callback,
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
try {
|
||||
String url = item.modules.moduleDynamic.major.common['jump_url'];
|
||||
String url = item.modules.moduleDynamic!.major!.common!['jump_url'];
|
||||
if (url.contains('bangumi/play') && PageUtils.viewPgcFromUri(url)) {
|
||||
return;
|
||||
}
|
||||
@@ -360,7 +355,7 @@ Widget forWard(bool isSave, item, BuildContext context, source, callback,
|
||||
radius: 8,
|
||||
width: 45,
|
||||
height: 45,
|
||||
src: item.modules.moduleDynamic.major.common['cover'],
|
||||
src: item.modules.moduleDynamic!.major!.common!['cover'],
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
@@ -368,7 +363,7 @@ Widget forWard(bool isSave, item, BuildContext context, source, callback,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.modules.moduleDynamic.major.common['title'],
|
||||
item.modules.moduleDynamic!.major!.common!['title'],
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
@@ -377,7 +372,7 @@ Widget forWard(bool isSave, item, BuildContext context, source, callback,
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
item.modules.moduleDynamic.major.common['desc'],
|
||||
item.modules.moduleDynamic!.major!.common!['desc'],
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
fontSize:
|
||||
@@ -394,7 +389,7 @@ Widget forWard(bool isSave, item, BuildContext context, source, callback,
|
||||
),
|
||||
);
|
||||
case 'DYNAMIC_TYPE_MUSIC':
|
||||
final Map music = item.modules.moduleDynamic.major.music;
|
||||
final Map music = item.modules.moduleDynamic!.major!.music!;
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
PageUtils.handleWebview("https:${music['jump_url']}");
|
||||
@@ -450,7 +445,7 @@ Widget forWard(bool isSave, item, BuildContext context, source, callback,
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Get.toNamed(
|
||||
'/member?mid=${item.modules.moduleAuthor.mid}',
|
||||
'/member?mid=${item.modules.moduleAuthor!.mid}',
|
||||
);
|
||||
},
|
||||
child: Row(
|
||||
@@ -459,15 +454,15 @@ Widget forWard(bool isSave, item, BuildContext context, source, callback,
|
||||
width: 28,
|
||||
height: 28,
|
||||
type: 'avatar',
|
||||
src: item.modules.moduleAuthor.face,
|
||||
src: item.modules.moduleAuthor!.face,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
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.of(context).colorScheme.onSurface,
|
||||
fontSize:
|
||||
@@ -486,17 +481,18 @@ Widget forWard(bool isSave, item, BuildContext context, source, callback,
|
||||
Stack(
|
||||
children: [
|
||||
Hero(
|
||||
tag: item.modules.moduleDynamic.major.medialist['cover'],
|
||||
tag: item.modules.moduleDynamic!.major!.medialist!['cover'],
|
||||
child: NetworkImgLayer(
|
||||
width: 180,
|
||||
height: 110,
|
||||
src: item.modules.moduleDynamic.major.medialist['cover'],
|
||||
src: item
|
||||
.modules.moduleDynamic!.major!.medialist!['cover'],
|
||||
),
|
||||
),
|
||||
PBadge(
|
||||
right: 6,
|
||||
top: 6,
|
||||
text: item.modules.moduleDynamic.major.medialist['badge']
|
||||
text: item.modules.moduleDynamic!.major!.medialist!['badge']
|
||||
?['text'],
|
||||
)
|
||||
],
|
||||
@@ -512,7 +508,7 @@ Widget forWard(bool isSave, item, BuildContext context, source, callback,
|
||||
children: [
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
item.modules.moduleDynamic.major.medialist['title'],
|
||||
item.modules.moduleDynamic!.major!.medialist!['title'],
|
||||
style: TextStyle(
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
@@ -520,13 +516,13 @@ Widget forWard(bool isSave, item, BuildContext context, source, callback,
|
||||
.fontSize,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
if (item.modules.moduleDynamic.major
|
||||
.medialist['sub_title'] !=
|
||||
if (item.modules.moduleDynamic?.major
|
||||
?.medialist?['sub_title'] !=
|
||||
null) ...[
|
||||
const Spacer(),
|
||||
Text(
|
||||
item.modules.moduleDynamic.major
|
||||
.medialist['sub_title'],
|
||||
item.modules.moduleDynamic!.major!
|
||||
.medialist!['sub_title'],
|
||||
style: TextStyle(
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
|
||||
@@ -9,10 +9,10 @@ import 'package:PiliPlus/utils/utils.dart';
|
||||
|
||||
import 'rich_node_panel.dart';
|
||||
|
||||
Widget liveRcmdPanel(source, item, context, {floor = 1}) {
|
||||
Widget liveRcmdPanel(source, DynamicItemModel item, context, {floor = 1}) {
|
||||
TextStyle authorStyle =
|
||||
TextStyle(color: Theme.of(context).colorScheme.primary);
|
||||
DynamicLiveModel liveRcmd = item.modules.moduleDynamic.major.liveRcmd;
|
||||
DynamicLiveModel liveRcmd = item.modules.moduleDynamic!.major!.liveRcmd!;
|
||||
int liveStatus = liveRcmd.liveStatus!;
|
||||
Map watchedShow = liveRcmd.watchedShow!;
|
||||
InlineSpan? richNodes = richNode(item, context);
|
||||
@@ -24,16 +24,16 @@ Widget liveRcmdPanel(source, item, context, {floor = 1}) {
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () => Get.toNamed(
|
||||
'/member?mid=${item.modules.moduleAuthor.mid}',
|
||||
arguments: {'face': item.modules.moduleAuthor.face}),
|
||||
'/member?mid=${item.modules.moduleAuthor?.mid}',
|
||||
arguments: {'face': item.modules.moduleAuthor?.face}),
|
||||
child: Text(
|
||||
'@${item.modules.moduleAuthor.name}',
|
||||
'@${item.modules.moduleAuthor?.name}',
|
||||
style: authorStyle,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
Utils.dateFormat(item.modules.moduleAuthor.pubTs),
|
||||
Utils.dateFormat(item.modules.moduleAuthor?.pubTs),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
fontSize: Theme.of(context).textTheme.labelSmall!.fontSize),
|
||||
@@ -42,20 +42,20 @@ Widget liveRcmdPanel(source, item, context, {floor = 1}) {
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 4),
|
||||
if (item.modules.moduleDynamic.topic != null) ...[
|
||||
if (item.modules.moduleDynamic?.topic != null) ...[
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: StyleString.safeSpace),
|
||||
child: GestureDetector(
|
||||
child: Text(
|
||||
'#${item.modules.moduleDynamic.topic.name}',
|
||||
'#${item.modules.moduleDynamic!.topic!.name}',
|
||||
style: authorStyle,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
],
|
||||
if (floor == 2 && item.modules.moduleDynamic.desc != null) ...[
|
||||
if (floor == 2 && item.modules.moduleDynamic?.desc != null) ...[
|
||||
if (richNodes != null) Text.rich(richNodes),
|
||||
const SizedBox(height: 6),
|
||||
],
|
||||
@@ -75,7 +75,7 @@ Widget liveRcmdPanel(source, item, context, {floor = 1}) {
|
||||
child: NetworkImgLayer(
|
||||
width: width,
|
||||
height: width / StyleString.aspectRatio,
|
||||
src: item.modules.moduleDynamic.major.liveRcmd.cover,
|
||||
src: item.modules.moduleDynamic?.major?.liveRcmd?.cover,
|
||||
),
|
||||
),
|
||||
PBadge(
|
||||
@@ -126,8 +126,8 @@ Widget liveRcmdPanel(source, item, context, {floor = 1}) {
|
||||
color: Colors.white),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(item.modules.moduleDynamic.major.liveRcmd
|
||||
.areaName ??
|
||||
Text(item.modules.moduleDynamic?.major?.liveRcmd
|
||||
?.areaName ??
|
||||
''),
|
||||
],
|
||||
),
|
||||
@@ -144,7 +144,7 @@ Widget liveRcmdPanel(source, item, context, {floor = 1}) {
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: StyleString.safeSpace),
|
||||
child: Text(
|
||||
item.modules.moduleDynamic.major.liveRcmd.title,
|
||||
item.modules.moduleDynamic!.major!.liveRcmd!.title!,
|
||||
maxLines: source == 'detail' ? null : 1,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
overflow: source == 'detail' ? null : TextOverflow.ellipsis,
|
||||
|
||||
@@ -272,9 +272,6 @@ class PageUtils {
|
||||
'id': id,
|
||||
'type': 'opus',
|
||||
},
|
||||
arguments: {
|
||||
'item': data,
|
||||
},
|
||||
off: off,
|
||||
);
|
||||
} else {
|
||||
@@ -344,7 +341,8 @@ class PageUtils {
|
||||
);
|
||||
}
|
||||
|
||||
static void pushDynDetail(item, floor, {action = 'all'}) async {
|
||||
static void pushDynDetail(DynamicItemModel item, floor,
|
||||
{action = 'all'}) async {
|
||||
feedBack();
|
||||
|
||||
/// 点击评论action 直接查看评论
|
||||
@@ -364,14 +362,14 @@ class PageUtils {
|
||||
|
||||
switch (item.type) {
|
||||
case 'DYNAMIC_TYPE_AV':
|
||||
if (item.modules.moduleDynamic.major.archive?.type == 2) {
|
||||
if (item.modules.moduleDynamic.major.archive.jumpUrl
|
||||
if (item.modules.moduleDynamic?.major?.archive?.type == 2) {
|
||||
if (item.modules.moduleDynamic!.major!.archive!.jumpUrl!
|
||||
.startsWith('//')) {
|
||||
item.modules.moduleDynamic.major.archive.jumpUrl =
|
||||
'https:${item.modules.moduleDynamic.major.archive.jumpUrl}';
|
||||
item.modules.moduleDynamic!.major!.archive!.jumpUrl =
|
||||
'https:${item.modules.moduleDynamic!.major!.archive!.jumpUrl!}';
|
||||
}
|
||||
String? redirectUrl = await UrlUtils.parseRedirectUrl(
|
||||
item.modules.moduleDynamic.major.archive.jumpUrl, false);
|
||||
item.modules.moduleDynamic!.major!.archive!.jumpUrl!, false);
|
||||
if (redirectUrl != null) {
|
||||
viewPgcFromUri(redirectUrl);
|
||||
return;
|
||||
@@ -379,8 +377,8 @@ class PageUtils {
|
||||
}
|
||||
|
||||
try {
|
||||
String bvid = item.modules.moduleDynamic.major.archive.bvid;
|
||||
String cover = item.modules.moduleDynamic.major.archive.cover;
|
||||
String bvid = item.modules.moduleDynamic!.major!.archive!.bvid!;
|
||||
String cover = item.modules.moduleDynamic!.major!.archive!.cover!;
|
||||
int cid = await SearchHttp.ab2c(bvid: bvid);
|
||||
toVideoPage(
|
||||
'bvid=$bvid&cid=$cid',
|
||||
@@ -397,7 +395,7 @@ class PageUtils {
|
||||
|
||||
/// 专栏文章查看
|
||||
case 'DYNAMIC_TYPE_ARTICLE':
|
||||
String? url = item?.modules?.moduleDynamic?.major?.opus?.jumpUrl;
|
||||
String? url = item.modules.moduleDynamic?.major?.opus?.jumpUrl;
|
||||
if (url != null) {
|
||||
if (url.contains('opus') || url.contains('read')) {
|
||||
RegExp digitRegExp = RegExp(r'\d+');
|
||||
@@ -422,8 +420,9 @@ class PageUtils {
|
||||
break;
|
||||
|
||||
case 'DYNAMIC_TYPE_LIVE_RCMD':
|
||||
DynamicLiveModel liveRcmd = item.modules.moduleDynamic.major.liveRcmd;
|
||||
ModuleAuthorModel author = item.modules.moduleAuthor;
|
||||
DynamicLiveModel liveRcmd =
|
||||
item.modules.moduleDynamic!.major!.liveRcmd!;
|
||||
ModuleAuthorModel author = item.modules.moduleAuthor!;
|
||||
LiveItemModel liveItem = LiveItemModel.fromJson({
|
||||
'title': liveRcmd.title,
|
||||
'uname': author.name,
|
||||
@@ -439,7 +438,7 @@ class PageUtils {
|
||||
/// 合集查看
|
||||
case 'DYNAMIC_TYPE_UGC_SEASON':
|
||||
DynamicArchiveModel ugcSeason =
|
||||
item.modules.moduleDynamic.major.ugcSeason;
|
||||
item.modules.moduleDynamic!.major!.ugcSeason!;
|
||||
int aid = ugcSeason.aid!;
|
||||
String bvid = IdUtils.av2bv(aid);
|
||||
String cover = ugcSeason.cover!;
|
||||
@@ -457,23 +456,23 @@ class PageUtils {
|
||||
/// 番剧查看
|
||||
case 'DYNAMIC_TYPE_PGC_UNION':
|
||||
debugPrint('DYNAMIC_TYPE_PGC_UNION 番剧');
|
||||
DynamicArchiveModel pgc = item.modules.moduleDynamic.major.pgc;
|
||||
DynamicArchiveModel pgc = item.modules.moduleDynamic!.major!.pgc!;
|
||||
if (pgc.epid != null) {
|
||||
viewBangumi(epId: pgc.epid);
|
||||
}
|
||||
break;
|
||||
case 'DYNAMIC_TYPE_MEDIALIST':
|
||||
if (item.modules?.moduleDynamic?.major?.medialist != null) {
|
||||
if (item.modules.moduleDynamic?.major?.medialist != null) {
|
||||
final String? url =
|
||||
item.modules.moduleDynamic.major.medialist['jump_url'];
|
||||
item.modules.moduleDynamic!.major!.medialist!['jump_url'];
|
||||
if (url?.contains('medialist/detail/ml') == true) {
|
||||
Get.toNamed(
|
||||
'/favDetail',
|
||||
parameters: {
|
||||
'heroTag':
|
||||
'${item.modules.moduleDynamic.major.medialist['cover']}',
|
||||
'${item.modules.moduleDynamic!.major!.medialist!['cover']}',
|
||||
'mediaId':
|
||||
'${item.modules.moduleDynamic.major.medialist['id']}',
|
||||
'${item.modules.moduleDynamic!.major!.medialist!['id']}',
|
||||
},
|
||||
);
|
||||
} else if (url != null) {
|
||||
|
||||
Reference in New Issue
Block a user