Sonnat Project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.3 KiB

1 year ago
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_svg/flutter_svg.dart';
  3. import 'package:sonnat/core/extensions/context_extension.dart';
  4. import 'package:sonnat/core/extensions/string_extension.dart';
  5. import 'package:sonnat/core/language/translator.dart';
  6. import 'package:sonnat/core/utils/app_constants.dart';
  7. class AddCommentWidget extends StatefulWidget {
  8. final Function(String comment) sendComment;
  9. const AddCommentWidget({super.key, required this.sendComment});
  10. @override
  11. State<AddCommentWidget> createState() => _AddCommentWidgetState();
  12. }
  13. class _AddCommentWidgetState extends State<AddCommentWidget> {
  14. final TextEditingController _controller = TextEditingController();
  15. @override
  16. Widget build(BuildContext context) {
  17. return SizedBox(
  18. height: 49 * context.height / AppConstants.instance.appHeight,
  19. child: TextFormField(
  20. autofocus: false,
  21. maxLength: 300,
  22. controller: _controller,
  23. maxLines: 10,
  24. minLines: 4,
  25. style: const TextStyle(
  26. color: Color(0xff8D95AB),
  27. fontSize: 10,
  28. ),
  29. decoration: InputDecoration(
  30. fillColor: Colors.transparent,
  31. contentPadding: const EdgeInsets.symmetric(
  32. vertical: 15,
  33. horizontal: 18,
  34. ),
  35. hintText: Translator.translate('write_comment'),
  36. filled: true,
  37. counterText: '',
  38. hintStyle: const TextStyle(
  39. color: Color(0xff8D95AB),
  40. fontSize: 10,
  41. ),
  42. enabledBorder: OutlineInputBorder(
  43. borderRadius: BorderRadius.circular(19),
  44. borderSide: const BorderSide(color: Color(0xff636E88)),
  45. ),
  46. suffixIcon: GestureDetector(
  47. onTap: () {
  48. if (_controller.text.trim().isNotEmpty) {
  49. widget.sendComment.call(_controller.text.trim());
  50. _controller.text = '';
  51. }
  52. },
  53. child: Padding(
  54. padding: const EdgeInsetsDirectional.only(end: 18, bottom: 8, top: 8),
  55. child: SvgPicture.asset('ic_send'.svgPath),
  56. ),
  57. ),
  58. focusedBorder: OutlineInputBorder(
  59. borderRadius: BorderRadius.circular(19),
  60. borderSide: const BorderSide(color: Color(0xff636E88)),
  61. ),
  62. ),
  63. ),
  64. );
  65. }
  66. }