56 lines
1.7 KiB
Dart
56 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:pyramid/features/rooms/room_list_item.dart';
|
|
import 'package:pyramid/features/rooms/rooms_provider.dart';
|
|
|
|
class RoomsPage extends ConsumerWidget {
|
|
const RoomsPage({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final roomsAsync = ref.watch(roomListProvider);
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Pyramid'),
|
|
actions: [
|
|
IconButton(
|
|
icon: const Icon(Icons.settings_outlined),
|
|
onPressed: () => context.go('/settings'),
|
|
),
|
|
],
|
|
),
|
|
body: roomsAsync.when(
|
|
loading: () => const Center(child: CircularProgressIndicator()),
|
|
error: (e, _) => Center(child: Text('Fehler: $e')),
|
|
data: (rooms) {
|
|
if (rooms.isEmpty) {
|
|
return const Center(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(Icons.forum_outlined, size: 64),
|
|
SizedBox(height: 16),
|
|
Text('Noch keine Räume'),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
return ListView.separated(
|
|
itemCount: rooms.length,
|
|
separatorBuilder: (context, i) => const Divider(height: 1, indent: 72),
|
|
itemBuilder: (context, i) {
|
|
final room = rooms[i];
|
|
return RoomListItem(
|
|
room: room,
|
|
onTap: () => context.go('/chat/${Uri.encodeComponent(room.id)}'),
|
|
);
|
|
},
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|