feat: 投稿番剧评论时转发到动态
This commit is contained in:
@ -152,16 +152,28 @@ class DynamicsHttp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Future dynamicCreate({
|
static Future dynamicCreate({
|
||||||
required String dynIdStr,
|
|
||||||
required int mid,
|
required int mid,
|
||||||
|
required int scene,
|
||||||
|
int? oid,
|
||||||
|
String? dynIdStr,
|
||||||
String? rawText,
|
String? rawText,
|
||||||
}) async {
|
}) async {
|
||||||
DateTime now = DateTime.now();
|
DateTime now = DateTime.now();
|
||||||
int timestamp = now.millisecondsSinceEpoch ~/ 1000;
|
int timestamp = now.millisecondsSinceEpoch ~/ 1000;
|
||||||
Random random = Random();
|
Random random = Random();
|
||||||
int randomNumber = random.nextInt(9000) + 1000;
|
int randomNumber = random.nextInt(9000) + 1000;
|
||||||
String uploadId =
|
String uploadId = '${mid}_${timestamp}_$randomNumber';
|
||||||
mid.toString() + timestamp.toString() + randomNumber.toString();
|
|
||||||
|
Map<String, dynamic> webRepostSrc = {
|
||||||
|
'dyn_id_str': dynIdStr ?? '',
|
||||||
|
};
|
||||||
|
|
||||||
|
/// 投稿转发
|
||||||
|
if (scene == 5) {
|
||||||
|
webRepostSrc = {
|
||||||
|
'revs_id': {'dyn_type': 8, 'rid': oid}
|
||||||
|
};
|
||||||
|
}
|
||||||
var res = await Request().post(Api.dynamicCreate, queryParameters: {
|
var res = await Request().post(Api.dynamicCreate, queryParameters: {
|
||||||
'platform': 'web',
|
'platform': 'web',
|
||||||
'csrf': await Request.getCsrf(),
|
'csrf': await Request.getCsrf(),
|
||||||
@ -174,14 +186,14 @@ class DynamicsHttp {
|
|||||||
{'raw_text': rawText ?? '', 'type': 1, 'biz_id': ''}
|
{'raw_text': rawText ?? '', 'type': 1, 'biz_id': ''}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
'scene': 4,
|
'scene': scene,
|
||||||
'attach_card': null,
|
'attach_card': null,
|
||||||
'upload_id': uploadId,
|
'upload_id': uploadId,
|
||||||
'meta': {
|
'meta': {
|
||||||
'app_meta': {'from': 'create.dynamic.web', 'mobi_app': 'web'}
|
'app_meta': {'from': 'create.dynamic.web', 'mobi_app': 'web'}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'web_repost_src': {'dyn_id_str': dynIdStr}
|
'web_repost_src': webRepostSrc
|
||||||
});
|
});
|
||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
return {
|
return {
|
||||||
|
@ -361,6 +361,7 @@ class _ActionPanelState extends State<ActionPanel>
|
|||||||
dynIdStr: dynamicId,
|
dynIdStr: dynamicId,
|
||||||
mid: _dynamicsController.userInfo.mid,
|
mid: _dynamicsController.userInfo.mid,
|
||||||
rawText: _inputText,
|
rawText: _inputText,
|
||||||
|
scene: 4,
|
||||||
);
|
);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
SmartDialog.showToast(type == 'forward' ? '转发成功' : '发布成功');
|
SmartDialog.showToast(type == 'forward' ? '转发成功' : '发布成功');
|
||||||
|
@ -2,6 +2,7 @@ import 'dart:async';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:pilipala/http/dynamics.dart';
|
||||||
import 'package:pilipala/http/video.dart';
|
import 'package:pilipala/http/video.dart';
|
||||||
import 'package:pilipala/models/common/reply_type.dart';
|
import 'package:pilipala/models/common/reply_type.dart';
|
||||||
import 'package:pilipala/models/video/reply/emote.dart';
|
import 'package:pilipala/models/video/reply/emote.dart';
|
||||||
@ -40,6 +41,8 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
|
|||||||
double keyboardHeight = 0.0; // 键盘高度
|
double keyboardHeight = 0.0; // 键盘高度
|
||||||
final _debouncer = Debouncer(milliseconds: 200); // 设置延迟时间
|
final _debouncer = Debouncer(milliseconds: 200); // 设置延迟时间
|
||||||
String toolbarType = 'input';
|
String toolbarType = 'input';
|
||||||
|
RxBool isForward = false.obs;
|
||||||
|
RxBool showForward = false.obs;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -52,6 +55,10 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
|
|||||||
_autoFocus();
|
_autoFocus();
|
||||||
// 监听聚焦状态
|
// 监听聚焦状态
|
||||||
_focuslistener();
|
_focuslistener();
|
||||||
|
final String routePath = Get.currentRoute;
|
||||||
|
if (routePath.startsWith('/video')) {
|
||||||
|
showForward.value = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_autoFocus() async {
|
_autoFocus() async {
|
||||||
@ -88,6 +95,16 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
|
|||||||
Get.back(result: {
|
Get.back(result: {
|
||||||
'data': ReplyItemModel.fromJson(result['data']['reply'], ''),
|
'data': ReplyItemModel.fromJson(result['data']['reply'], ''),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/// 投稿、番剧页面
|
||||||
|
if (isForward.value) {
|
||||||
|
await DynamicsHttp.dynamicCreate(
|
||||||
|
mid: 0,
|
||||||
|
rawText: message,
|
||||||
|
oid: widget.oid!,
|
||||||
|
scene: 5,
|
||||||
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
SmartDialog.showToast(result['msg']);
|
SmartDialog.showToast(result['msg']);
|
||||||
}
|
}
|
||||||
@ -145,7 +162,6 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
|
|||||||
double _keyboardHeight = EdgeInsets.fromViewPadding(
|
double _keyboardHeight = EdgeInsets.fromViewPadding(
|
||||||
View.of(context).viewInsets, View.of(context).devicePixelRatio)
|
View.of(context).viewInsets, View.of(context).devicePixelRatio)
|
||||||
.bottom;
|
.bottom;
|
||||||
print('_keyboardHeight: $_keyboardHeight');
|
|
||||||
return Container(
|
return Container(
|
||||||
clipBehavior: Clip.hardEdge,
|
clipBehavior: Clip.hardEdge,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@ -225,9 +241,37 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
|
|||||||
toolbarType: toolbarType,
|
toolbarType: toolbarType,
|
||||||
selected: toolbarType == 'emote',
|
selected: toolbarType == 'emote',
|
||||||
),
|
),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
Obx(
|
||||||
|
() => showForward.value
|
||||||
|
? TextButton.icon(
|
||||||
|
onPressed: () {
|
||||||
|
isForward.value = !isForward.value;
|
||||||
|
},
|
||||||
|
icon: Icon(
|
||||||
|
isForward.value
|
||||||
|
? Icons.check_box
|
||||||
|
: Icons.check_box_outline_blank,
|
||||||
|
size: 22),
|
||||||
|
label: const Text('转发到动态'),
|
||||||
|
style: ButtonStyle(
|
||||||
|
foregroundColor: MaterialStateProperty.all(
|
||||||
|
isForward.value
|
||||||
|
? Theme.of(context).colorScheme.primary
|
||||||
|
: Theme.of(context).colorScheme.outline,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: const SizedBox(),
|
||||||
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
TextButton(
|
SizedBox(
|
||||||
onPressed: () => submitReplyAdd(), child: const Text('发送'))
|
height: 36,
|
||||||
|
child: FilledButton(
|
||||||
|
onPressed: () => submitReplyAdd(),
|
||||||
|
child: const Text('发送'),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user