59 lines
1.7 KiB
Dart
59 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:matrix/matrix.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:zenith/room.dart';
|
|
import 'package:zenith/zenith_client_provider.dart';
|
|
|
|
class RoomsPage extends StatefulWidget {
|
|
const RoomsPage({super.key});
|
|
|
|
@override
|
|
State<RoomsPage> createState() => _RoomsPageState();
|
|
}
|
|
|
|
class _RoomsPageState extends State<RoomsPage> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
void sendMessage() {}
|
|
|
|
void viewRoom(Room room) {
|
|
Navigator.push(
|
|
context, MaterialPageRoute(builder: (context) => RoomPage(room: room)));
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
|
title: const Text("Zenith"),
|
|
),
|
|
body: Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: Center(child: Consumer<ZenithClientProvider>(
|
|
builder: (context, provider, child) {
|
|
if (provider.loading)
|
|
return const CircularProgressIndicator();
|
|
else
|
|
return ListView.builder(
|
|
itemCount: provider.client.rooms.length,
|
|
itemBuilder: (context, index) => ListTile(
|
|
title: Text(provider.client.rooms[index]
|
|
.getLocalizedDisplayname()),
|
|
onTap: () => viewRoom(provider.client.rooms[index]),
|
|
));
|
|
},
|
|
)),
|
|
),
|
|
floatingActionButton: FloatingActionButton(
|
|
onPressed: sendMessage,
|
|
tooltip: 'Send message',
|
|
child: const Icon(Icons.send),
|
|
),
|
|
);
|
|
}
|
|
}
|