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.

75 lines
2.5 KiB

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