mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-08-03 03:36:23 -04:00
xfer
This commit is contained in:
parent
6c805accb5
commit
13ddb4f22c
18 changed files with 514 additions and 73 deletions
|
@ -1,5 +1,20 @@
|
|||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_translate/flutter_translate.dart';
|
||||
|
||||
import '../../components/chat_list_widget.dart';
|
||||
import '../../components/empty_chat_list_widget.dart';
|
||||
import '../../entities/local_account.dart';
|
||||
import '../../entities/proto.dart' as proto;
|
||||
import '../../providers/account.dart';
|
||||
import '../../providers/chat.dart';
|
||||
import '../../providers/contact.dart';
|
||||
import '../../providers/contact_invite.dart';
|
||||
import '../../providers/local_accounts.dart';
|
||||
import '../../providers/logins.dart';
|
||||
import '../../tools/tools.dart';
|
||||
import '../../veilid_support/veilid_support.dart';
|
||||
|
||||
class ChatsPage extends ConsumerStatefulWidget {
|
||||
const ChatsPage({super.key});
|
||||
|
@ -22,9 +37,69 @@ class ChatsPageState extends ConsumerState<ChatsPage> {
|
|||
super.dispose();
|
||||
}
|
||||
|
||||
/// We have an active, unlocked, user login
|
||||
Widget buildChatList(
|
||||
BuildContext context,
|
||||
IList<LocalAccount> localAccounts,
|
||||
TypedKey activeUserLogin,
|
||||
proto.Account account,
|
||||
// ignore: prefer_expression_function_bodies
|
||||
) {
|
||||
final contactList = ref.watch(fetchContactListProvider).asData?.value ??
|
||||
const IListConst([]);
|
||||
final chatList =
|
||||
ref.watch(fetchChatListProvider).asData?.value ?? const IListConst([]);
|
||||
|
||||
return Column(children: <Widget>[
|
||||
if (chatList.isNotEmpty)
|
||||
ExpansionTile(
|
||||
title: Text(translate('chat_page.conversations')),
|
||||
initiallyExpanded: true,
|
||||
children: [
|
||||
ChatListWidget(contactList: contactList, chatList: chatList)
|
||||
],
|
||||
),
|
||||
if (chatList.isEmpty) const EmptyChatListWidget(),
|
||||
]);
|
||||
}
|
||||
|
||||
@override
|
||||
// ignore: prefer_expression_function_bodies
|
||||
Widget build(BuildContext context) {
|
||||
return Center(child: Text("Conversations Page"));
|
||||
final localAccountsV = ref.watch(localAccountsProvider);
|
||||
final loginsV = ref.watch(loginsProvider);
|
||||
|
||||
if (!localAccountsV.hasValue || !loginsV.hasValue) {
|
||||
return waitingPage(context);
|
||||
}
|
||||
final localAccounts = localAccountsV.requireValue;
|
||||
final logins = loginsV.requireValue;
|
||||
|
||||
final activeUserLogin = logins.activeUserLogin;
|
||||
if (activeUserLogin == null) {
|
||||
// If no logged in user is active show a placeholder
|
||||
return waitingPage(context);
|
||||
}
|
||||
final accountV = ref
|
||||
.watch(fetchAccountProvider(accountMasterRecordKey: activeUserLogin));
|
||||
if (!accountV.hasValue) {
|
||||
return waitingPage(context);
|
||||
}
|
||||
final account = accountV.requireValue;
|
||||
switch (account.status) {
|
||||
case AccountInfoStatus.noAccount:
|
||||
return waitingPage(context);
|
||||
case AccountInfoStatus.accountInvalid:
|
||||
return waitingPage(context);
|
||||
case AccountInfoStatus.accountLocked:
|
||||
return waitingPage(context);
|
||||
case AccountInfoStatus.accountReady:
|
||||
return buildChatList(
|
||||
context,
|
||||
localAccounts,
|
||||
activeUserLogin,
|
||||
account.account!,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,9 @@ class MainPager extends ConsumerStatefulWidget {
|
|||
|
||||
@override
|
||||
MainPagerState createState() => MainPagerState();
|
||||
|
||||
static MainPagerState? of(BuildContext context) =>
|
||||
context.findAncestorStateOfType<MainPagerState>();
|
||||
}
|
||||
|
||||
class MainPagerState extends ConsumerState<MainPager>
|
||||
|
@ -31,7 +34,7 @@ class MainPagerState extends ConsumerState<MainPager>
|
|||
|
||||
final _unfocusNode = FocusNode();
|
||||
|
||||
final _pageController = PageController();
|
||||
final pageController = PageController();
|
||||
var _currentPage = 0;
|
||||
|
||||
final _selectedIconList = <IconData>[Icons.person, Icons.chat];
|
||||
|
@ -62,7 +65,7 @@ class MainPagerState extends ConsumerState<MainPager>
|
|||
@override
|
||||
void dispose() {
|
||||
_unfocusNode.dispose();
|
||||
_pageController.dispose();
|
||||
pageController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
@ -231,7 +234,7 @@ class MainPagerState extends ConsumerState<MainPager>
|
|||
body: NotificationListener<ScrollNotification>(
|
||||
onNotification: onScrollNotification,
|
||||
child: PageView(
|
||||
controller: _pageController,
|
||||
controller: pageController,
|
||||
//physics: const NeverScrollableScrollPhysics(),
|
||||
children: List.generate(
|
||||
_bottomBarPages.length, (index) => _bottomBarPages[index]),
|
||||
|
@ -266,7 +269,7 @@ class MainPagerState extends ConsumerState<MainPager>
|
|||
fabLocation: StylishBarFabLocation.end,
|
||||
currentIndex: _currentPage,
|
||||
onTap: (index) async {
|
||||
await _pageController.animateToPage(index,
|
||||
await pageController.animateToPage(index,
|
||||
duration: 250.ms, curve: Curves.easeInOut);
|
||||
setState(() {
|
||||
_currentPage = index;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue