more debugging

This commit is contained in:
Christien Rioux 2024-02-14 21:33:15 -05:00
parent 9219e1307e
commit 5cec423351
13 changed files with 424 additions and 708 deletions

View File

@ -53,9 +53,9 @@ class AccountRepository {
static AccountRepository instance = AccountRepository._(); static AccountRepository instance = AccountRepository._();
Future<void> init() async { Future<void> init() async {
await _localAccounts.load(); await _localAccounts.get();
await _userLogins.load(); await _userLogins.get();
await _activeLocalAccount.load(); await _activeLocalAccount.get();
await _openLoggedInDHTRecords(); await _openLoggedInDHTRecords();
} }

View File

@ -1,4 +1,3 @@
import 'dart:async';
import 'dart:math'; import 'dart:math';
import 'package:awesome_extensions/awesome_extensions.dart'; import 'package:awesome_extensions/awesome_extensions.dart';
@ -20,12 +19,10 @@ class InvitationGeneratorCubit extends FutureCubit<Uint8List> {
class ContactInvitationDisplayDialog extends StatefulWidget { class ContactInvitationDisplayDialog extends StatefulWidget {
const ContactInvitationDisplayDialog({ const ContactInvitationDisplayDialog({
required this.message, required this.message,
required this.generator,
super.key, super.key,
}); });
final String message; final String message;
final FutureOr<Uint8List> generator;
@override @override
ContactInvitationDisplayDialogState createState() => ContactInvitationDisplayDialogState createState() =>
@ -34,9 +31,7 @@ class ContactInvitationDisplayDialog extends StatefulWidget {
@override @override
void debugFillProperties(DiagnosticPropertiesBuilder properties) { void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties); super.debugFillProperties(properties);
properties properties.add(StringProperty('message', message));
..add(StringProperty('message', message))
..add(DiagnosticsProperty<FutureOr<Uint8List>?>('generator', generator));
} }
} }

View File

@ -102,8 +102,6 @@ class ContactInvitationItemWidget extends StatelessWidget {
contactInvitationRecord.invitation))), contactInvitationRecord.invitation))),
child: ContactInvitationDisplayDialog( child: ContactInvitationDisplayDialog(
message: contactInvitationRecord.message, message: contactInvitationRecord.message,
generator: Uint8List.fromList(
contactInvitationRecord.invitation),
))); )));
}, },
title: Text( title: Text(

View File

@ -13,7 +13,8 @@ import '../contact_invitation.dart';
class InviteDialog extends StatefulWidget { class InviteDialog extends StatefulWidget {
const InviteDialog( const InviteDialog(
{required this.onValidationCancelled, {required this.modalContext,
required this.onValidationCancelled,
required this.onValidationSuccess, required this.onValidationSuccess,
required this.onValidationFailed, required this.onValidationFailed,
required this.inviteControlIsValid, required this.inviteControlIsValid,
@ -29,6 +30,7 @@ class InviteDialog extends StatefulWidget {
InviteDialogState dialogState, InviteDialogState dialogState,
Future<void> Function({required Uint8List inviteData}) Future<void> Function({required Uint8List inviteData})
validateInviteData) buildInviteControl; validateInviteData) buildInviteControl;
final BuildContext modalContext;
@override @override
InviteDialogState createState() => InviteDialogState(); InviteDialogState createState() => InviteDialogState();
@ -50,7 +52,8 @@ class InviteDialog extends StatefulWidget {
InviteDialogState dialogState, InviteDialogState dialogState,
Future<void> Function({required Uint8List inviteData}) Future<void> Function({required Uint8List inviteData})
validateInviteData)>.has( validateInviteData)>.has(
'buildInviteControl', buildInviteControl)); 'buildInviteControl', buildInviteControl))
..add(DiagnosticsProperty<BuildContext>('modalContext', modalContext));
} }
} }
@ -69,8 +72,8 @@ 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 = widget.modalContext.read<ActiveAccountInfo>();
final contactList = context.read<ContactListCubit>(); final contactList = widget.modalContext.read<ContactListCubit>();
setState(() { setState(() {
_isAccepting = true; _isAccepting = true;
@ -133,7 +136,7 @@ class InviteDialogState extends State<InviteDialog> {
}) async { }) async {
try { try {
final contactInvitationListCubit = final contactInvitationListCubit =
context.read<ContactInvitationListCubit>(); widget.modalContext.read<ContactInvitationListCubit>();
setState(() { setState(() {
_isValidating = true; _isValidating = true;

View File

@ -8,8 +8,9 @@ import 'paste_invite_dialog.dart';
import 'scan_invite_dialog.dart'; import 'scan_invite_dialog.dart';
import 'send_invite_dialog.dart'; import 'send_invite_dialog.dart';
Widget newContactInvitationBottomSheetBuilder(BuildContext context) { Widget newContactInvitationBottomSheetBuilder(
final theme = Theme.of(context); BuildContext sheetContext, BuildContext context) {
final theme = Theme.of(sheetContext);
final textTheme = theme.textTheme; final textTheme = theme.textTheme;
final scale = theme.extension<ScaleScheme>()!; final scale = theme.extension<ScaleScheme>()!;
@ -17,7 +18,7 @@ Widget newContactInvitationBottomSheetBuilder(BuildContext context) {
focusNode: FocusNode(), focusNode: FocusNode(),
onKeyEvent: (ke) { onKeyEvent: (ke) {
if (ke.logicalKey == LogicalKeyboardKey.escape) { if (ke.logicalKey == LogicalKeyboardKey.escape) {
Navigator.pop(context); Navigator.pop(sheetContext);
} }
}, },
child: SizedBox( child: SizedBox(
@ -30,7 +31,7 @@ Widget newContactInvitationBottomSheetBuilder(BuildContext context) {
Column(children: [ Column(children: [
IconButton( IconButton(
onPressed: () async { onPressed: () async {
Navigator.pop(context); Navigator.pop(sheetContext);
await SendInviteDialog.show(context); await SendInviteDialog.show(context);
}, },
iconSize: 64, iconSize: 64,
@ -41,7 +42,7 @@ Widget newContactInvitationBottomSheetBuilder(BuildContext context) {
Column(children: [ Column(children: [
IconButton( IconButton(
onPressed: () async { onPressed: () async {
Navigator.pop(context); Navigator.pop(sheetContext);
await ScanInviteDialog.show(context); await ScanInviteDialog.show(context);
}, },
iconSize: 64, iconSize: 64,
@ -52,7 +53,7 @@ Widget newContactInvitationBottomSheetBuilder(BuildContext context) {
Column(children: [ Column(children: [
IconButton( IconButton(
onPressed: () async { onPressed: () async {
Navigator.pop(context); Navigator.pop(sheetContext);
await PasteInviteDialog.show(context); await PasteInviteDialog.show(context);
}, },
iconSize: 64, iconSize: 64,

View File

@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:typed_data'; import 'dart:typed_data';
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_translate/flutter_translate.dart'; import 'package:flutter_translate/flutter_translate.dart';
import 'package:veilid_support/veilid_support.dart'; import 'package:veilid_support/veilid_support.dart';
@ -11,7 +12,7 @@ import '../../tools/tools.dart';
import 'invite_dialog.dart'; import 'invite_dialog.dart';
class PasteInviteDialog extends StatefulWidget { class PasteInviteDialog extends StatefulWidget {
const PasteInviteDialog({super.key}); const PasteInviteDialog({required this.modalContext, super.key});
@override @override
PasteInviteDialogState createState() => PasteInviteDialogState(); PasteInviteDialogState createState() => PasteInviteDialogState();
@ -20,7 +21,16 @@ class PasteInviteDialog extends StatefulWidget {
await showStyledDialog<void>( await showStyledDialog<void>(
context: context, context: context,
title: translate('paste_invite_dialog.title'), title: translate('paste_invite_dialog.title'),
child: const PasteInviteDialog()); child: PasteInviteDialog(modalContext: context));
}
final BuildContext modalContext;
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties
.add(DiagnosticsProperty<BuildContext>('modalContext', modalContext));
} }
} }
@ -122,6 +132,7 @@ class PasteInviteDialogState extends State<PasteInviteDialog> {
// ignore: prefer_expression_function_bodies // ignore: prefer_expression_function_bodies
Widget build(BuildContext context) { Widget build(BuildContext context) {
return InviteDialog( return InviteDialog(
modalContext: widget.modalContext,
onValidationCancelled: onValidationCancelled, onValidationCancelled: onValidationCancelled,
onValidationSuccess: onValidationSuccess, onValidationSuccess: onValidationSuccess,
onValidationFailed: onValidationFailed, onValidationFailed: onValidationFailed,

View File

@ -104,7 +104,7 @@ class ScannerOverlay extends CustomPainter {
} }
class ScanInviteDialog extends StatefulWidget { class ScanInviteDialog extends StatefulWidget {
const ScanInviteDialog({super.key}); const ScanInviteDialog({required this.modalContext, super.key});
@override @override
ScanInviteDialogState createState() => ScanInviteDialogState(); ScanInviteDialogState createState() => ScanInviteDialogState();
@ -113,7 +113,16 @@ class ScanInviteDialog extends StatefulWidget {
await showStyledDialog<void>( await showStyledDialog<void>(
context: context, context: context,
title: translate('scan_invite_dialog.title'), title: translate('scan_invite_dialog.title'),
child: const ScanInviteDialog()); child: ScanInviteDialog(modalContext: context));
}
final BuildContext modalContext;
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties
.add(DiagnosticsProperty<BuildContext>('modalContext', modalContext));
} }
} }
@ -380,6 +389,7 @@ class ScanInviteDialogState extends State<ScanInviteDialog> {
// ignore: prefer_expression_function_bodies // ignore: prefer_expression_function_bodies
Widget build(BuildContext context) { Widget build(BuildContext context) {
return InviteDialog( return InviteDialog(
modalContext: widget.modalContext,
onValidationCancelled: onValidationCancelled, onValidationCancelled: onValidationCancelled,
onValidationSuccess: onValidationSuccess, onValidationSuccess: onValidationSuccess,
onValidationFailed: onValidationFailed, onValidationFailed: onValidationFailed,

View File

@ -14,7 +14,7 @@ import '../../tools/tools.dart';
import '../contact_invitation.dart'; import '../contact_invitation.dart';
class SendInviteDialog extends StatefulWidget { class SendInviteDialog extends StatefulWidget {
const SendInviteDialog({super.key}); const SendInviteDialog({required this.modalContext, super.key});
@override @override
SendInviteDialogState createState() => SendInviteDialogState(); SendInviteDialogState createState() => SendInviteDialogState();
@ -23,7 +23,16 @@ class SendInviteDialog extends StatefulWidget {
await showStyledDialog<void>( await showStyledDialog<void>(
context: context, context: context,
title: translate('send_invite_dialog.title'), title: translate('send_invite_dialog.title'),
child: const SendInviteDialog()); child: SendInviteDialog(modalContext: context));
}
final BuildContext modalContext;
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties
.add(DiagnosticsProperty<BuildContext>('modalContext', modalContext));
} }
} }
@ -132,7 +141,7 @@ class SendInviteDialogState extends State<SendInviteDialog> {
// Start generation // Start generation
final contactInvitationListCubit = final contactInvitationListCubit =
context.read<ContactInvitationListCubit>(); widget.modalContext.read<ContactInvitationListCubit>();
final generator = contactInvitationListCubit.createInvitation( final generator = contactInvitationListCubit.createInvitation(
encryptionKeyType: _encryptionKeyType, encryptionKeyType: _encryptionKeyType,
@ -145,10 +154,11 @@ class SendInviteDialogState extends State<SendInviteDialog> {
} }
await showDialog<void>( await showDialog<void>(
context: context, context: context,
builder: (context) => ContactInvitationDisplayDialog( builder: (context) => BlocProvider(
create: (context) => InvitationGeneratorCubit(generator),
child: ContactInvitationDisplayDialog(
message: _messageTextController.text, message: _messageTextController.text,
generator: generator, )));
));
// if (ret == null) { // if (ret == null) {
// return; // return;
// } // }

View File

@ -110,37 +110,38 @@ class MainPagerState extends State<MainPager> with TickerProviderStateMixin {
context: context, context: context,
// ignore: prefer_expression_function_bodies // ignore: prefer_expression_function_bodies
builder: (context) { builder: (context) {
return const AlertDialog( return AlertDialog(
shape: RoundedRectangleBorder( shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20)), borderRadius: BorderRadius.all(Radius.circular(20)),
), ),
contentPadding: EdgeInsets.only( contentPadding: const EdgeInsets.only(
top: 10, top: 10,
), ),
title: Text( title: const Text(
'Scan Contact Invite', 'Scan Contact Invite',
style: TextStyle(fontSize: 24), style: TextStyle(fontSize: 24),
), ),
content: ScanInviteDialog()); content: ScanInviteDialog(
modalContext: context,
));
}); });
} }
// ignore: prefer_expression_function_bodies Widget _onNewChatBottomSheetBuilder(
Widget _onNewChatBottomSheetBuilder(BuildContext context) { BuildContext sheetContext, BuildContext context) =>
return const SizedBox( const SizedBox(
height: 200, height: 200,
child: Center( child: Center(
child: Text( child: Text(
'Group and custom chat functionality is not available yet'))); 'Group and custom chat functionality is not available yet')));
}
Widget _bottomSheetBuilder(BuildContext context) { Widget _bottomSheetBuilder(BuildContext sheetContext, BuildContext context) {
if (_currentPage == 0) { if (_currentPage == 0) {
// New contact invitation // New contact invitation
return newContactInvitationBottomSheetBuilder(context); return newContactInvitationBottomSheetBuilder(sheetContext, context);
} else if (_currentPage == 1) { } else if (_currentPage == 1) {
// New chat // New chat
return _onNewChatBottomSheetBuilder(context); return _onNewChatBottomSheetBuilder(sheetContext, context);
} else { } else {
// Unknown error // Unknown error
return debugPage('unknown page'); return debugPage('unknown page');
@ -214,7 +215,8 @@ class MainPagerState extends State<MainPager> with TickerProviderStateMixin {
_fabIconList[_currentPage], _fabIconList[_currentPage],
color: scale.secondaryScale.text, color: scale.secondaryScale.text,
), ),
bottomSheetBuilder: _bottomSheetBuilder), bottomSheetBuilder: (sheetContext) =>
_bottomSheetBuilder(sheetContext, context)),
floatingActionButtonLocation: FloatingActionButtonLocation.endDocked, floatingActionButtonLocation: FloatingActionButtonLocation.endDocked,
); );
} }

File diff suppressed because it is too large Load Diff

View File

@ -31,7 +31,9 @@ class RouterCubit extends Cubit<RouterState> {
// Watch for changes that the router will care about // Watch for changes that the router will care about
Future.delayed(Duration.zero, () async { Future.delayed(Duration.zero, () async {
await eventualInitialized.future; await eventualInitialized.future;
emit(state.copyWith(isInitialized: true)); emit(state.copyWith(
isInitialized: true,
hasAnyAccount: accountRepository.getLocalAccounts().isNotEmpty));
}); });
// Subscribe to repository streams // Subscribe to repository streams

View File

@ -118,7 +118,7 @@ class __$$RouterStateImplCopyWithImpl<$Res>
/// @nodoc /// @nodoc
@JsonSerializable() @JsonSerializable()
class _$RouterStateImpl implements _RouterState { class _$RouterStateImpl with DiagnosticableTreeMixin implements _RouterState {
const _$RouterStateImpl( const _$RouterStateImpl(
{required this.isInitialized, {required this.isInitialized,
required this.hasAnyAccount, required this.hasAnyAccount,
@ -135,10 +135,20 @@ class _$RouterStateImpl implements _RouterState {
final bool hasActiveChat; final bool hasActiveChat;
@override @override
String toString() { String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
return 'RouterState(isInitialized: $isInitialized, hasAnyAccount: $hasAnyAccount, hasActiveChat: $hasActiveChat)'; return 'RouterState(isInitialized: $isInitialized, hasAnyAccount: $hasAnyAccount, hasActiveChat: $hasActiveChat)';
} }
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties
..add(DiagnosticsProperty('type', 'RouterState'))
..add(DiagnosticsProperty('isInitialized', isInitialized))
..add(DiagnosticsProperty('hasAnyAccount', hasAnyAccount))
..add(DiagnosticsProperty('hasActiveChat', hasActiveChat));
}
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || return identical(this, other) ||

View File

@ -60,6 +60,13 @@ Future<VeilidConfig> getVeilidConfig(bool isWeb, String appName) async {
config.network.routingTable.copyWith(bootstrap: bootstrap))); config.network.routingTable.copyWith(bootstrap: bootstrap)));
} }
// ignore: do_not_use_environment
const envNetworkKey = String.fromEnvironment('NETWORK_KEY');
if (envNetworkKey.isNotEmpty) {
config = config.copyWith(
network: config.network.copyWith(networkKeyPassword: envNetworkKey));
}
// ignore: do_not_use_environment // ignore: do_not_use_environment
const envBootstrap = String.fromEnvironment('BOOTSTRAP'); const envBootstrap = String.fromEnvironment('BOOTSTRAP');
if (envBootstrap.isNotEmpty) { if (envBootstrap.isNotEmpty) {