| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- 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/constant/size_res.dart';
- import 'package:news_app/widget/my_txt.dart';
- import '../../widget/auth_gesture_detector.dart';
- /// @author: bo.zeng
- /// @email: cnhbwds@gmail.com
- /// @date: 2025 2025/4/17 12:22
- /// @description:
- class CommentInputBarWidget extends ConsumerStatefulWidget {
- final FocusNode focusNode;
- final String id;
- final Function(String)? onSend;
- const CommentInputBarWidget(
- this.focusNode,
- this.onSend,
- this.id, {
- super.key,
- });
- @override
- ConsumerState<ConsumerStatefulWidget> createState() =>
- _CommentInputBarState();
- }
- class _CommentInputBarState extends ConsumerState<CommentInputBarWidget> {
- final TextEditingController _controller = TextEditingController();
- @override
- Widget build(BuildContext context) {
- double size = MediaQuery.of(context).padding.bottom;
- return Container(
- decoration: BoxDecoration(
- color: Colors.white,
- border: Border(top: BorderSide(color: colorE5E5E5, width: 0.5)),
- ),
- padding: EdgeInsets.only(
- top: horizontalPadding,
- bottom: size > 0 ? size : horizontalPadding,
- ),
- child: Row(
- children: [
- Expanded(
- child: Container(
- height: 40.h,
- margin: EdgeInsets.only(right: 10.w),
- child: TextField(
- decoration: InputDecoration(
- fillColor: colorF5F7FA,
- filled: true,
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(5.r),
- borderSide: BorderSide.none,
- ),
- contentPadding: EdgeInsets.symmetric(
- horizontal: 10.w,
- vertical: 20.h,
- ),
- hintText: '快来写下你的评论吧~',
- hintStyle: TextStyle(color: color7788A0, fontSize: 12.sp),
- ),
- focusNode: widget.focusNode,
- controller: _controller,
- ),
- ),
- ),
- if (widget.focusNode.hasFocus)
- AuthGestureDetector(
- onTap: () {
- widget.onSend?.call(_controller.text);
- _controller.clear();
- },
- child: Container(
- width: 50.w,
- padding: EdgeInsets.symmetric(vertical: 5.h),
- alignment: Alignment.center,
- decoration: BoxDecoration(
- color: color188FFF,
- borderRadius: BorderRadius.circular(5.r),
- ),
- child: myTxt(text: "发送", color: Colors.white, fontSize: 12.sp),
- ),
- ),
- ],
- ),
- );
- }
- }
|