🐛 Fix and optimize something

This commit is contained in:
2024-03-24 20:51:12 +08:00
parent 92354eee34
commit a303f5c30c
3 changed files with 29 additions and 16 deletions

View File

@ -74,8 +74,18 @@ class _ReactionListState extends State<ReactionList> {
);
if (res.statusCode == 201) {
widget.onReact(symbol, 1);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("Your reaction has been added onto this post."),
),
);
} else if (res.statusCode == 204) {
widget.onReact(symbol, -1);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("Your reaction has been removed from this post."),
),
);
} else {
var message = utf8.decode(res.bodyBytes);
ScaffoldMessenger.of(context).showSnackBar(
@ -105,10 +115,7 @@ class _ReactionListState extends State<ReactionList> {
),
child: Text(
'Reactions',
style: Theme
.of(context)
.textTheme
.headlineSmall,
style: Theme.of(context).textTheme.headlineSmall,
),
),
FutureBuilder(
@ -119,7 +126,7 @@ class _ReactionListState extends State<ReactionList> {
icon: const Icon(Icons.add_reaction),
label: const Text("REACT"),
onPressed:
isSubmitting ? null : () => viewReactMenu(context),
isSubmitting ? null : () => viewReactMenu(context),
);
} else {
return Container();
@ -141,17 +148,16 @@ class _ReactionListState extends State<ReactionList> {
onTap: isSubmitting
? null
: () {
doReact(
element.key,
ReactionList.emojis[element.key]!['attitude'],
);
},
doReact(
element.key,
ReactionList.emojis[element.key]!['attitude'],
);
},
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 6.0),
child: ListTile(
title: Text(
"${ReactionList.emojis[element.key]!['icon']} x${element
.value.toString()}",
"${ReactionList.emojis[element.key]!['icon']} x${element.value.toString()}",
),
subtitle: Text(
":${element.key}:",