Implement auto-inserting post number to comment text box on click

This commit is contained in:
ChronosX88 2022-04-18 02:35:03 +03:00
parent 755679c90f
commit 18d4f2dc0b
Signed by: ChronosXYZ
GPG Key ID: 085A69A82C8C511A
3 changed files with 25 additions and 21 deletions

View File

@ -1,4 +1,6 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:wind/thread_model.dart';
class MessageItemView extends StatelessWidget {
const MessageItemView({Key? key, required this.item, required this.isOpPost})
@ -48,7 +50,12 @@ class MessageItemView extends StatelessWidget {
"#${item.number}",
style: TextStyle(fontSize: 15, color: Colors.grey),
),
onTap: () => {},
onTap: () {
var model =
Provider.of<ThreadModel>(context, listen: false);
model.commentTextController.text +=
">>${item.number}\n";
},
)
],
),

View File

@ -5,12 +5,7 @@ import 'package:wind/nntp_client.dart';
class ThreadModel extends ChangeNotifier {
NNTPClient? client;
String _commentText = "";
String get commentText => _commentText;
set commentText(String text) {
_commentText = text;
notifyListeners();
}
var commentTextController = TextEditingController(text: "");
Future<MessageItem> getPost(int number) async {
var msg = await client!.getPost(number);

View File

@ -107,7 +107,9 @@ class SendMessageFormState extends State<SendMessageForm> {
children: [
Center(
child: Column(children: [
TextFormField(
Consumer<ThreadModel>(
builder: ((context, value, child) => TextFormField(
controller: value.commentTextController,
minLines: 5,
keyboardType: TextInputType.multiline,
maxLines: null,
@ -120,7 +122,7 @@ class SendMessageFormState extends State<SendMessageForm> {
}
return null;
},
),
))),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: Row(