forked from Nexus/nexus
mass migrate to adaptive sheets
This commit is contained in:
parent
ba258c2fcd
commit
9117663c48
13 changed files with 292 additions and 289 deletions
62
lib/widgets/join_sheet.dart
Normal file
62
lib/widgets/join_sheet.dart
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
import "package:material_ui/material_ui.dart";
|
||||
import "package:nexus/helpers/extensions/show_adaptive_sheet.dart";
|
||||
import "package:nexus/widgets/sheet_layout.dart";
|
||||
import "package:flutter_hooks/flutter_hooks.dart";
|
||||
import "package:hooks_riverpod/hooks_riverpod.dart";
|
||||
import "package:nexus/controllers/room_summary.dart";
|
||||
import "package:nexus/helpers/extensions/get_link_info.dart";
|
||||
import "package:nexus/widgets/room_summary_sheet.dart";
|
||||
|
||||
class const JoinSheet(final WidgetRef ref, {super.key}) extends HookWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final roomAlias = useTextEditingController();
|
||||
|
||||
Future<void> onJoin() async {
|
||||
Navigator.of(context).pop();
|
||||
|
||||
final linkInfo = roomAlias.text.linkInfo;
|
||||
final via = linkInfo?.via ?? const .empty();
|
||||
final roomIdOrAlias = linkInfo?.identifier ?? roomAlias.text;
|
||||
|
||||
context.showAdaptiveSheet(
|
||||
(context) => Consumer(
|
||||
builder: (context, ref, _) => switch (ref.watch(
|
||||
RoomSummaryController.provider(
|
||||
.new(roomIdOrAlias: roomIdOrAlias, via: via),
|
||||
),
|
||||
)) {
|
||||
AsyncData(:final value) => RoomSummarySheet(value, via: via),
|
||||
AsyncError _ || AsyncLoading _ => RoomSummarySheet(
|
||||
.new(roomId: roomIdOrAlias),
|
||||
via: via,
|
||||
),
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return SheetLayout(
|
||||
title: Text("Join a Room"),
|
||||
actions: [
|
||||
TextButton(onPressed: Navigator.of(context).pop, child: Text("Cancel")),
|
||||
TextButton(onPressed: onJoin, child: Text("Join")),
|
||||
],
|
||||
children: [
|
||||
Column(
|
||||
mainAxisSize: .min,
|
||||
crossAxisAlignment: .start,
|
||||
children: [
|
||||
Text("Enter the room alias, Matrix URI, or Matrix.to link."),
|
||||
SizedBox(height: 12),
|
||||
TextField(
|
||||
controller: roomAlias,
|
||||
decoration: .new(hintText: "#room:server.name"),
|
||||
onEditingComplete: onJoin,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue