loading spaces

This commit is contained in:
Henry Hiles 2025-11-10 21:50:21 -05:00
commit 65028a1231
No known key found for this signature in database
14 changed files with 629 additions and 86 deletions

View file

@ -0,0 +1,36 @@
import "package:flutter/widgets.dart";
import "package:matrix/matrix.dart";
import "package:flutter_riverpod/flutter_riverpod.dart";
import "package:nexus/controllers/client_controller.dart";
import "package:nexus/models/space.dart";
class SpacesController extends AsyncNotifier<List<Space>> {
@override
Future<List<Space>> build() async {
final client = await ref.watch(ClientController.provider.future);
return Future.wait(
client.rooms.where((room) => room.isSpace).map((data) async {
final thumb = await data.avatar?.getThumbnailUri(
client,
width: 40,
height: 40,
);
return Space(
roomData: data,
avatar: thumb == null
? null
: Image.network(
thumb.toString(),
width: 40,
headers: {"authorization": "Bearer ${client.accessToken}"},
),
);
}),
);
}
static final provider = AsyncNotifierProvider<SpacesController, List<Space>>(
SpacesController.new,
);
}