mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-05-14 20:22:15 -04:00
more refactor, conversation work
This commit is contained in:
parent
20047a956f
commit
7bd426ce98
15 changed files with 204 additions and 390 deletions
|
@ -1,13 +1,11 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:awesome_extensions/awesome_extensions.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_translate/flutter_translate.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:veilid_support/veilid_support.dart';
|
||||
|
||||
import '../../../account_manager/account_manager.dart';
|
||||
import '../../../contact_invitation/contact_invitation.dart';
|
||||
|
@ -19,11 +17,13 @@ import 'main_pager/main_pager.dart';
|
|||
class HomeAccountReady extends StatefulWidget {
|
||||
const HomeAccountReady(
|
||||
{required ActiveAccountInfo activeAccountInfo,
|
||||
required Account account,
|
||||
required proto.Account account,
|
||||
super.key})
|
||||
: _accountReadyContext = accountReadyContext;
|
||||
: _activeAccountInfo = activeAccountInfo,
|
||||
_account = account;
|
||||
|
||||
final AccountReadyContext _accountReadyContext;
|
||||
final ActiveAccountInfo _activeAccountInfo;
|
||||
final proto.Account _account;
|
||||
|
||||
@override
|
||||
HomeAccountReadyState createState() => HomeAccountReadyState();
|
||||
|
@ -31,32 +31,10 @@ class HomeAccountReady extends StatefulWidget {
|
|||
|
||||
class HomeAccountReadyState extends State<HomeAccountReady>
|
||||
with TickerProviderStateMixin {
|
||||
//
|
||||
ContactInvitationRepository? _contactInvitationRepository;
|
||||
|
||||
//
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
// Async initialize repositories for the active user
|
||||
// xxx: this should not be necessary
|
||||
// xxx: but RepositoryProvider doesn't call dispose()
|
||||
Future.delayed(Duration.zero, () async {
|
||||
//
|
||||
final cir = await ContactInvitationRepository.open(
|
||||
widget.activeAccountInfo, widget._accountReadyContext.account);
|
||||
|
||||
setState(() {
|
||||
_contactInvitationRepository = cir;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
_contactInvitationRepository?.dispose();
|
||||
}
|
||||
|
||||
Widget buildUnlockAccount(
|
||||
|
@ -87,11 +65,11 @@ class HomeAccountReadyState extends State<HomeAccountReady>
|
|||
context.go('/home/settings');
|
||||
}).paddingLTRB(0, 0, 8, 0),
|
||||
ProfileWidget(
|
||||
name: widget._accountReadyContext.account.profile.name,
|
||||
pronouns: widget._accountReadyContext.account.profile.pronouns,
|
||||
name: widget._account.profile.name,
|
||||
pronouns: widget._account.profile.pronouns,
|
||||
).expanded(),
|
||||
]).paddingAll(8),
|
||||
MainPager().expanded()
|
||||
const MainPager().expanded()
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -129,18 +107,14 @@ class HomeAccountReadyState extends State<HomeAccountReady>
|
|||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (_contactInvitationRepository == null) {
|
||||
return waitingPage(context);
|
||||
}
|
||||
|
||||
return RepositoryProvider.value(
|
||||
value: _contactInvitationRepository,
|
||||
child: responsiveVisibility(
|
||||
context: context,
|
||||
phone: false,
|
||||
)
|
||||
? buildTablet(context)
|
||||
: buildPhone(context));
|
||||
}
|
||||
Widget build(BuildContext context) => BlocProvider(
|
||||
create: (context) => ContactInvitationListCubit(
|
||||
activeAccountInfo: widget._activeAccountInfo,
|
||||
account: widget._account),
|
||||
child: responsiveVisibility(
|
||||
context: context,
|
||||
phone: false,
|
||||
)
|
||||
? buildTablet(context)
|
||||
: buildPhone(context));
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@ import 'package:awesome_extensions/awesome_extensions.dart';
|
|||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_translate/flutter_translate.dart';
|
||||
import 'package:veilid_support/veilid_support.dart';
|
||||
|
||||
import '../../../../account_manager/account_manager.dart';
|
||||
import '../../../../proto/proto.dart' as proto;
|
||||
import '../../../../contact_invitation/contact_invitation.dart';
|
||||
import '../../../../theme/theme.dart';
|
||||
|
||||
class AccountPage extends StatefulWidget {
|
||||
|
@ -39,19 +39,17 @@ class AccountPageState extends State<AccountPage> {
|
|||
final textTheme = theme.textTheme;
|
||||
final scale = theme.extension<ScaleScheme>()!;
|
||||
|
||||
final records = widget.account.contactInvitationRecords;
|
||||
|
||||
final contactInvitationRecordList =
|
||||
ref.watch(fetchContactInvitationRecordsProvider).asData?.value ??
|
||||
context.watch<ContactInvitationListCubit>().state.data?.value ??
|
||||
const IListConst([]);
|
||||
final contactList = ref.watch(fetchContactListProvider).asData?.value ??
|
||||
final contactList = context.watch<ContactListCubit>().state.data?.value ??
|
||||
const IListConst([]);
|
||||
|
||||
return SizedBox(
|
||||
child: Column(children: <Widget>[
|
||||
if (contactInvitationRecordList.isNotEmpty)
|
||||
ExpansionTile(
|
||||
tilePadding: EdgeInsets.fromLTRB(8, 0, 8, 0),
|
||||
tilePadding: const EdgeInsets.fromLTRB(8, 0, 8, 0),
|
||||
backgroundColor: scale.primaryScale.border,
|
||||
collapsedBackgroundColor: scale.primaryScale.border,
|
||||
shape: RoundedRectangleBorder(
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_animate/flutter_animate.dart';
|
||||
|
@ -9,41 +7,22 @@ import 'package:flutter_translate/flutter_translate.dart';
|
|||
import 'package:preload_page_view/preload_page_view.dart';
|
||||
import 'package:stylish_bottom_bar/model/bar_items.dart';
|
||||
import 'package:stylish_bottom_bar/stylish_bottom_bar.dart';
|
||||
import 'package:veilid_support/veilid_support.dart';
|
||||
|
||||
import '../../../../proto/proto.dart' as proto;
|
||||
import '../../../../contact_invitation/contact_invitation.dart';
|
||||
import '../../../../theme/theme.dart';
|
||||
import '../../../../tools/tools.dart';
|
||||
import '../../../account_manager/account_manager.dart';
|
||||
import '../../../contact_invitation/contact_invitation.dart';
|
||||
import '../../../theme/theme.dart';
|
||||
import 'account_page.dart';
|
||||
import 'bottom_sheet_action_button.dart';
|
||||
import 'chats_page.dart';
|
||||
|
||||
class MainPager extends StatefulWidget {
|
||||
const MainPager(
|
||||
{required this.localAccounts,
|
||||
required this.activeUserLogin,
|
||||
required this.account,
|
||||
super.key});
|
||||
|
||||
final IList<LocalAccount> localAccounts;
|
||||
final TypedKey activeUserLogin;
|
||||
final proto.Account account;
|
||||
const MainPager({super.key});
|
||||
|
||||
@override
|
||||
MainPagerState createState() => MainPagerState();
|
||||
|
||||
static MainPagerState? of(BuildContext context) =>
|
||||
context.findAncestorStateOfType<MainPagerState>();
|
||||
@override
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||
super.debugFillProperties(properties);
|
||||
properties
|
||||
..add(IterableProperty<LocalAccount>('localAccounts', localAccounts))
|
||||
..add(DiagnosticsProperty<TypedKey>('activeUserLogin', activeUserLogin))
|
||||
..add(DiagnosticsProperty<proto.Account>('account', account));
|
||||
}
|
||||
}
|
||||
|
||||
class MainPagerState extends State<MainPager> with TickerProviderStateMixin {
|
||||
|
@ -187,12 +166,9 @@ class MainPagerState extends State<MainPager> with TickerProviderStateMixin {
|
|||
_currentPage = index;
|
||||
});
|
||||
},
|
||||
children: [
|
||||
AccountPage(
|
||||
localAccounts: widget.localAccounts,
|
||||
activeUserLogin: widget.activeUserLogin,
|
||||
account: widget.account),
|
||||
const ChatsPage(),
|
||||
children: const [
|
||||
AccountPage(),
|
||||
ChatsPage(),
|
||||
])),
|
||||
// appBar: AppBar(
|
||||
// toolbarHeight: 24,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue