build method
dynamic
build( - dynamic context,
- dynamic ref
)
Implementation
@override
Widget build(BuildContext context, WidgetRef ref) {
final senderId = news.sender().toString();
final canRedact = ref.watch(canRedactProvider(news));
final isAuthor = senderId == userId;
List<Widget> actions = [
Text(L10n.of(context).actions),
const Divider(),
];
if (canRedact.valueOrNull == true) {
actions.add(
TextButton.icon(
key: NewsUpdateKeys.newsSidebarActionRemoveBtn,
onPressed: () => openRedactContentDialog(
context,
title: L10n.of(context).removeThisPost,
eventId: news.eventId().toString(),
onSuccess: () async {
if (!await Navigator.maybePop(context)) {
if (context.mounted) {
// fallback to go to home
Navigator.pushReplacementNamed(context, Routes.main.name);
}
}
},
roomId: roomId,
isSpace: true,
removeBtnKey: NewsUpdateKeys.removeButton,
),
icon: const Icon(Atlas.trash_thin),
label: Text(L10n.of(context).remove),
),
);
} else if (!isAuthor) {
actions.add(
TextButton.icon(
key: NewsUpdateKeys.newsSidebarActionReportBtn,
onPressed: () => openReportContentDialog(
context,
title: L10n.of(context).reportThisPost,
eventId: news.eventId().toString(),
description: L10n.of(context).reportPostContent,
senderId: senderId,
roomId: roomId,
isSpace: true,
),
icon: const Icon(Atlas.exclamation_chat_thin),
label: Text(L10n.of(context).reportThis),
),
);
}
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: actions,
);
}