Merge branch 'feature-dynamicForward'
This commit is contained in:
@ -14,10 +14,10 @@ import 'rich_node_panel.dart';
|
|||||||
class ActionPanel extends StatefulWidget {
|
class ActionPanel extends StatefulWidget {
|
||||||
const ActionPanel({
|
const ActionPanel({
|
||||||
super.key,
|
super.key,
|
||||||
this.item,
|
required this.item,
|
||||||
});
|
});
|
||||||
// ignore: prefer_typing_uninitialized_variables
|
// ignore: prefer_typing_uninitialized_variables
|
||||||
final item;
|
final DynamicItemModel item;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ActionPanel> createState() => _ActionPanelState();
|
State<ActionPanel> createState() => _ActionPanelState();
|
||||||
@ -28,7 +28,8 @@ class _ActionPanelState extends State<ActionPanel>
|
|||||||
final DynamicsController _dynamicsController = Get.put(DynamicsController());
|
final DynamicsController _dynamicsController = Get.put(DynamicsController());
|
||||||
late ModuleStatModel stat;
|
late ModuleStatModel stat;
|
||||||
bool isProcessing = false;
|
bool isProcessing = false;
|
||||||
RxDouble height = (310.0).obs;
|
double defaultHeight = 260;
|
||||||
|
RxDouble height = 0.0.obs;
|
||||||
RxBool isExpand = false.obs;
|
RxBool isExpand = false.obs;
|
||||||
late double statusHeight;
|
late double statusHeight;
|
||||||
TextEditingController _inputController = TextEditingController();
|
TextEditingController _inputController = TextEditingController();
|
||||||
@ -48,7 +49,7 @@ class _ActionPanelState extends State<ActionPanel>
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
stat = widget.item!.modules.moduleStat;
|
stat = widget.item.modules!.moduleStat!;
|
||||||
onInit();
|
onInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +63,7 @@ class _ActionPanelState extends State<ActionPanel>
|
|||||||
var item = widget.item!;
|
var item = widget.item!;
|
||||||
String dynamicId = item.idStr!;
|
String dynamicId = item.idStr!;
|
||||||
// 1 已点赞 2 不喜欢 0 未操作
|
// 1 已点赞 2 不喜欢 0 未操作
|
||||||
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!;
|
||||||
int up = status ? 2 : 1;
|
int up = status ? 2 : 1;
|
||||||
@ -70,15 +71,15 @@ class _ActionPanelState extends State<ActionPanel>
|
|||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
SmartDialog.showToast(!status ? '点赞成功' : '取消赞');
|
SmartDialog.showToast(!status ? '点赞成功' : '取消赞');
|
||||||
if (up == 1) {
|
if (up == 1) {
|
||||||
item.modules.moduleStat.like.count = (count + 1).toString();
|
item.modules!.moduleStat!.like!.count = (count + 1).toString();
|
||||||
item.modules.moduleStat.like.status = true;
|
item.modules!.moduleStat!.like!.status = true;
|
||||||
} else {
|
} else {
|
||||||
if (count == 1) {
|
if (count == 1) {
|
||||||
item.modules.moduleStat.like.count = '点赞';
|
item.modules!.moduleStat!.like!.count = '点赞';
|
||||||
} else {
|
} else {
|
||||||
item.modules.moduleStat.like.count = (count - 1).toString();
|
item.modules!.moduleStat!.like!.count = (count - 1).toString();
|
||||||
}
|
}
|
||||||
item.modules.moduleStat.like.status = false;
|
item.modules!.moduleStat!.like!.status = false;
|
||||||
}
|
}
|
||||||
setState(() {});
|
setState(() {});
|
||||||
} else {
|
} else {
|
||||||
@ -88,50 +89,134 @@ class _ActionPanelState extends State<ActionPanel>
|
|||||||
|
|
||||||
// 转发动态预览
|
// 转发动态预览
|
||||||
Widget dynamicPreview() {
|
Widget dynamicPreview() {
|
||||||
return Padding(
|
ItemModulesModel? modules = widget.item.modules;
|
||||||
padding: const EdgeInsets.fromLTRB(12, 0, 14, 12),
|
final String type = widget.item.type!;
|
||||||
child: Container(
|
String? cover = modules?.moduleAuthor?.face;
|
||||||
width: double.infinity,
|
switch (type) {
|
||||||
decoration: BoxDecoration(
|
/// 图文动态
|
||||||
color:
|
case 'DYNAMIC_TYPE_DRAW':
|
||||||
Theme.of(context).colorScheme.secondaryContainer.withOpacity(0.4),
|
cover = modules?.moduleDynamic?.major?.opus?.pics?.first.url;
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
|
/// 投稿
|
||||||
|
case 'DYNAMIC_TYPE_AV':
|
||||||
|
cover = modules?.moduleDynamic?.major?.archive?.cover;
|
||||||
|
|
||||||
|
/// 转发的动态
|
||||||
|
case 'DYNAMIC_TYPE_FORWARD':
|
||||||
|
String forwardType = widget.item.orig!.type!;
|
||||||
|
switch (forwardType) {
|
||||||
|
/// 图文动态
|
||||||
|
case 'DYNAMIC_TYPE_DRAW':
|
||||||
|
cover = modules?.moduleDynamic?.major?.opus?.pics?.first.url;
|
||||||
|
|
||||||
|
/// 投稿
|
||||||
|
case 'DYNAMIC_TYPE_AV':
|
||||||
|
cover = modules?.moduleDynamic?.major?.archive?.cover;
|
||||||
|
|
||||||
|
/// 专栏文章
|
||||||
|
case 'DYNAMIC_TYPE_ARTICLE':
|
||||||
|
cover = '';
|
||||||
|
|
||||||
|
/// 番剧
|
||||||
|
case 'DYNAMIC_TYPE_PGC':
|
||||||
|
cover = '';
|
||||||
|
|
||||||
|
/// 纯文字动态
|
||||||
|
case 'DYNAMIC_TYPE_WORD':
|
||||||
|
cover = '';
|
||||||
|
|
||||||
|
/// 直播
|
||||||
|
case 'DYNAMIC_TYPE_LIVE_RCMD':
|
||||||
|
cover = '';
|
||||||
|
|
||||||
|
/// 合集查看
|
||||||
|
case 'DYNAMIC_TYPE_UGC_SEASON':
|
||||||
|
cover = '';
|
||||||
|
|
||||||
|
/// 番剧
|
||||||
|
case 'DYNAMIC_TYPE_PGC_UNION':
|
||||||
|
cover = modules?.moduleDynamic?.major?.pgc?.cover;
|
||||||
|
|
||||||
|
default:
|
||||||
|
cover = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 专栏文章
|
||||||
|
case 'DYNAMIC_TYPE_ARTICLE':
|
||||||
|
cover = '';
|
||||||
|
|
||||||
|
/// 番剧
|
||||||
|
case 'DYNAMIC_TYPE_PGC':
|
||||||
|
cover = '';
|
||||||
|
|
||||||
|
/// 纯文字动态
|
||||||
|
case 'DYNAMIC_TYPE_WORD':
|
||||||
|
cover = '';
|
||||||
|
|
||||||
|
/// 直播
|
||||||
|
case 'DYNAMIC_TYPE_LIVE_RCMD':
|
||||||
|
cover = '';
|
||||||
|
|
||||||
|
/// 合集查看
|
||||||
|
case 'DYNAMIC_TYPE_UGC_SEASON':
|
||||||
|
cover = '';
|
||||||
|
|
||||||
|
/// 番剧查看
|
||||||
|
case 'DYNAMIC_TYPE_PGC_UNION':
|
||||||
|
cover = '';
|
||||||
|
|
||||||
|
default:
|
||||||
|
cover = '';
|
||||||
|
}
|
||||||
|
return Container(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 95,
|
||||||
|
margin: const EdgeInsets.fromLTRB(12, 0, 12, 14),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color:
|
||||||
|
Theme.of(context).colorScheme.secondaryContainer.withOpacity(0.4),
|
||||||
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
border: Border(
|
||||||
|
left: BorderSide(
|
||||||
|
width: 4,
|
||||||
|
color: Theme.of(context).colorScheme.primary.withOpacity(0.8)),
|
||||||
),
|
),
|
||||||
child: Padding(
|
),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 14),
|
child: Padding(
|
||||||
child: Column(
|
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 14),
|
||||||
mainAxisSize: MainAxisSize.min,
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'@${widget.item.modules!.moduleAuthor!.name}',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
NetworkImgLayer(
|
||||||
'@${widget.item.modules.moduleAuthor.name}',
|
src: cover ?? '',
|
||||||
style: TextStyle(
|
width: 34,
|
||||||
color: Theme.of(context).colorScheme.primary,
|
height: 34,
|
||||||
|
type: 'emote',
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Expanded(
|
||||||
|
child: Text.rich(
|
||||||
|
style: const TextStyle(height: 0),
|
||||||
|
richNode(widget.item, context),
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 6),
|
// Text(data)
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
NetworkImgLayer(
|
|
||||||
src: widget.item.modules.moduleAuthor.face,
|
|
||||||
width: 34,
|
|
||||||
height: 34,
|
|
||||||
type: 'emote',
|
|
||||||
),
|
|
||||||
const SizedBox(width: 10),
|
|
||||||
Expanded(
|
|
||||||
child: Text.rich(
|
|
||||||
style: const TextStyle(height: 0),
|
|
||||||
richNode(widget.item, context),
|
|
||||||
maxLines: 2,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// Text(data)
|
|
||||||
],
|
|
||||||
)
|
|
||||||
],
|
],
|
||||||
)),
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -149,56 +234,54 @@ class _ActionPanelState extends State<ActionPanel>
|
|||||||
duration: Durations.medium1,
|
duration: Durations.medium1,
|
||||||
onEnd: () async {
|
onEnd: () async {
|
||||||
if (isExpand.value) {
|
if (isExpand.value) {
|
||||||
await Future.delayed(const Duration(milliseconds: 120));
|
await Future.delayed(const Duration(milliseconds: 80));
|
||||||
myFocusNode.requestFocus();
|
myFocusNode.requestFocus();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
height: height.value,
|
height: height.value + MediaQuery.of(context).padding.bottom,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
children: [
|
||||||
AnimatedContainer(
|
AnimatedContainer(
|
||||||
duration: Durations.medium1,
|
duration: Durations.medium1,
|
||||||
height: isExpand.value ? statusHeight : 0,
|
height: isExpand.value ? statusHeight : 0,
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(16, 10, 12, 0),
|
padding: EdgeInsets.fromLTRB(
|
||||||
|
isExpand.value ? 10 : 16,
|
||||||
|
10,
|
||||||
|
isExpand.value ? 14 : 12,
|
||||||
|
0,
|
||||||
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
AnimatedSwitcher(
|
if (isExpand.value) ...[
|
||||||
duration: Durations.medium1,
|
IconButton(
|
||||||
transitionBuilder:
|
onPressed: () => togglePanelState(false),
|
||||||
(Widget child, Animation<double> animation) {
|
icon: const Icon(Icons.close),
|
||||||
return ScaleTransition(
|
),
|
||||||
scale: animation, child: child);
|
Text(
|
||||||
},
|
'转发动态',
|
||||||
child: isExpand.value
|
style: Theme.of(context)
|
||||||
? IconButton(
|
.textTheme
|
||||||
onPressed: () => togglePanelState(false),
|
.titleMedium!
|
||||||
icon: const Icon(Icons.close))
|
.copyWith(fontWeight: FontWeight.bold),
|
||||||
: const Text(
|
)
|
||||||
'转发动态',
|
] else ...[
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
const Text(
|
||||||
),
|
'转发动态',
|
||||||
),
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
AnimatedSwitcher(
|
)
|
||||||
duration: Durations.medium1,
|
],
|
||||||
transitionBuilder:
|
isExpand.value
|
||||||
(Widget child, Animation<double> animation) {
|
? FilledButton(
|
||||||
return ScaleTransition(
|
onPressed: () => dynamicForward('forward'),
|
||||||
scale: animation, child: child);
|
child: const Text('转发'),
|
||||||
},
|
)
|
||||||
child: isExpand.value
|
: TextButton(
|
||||||
? FilledButton(
|
onPressed: () {},
|
||||||
onPressed: () => dynamicForward('forward'),
|
child: const Text('立即转发'),
|
||||||
child: const Text('转发'),
|
)
|
||||||
)
|
|
||||||
: TextButton(
|
|
||||||
onPressed: () {},
|
|
||||||
child: const Text('立即转发'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -209,7 +292,7 @@ class _ActionPanelState extends State<ActionPanel>
|
|||||||
child: Container(
|
child: Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
padding: const EdgeInsets.fromLTRB(16, 0, 10, 15),
|
padding: const EdgeInsets.fromLTRB(16, 0, 10, 14),
|
||||||
child: Text(
|
child: Text(
|
||||||
'说点什么吧',
|
'说点什么吧',
|
||||||
textAlign: TextAlign.start,
|
textAlign: TextAlign.start,
|
||||||
@ -251,9 +334,6 @@ class _ActionPanelState extends State<ActionPanel>
|
|||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
|
||||||
height: MediaQuery.of(context).padding.bottom + 20,
|
|
||||||
)
|
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -266,7 +346,7 @@ class _ActionPanelState extends State<ActionPanel>
|
|||||||
togglePanelState(status) {
|
togglePanelState(status) {
|
||||||
if (!status) {
|
if (!status) {
|
||||||
Get.back();
|
Get.back();
|
||||||
height.value = 310;
|
height.value = defaultHeight;
|
||||||
_inputText = '';
|
_inputText = '';
|
||||||
_inputController.clear();
|
_inputController.clear();
|
||||||
} else {
|
} else {
|
||||||
@ -298,6 +378,8 @@ class _ActionPanelState extends State<ActionPanel>
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var color = Theme.of(context).colorScheme.outline;
|
var color = Theme.of(context).colorScheme.outline;
|
||||||
var primary = Theme.of(context).colorScheme.primary;
|
var primary = Theme.of(context).colorScheme.primary;
|
||||||
|
height.value = defaultHeight;
|
||||||
|
print('height.value: ${height.value}');
|
||||||
return Row(
|
return Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@ -1,15 +1,16 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:pilipala/pages/dynamics/index.dart';
|
import 'package:pilipala/pages/dynamics/index.dart';
|
||||||
|
import '../../../models/dynamics/result.dart';
|
||||||
import 'action_panel.dart';
|
import 'action_panel.dart';
|
||||||
import 'author_panel.dart';
|
import 'author_panel.dart';
|
||||||
import 'content_panel.dart';
|
import 'content_panel.dart';
|
||||||
import 'forward_panel.dart';
|
import 'forward_panel.dart';
|
||||||
|
|
||||||
class DynamicPanel extends StatelessWidget {
|
class DynamicPanel extends StatelessWidget {
|
||||||
final dynamic item;
|
final DynamicItemModel item;
|
||||||
final String? source;
|
final String? source;
|
||||||
DynamicPanel({this.item, this.source, Key? key}) : super(key: key);
|
DynamicPanel({required this.item, this.source, Key? key}) : super(key: key);
|
||||||
final DynamicsController _dynamicsController = Get.put(DynamicsController());
|
final DynamicsController _dynamicsController = Get.put(DynamicsController());
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -41,8 +42,8 @@ class DynamicPanel extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.fromLTRB(12, 12, 12, 8),
|
padding: const EdgeInsets.fromLTRB(12, 12, 12, 8),
|
||||||
child: AuthorPanel(item: item),
|
child: AuthorPanel(item: item),
|
||||||
),
|
),
|
||||||
if (item!.modules!.moduleDynamic!.desc != null ||
|
if (item.modules!.moduleDynamic!.desc != null ||
|
||||||
item!.modules!.moduleDynamic!.major != null)
|
item.modules!.moduleDynamic!.major != null)
|
||||||
Content(item: item, source: source),
|
Content(item: item, source: source),
|
||||||
forWard(item, context, _dynamicsController, source),
|
forWard(item, context, _dynamicsController, source),
|
||||||
const SizedBox(height: 2),
|
const SizedBox(height: 2),
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import 'package:pilipala/pages/member_dynamics/index.dart';
|
|||||||
import 'package:pilipala/utils/utils.dart';
|
import 'package:pilipala/utils/utils.dart';
|
||||||
|
|
||||||
import '../../common/widgets/http_error.dart';
|
import '../../common/widgets/http_error.dart';
|
||||||
|
import '../../models/dynamics/result.dart';
|
||||||
import '../dynamics/widgets/dynamic_panel.dart';
|
import '../dynamics/widgets/dynamic_panel.dart';
|
||||||
|
|
||||||
class MemberDynamicsPage extends StatefulWidget {
|
class MemberDynamicsPage extends StatefulWidget {
|
||||||
@ -66,7 +67,8 @@ class _MemberDynamicsPageState extends State<MemberDynamicsPage> {
|
|||||||
if (snapshot.connectionState == ConnectionState.done) {
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
if (snapshot.data != null) {
|
if (snapshot.data != null) {
|
||||||
Map data = snapshot.data as Map;
|
Map data = snapshot.data as Map;
|
||||||
List list = _memberDynamicController.dynamicsList;
|
RxList<DynamicItemModel> list =
|
||||||
|
_memberDynamicController.dynamicsList;
|
||||||
if (data['status']) {
|
if (data['status']) {
|
||||||
return Obx(
|
return Obx(
|
||||||
() => list.isNotEmpty
|
() => list.isNotEmpty
|
||||||
|
|||||||
Reference in New Issue
Block a user