mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
fix: view forwarded dyn
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -35,47 +35,23 @@ class DynamicItemModel {
|
||||
Map? basic;
|
||||
dynamic idStr;
|
||||
ItemModulesModel? modules;
|
||||
ItemOrigModel? orig;
|
||||
DynamicItemModel? orig;
|
||||
String? type;
|
||||
bool? visible;
|
||||
bool? isForwarded;
|
||||
|
||||
DynamicItemModel.fromJson(Map<String, dynamic> json) {
|
||||
basic = json['basic'];
|
||||
idStr = json['id_str'];
|
||||
modules = ItemModulesModel.fromJson(json['modules']);
|
||||
orig = json['orig'] != null ? ItemOrigModel.fromJson(json['orig']) : null;
|
||||
orig =
|
||||
json['orig'] != null ? DynamicItemModel.fromJson(json['orig']) : null;
|
||||
orig?.isForwarded = true;
|
||||
type = json['type'];
|
||||
visible = json['visible'];
|
||||
}
|
||||
}
|
||||
|
||||
class ItemOrigModel {
|
||||
ItemOrigModel({
|
||||
this.basic,
|
||||
this.isStr,
|
||||
this.modules,
|
||||
this.type,
|
||||
this.visible,
|
||||
this.idStr,
|
||||
});
|
||||
|
||||
Map? basic;
|
||||
String? isStr;
|
||||
ItemModulesModel? modules;
|
||||
String? type;
|
||||
bool? visible;
|
||||
dynamic idStr;
|
||||
|
||||
ItemOrigModel.fromJson(Map<String, dynamic> json) {
|
||||
basic = json['basic'];
|
||||
isStr = json['is_str'];
|
||||
modules = ItemModulesModel.fromJson(json['modules']);
|
||||
type = json['type'];
|
||||
visible = json['visible'];
|
||||
idStr = json['id_str'];
|
||||
}
|
||||
}
|
||||
|
||||
// 单个动态详情
|
||||
class ItemModulesModel {
|
||||
ItemModulesModel({
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:PiliPlus/grpc/app/main/community/reply/v1/reply.pb.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/dynamics/result.dart';
|
||||
import 'package:PiliPlus/pages/common/reply_controller.dart';
|
||||
import 'package:PiliPlus/utils/global_data.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
@@ -12,7 +13,7 @@ class DynamicDetailController extends ReplyController {
|
||||
DynamicDetailController(this.oid, this.type);
|
||||
int? oid;
|
||||
int? type;
|
||||
dynamic item;
|
||||
late DynamicItemModel item;
|
||||
int? floor;
|
||||
|
||||
late final horizontalPreview = GStorage.horizontalPreview;
|
||||
|
||||
@@ -474,15 +474,19 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
_dynamicDetailController
|
||||
.item
|
||||
.modules
|
||||
.moduleStat
|
||||
.forward
|
||||
?.moduleStat
|
||||
?.forward
|
||||
?.count ??
|
||||
'0') ??
|
||||
0;
|
||||
_dynamicDetailController.item.modules
|
||||
?.moduleStat ??= ModuleStatModel();
|
||||
_dynamicDetailController.item.modules!
|
||||
.moduleStat?.forward ??= ForWard();
|
||||
_dynamicDetailController
|
||||
.item
|
||||
.modules
|
||||
.moduleStat
|
||||
.modules!
|
||||
.moduleStat!
|
||||
.forward!
|
||||
.count = (count + 1).toString();
|
||||
if (btnContext.mounted) {
|
||||
@@ -507,12 +511,12 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
),
|
||||
label: Text(
|
||||
_dynamicDetailController.item.modules
|
||||
.moduleStat.forward!.count !=
|
||||
?.moduleStat?.forward?.count !=
|
||||
null
|
||||
? Utils.numFormat(_dynamicDetailController
|
||||
.item
|
||||
.modules
|
||||
.moduleStat
|
||||
.modules!
|
||||
.moduleStat!
|
||||
.forward!
|
||||
.count)
|
||||
: '转发',
|
||||
@@ -553,17 +557,24 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
},
|
||||
),
|
||||
icon: Icon(
|
||||
_dynamicDetailController
|
||||
.item.modules.moduleStat.like!.status!
|
||||
_dynamicDetailController.item.modules
|
||||
?.moduleStat?.like?.status ==
|
||||
true
|
||||
? FontAwesomeIcons.solidThumbsUp
|
||||
: FontAwesomeIcons.thumbsUp,
|
||||
size: 16,
|
||||
color: _dynamicDetailController
|
||||
.item.modules.moduleStat.like!.status!
|
||||
color: _dynamicDetailController.item.modules
|
||||
?.moduleStat?.like?.status ==
|
||||
true
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: Theme.of(context).colorScheme.outline,
|
||||
semanticLabel: _dynamicDetailController
|
||||
.item.modules.moduleStat.like!.status!
|
||||
.item
|
||||
.modules
|
||||
?.moduleStat
|
||||
?.like
|
||||
?.status ==
|
||||
true
|
||||
? "已赞"
|
||||
: "点赞",
|
||||
),
|
||||
@@ -582,15 +593,24 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
},
|
||||
child: Text(
|
||||
_dynamicDetailController.item.modules
|
||||
.moduleStat.like!.count !=
|
||||
?.moduleStat?.like?.count !=
|
||||
null
|
||||
? Utils.numFormat(
|
||||
_dynamicDetailController.item
|
||||
.modules.moduleStat.like!.count)
|
||||
_dynamicDetailController
|
||||
.item
|
||||
.modules!
|
||||
.moduleStat!
|
||||
.like!
|
||||
.count)
|
||||
: '点赞',
|
||||
style: TextStyle(
|
||||
color: _dynamicDetailController.item
|
||||
.modules.moduleStat.like!.status!
|
||||
color: _dynamicDetailController
|
||||
.item
|
||||
.modules
|
||||
?.moduleStat
|
||||
?.like
|
||||
?.status ==
|
||||
true
|
||||
? Theme.of(context)
|
||||
.colorScheme
|
||||
.primary
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'package:PiliPlus/common/widgets/radio_widget.dart';
|
||||
import 'package:PiliPlus/http/index.dart';
|
||||
import 'package:PiliPlus/models/dynamics/result.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
@@ -98,7 +97,7 @@ class AuthorPanel extends StatelessWidget {
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(item is ItemOrigModel
|
||||
Text(item.isForwarded == true
|
||||
? Utils.dateFormat(item.modules.moduleAuthor.pubTs)
|
||||
: item.modules.moduleAuthor.pubTime),
|
||||
if (item.modules.moduleAuthor.pubTime != '' &&
|
||||
|
||||
@@ -162,37 +162,38 @@ Widget forWard(item, context, source, callback, {floor = 1}) {
|
||||
// 文章
|
||||
case 'DYNAMIC_TYPE_ARTICLE':
|
||||
return switch (item) {
|
||||
ItemOrigModel() => articlePanel(item, context, callback, floor: floor),
|
||||
DynamicItemModel() => 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(),
|
||||
DynamicItemModel() => item.isForwarded == true
|
||||
? articlePanel(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(),
|
||||
};
|
||||
// return Container(
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// 视频or合集
|
||||
import 'package:PiliPlus/models/dynamics/result.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
@@ -159,7 +158,7 @@ Widget videoSeasonWidget(item, context, type, {floor = 1}) {
|
||||
if (richNodes != null) Text.rich(richNodes),
|
||||
const SizedBox(height: 6),
|
||||
],
|
||||
if (item is ItemOrigModel)
|
||||
if (item.isForwarded == true)
|
||||
buildCover()
|
||||
else
|
||||
Padding(
|
||||
|
||||
@@ -51,9 +51,11 @@ class Utils {
|
||||
feedBack();
|
||||
String dynamicId = item.idStr!;
|
||||
// 1 已点赞 2 不喜欢 0 未操作
|
||||
item.modules?.moduleStat ??= ModuleStatModel();
|
||||
item.modules?.moduleStat.like ??= Like();
|
||||
Like like = item.modules.moduleStat.like;
|
||||
int count = like.count == '点赞' ? 0 : int.parse(like.count ?? '0');
|
||||
bool status = like.status!;
|
||||
bool status = like.status ?? false;
|
||||
int up = status ? 2 : 1;
|
||||
var res = await DynamicsHttp.likeDynamic(dynamicId: dynamicId, up: up);
|
||||
if (res['status']) {
|
||||
|
||||
Reference in New Issue
Block a user