mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-04-25 09:39:12 -04:00
everything but chat
This commit is contained in:
parent
ba73123702
commit
2e4deb2038
@ -1,46 +1,18 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:awesome_extensions/awesome_extensions.dart';
|
import 'package:awesome_extensions/awesome_extensions.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_chat_types/flutter_chat_types.dart' as types;
|
import 'package:flutter_chat_types/flutter_chat_types.dart' as types;
|
||||||
import 'package:flutter_chat_ui/flutter_chat_ui.dart';
|
import 'package:flutter_chat_ui/flutter_chat_ui.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
||||||
|
|
||||||
import '../../old_to_refactor/proto/proto.dart' as proto;
|
class ChatComponent extends StatefulWidget {
|
||||||
import '../../old_to_refactor/providers/account.dart';
|
const ChatComponent({super.key});
|
||||||
import '../../old_to_refactor/providers/chat.dart';
|
|
||||||
import '../../contacts/models/conversation.dart';
|
|
||||||
import '../../old_to_refactor/tools/tools.dart';
|
|
||||||
import '../../old_to_refactor/veilid_init.dart';
|
|
||||||
import '../../old_to_refactor/veilid_support/veilid_support.dart';
|
|
||||||
|
|
||||||
class ChatComponent extends ConsumerStatefulWidget {
|
|
||||||
const ChatComponent(
|
|
||||||
{required this.activeAccountInfo,
|
|
||||||
required this.activeChat,
|
|
||||||
required this.activeChatContact,
|
|
||||||
super.key});
|
|
||||||
|
|
||||||
final ActiveAccountInfo activeAccountInfo;
|
|
||||||
final TypedKey activeChat;
|
|
||||||
final proto.Contact activeChatContact;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ChatComponentState createState() => ChatComponentState();
|
ChatComponentState createState() => ChatComponentState();
|
||||||
@override
|
|
||||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
|
||||||
super.debugFillProperties(properties);
|
|
||||||
properties
|
|
||||||
..add(DiagnosticsProperty<ActiveAccountInfo>(
|
|
||||||
'activeAccountInfo', activeAccountInfo))
|
|
||||||
..add(DiagnosticsProperty<TypedKey>('activeChat', activeChat))
|
|
||||||
..add(DiagnosticsProperty<proto.Contact>(
|
|
||||||
'activeChatContact', activeChatContact));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ChatComponentState extends ConsumerState<ChatComponent> {
|
class ChatComponentState extends State<ChatComponent> {
|
||||||
final _unfocusNode = FocusNode();
|
final _unfocusNode = FocusNode();
|
||||||
late final types.User _localUser;
|
late final types.User _localUser;
|
||||||
late final types.User _remoteUser;
|
late final types.User _remoteUser;
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
export 'chat_single_contact_item_widget.dart';
|
||||||
|
export 'chat_single_contact_list_widget.dart';
|
||||||
|
export 'empty_chat_list_widget.dart';
|
@ -7,6 +7,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'package:flutter_translate/flutter_translate.dart';
|
import 'package:flutter_translate/flutter_translate.dart';
|
||||||
|
|
||||||
import '../../account_manager/account_manager.dart';
|
import '../../account_manager/account_manager.dart';
|
||||||
|
import '../../contacts/contacts.dart';
|
||||||
import '../../tools/tools.dart';
|
import '../../tools/tools.dart';
|
||||||
import '../contact_invitation.dart';
|
import '../contact_invitation.dart';
|
||||||
|
|
||||||
@ -69,6 +70,7 @@ class InviteDialogState extends State<InviteDialog> {
|
|||||||
Future<void> _onAccept() async {
|
Future<void> _onAccept() async {
|
||||||
final navigator = Navigator.of(context);
|
final navigator = Navigator.of(context);
|
||||||
final activeAccountInfo = context.read<ActiveAccountInfo>();
|
final activeAccountInfo = context.read<ActiveAccountInfo>();
|
||||||
|
final contactList = context.read<ContactListCubit>();
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_isAccepting = true;
|
_isAccepting = true;
|
||||||
@ -83,9 +85,8 @@ class InviteDialogState extends State<InviteDialog> {
|
|||||||
activeAccountInfo.localAccount.identityMaster.identityPublicKey ==
|
activeAccountInfo.localAccount.identityMaster.identityPublicKey ==
|
||||||
acceptedContact.remoteIdentity.identityPublicKey;
|
acceptedContact.remoteIdentity.identityPublicKey;
|
||||||
if (!isSelf) {
|
if (!isSelf) {
|
||||||
await createContact(
|
await contactList.createContact(
|
||||||
activeAccountInfo: activeAccountInfo,
|
remoteProfile: acceptedContact.remoteProfile,
|
||||||
profile: acceptedContact.remoteProfile,
|
|
||||||
remoteIdentity: acceptedContact.remoteIdentity,
|
remoteIdentity: acceptedContact.remoteIdentity,
|
||||||
remoteConversationRecordKey:
|
remoteConversationRecordKey:
|
||||||
acceptedContact.remoteConversationRecordKey,
|
acceptedContact.remoteConversationRecordKey,
|
||||||
|
@ -5,6 +5,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'package:flutter_slidable/flutter_slidable.dart';
|
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||||
import 'package:flutter_translate/flutter_translate.dart';
|
import 'package:flutter_translate/flutter_translate.dart';
|
||||||
import '../../chat_list/chat_list.dart';
|
import '../../chat_list/chat_list.dart';
|
||||||
|
import '../../layout/layout.dart';
|
||||||
import '../../proto/proto.dart' as proto;
|
import '../../proto/proto.dart' as proto;
|
||||||
import '../../theme/theme.dart';
|
import '../../theme/theme.dart';
|
||||||
import '../contacts.dart';
|
import '../contacts.dart';
|
||||||
@ -70,23 +71,14 @@ class ContactItemWidget extends StatelessWidget {
|
|||||||
// component is not dragged.
|
// component is not dragged.
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final activeAccountInfo =
|
// Start a chat
|
||||||
await ref.read(fetchActiveAccountProvider.future);
|
final chatListCubit = context.read<ChatListCubit>();
|
||||||
if (activeAccountInfo != null) {
|
await chatListCubit.getOrCreateChatSingleContact(
|
||||||
// Start a chat
|
remoteConversationRecordKey: remoteConversationKey);
|
||||||
await getOrCreateChatSingleContact(
|
// Click over to chats
|
||||||
activeAccountInfo: activeAccountInfo,
|
if (context.mounted) {
|
||||||
remoteConversationRecordKey: remoteConversationKey);
|
await MainPager.of(context)?.pageController.animateToPage(1,
|
||||||
ref
|
duration: 250.ms, curve: Curves.easeInOut);
|
||||||
..invalidate(fetchContactListProvider)
|
|
||||||
..invalidate(fetchChatListProvider);
|
|
||||||
// Click over to chats
|
|
||||||
if (context.mounted) {
|
|
||||||
await MainPager.of(context)?.pageController.animateToPage(
|
|
||||||
1,
|
|
||||||
duration: 250.ms,
|
|
||||||
curve: Curves.easeInOut);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// // ignore: use_build_context_synchronously
|
// // ignore: use_build_context_synchronously
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
import 'package:awesome_extensions/awesome_extensions.dart';
|
import 'package:awesome_extensions/awesome_extensions.dart';
|
||||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../../proto/proto.dart' as proto;
|
import '../../../../chat_list/chat_list.dart';
|
||||||
import '../../../account_manager/account_manager.dart';
|
|
||||||
import '../../../tools/tools.dart';
|
|
||||||
|
|
||||||
class ChatsPage extends StatefulWidget {
|
class ChatsPage extends StatefulWidget {
|
||||||
const ChatsPage({super.key});
|
const ChatsPage({super.key});
|
||||||
@ -30,16 +27,8 @@ class ChatsPageState extends State<ChatsPage> {
|
|||||||
@override
|
@override
|
||||||
// ignore: prefer_expression_function_bodies
|
// ignore: prefer_expression_function_bodies
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final contactList = ref.watch(fetchContactListProvider).asData?.value ??
|
|
||||||
const IListConst([]);
|
|
||||||
final chatList =
|
|
||||||
ref.watch(fetchChatListProvider).asData?.value ?? const IListConst([]);
|
|
||||||
|
|
||||||
return Column(children: <Widget>[
|
return Column(children: <Widget>[
|
||||||
if (chatList.isNotEmpty)
|
const ChatSingleContactListWidget().expanded(),
|
||||||
ChatSingleContactListWidget(
|
|
||||||
contactList: contactList, chatList: chatList)
|
|
||||||
.expanded(),
|
|
||||||
if (chatList.isEmpty) const EmptyChatListWidget().expanded(),
|
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
export 'default_app_bar.dart';
|
export 'default_app_bar.dart';
|
||||||
export 'home/home.dart';
|
export 'home/home.dart';
|
||||||
|
export 'home/home_account_ready/main_pager/main_pager.dart';
|
||||||
export 'index.dart';
|
export 'index.dart';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user