| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- import 'package:flutter/material.dart';
- import 'package:flutter_riverpod/flutter_riverpod.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:news_app/constant/color_res.dart';
- import 'package:news_app/extension/base.dart';
- import '../../model/new_comment_model.dart';
- import '../../widget/auth_gesture_detector.dart';
- /// @author: bo.zeng
- /// @email: cnhbwds@gmail.com
- /// @date: 2025 2025/4/17 12:22
- /// @description:
- class CommentItemWidget extends ConsumerStatefulWidget {
- //加一个回调函数
- final Function(int, String)? onTap;
- final Function(int)? onLongTap;
- final Comment comment;
- final int commentIndex;
- const CommentItemWidget(
- this.onTap,this.onLongTap,{
- super.key,
- required this.comment,
- required this.commentIndex,
- });
- @override
- ConsumerState<ConsumerStatefulWidget> createState() =>
- _CommentItemWidgetState();
- }
- class _CommentItemWidgetState extends ConsumerState<CommentItemWidget> {
- @override
- Widget build(BuildContext context) {
- return Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- CircleAvatar(
- radius: 13.w,
- backgroundImage: NetworkImage(
- widget.comment.fromUser?.avatar ?? "",
- ),
- ),
- SizedBox(width: 5.w),
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- spacing: 4.h,
- children: [
- Text(
- widget.comment.fromUser?.nickname ?? "",
- style: TextStyle(
- fontWeight: FontWeight.bold,
- color: color333333,
- fontSize: 14.sp,
- ),
- ),
- Text(
- widget.comment.content ?? "",
- style: TextStyle(color: color333333, fontSize: 14.sp),
- ),
- Row(
- spacing: 10.w,
- children: [
- Text(
- widget.comment.createTime ?? "",
- style: TextStyle(color: color7788A0, fontSize: 12.sp),
- ),
- AuthGestureDetector(
- onTap: () {
- widget.onTap?.call(
- widget.commentIndex,
- widget.comment.fromUser?.nickname ?? "",
- );
- },
- child: Text(
- '回复',
- style: TextStyle(color: color333333, fontSize: 12.sp),
- ),
- ),
- SizedBox(width:5.w,),
- AuthGestureDetector(
- onTap: () {
- widget.onLongTap?.call(
- widget.commentIndex,
- );
- },
- child: Text(
- '举报',
- style: TextStyle(color: color333333, fontSize: 12.sp),
- ),
- ),
- ],
- ),
- ],
- ),
- ),
- ],
- ),
- if (widget.comment.subComment.isSafeData)
- Padding(
- padding: EdgeInsets.only(left: 30.w, top: 10.h),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children:
- widget.comment.subComment!.map((sub) {
- return Padding(
- padding: EdgeInsets.only(bottom: 8.h),
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- CircleAvatar(
- radius: 13.w,
- backgroundImage: NetworkImage(
- widget.comment.fromUser?.avatar ?? "",
- ),
- ),
- SizedBox(width: 5.w),
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- spacing: 4.h,
- children: [
- Text(
- //'${reply.name} 回复 ${reply.replyTo}:',
- sub.fromUser?.nickname ?? "",
- style: TextStyle(
- fontWeight: FontWeight.bold,
- fontSize: 14.sp,
- ),
- ),
- Text(
- sub.content ?? "",
- style: TextStyle(fontSize: 14.sp),
- ),
- Row(
- spacing: 10.w,
- children: [
- Text(
- sub.createTime ?? "",
- style: TextStyle(
- color: color7788A0,
- fontSize: 12.sp,
- ),
- ),
- /* GestureDetector(
- onTap: () {
- widget.onTap?.call(
- widget.commentIndex,
- //reply.name,
- sub.fromUser?.nickname ?? "",
- );
- },
- child: Text(
- '回复',
- style: TextStyle(
- color: color333333,
- fontSize: 12.sp,
- ),
- ),
- ),*/
- ],
- ),
- ],
- ),
- ),
- ],
- ),
- );
- }).toList(),
- ),
- ),
- ],
- );
- }
- }
|