lemmur-app-android/lib/widgets/report_dialog.dart

40 lines
1.1 KiB
Dart
Raw Normal View History

2021-10-24 22:36:41 +02:00
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
class ReportDialog extends HookWidget {
const ReportDialog();
@override
Widget build(BuildContext context) {
final controller = useListenable(useTextEditingController());
2021-10-25 19:52:29 +02:00
2021-10-24 22:36:41 +02:00
return AlertDialog(
title: const Text('Report'),
content: TextField(
autofocus: true,
controller: controller,
decoration: const InputDecoration(
label: Text('reason'),
),
minLines: 1,
maxLines: 3,
),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: const Text('cancel'),
),
TextButton(
onPressed: controller.text.trim().isEmpty
? null
: () => Navigator.of(context).pop(controller.text.trim()),
child: const Text('report'),
),
],
);
}
static Future<String?> show(BuildContext context) async =>
showDialog(context: context, builder: (context) => const ReportDialog());
}