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:convert";
|
||||||
import "dart:io";
|
import "dart:io";
|
||||||
import "package:flutter/foundation.dart";
|
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:matrix/matrix.dart";
|
||||||
import "package:flutter_riverpod/flutter_riverpod.dart";
|
import "package:flutter_riverpod/flutter_riverpod.dart";
|
||||||
import "package:nexus/controllers/secure_storage_controller.dart";
|
import "package:nexus/controllers/secure_storage_controller.dart";
|
||||||
|
|
@ -14,7 +15,7 @@ class ClientController extends AsyncNotifier<Client> {
|
||||||
static const sessionBackupKey = "sessionBackup";
|
static const sessionBackupKey = "sessionBackup";
|
||||||
@override
|
@override
|
||||||
Future<Client> build() async {
|
Future<Client> build() async {
|
||||||
await init();
|
if (!voz.isInitialized()) await voz_fl.init();
|
||||||
final client = Client(
|
final client = Client(
|
||||||
"nexus",
|
"nexus",
|
||||||
logLevel: kReleaseMode ? Level.warning : Level.verbose,
|
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;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import "package:flutter/material.dart";
|
import "package:flutter/material.dart";
|
||||||
import "package:nexus/widgets/chat/room_chat.dart";
|
import "package:nexus/widgets/chat_page/room_chat.dart";
|
||||||
import "package:nexus/widgets/chat/sidebar.dart";
|
import "package:nexus/widgets/chat_page/sidebar.dart";
|
||||||
|
|
||||||
class ChatPage extends StatelessWidget {
|
class ChatPage extends StatelessWidget {
|
||||||
const ChatPage({super.key});
|
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/controllers/room_chat_controller.dart";
|
||||||
import "package:nexus/helpers/extension_helper.dart";
|
import "package:nexus/helpers/extension_helper.dart";
|
||||||
import "package:nexus/helpers/launch_helper.dart";
|
import "package:nexus/helpers/launch_helper.dart";
|
||||||
import "package:nexus/widgets/chat/chat_box.dart";
|
import "package:nexus/widgets/chat_page/chat_box.dart";
|
||||||
import "package:nexus/widgets/chat/code_block.dart";
|
import "package:nexus/widgets/chat_page/code_block.dart";
|
||||||
import "package:nexus/widgets/chat/member_list.dart";
|
import "package:nexus/widgets/chat_page/member_list.dart";
|
||||||
import "package:nexus/widgets/chat/room_appbar.dart";
|
import "package:nexus/widgets/chat_page/room_appbar.dart";
|
||||||
import "package:nexus/widgets/chat/spoiler_text.dart";
|
import "package:nexus/widgets/chat_page/spoiler_text.dart";
|
||||||
import "package:nexus/widgets/chat/top_widget.dart";
|
import "package:nexus/widgets/chat_page/top_widget.dart";
|
||||||
import "package:flutter_widget_from_html_core/flutter_widget_from_html_core.dart";
|
import "package:flutter_widget_from_html_core/flutter_widget_from_html_core.dart";
|
||||||
|
|
||||||
class RoomChat extends HookConsumerWidget {
|
class RoomChat extends HookConsumerWidget {
|
||||||
|
|
@ -40,11 +40,22 @@ class Sidebar extends HookConsumerWidget {
|
||||||
destinations: spaces
|
destinations: spaces
|
||||||
.map(
|
.map(
|
||||||
(space) => NavigationRailDestination(
|
(space) => NavigationRailDestination(
|
||||||
icon: AvatarOrHash(
|
icon: Badge(
|
||||||
space.avatar,
|
smallSize: 8,
|
||||||
fallback: space.icon,
|
backgroundColor: Theme.of(
|
||||||
space.title,
|
context,
|
||||||
headers: space.client.headers,
|
).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),
|
label: Text(space.title),
|
||||||
padding: EdgeInsets.only(top: 4),
|
padding: EdgeInsets.only(top: 4),
|
||||||
|
|
@ -73,18 +84,11 @@ class Sidebar extends HookConsumerWidget {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
leading: Badge(
|
leading: AvatarOrHash(
|
||||||
isLabelVisible:
|
space.avatar,
|
||||||
space.children.firstWhereOrNull(
|
fallback: space.icon,
|
||||||
(room) => room.roomData.isUnread,
|
space.title,
|
||||||
) !=
|
headers: space.client.headers,
|
||||||
null,
|
|
||||||
child: AvatarOrHash(
|
|
||||||
space.avatar,
|
|
||||||
fallback: space.icon,
|
|
||||||
space.title,
|
|
||||||
headers: space.client.headers,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
space.title,
|
space.title,
|
||||||
|
|
@ -104,7 +108,7 @@ class Sidebar extends HookConsumerWidget {
|
||||||
(room) => NavigationRailDestination(
|
(room) => NavigationRailDestination(
|
||||||
label: Text(room.title),
|
label: Text(room.title),
|
||||||
icon: Badge(
|
icon: Badge(
|
||||||
isLabelVisible: room.roomData.isUnread,
|
isLabelVisible: room.roomData.hasNewMessages,
|
||||||
child: AvatarOrHash(
|
child: AvatarOrHash(
|
||||||
room.avatar,
|
room.avatar,
|
||||||
room.title,
|
room.title,
|
||||||
|
|
@ -1589,7 +1589,7 @@ packages:
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "15.0.2"
|
version: "15.0.2"
|
||||||
vodozemac:
|
vodozemac:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: vodozemac
|
name: vodozemac
|
||||||
sha256: "39144e20740807731871c9248d811ed5a037b21d0aa9ffcfa630954de74139d9"
|
sha256: "39144e20740807731871c9248d811ed5a037b21d0aa9ffcfa630954de74139d9"
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ dependencies:
|
||||||
flutter_svg: ^2.2.2
|
flutter_svg: ^2.2.2
|
||||||
simple_secure_storage: ^0.3.6
|
simple_secure_storage: ^0.3.6
|
||||||
json_annotation: ^4.9.0
|
json_annotation: ^4.9.0
|
||||||
|
vodozemac: ^0.4.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
build_runner: ^2.4.11
|
build_runner: ^2.4.11
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue