import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:sonnat/core/extensions/context_extension.dart'; import 'package:sonnat/core/extensions/string_extension.dart'; import 'package:sonnat/core/language/translator.dart'; import 'package:sonnat/core/utils/app_constants.dart'; import 'package:sonnat/core/utils/initializer.dart'; class AddCommentWidget extends StatefulWidget { final Function(String comment) sendComment; const AddCommentWidget({super.key, required this.sendComment}); @override State createState() => _AddCommentWidgetState(); } class _AddCommentWidgetState extends State { final TextEditingController _controller = TextEditingController(); @override Widget build(BuildContext context) { return SizedBox( height: 49 * context.height / AppConstants.instance.appHeight, child: TextFormField( autofocus: false, maxLength: 300, controller: _controller, maxLines: 10, minLines: 4, style: const TextStyle( color: Color(0xff8D95AB), fontSize: 10, ), decoration: InputDecoration( fillColor: Colors.transparent, contentPadding: const EdgeInsets.symmetric( vertical: 15, horizontal: 18, ), hintText: Translator.translate('write_comment'), filled: true, counterText: '', hintStyle: const TextStyle( color: Color(0xff8D95AB), fontSize: 10, ), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(19), borderSide: const BorderSide(color: Color(0xff636E88)), ), suffixIcon: GestureDetector( onTap: () { if (_controller.text.trim().isNotEmpty) { widget.sendComment.call(_controller.text.trim()); _controller.text = ''; } }, child: Padding( padding: const EdgeInsetsDirectional.only(end: 18, bottom: 8, top: 8), child: RotatedBox( child: SvgPicture.asset('ic_send'.svgPath), quarterTurns: Initializer.instance.getTextDirection() == TextDirection.ltr ? 90 : 0, ), ), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(19), borderSide: const BorderSide(color: Color(0xff636E88)), ), ), ), ); } }