reorganize and rename widgets
This commit is contained in:
parent
05d25869ef
commit
d5f29dc344
1 changed files with 568 additions and 547 deletions
51
lib/widgets/rooms/knock_sheet.dart
Normal file
51
lib/widgets/rooms/knock_sheet.dart
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||
import "package:flutter_hooks/flutter_hooks.dart";
|
||||
import "package:material_ui/material_ui.dart";
|
||||
import "package:material_adaptive_sheets/material_adaptive_sheets.dart";
|
||||
import "package:nexus/helpers/extensions/join_room.dart";
|
||||
|
||||
/// Asks the moderators of a room to let the user in, with an optional reason.
|
||||
///
|
||||
/// Pops with true once the request has been sent.
|
||||
class const KnockSheet(
|
||||
final String roomId, {
|
||||
required final String name,
|
||||
final IList<String> via = const .empty(),
|
||||
super.key,
|
||||
}) extends HookWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final reason = useTextEditingController();
|
||||
|
||||
void onKnock() {
|
||||
context.knockRoom(
|
||||
.new(
|
||||
roomIdOrAlias: roomId,
|
||||
via: via,
|
||||
reason: reason.text.isEmpty ? null : reason.text,
|
||||
),
|
||||
name: name,
|
||||
);
|
||||
Navigator.of(context).pop(true);
|
||||
}
|
||||
|
||||
return SheetLayout(
|
||||
title: Text("Knock on $name"),
|
||||
actions: [
|
||||
TextButton(onPressed: Navigator.of(context).pop, child: Text("Cancel")),
|
||||
TextButton(onPressed: onKnock, child: Text("Knock")),
|
||||
],
|
||||
children: [
|
||||
Text(
|
||||
"This room requires knocking to join. Its moderators will be able to see your knock and let you in.",
|
||||
),
|
||||
TextField(
|
||||
textCapitalization: .sentences,
|
||||
controller: reason,
|
||||
decoration: .new(labelText: "Reason (optional)"),
|
||||
onEditingComplete: onKnock,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue