This commit is contained in:
Filip Krawczyk 2021-10-25 19:52:29 +02:00
parent 8703246c65
commit 725807c75b
3 changed files with 23 additions and 24 deletions

View File

@ -1,5 +1,3 @@
import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:lemmy_api_client/v3.dart'; import 'package:lemmy_api_client/v3.dart';
@ -163,16 +161,17 @@ class _CommentMoreMenuPopup extends HookWidget {
? const CircularProgressIndicator.adaptive() ? const CircularProgressIndicator.adaptive()
: const Icon(Icons.flag), : const Icon(Icons.flag),
title: const Text('Report'), title: const Text('Report'),
onTap: () { onTap: store.reportingState.isLoading
if (store.reportingState.isLoading) return; ? null
Navigator.of(context).pop(); : () {
loggedInAction((token) async { Navigator.of(context).pop();
final reason = await ReportDialog.show(context); loggedInAction((token) async {
if (reason != null) { final reason = await ReportDialog.show(context);
unawaited(store.report(token, reason)); if (reason != null) {
} await store.report(token, reason);
})(); }
}, })();
},
), ),
ListTile( ListTile(
leading: const Icon(Icons.info_outline), leading: const Icon(Icons.info_outline),

View File

@ -1,5 +1,3 @@
import 'dart:async';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_hooks/flutter_hooks.dart';
@ -129,16 +127,17 @@ class PostMoreMenu extends HookWidget {
? const CircularProgressIndicator.adaptive() ? const CircularProgressIndicator.adaptive()
: const Icon(Icons.flag), : const Icon(Icons.flag),
title: const Text('Report'), title: const Text('Report'),
onTap: () { onTap: store.reportingState.isLoading
if (store.reportingState.isLoading) return; ? null
Navigator.of(context).pop(); : () {
loggedInAction((token) async { Navigator.of(context).pop();
final reason = await ReportDialog.show(context); loggedInAction((token) async {
if (reason != null) { final reason = await ReportDialog.show(context);
unawaited(store.report(token, reason)); if (reason != null) {
} await store.report(token, reason);
})(); }
}, })();
},
), ),
ListTile( ListTile(
leading: const Icon(Icons.info_outline), leading: const Icon(Icons.info_outline),

View File

@ -7,6 +7,7 @@ class ReportDialog extends HookWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final controller = useListenable(useTextEditingController()); final controller = useListenable(useTextEditingController());
return AlertDialog( return AlertDialog(
title: const Text('Report'), title: const Text('Report'),
content: TextField( content: TextField(