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