reorganize
This commit is contained in:
parent
b9a2e09e74
commit
220c13a245
12 changed files with 39 additions and 29 deletions
|
|
@ -1,7 +1,8 @@
|
|||
import "dart:convert";
|
||||
import "dart:io";
|
||||
import "package:flutter/foundation.dart";
|
||||
import "package:flutter_vodozemac/flutter_vodozemac.dart";
|
||||
import "package:vodozemac/vodozemac.dart" as voz;
|
||||
import "package:flutter_vodozemac/flutter_vodozemac.dart" as voz_fl;
|
||||
import "package:matrix/matrix.dart";
|
||||
import "package:flutter_riverpod/flutter_riverpod.dart";
|
||||
import "package:nexus/controllers/secure_storage_controller.dart";
|
||||
|
|
@ -14,7 +15,7 @@ class ClientController extends AsyncNotifier<Client> {
|
|||
static const sessionBackupKey = "sessionBackup";
|
||||
@override
|
||||
Future<Client> build() async {
|
||||
await init();
|
||||
if (!voz.isInitialized()) await voz_fl.init();
|
||||
final client = Client(
|
||||
"nexus",
|
||||
logLevel: kReleaseMode ? Level.warning : Level.verbose,
|
||||
|
|
@ -45,6 +46,10 @@ class ClientController extends AsyncNotifier<Client> {
|
|||
);
|
||||
}
|
||||
|
||||
ref.onDispose(
|
||||
client.onRoomState.stream.listen((_) => ref.notifyListeners()).cancel,
|
||||
);
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import "package:flutter/material.dart";
|
||||
import "package:nexus/widgets/chat/room_chat.dart";
|
||||
import "package:nexus/widgets/chat/sidebar.dart";
|
||||
import "package:nexus/widgets/chat_page/room_chat.dart";
|
||||
import "package:nexus/widgets/chat_page/sidebar.dart";
|
||||
|
||||
class ChatPage extends StatelessWidget {
|
||||
const ChatPage({super.key});
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@ import "package:nexus/controllers/current_room_controller.dart";
|
|||
import "package:nexus/controllers/room_chat_controller.dart";
|
||||
import "package:nexus/helpers/extension_helper.dart";
|
||||
import "package:nexus/helpers/launch_helper.dart";
|
||||
import "package:nexus/widgets/chat/chat_box.dart";
|
||||
import "package:nexus/widgets/chat/code_block.dart";
|
||||
import "package:nexus/widgets/chat/member_list.dart";
|
||||
import "package:nexus/widgets/chat/room_appbar.dart";
|
||||
import "package:nexus/widgets/chat/spoiler_text.dart";
|
||||
import "package:nexus/widgets/chat/top_widget.dart";
|
||||
import "package:nexus/widgets/chat_page/chat_box.dart";
|
||||
import "package:nexus/widgets/chat_page/code_block.dart";
|
||||
import "package:nexus/widgets/chat_page/member_list.dart";
|
||||
import "package:nexus/widgets/chat_page/room_appbar.dart";
|
||||
import "package:nexus/widgets/chat_page/spoiler_text.dart";
|
||||
import "package:nexus/widgets/chat_page/top_widget.dart";
|
||||
import "package:flutter_widget_from_html_core/flutter_widget_from_html_core.dart";
|
||||
|
||||
class RoomChat extends HookConsumerWidget {
|
||||
|
|
@ -40,11 +40,22 @@ class Sidebar extends HookConsumerWidget {
|
|||
destinations: spaces
|
||||
.map(
|
||||
(space) => NavigationRailDestination(
|
||||
icon: AvatarOrHash(
|
||||
space.avatar,
|
||||
fallback: space.icon,
|
||||
space.title,
|
||||
headers: space.client.headers,
|
||||
icon: Badge(
|
||||
smallSize: 8,
|
||||
backgroundColor: Theme.of(
|
||||
context,
|
||||
).colorScheme.primary,
|
||||
isLabelVisible:
|
||||
space.children.firstWhereOrNull(
|
||||
(room) => room.roomData.hasNewMessages,
|
||||
) !=
|
||||
null,
|
||||
child: AvatarOrHash(
|
||||
space.avatar,
|
||||
fallback: space.icon,
|
||||
space.title,
|
||||
headers: space.client.headers,
|
||||
),
|
||||
),
|
||||
label: Text(space.title),
|
||||
padding: EdgeInsets.only(top: 4),
|
||||
|
|
@ -73,18 +84,11 @@ class Sidebar extends HookConsumerWidget {
|
|||
return Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
appBar: AppBar(
|
||||
leading: Badge(
|
||||
isLabelVisible:
|
||||
space.children.firstWhereOrNull(
|
||||
(room) => room.roomData.isUnread,
|
||||
) !=
|
||||
null,
|
||||
child: AvatarOrHash(
|
||||
space.avatar,
|
||||
fallback: space.icon,
|
||||
space.title,
|
||||
headers: space.client.headers,
|
||||
),
|
||||
leading: AvatarOrHash(
|
||||
space.avatar,
|
||||
fallback: space.icon,
|
||||
space.title,
|
||||
headers: space.client.headers,
|
||||
),
|
||||
title: Text(
|
||||
space.title,
|
||||
|
|
@ -104,7 +108,7 @@ class Sidebar extends HookConsumerWidget {
|
|||
(room) => NavigationRailDestination(
|
||||
label: Text(room.title),
|
||||
icon: Badge(
|
||||
isLabelVisible: room.roomData.isUnread,
|
||||
isLabelVisible: room.roomData.hasNewMessages,
|
||||
child: AvatarOrHash(
|
||||
room.avatar,
|
||||
room.title,
|
||||
Loading…
Add table
Add a link
Reference in a new issue