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;
|
Map? basic;
|
||||||
dynamic idStr;
|
dynamic idStr;
|
||||||
ItemModulesModel? modules;
|
ItemModulesModel? modules;
|
||||||
ItemOrigModel? orig;
|
DynamicItemModel? orig;
|
||||||
String? type;
|
String? type;
|
||||||
bool? visible;
|
bool? visible;
|
||||||
|
bool? isForwarded;
|
||||||
|
|
||||||
DynamicItemModel.fromJson(Map<String, dynamic> json) {
|
DynamicItemModel.fromJson(Map<String, dynamic> json) {
|
||||||
basic = json['basic'];
|
basic = json['basic'];
|
||||||
idStr = json['id_str'];
|
idStr = json['id_str'];
|
||||||
modules = ItemModulesModel.fromJson(json['modules']);
|
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'];
|
type = json['type'];
|
||||||
visible = json['visible'];
|
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 {
|
class ItemModulesModel {
|
||||||
ItemModulesModel({
|
ItemModulesModel({
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:PiliPlus/grpc/app/main/community/reply/v1/reply.pb.dart';
|
import 'package:PiliPlus/grpc/app/main/community/reply/v1/reply.pb.dart';
|
||||||
import 'package:PiliPlus/http/loading_state.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/pages/common/reply_controller.dart';
|
||||||
import 'package:PiliPlus/utils/global_data.dart';
|
import 'package:PiliPlus/utils/global_data.dart';
|
||||||
import 'package:PiliPlus/utils/storage.dart';
|
import 'package:PiliPlus/utils/storage.dart';
|
||||||
@@ -12,7 +13,7 @@ class DynamicDetailController extends ReplyController {
|
|||||||
DynamicDetailController(this.oid, this.type);
|
DynamicDetailController(this.oid, this.type);
|
||||||
int? oid;
|
int? oid;
|
||||||
int? type;
|
int? type;
|
||||||
dynamic item;
|
late DynamicItemModel item;
|
||||||
int? floor;
|
int? floor;
|
||||||
|
|
||||||
late final horizontalPreview = GStorage.horizontalPreview;
|
late final horizontalPreview = GStorage.horizontalPreview;
|
||||||
|
|||||||
@@ -474,15 +474,19 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
|||||||
_dynamicDetailController
|
_dynamicDetailController
|
||||||
.item
|
.item
|
||||||
.modules
|
.modules
|
||||||
.moduleStat
|
?.moduleStat
|
||||||
.forward
|
?.forward
|
||||||
?.count ??
|
?.count ??
|
||||||
'0') ??
|
'0') ??
|
||||||
0;
|
0;
|
||||||
|
_dynamicDetailController.item.modules
|
||||||
|
?.moduleStat ??= ModuleStatModel();
|
||||||
|
_dynamicDetailController.item.modules!
|
||||||
|
.moduleStat?.forward ??= ForWard();
|
||||||
_dynamicDetailController
|
_dynamicDetailController
|
||||||
.item
|
.item
|
||||||
.modules
|
.modules!
|
||||||
.moduleStat
|
.moduleStat!
|
||||||
.forward!
|
.forward!
|
||||||
.count = (count + 1).toString();
|
.count = (count + 1).toString();
|
||||||
if (btnContext.mounted) {
|
if (btnContext.mounted) {
|
||||||
@@ -507,12 +511,12 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
|||||||
),
|
),
|
||||||
label: Text(
|
label: Text(
|
||||||
_dynamicDetailController.item.modules
|
_dynamicDetailController.item.modules
|
||||||
.moduleStat.forward!.count !=
|
?.moduleStat?.forward?.count !=
|
||||||
null
|
null
|
||||||
? Utils.numFormat(_dynamicDetailController
|
? Utils.numFormat(_dynamicDetailController
|
||||||
.item
|
.item
|
||||||
.modules
|
.modules!
|
||||||
.moduleStat
|
.moduleStat!
|
||||||
.forward!
|
.forward!
|
||||||
.count)
|
.count)
|
||||||
: '转发',
|
: '转发',
|
||||||
@@ -553,17 +557,24 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
_dynamicDetailController
|
_dynamicDetailController.item.modules
|
||||||
.item.modules.moduleStat.like!.status!
|
?.moduleStat?.like?.status ==
|
||||||
|
true
|
||||||
? FontAwesomeIcons.solidThumbsUp
|
? FontAwesomeIcons.solidThumbsUp
|
||||||
: FontAwesomeIcons.thumbsUp,
|
: FontAwesomeIcons.thumbsUp,
|
||||||
size: 16,
|
size: 16,
|
||||||
color: _dynamicDetailController
|
color: _dynamicDetailController.item.modules
|
||||||
.item.modules.moduleStat.like!.status!
|
?.moduleStat?.like?.status ==
|
||||||
|
true
|
||||||
? Theme.of(context).colorScheme.primary
|
? Theme.of(context).colorScheme.primary
|
||||||
: Theme.of(context).colorScheme.outline,
|
: Theme.of(context).colorScheme.outline,
|
||||||
semanticLabel: _dynamicDetailController
|
semanticLabel: _dynamicDetailController
|
||||||
.item.modules.moduleStat.like!.status!
|
.item
|
||||||
|
.modules
|
||||||
|
?.moduleStat
|
||||||
|
?.like
|
||||||
|
?.status ==
|
||||||
|
true
|
||||||
? "已赞"
|
? "已赞"
|
||||||
: "点赞",
|
: "点赞",
|
||||||
),
|
),
|
||||||
@@ -582,15 +593,24 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
|||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
_dynamicDetailController.item.modules
|
_dynamicDetailController.item.modules
|
||||||
.moduleStat.like!.count !=
|
?.moduleStat?.like?.count !=
|
||||||
null
|
null
|
||||||
? Utils.numFormat(
|
? Utils.numFormat(
|
||||||
_dynamicDetailController.item
|
_dynamicDetailController
|
||||||
.modules.moduleStat.like!.count)
|
.item
|
||||||
|
.modules!
|
||||||
|
.moduleStat!
|
||||||
|
.like!
|
||||||
|
.count)
|
||||||
: '点赞',
|
: '点赞',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: _dynamicDetailController.item
|
color: _dynamicDetailController
|
||||||
.modules.moduleStat.like!.status!
|
.item
|
||||||
|
.modules
|
||||||
|
?.moduleStat
|
||||||
|
?.like
|
||||||
|
?.status ==
|
||||||
|
true
|
||||||
? Theme.of(context)
|
? Theme.of(context)
|
||||||
.colorScheme
|
.colorScheme
|
||||||
.primary
|
.primary
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'package:PiliPlus/common/widgets/radio_widget.dart';
|
import 'package:PiliPlus/common/widgets/radio_widget.dart';
|
||||||
import 'package:PiliPlus/http/index.dart';
|
import 'package:PiliPlus/http/index.dart';
|
||||||
import 'package:PiliPlus/models/dynamics/result.dart';
|
|
||||||
import 'package:PiliPlus/utils/extension.dart';
|
import 'package:PiliPlus/utils/extension.dart';
|
||||||
import 'package:PiliPlus/utils/storage.dart';
|
import 'package:PiliPlus/utils/storage.dart';
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
@@ -98,7 +97,7 @@ class AuthorPanel extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Text(item is ItemOrigModel
|
Text(item.isForwarded == true
|
||||||
? Utils.dateFormat(item.modules.moduleAuthor.pubTs)
|
? Utils.dateFormat(item.modules.moduleAuthor.pubTs)
|
||||||
: item.modules.moduleAuthor.pubTime),
|
: item.modules.moduleAuthor.pubTime),
|
||||||
if (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':
|
case 'DYNAMIC_TYPE_ARTICLE':
|
||||||
return switch (item) {
|
return switch (item) {
|
||||||
ItemOrigModel() => articlePanel(item, context, callback, floor: floor),
|
DynamicItemModel() => item.isForwarded == true
|
||||||
DynamicItemModel() => item.modules?.moduleDynamic?.major?.blocked !=
|
? articlePanel(item, context, callback, floor: floor)
|
||||||
null
|
: item.modules?.moduleDynamic?.major?.blocked != null
|
||||||
? Padding(
|
? Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
if (item.modules?.moduleDynamic?.major?.blocked?['title'] !=
|
if (item.modules?.moduleDynamic?.major
|
||||||
null)
|
?.blocked?['title'] !=
|
||||||
Text(
|
null)
|
||||||
'${item.modules?.moduleDynamic?.major?.blocked!['title']}',
|
Text(
|
||||||
style: TextStyle(
|
'${item.modules?.moduleDynamic?.major?.blocked!['title']}',
|
||||||
color: Theme.of(context).colorScheme.secondary,
|
style: TextStyle(
|
||||||
),
|
color: Theme.of(context).colorScheme.secondary,
|
||||||
),
|
),
|
||||||
if (item.modules?.moduleDynamic?.major
|
),
|
||||||
?.blocked?['hint_message'] !=
|
if (item.modules?.moduleDynamic?.major
|
||||||
null)
|
?.blocked?['hint_message'] !=
|
||||||
Text(
|
null)
|
||||||
'${item.modules?.moduleDynamic?.major?.blocked!['hint_message']}',
|
Text(
|
||||||
style: TextStyle(
|
'${item.modules?.moduleDynamic?.major?.blocked!['hint_message']}',
|
||||||
fontSize: 12,
|
style: TextStyle(
|
||||||
color: Theme.of(context).colorScheme.outline,
|
fontSize: 12,
|
||||||
),
|
color: Theme.of(context).colorScheme.outline,
|
||||||
)
|
),
|
||||||
],
|
)
|
||||||
),
|
],
|
||||||
)
|
),
|
||||||
: const SizedBox.shrink(),
|
)
|
||||||
|
: const SizedBox.shrink(),
|
||||||
_ => const SizedBox.shrink(),
|
_ => const SizedBox.shrink(),
|
||||||
};
|
};
|
||||||
// return Container(
|
// return Container(
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// 视频or合集
|
// 视频or合集
|
||||||
import 'package:PiliPlus/models/dynamics/result.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:PiliPlus/common/constants.dart';
|
import 'package:PiliPlus/common/constants.dart';
|
||||||
@@ -159,7 +158,7 @@ Widget videoSeasonWidget(item, context, type, {floor = 1}) {
|
|||||||
if (richNodes != null) Text.rich(richNodes),
|
if (richNodes != null) Text.rich(richNodes),
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
],
|
],
|
||||||
if (item is ItemOrigModel)
|
if (item.isForwarded == true)
|
||||||
buildCover()
|
buildCover()
|
||||||
else
|
else
|
||||||
Padding(
|
Padding(
|
||||||
|
|||||||
@@ -51,9 +51,11 @@ class Utils {
|
|||||||
feedBack();
|
feedBack();
|
||||||
String dynamicId = item.idStr!;
|
String dynamicId = item.idStr!;
|
||||||
// 1 已点赞 2 不喜欢 0 未操作
|
// 1 已点赞 2 不喜欢 0 未操作
|
||||||
|
item.modules?.moduleStat ??= ModuleStatModel();
|
||||||
|
item.modules?.moduleStat.like ??= Like();
|
||||||
Like like = item.modules.moduleStat.like;
|
Like like = item.modules.moduleStat.like;
|
||||||
int count = like.count == '点赞' ? 0 : int.parse(like.count ?? '0');
|
int count = like.count == '点赞' ? 0 : int.parse(like.count ?? '0');
|
||||||
bool status = like.status!;
|
bool status = like.status ?? false;
|
||||||
int up = status ? 2 : 1;
|
int up = status ? 2 : 1;
|
||||||
var res = await DynamicsHttp.likeDynamic(dynamicId: dynamicId, up: up);
|
var res = await DynamicsHttp.likeDynamic(dynamicId: dynamicId, up: up);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
|
|||||||
Reference in New Issue
Block a user