mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-06-06 21:58:49 -04:00
checkpoint
This commit is contained in:
parent
09ae8ff6bb
commit
aa376a449d
3 changed files with 95 additions and 67 deletions
|
@ -4,7 +4,7 @@ import 'package:veilid_support/veilid_support.dart';
|
|||
class ActiveChatCubit extends Cubit<TypedKey?> {
|
||||
ActiveChatCubit(super.initialState);
|
||||
|
||||
void setActiveChat(TypedKey? activeChat) {
|
||||
emit(activeChat);
|
||||
void setActiveChat(TypedKey? activeChatRemoteConversationRecordKey) {
|
||||
emit(activeChatRemoteConversationRecordKey);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,11 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||
import 'package:flutter_chat_types/flutter_chat_types.dart' as types;
|
||||
import 'package:flutter_chat_ui/flutter_chat_ui.dart';
|
||||
|
||||
import '../../account_manager/account_manager.dart';
|
||||
import '../../contacts/contacts.dart';
|
||||
import '../../proto/proto.dart' as proto;
|
||||
import '../../theme/theme.dart';
|
||||
import '../../tools/tools.dart';
|
||||
import '../chat.dart';
|
||||
|
||||
class ChatComponent extends StatefulWidget {
|
||||
|
@ -109,7 +112,30 @@ class ChatComponentState extends State<ChatComponent> {
|
|||
final scale = theme.extension<ScaleScheme>()!;
|
||||
final textTheme = Theme.of(context).textTheme;
|
||||
final chatTheme = makeChatTheme(scale, textTheme);
|
||||
final contactName = widget.activeChatContact.editedProfile.name;
|
||||
|
||||
final activeChatCubit = context.watch<ActiveChatCubit>();
|
||||
final contactListCubit = context.watch<ContactListCubit>();
|
||||
|
||||
final activeChatContactKey = activeChatCubit.state;
|
||||
if (activeChatContactKey == null) {
|
||||
return const NoConversationWidget();
|
||||
}
|
||||
return contactListCubit.state.builder((context, contactList) {
|
||||
|
||||
// Get active chat contact profile
|
||||
final activeChatContactIdx = contactList.indexWhere(
|
||||
(c) => activeChatContactKey == c.remoteConversationRecordKey);
|
||||
late final proto.Contact activeChatContact;
|
||||
if (activeChatContactIdx == -1) {
|
||||
activeChatCubit.setActiveChat(null);
|
||||
return const NoConversationWidget();
|
||||
} else {
|
||||
activeChatContact = contactList[activeChatContactIdx];
|
||||
}
|
||||
final contactName = activeChatContact.editedProfile.name;
|
||||
|
||||
// Make a messages cubit for this conversation
|
||||
xxx
|
||||
|
||||
final protoMessages =
|
||||
ref.watch(activeConversationMessagesProvider).asData?.value;
|
||||
|
@ -149,7 +175,9 @@ class ChatComponentState extends State<ChatComponent> {
|
|||
IconButton(
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: () async {
|
||||
context.read<ActiveChatCubit>().setActiveChat(null);
|
||||
context
|
||||
.read<ActiveChatCubit>()
|
||||
.setActiveChat(null);
|
||||
}).paddingLTRB(16, 0, 16, 0)
|
||||
]),
|
||||
),
|
||||
|
@ -177,5 +205,6 @@ class ChatComponentState extends State<ChatComponent> {
|
|||
],
|
||||
),
|
||||
));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
//XXX should rename this
|
||||
class NoContactWidget extends StatelessWidget {
|
||||
const NoContactWidget({super.key});
|
||||
class NoConversationWidget extends StatelessWidget {
|
||||
const NoConversationWidget({super.key});
|
||||
|
||||
@override
|
||||
// ignore: prefer_expression_function_bodies
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue