mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-05-14 12:12:27 -04:00
checkpoint
This commit is contained in:
parent
ff14969ffa
commit
a6ba08255b
34 changed files with 1301 additions and 706 deletions
|
@ -1,146 +1,3 @@
|
|||
import 'package:awesome_extensions/awesome_extensions.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 '../../../account_manager/account_manager.dart';
|
||||
import '../../../chat/chat.dart';
|
||||
import '../../../chat_list/chat_list.dart';
|
||||
import '../../../contact_invitation/contact_invitation.dart';
|
||||
import '../../../contacts/contacts.dart';
|
||||
import '../../../theme/theme.dart';
|
||||
import '../../../tools/tools.dart';
|
||||
import 'main_pager/main_pager.dart';
|
||||
|
||||
class HomeAccountReady extends StatefulWidget {
|
||||
const HomeAccountReady({super.key});
|
||||
|
||||
@override
|
||||
HomeAccountReadyState createState() => HomeAccountReadyState();
|
||||
}
|
||||
|
||||
class HomeAccountReadyState extends State<HomeAccountReady>
|
||||
with TickerProviderStateMixin {
|
||||
//
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
Widget buildUnlockAccount(
|
||||
BuildContext context,
|
||||
IList<LocalAccount> localAccounts,
|
||||
// ignore: prefer_expression_function_bodies
|
||||
) {
|
||||
return const Center(child: Text('unlock account'));
|
||||
}
|
||||
|
||||
Widget buildUserPanel() => Builder(builder: (context) {
|
||||
final account = context.watch<AccountRecordCubit>().state;
|
||||
final theme = Theme.of(context);
|
||||
final scale = theme.extension<ScaleScheme>()!;
|
||||
|
||||
return Column(children: <Widget>[
|
||||
Row(children: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.settings),
|
||||
color: scale.secondaryScale.text,
|
||||
constraints: const BoxConstraints.expand(height: 64, width: 64),
|
||||
style: ButtonStyle(
|
||||
backgroundColor:
|
||||
MaterialStateProperty.all(scale.secondaryScale.border),
|
||||
shape: MaterialStateProperty.all(
|
||||
const RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.all(Radius.circular(16))))),
|
||||
tooltip: translate('app_bar.settings_tooltip'),
|
||||
onPressed: () async {
|
||||
context.go('/home/settings');
|
||||
}).paddingLTRB(0, 0, 8, 0),
|
||||
asyncValueBuilder(account,
|
||||
(_, account) => ProfileWidget(profile: account.profile))
|
||||
.expanded(),
|
||||
]).paddingAll(8),
|
||||
const MainPager().expanded()
|
||||
]);
|
||||
});
|
||||
|
||||
Widget buildPhone(BuildContext context) =>
|
||||
Material(color: Colors.transparent, child: buildUserPanel());
|
||||
|
||||
Widget buildTabletLeftPane(BuildContext context) => Builder(
|
||||
builder: (context) =>
|
||||
Material(color: Colors.transparent, child: buildUserPanel()));
|
||||
|
||||
Widget buildTabletRightPane(BuildContext context) {
|
||||
final activeChatRemoteConversationKey =
|
||||
context.watch<ActiveChatCubit>().state;
|
||||
if (activeChatRemoteConversationKey == null) {
|
||||
return const EmptyChatWidget();
|
||||
}
|
||||
return ChatComponent.builder(
|
||||
remoteConversationRecordKey: activeChatRemoteConversationKey);
|
||||
}
|
||||
|
||||
// ignore: prefer_expression_function_bodies
|
||||
Widget buildTablet(BuildContext context) {
|
||||
final w = MediaQuery.of(context).size.width;
|
||||
final theme = Theme.of(context);
|
||||
final scale = theme.extension<ScaleScheme>()!;
|
||||
|
||||
final children = [
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(minWidth: 300, maxWidth: 300),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(maxWidth: w / 2),
|
||||
child: buildTabletLeftPane(context))),
|
||||
SizedBox(
|
||||
width: 2,
|
||||
height: double.infinity,
|
||||
child: ColoredBox(color: scale.primaryScale.hoverBorder)),
|
||||
Expanded(child: buildTabletRightPane(context)),
|
||||
];
|
||||
|
||||
return Row(
|
||||
children: children,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final activeAccountInfo = context.watch<ActiveAccountInfo>();
|
||||
final accountData = context.watch<AccountRecordCubit>().state.data;
|
||||
|
||||
if (accountData == null) {
|
||||
return waitingPage();
|
||||
}
|
||||
|
||||
return MultiBlocProvider(
|
||||
providers: [
|
||||
BlocProvider(
|
||||
create: (context) => ContactInvitationListCubit(
|
||||
activeAccountInfo: activeAccountInfo,
|
||||
account: accountData.value)),
|
||||
BlocProvider(
|
||||
create: (context) => ContactListCubit(
|
||||
activeAccountInfo: activeAccountInfo,
|
||||
account: accountData.value)),
|
||||
BlocProvider(
|
||||
create: (context) => ChatListCubit(
|
||||
activeAccountInfo: activeAccountInfo,
|
||||
account: accountData.value)),
|
||||
BlocProvider(
|
||||
create: (context) => ActiveConversationsCubit(
|
||||
activeAccountInfo: activeAccountInfo)),
|
||||
BlocProvider(create: (context) => ActiveChatCubit(null))
|
||||
],
|
||||
child: responsiveVisibility(
|
||||
context: context,
|
||||
phone: false,
|
||||
)
|
||||
? buildTablet(context)
|
||||
: buildPhone(context));
|
||||
}
|
||||
}
|
||||
export 'home_account_ready_chat.dart';
|
||||
export 'home_account_ready_main.dart';
|
||||
export 'home_account_ready_shell.dart';
|
||||
|
|
|
@ -2,28 +2,20 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../chat/chat.dart';
|
||||
import '../../../tools/tools.dart';
|
||||
|
||||
class ChatOnlyPage extends StatefulWidget {
|
||||
const ChatOnlyPage({super.key});
|
||||
class HomeAccountReadyChat extends StatefulWidget {
|
||||
const HomeAccountReadyChat({super.key});
|
||||
|
||||
@override
|
||||
ChatOnlyPageState createState() => ChatOnlyPageState();
|
||||
HomeAccountReadyChatState createState() => HomeAccountReadyChatState();
|
||||
}
|
||||
|
||||
class ChatOnlyPageState extends State<ChatOnlyPage>
|
||||
with TickerProviderStateMixin {
|
||||
class HomeAccountReadyChatState extends State<HomeAccountReadyChat> {
|
||||
final _unfocusNode = FocusNode();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
setState(() {});
|
||||
await changeWindowSetup(
|
||||
TitleBarStyle.normal, OrientationCapability.normal);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
|
@ -0,0 +1,94 @@
|
|||
import 'package:awesome_extensions/awesome_extensions.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 '../../../account_manager/account_manager.dart';
|
||||
import '../../../chat/chat.dart';
|
||||
import '../../../theme/theme.dart';
|
||||
import '../../../tools/tools.dart';
|
||||
import 'main_pager/main_pager.dart';
|
||||
|
||||
class HomeAccountReadyMain extends StatelessWidget {
|
||||
const HomeAccountReadyMain({super.key});
|
||||
|
||||
Widget buildUserPanel() => Builder(builder: (context) {
|
||||
final account = context.watch<AccountRecordCubit>().state;
|
||||
final theme = Theme.of(context);
|
||||
final scale = theme.extension<ScaleScheme>()!;
|
||||
|
||||
return Column(children: <Widget>[
|
||||
Row(children: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.settings),
|
||||
color: scale.secondaryScale.text,
|
||||
constraints: const BoxConstraints.expand(height: 64, width: 64),
|
||||
style: ButtonStyle(
|
||||
backgroundColor:
|
||||
MaterialStateProperty.all(scale.secondaryScale.border),
|
||||
shape: MaterialStateProperty.all(
|
||||
const RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.all(Radius.circular(16))))),
|
||||
tooltip: translate('app_bar.settings_tooltip'),
|
||||
onPressed: () async {
|
||||
await GoRouterHelper(context).push('/settings');
|
||||
}).paddingLTRB(0, 0, 8, 0),
|
||||
asyncValueBuilder(account,
|
||||
(_, account) => ProfileWidget(profile: account.profile))
|
||||
.expanded(),
|
||||
]).paddingAll(8),
|
||||
const MainPager().expanded()
|
||||
]);
|
||||
});
|
||||
|
||||
Widget buildPhone(BuildContext context) =>
|
||||
Material(color: Colors.transparent, child: buildUserPanel());
|
||||
|
||||
Widget buildTabletLeftPane(BuildContext context) => Builder(
|
||||
builder: (context) =>
|
||||
Material(color: Colors.transparent, child: buildUserPanel()));
|
||||
|
||||
Widget buildTabletRightPane(BuildContext context) {
|
||||
final activeChatRemoteConversationKey =
|
||||
context.watch<ActiveChatCubit>().state;
|
||||
if (activeChatRemoteConversationKey == null) {
|
||||
return const EmptyChatWidget();
|
||||
}
|
||||
return ChatComponent.builder(
|
||||
remoteConversationRecordKey: activeChatRemoteConversationKey);
|
||||
}
|
||||
|
||||
// ignore: prefer_expression_function_bodies
|
||||
Widget buildTablet(BuildContext context) {
|
||||
final w = MediaQuery.of(context).size.width;
|
||||
final theme = Theme.of(context);
|
||||
final scale = theme.extension<ScaleScheme>()!;
|
||||
|
||||
final children = [
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(minWidth: 300, maxWidth: 300),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(maxWidth: w / 2),
|
||||
child: buildTabletLeftPane(context))),
|
||||
SizedBox(
|
||||
width: 2,
|
||||
height: double.infinity,
|
||||
child: ColoredBox(color: scale.primaryScale.hoverBorder)),
|
||||
Expanded(child: buildTabletRightPane(context)),
|
||||
];
|
||||
|
||||
return Row(
|
||||
children: children,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => responsiveVisibility(
|
||||
context: context,
|
||||
phone: false,
|
||||
)
|
||||
? buildTablet(context)
|
||||
: buildPhone(context);
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../account_manager/account_manager.dart';
|
||||
import '../../../chat/chat.dart';
|
||||
import '../../../chat_list/chat_list.dart';
|
||||
import '../../../contact_invitation/contact_invitation.dart';
|
||||
import '../../../contacts/contacts.dart';
|
||||
import '../../../tools/tools.dart';
|
||||
|
||||
class HomeAccountReadyShell extends StatefulWidget {
|
||||
const HomeAccountReadyShell({required this.child, super.key});
|
||||
|
||||
@override
|
||||
HomeAccountReadyShellState createState() => HomeAccountReadyShellState();
|
||||
|
||||
final Widget child;
|
||||
}
|
||||
|
||||
class HomeAccountReadyShellState extends State<HomeAccountReadyShell>
|
||||
with TickerProviderStateMixin {
|
||||
//
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
// xxx figure out how to do this switch
|
||||
|
||||
// Widget buildWithLogin(BuildContext context) {
|
||||
// final activeUserLogin = context.watch<ActiveUserLoginCubit>().state;
|
||||
|
||||
// if (activeUserLogin == null) {
|
||||
// // If no logged in user is active, show the loading panel
|
||||
// return const HomeNoActive();
|
||||
// }
|
||||
|
||||
// final accountInfo = AccountRepository.instance
|
||||
// .getAccountInfo(accountMasterRecordKey: activeUserLogin)!;
|
||||
|
||||
// switch (accountInfo.status) {
|
||||
// case AccountInfoStatus.noAccount:
|
||||
// return const HomeAccountMissing();
|
||||
// case AccountInfoStatus.accountInvalid:
|
||||
// return const HomeAccountInvalid();
|
||||
// case AccountInfoStatus.accountLocked:
|
||||
// return const HomeAccountLocked();
|
||||
// case AccountInfoStatus.accountReady:
|
||||
// return Provider<ActiveAccountInfo>.value(
|
||||
// value: accountInfo.activeAccountInfo!,
|
||||
// child: BlocProvider(
|
||||
// create: (context) => AccountRecordCubit(
|
||||
// record: accountInfo.activeAccountInfo!.accountRecord),
|
||||
// child: const HomeAccountReady()));
|
||||
// }
|
||||
// }
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// These must be valid already before making this widget,
|
||||
// per the ShellRoute above it
|
||||
final activeUserLogin = context.read<ActiveUserLoginCubit>().state!;
|
||||
final accountInfo = AccountRepository.instance
|
||||
.getAccountInfo(accountMasterRecordKey: activeUserLogin)!;
|
||||
final activeAccountInfo = accountInfo.activeAccountInfo!;
|
||||
|
||||
return Provider<ActiveAccountInfo>.value(
|
||||
value: activeAccountInfo,
|
||||
child: BlocProvider(
|
||||
create: (context) => AccountRecordCubit(
|
||||
record: accountInfo.activeAccountInfo!.accountRecord),
|
||||
child: Builder(builder: (context) {
|
||||
final account =
|
||||
context.watch<AccountRecordCubit>().state.data?.value;
|
||||
if (account == null) {
|
||||
return waitingPage();
|
||||
}
|
||||
return MultiBlocProvider(providers: [
|
||||
BlocProvider(
|
||||
create: (context) => ContactInvitationListCubit(
|
||||
activeAccountInfo: activeAccountInfo,
|
||||
account: account)),
|
||||
BlocProvider(
|
||||
create: (context) => ContactListCubit(
|
||||
activeAccountInfo: activeAccountInfo,
|
||||
account: account)),
|
||||
BlocProvider(
|
||||
create: (context) => ChatListCubit(
|
||||
activeAccountInfo: activeAccountInfo,
|
||||
account: account)),
|
||||
BlocProvider(
|
||||
create: (context) => ActiveConversationsCubit(
|
||||
activeAccountInfo: activeAccountInfo)),
|
||||
BlocProvider(create: (context) => ActiveChatCubit(null))
|
||||
], child: widget.child);
|
||||
})));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue