推荐视频评论和点赞
This commit is contained in:
parent
a78acc0f5c
commit
6cec14448c
@ -8,6 +8,9 @@ class VideoApi {
|
||||
// post
|
||||
static const String myPublicList = '/app/vlog/myPublicList'; // 我发布的视频
|
||||
static const String myLikedList = '/app/vlog/myLikedList'; // 我点赞的视频
|
||||
static const String videoCommentList = '/comment/list'; // 视频点赞列表
|
||||
static const String doVideoComment = '/app/comment/publish'; // 发布评论
|
||||
|
||||
|
||||
static const String unlike = '/app/vlog/unlike'; //取消点赞
|
||||
static const String totalLikedCounts = '/app/vlog/totalLikedCounts'; //收到点赞总数
|
||||
|
@ -1,4 +1,3 @@
|
||||
/// 底部评论框
|
||||
library;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
@ -7,11 +6,15 @@ import 'package:get/get.dart';
|
||||
class PopupReply extends StatefulWidget {
|
||||
const PopupReply({
|
||||
super.key,
|
||||
this.onChanged
|
||||
this.onChanged,
|
||||
this.onSubmitted, // 添加 onSubmitted 参数
|
||||
this.hintText = '说点什么...',
|
||||
});
|
||||
|
||||
// 输入框值改变
|
||||
final ValueChanged? onChanged;
|
||||
final ValueChanged<String>? onChanged;
|
||||
final ValueChanged<String>? onSubmitted; // 定义 onSubmitted
|
||||
final String hintText;
|
||||
|
||||
@override
|
||||
State<PopupReply> createState() => _PopupReplyState();
|
||||
@ -31,6 +34,26 @@ class _PopupReplyState extends State<PopupReply> {
|
||||
controller.dispose();
|
||||
}
|
||||
|
||||
// 处理提交事件
|
||||
void _handleSubmit() {
|
||||
final text = controller.text.trim();
|
||||
if (text.isNotEmpty) {
|
||||
// 优先调用 onSubmitted
|
||||
if (widget.onSubmitted != null) {
|
||||
widget.onSubmitted!(text);
|
||||
} else if (widget.onChanged != null) {
|
||||
// 如果没有 onSubmitted,则使用 onChanged
|
||||
widget.onChanged!(text);
|
||||
Get.back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理 onSubmitted 回调(接收 String 参数)
|
||||
void _onSubmitted(String value) {
|
||||
_handleSubmit();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@ -62,7 +85,7 @@ class _PopupReplyState extends State<PopupReply> {
|
||||
),
|
||||
child: TextField(
|
||||
decoration: InputDecoration(
|
||||
hintText: '说点什么...',
|
||||
hintText: widget.hintText,
|
||||
isDense: true,
|
||||
hoverColor: Colors.transparent,
|
||||
contentPadding: EdgeInsets.all(10.0),
|
||||
@ -74,11 +97,9 @@ class _PopupReplyState extends State<PopupReply> {
|
||||
maxLines: null,
|
||||
controller: controller,
|
||||
cursorColor: Color(0xFFFF5000),
|
||||
onEditingComplete: () {
|
||||
widget.onChanged!(controller.text);
|
||||
Get.back();
|
||||
},
|
||||
onChanged: (value) {},
|
||||
onEditingComplete: _handleSubmit, // 使用统一的提交处理
|
||||
onChanged: widget.onChanged, // 直接传递 onChanged
|
||||
onSubmitted: _onSubmitted, // 传递正确的函数签名
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -91,10 +112,7 @@ class _PopupReplyState extends State<PopupReply> {
|
||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0))
|
||||
)
|
||||
),
|
||||
onPressed: () {
|
||||
widget.onChanged!(controller.text);
|
||||
Get.back();
|
||||
},
|
||||
onPressed: _handleSubmit, // 使用统一的提交处理
|
||||
child: Text('发送',),
|
||||
),
|
||||
],
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user