import 'package:comunic/helpers/server_config_helper.dart'; import 'package:comunic/models/report_target.dart'; import 'package:comunic/models/server_config.dart'; import 'package:comunic/ui/widgets/dialogs/cancel_dialog_button.dart'; import 'package:comunic/utils/intl_utils.dart'; import 'package:flutter/material.dart'; enum _Status { ChooseCause, GiveComment, Sending } /// Show a dialog to report some content Future showReportDialog({ required BuildContext ctx, required ReportTarget target, }) async { await showDialog( context: ctx, builder: (ctx) => _ReportDialog( target: target, )); } class _ReportDialog extends StatefulWidget { final ReportTarget target; const _ReportDialog({Key? key, required this.target}) : super(key: key); @override State<_ReportDialog> createState() => _ReportDialogState(); } class _ReportDialogState extends State<_ReportDialog> { var _cause = srvConfig!.reportPolicy!.causes.length - 1; var _status = _Status.ChooseCause; List get _causes => srvConfig!.reportPolicy!.causes; @override Widget build(BuildContext context) { return AlertDialog( title: Text(tr("Report abuse")!), content: Container(width: 100, height: 200, child: _buildContent()), actions: _status == _Status.Sending ? [] : [ CancelDialogButton(), MaterialButton( onPressed: null, child: Text( (_status == _Status.ChooseCause ? tr("Next")! : tr("Send")!) .toUpperCase()), ) ], ); } Widget _buildContent() { if (_status == _Status.Sending) return Center(child: CircularProgressIndicator()); if (_status == _Status.ChooseCause) return Column( children: [ Text(tr("Please choose the reason of your report (you can scroll to access all reasons):")!), Expanded( child: ListView.builder( itemBuilder: (c, i) => RadioListTile( dense: false, title: Text(_causes[i].localeLabel), value: i, groupValue: _cause, onChanged: (_i) => setState(() => _cause = i)), itemCount: _causes.length, ), ), ], ); throw Exception("todo"); } }