fix up of votes
This commit is contained in:
parent
e7876af0bc
commit
a50501d434
|
@ -440,7 +440,7 @@ class _Voting extends HookWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
final myVote = useState(post.myVote ?? 0);
|
final myVote = useState(post.myVote ?? VoteType.none);
|
||||||
final loading = useDelayedLoading(Duration(milliseconds: 500));
|
final loading = useDelayedLoading(Duration(milliseconds: 500));
|
||||||
final loggedInAction = useLoggedInAction(post.instanceUrl);
|
final loggedInAction = useLoggedInAction(post.instanceUrl);
|
||||||
|
|
||||||
|
@ -466,24 +466,28 @@ class _Voting extends HookWidget {
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.arrow_upward,
|
Icons.arrow_upward,
|
||||||
color: myVote.value == 1 ? theme.accentColor : null,
|
color: myVote.value == VoteType.up ? theme.accentColor : null,
|
||||||
),
|
),
|
||||||
onPressed: loggedInAction(
|
onPressed: loggedInAction(
|
||||||
(token) =>
|
(token) => vote(
|
||||||
vote(myVote.value == 1 ? VoteType.none : VoteType.up, token),
|
myVote.value == VoteType.up ? VoteType.none : VoteType.up,
|
||||||
|
token,
|
||||||
|
),
|
||||||
)),
|
)),
|
||||||
if (loading.loading)
|
if (loading.loading)
|
||||||
SizedBox(child: CircularProgressIndicator(), width: 20, height: 20)
|
SizedBox(child: CircularProgressIndicator(), width: 20, height: 20)
|
||||||
else
|
else
|
||||||
Text(NumberFormat.compact().format(post.score + myVote.value)),
|
Text(NumberFormat.compact().format(post.score + myVote.value.value)),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.arrow_downward,
|
Icons.arrow_downward,
|
||||||
color: myVote.value == -1 ? Colors.red : null,
|
color: myVote.value == VoteType.down ? Colors.red : null,
|
||||||
),
|
),
|
||||||
onPressed: loggedInAction(
|
onPressed: loggedInAction(
|
||||||
(token) => vote(
|
(token) => vote(
|
||||||
myVote.value == -1 ? VoteType.none : VoteType.down, token),
|
myVote.value == VoteType.down ? VoteType.none : VoteType.down,
|
||||||
|
token,
|
||||||
|
),
|
||||||
)),
|
)),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue