showKickUserDialog function
Future<void>
showKickUserDialog( - dynamic context,
- dynamic member
)
Implementation
Future<void> showKickUserDialog(BuildContext context, Member member) async {
final userId = member.userId().toString();
final roomId = member.roomIdStr();
await showDialog(
context: context,
builder: (BuildContext context) {
final reason = TextEditingController();
return AlertDialog(
title: Text(L10n.of(context).kickUserTitle(userId)),
content: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(L10n.of(context).kickUserDescription(userId, roomId)),
TextFormField(
controller: reason,
decoration: InputDecoration(
hintText: L10n.of(context).reasonHint,
labelText: L10n.of(context).reasonLabel,
),
),
Text(L10n.of(context).continueQuestion),
],
),
),
actionsAlignment: MainAxisAlignment.spaceEvenly,
actions: <Widget>[
OutlinedButton(
onPressed: () => Navigator.pop(context),
child: Text(L10n.of(context).no),
),
ActerPrimaryActionButton(
onPressed: () async {
EasyLoading.show(status: L10n.of(context).kickProgress);
try {
final maybeReason = reason.text.isNotEmpty ? reason.text : null;
await member.kick(maybeReason);
if (!context.mounted) {
EasyLoading.dismiss();
return;
}
EasyLoading.showToast(L10n.of(context).kickSuccess);
Navigator.pop(context);
} catch (e, s) {
_log.severe('Failed to kick user', e, s);
if (!context.mounted) {
EasyLoading.dismiss();
return;
}
EasyLoading.showError(
L10n.of(context).kickFailed(e),
duration: const Duration(seconds: 3),
);
}
},
child: Text(L10n.of(context).yes),
),
],
);
},
);
}