mirror of
https://github.com/ChronosX88/wind.git
synced 2024-12-05 02:22:17 +00:00
Implement auto-inserting post number to comment text box on click
This commit is contained in:
parent
755679c90f
commit
18d4f2dc0b
@ -1,4 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:wind/thread_model.dart';
|
||||||
|
|
||||||
class MessageItemView extends StatelessWidget {
|
class MessageItemView extends StatelessWidget {
|
||||||
const MessageItemView({Key? key, required this.item, required this.isOpPost})
|
const MessageItemView({Key? key, required this.item, required this.isOpPost})
|
||||||
@ -48,7 +50,12 @@ class MessageItemView extends StatelessWidget {
|
|||||||
"#${item.number}",
|
"#${item.number}",
|
||||||
style: TextStyle(fontSize: 15, color: Colors.grey),
|
style: TextStyle(fontSize: 15, color: Colors.grey),
|
||||||
),
|
),
|
||||||
onTap: () => {},
|
onTap: () {
|
||||||
|
var model =
|
||||||
|
Provider.of<ThreadModel>(context, listen: false);
|
||||||
|
model.commentTextController.text +=
|
||||||
|
">>${item.number}\n";
|
||||||
|
},
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -5,12 +5,7 @@ import 'package:wind/nntp_client.dart';
|
|||||||
class ThreadModel extends ChangeNotifier {
|
class ThreadModel extends ChangeNotifier {
|
||||||
NNTPClient? client;
|
NNTPClient? client;
|
||||||
|
|
||||||
String _commentText = "";
|
var commentTextController = TextEditingController(text: "");
|
||||||
String get commentText => _commentText;
|
|
||||||
set commentText(String text) {
|
|
||||||
_commentText = text;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<MessageItem> getPost(int number) async {
|
Future<MessageItem> getPost(int number) async {
|
||||||
var msg = await client!.getPost(number);
|
var msg = await client!.getPost(number);
|
||||||
|
@ -107,20 +107,22 @@ class SendMessageFormState extends State<SendMessageForm> {
|
|||||||
children: [
|
children: [
|
||||||
Center(
|
Center(
|
||||||
child: Column(children: [
|
child: Column(children: [
|
||||||
TextFormField(
|
Consumer<ThreadModel>(
|
||||||
minLines: 5,
|
builder: ((context, value, child) => TextFormField(
|
||||||
keyboardType: TextInputType.multiline,
|
controller: value.commentTextController,
|
||||||
maxLines: null,
|
minLines: 5,
|
||||||
decoration: InputDecoration(
|
keyboardType: TextInputType.multiline,
|
||||||
border: OutlineInputBorder(), labelText: "Comment"),
|
maxLines: null,
|
||||||
// The validator receives the text that the user has entered.
|
decoration: InputDecoration(
|
||||||
validator: (value) {
|
border: OutlineInputBorder(), labelText: "Comment"),
|
||||||
if (value == null || value.isEmpty) {
|
// The validator receives the text that the user has entered.
|
||||||
return 'Please enter some text';
|
validator: (value) {
|
||||||
}
|
if (value == null || value.isEmpty) {
|
||||||
return null;
|
return 'Please enter some text';
|
||||||
},
|
}
|
||||||
),
|
return null;
|
||||||
|
},
|
||||||
|
))),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
|
Loading…
Reference in New Issue
Block a user