fixed the issue when user licks on comment same multiple taps duplicate comments creating
This commit is contained in:
parent
a6da579f07
commit
c9882879ff
@ -1,7 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_quill/flutter_quill.dart' as quill;
|
import 'package:flutter_quill/flutter_quill.dart' as quill;
|
||||||
|
import 'package:marco/helpers/widgets/my_text.dart';
|
||||||
|
|
||||||
class CommentEditorCard extends StatelessWidget {
|
class CommentEditorCard extends StatefulWidget {
|
||||||
final quill.QuillController controller;
|
final quill.QuillController controller;
|
||||||
final VoidCallback onCancel;
|
final VoidCallback onCancel;
|
||||||
final Future<void> Function(quill.QuillController controller) onSave;
|
final Future<void> Function(quill.QuillController controller) onSave;
|
||||||
@ -13,13 +14,31 @@ class CommentEditorCard extends StatelessWidget {
|
|||||||
required this.onSave,
|
required this.onSave,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CommentEditorCard> createState() => _CommentEditorCardState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CommentEditorCardState extends State<CommentEditorCard> {
|
||||||
|
bool _isSubmitting = false;
|
||||||
|
|
||||||
|
Future<void> _handleSave() async {
|
||||||
|
if (_isSubmitting) return;
|
||||||
|
setState(() => _isSubmitting = true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await widget.onSave(widget.controller);
|
||||||
|
} finally {
|
||||||
|
if (mounted) setState(() => _isSubmitting = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
quill.QuillSimpleToolbar(
|
quill.QuillSimpleToolbar(
|
||||||
controller: controller,
|
controller: widget.controller,
|
||||||
configurations: const quill.QuillSimpleToolbarConfigurations(
|
configurations: const quill.QuillSimpleToolbarConfigurations(
|
||||||
showBoldButton: true,
|
showBoldButton: true,
|
||||||
showItalicButton: true,
|
showItalicButton: true,
|
||||||
@ -48,7 +67,7 @@ class CommentEditorCard extends StatelessWidget {
|
|||||||
multiRowsDisplay: false,
|
multiRowsDisplay: false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 38),
|
const SizedBox(height: 24),
|
||||||
Container(
|
Container(
|
||||||
height: 140,
|
height: 140,
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
@ -58,7 +77,7 @@ class CommentEditorCard extends StatelessWidget {
|
|||||||
color: const Color(0xFFFDFDFD),
|
color: const Color(0xFFFDFDFD),
|
||||||
),
|
),
|
||||||
child: quill.QuillEditor.basic(
|
child: quill.QuillEditor.basic(
|
||||||
controller: controller,
|
controller: widget.controller,
|
||||||
configurations: const quill.QuillEditorConfigurations(
|
configurations: const quill.QuillEditorConfigurations(
|
||||||
autoFocus: true,
|
autoFocus: true,
|
||||||
expands: false,
|
expands: false,
|
||||||
@ -66,32 +85,50 @@ class CommentEditorCard extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 16),
|
||||||
Align(
|
|
||||||
alignment: Alignment.centerRight,
|
// 👇 Buttons same as BaseBottomSheet
|
||||||
child: Wrap(
|
Row(
|
||||||
spacing: 8,
|
children: [
|
||||||
children: [
|
Expanded(
|
||||||
OutlinedButton.icon(
|
child: ElevatedButton.icon(
|
||||||
onPressed: onCancel,
|
onPressed: _isSubmitting ? null : widget.onCancel,
|
||||||
icon: const Icon(Icons.close, size: 18),
|
icon: const Icon(Icons.close, color: Colors.white),
|
||||||
label: const Text("Cancel"),
|
label: MyText.bodyMedium(
|
||||||
style: OutlinedButton.styleFrom(
|
"Cancel",
|
||||||
foregroundColor: Colors.grey[700],
|
color: Colors.white,
|
||||||
|
fontWeight: 600,
|
||||||
|
),
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: Colors.grey,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
ElevatedButton.icon(
|
),
|
||||||
onPressed: () => onSave(controller),
|
const SizedBox(width: 12),
|
||||||
icon: const Icon(Icons.save, size: 18),
|
Expanded(
|
||||||
label: const Text("Save"),
|
child: ElevatedButton.icon(
|
||||||
|
onPressed: _isSubmitting ? null : _handleSave,
|
||||||
|
icon: const Icon(Icons.check_circle_outline, color: Colors.white),
|
||||||
|
label: MyText.bodyMedium(
|
||||||
|
_isSubmitting ? "Submitting..." : "Submit",
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: 600,
|
||||||
|
),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: Colors.indigo,
|
backgroundColor: Colors.indigo,
|
||||||
foregroundColor: Colors.white,
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
)
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user