Initial commit
Some checks failed
Main Deploy Workflow / deploy_web (push) Has been cancelled
Main Deploy Workflow / deploy_playstore_internal (push) Has been cancelled
Close stale issues and PRs / stale (push) Has been cancelled

This commit is contained in:
2026-09-11 15:59:56 -03:00
commit 0037b0b9cf
651 changed files with 199705 additions and 0 deletions

View File

@@ -0,0 +1,89 @@
// SPDX-FileCopyrightText: 2019-Present Christian Kußowski
// SPDX-FileCopyrightText: 2019-Present Contributors to FluffyChat
//
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'package:go_router/go_router.dart';
import 'package:material_ui/material_ui.dart';
import 'package:matrix/matrix.dart';
import 'package:tatchat/l10n/l10n.dart';
import 'package:tatchat/pages/chat_list/chat_list.dart';
import 'package:tatchat/pages/chat_list/chat_list_item.dart';
import 'package:tatchat/pages/chat_list/tabs/empty_tab_view.dart';
import 'package:tatchat/pages/chat_list/tabs/home_tab.dart';
import 'package:tatchat/utils/stream_extension.dart';
import 'package:tatchat/widgets/matrix.dart';
class SpacesTab extends StatelessWidget {
final ChatListController controller;
const SpacesTab(this.controller, {super.key});
@override
Widget build(BuildContext context) {
final client = Matrix.of(context).client;
final theme = Theme.of(context);
return StreamBuilder(
key: ValueKey(client.userID.toString()),
stream: client.onSync.stream
.where((s) => s.hasRoomUpdate)
.rateLimit(const Duration(seconds: 1)),
builder: (context, _) {
final spaces = client.rooms.where((room) => room.isSpace).toList();
return CustomScrollView(
slivers: [
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
children: [
Icon(
Icons.workspaces_outlined,
color: theme.colorScheme.primary,
),
const SizedBox(width: 8),
Text(
L10n.of(context).spaces,
style: theme.textTheme.titleLarge,
),
],
),
),
),
if (spaces.isEmpty)
SliverFillRemaining(
hasScrollBody: false,
child: EmptyTabView(
icon: Icons.workspaces_outlined,
title: L10n.of(context).noSpacesFound,
),
)
else
SliverList.builder(
itemCount: spaces.length + 1,
itemBuilder: (context, i) {
if (i == spaces.length) {
return ListTile(
leading: const Icon(Icons.add),
title: Text(L10n.of(context).createNewSpace),
onTap: () => context.go('/rooms/newspace'),
);
}
final space = spaces[i];
return ChatListItem(
space,
key: Key('spaces_tab_item_${space.id}'),
activeChat: controller.activeSpaceId == space.id,
onTap: () {
controller.setActiveSpace(space.id);
controller.setHomeTab(HomeTab.chats);
},
);
},
),
],
);
},
);
}
}