account management update

This commit is contained in:
Christien Rioux 2024-07-31 12:04:43 -05:00
parent 01c6490ec4
commit 5e4f47d5a1
42 changed files with 1663 additions and 831 deletions

View file

@ -3,17 +3,15 @@ import 'dart:async';
import 'package:awesome_extensions/awesome_extensions.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:flutter_translate/flutter_translate.dart';
import 'package:go_router/go_router.dart';
import '../../layout/default_app_bar.dart';
import '../../proto/proto.dart' as proto;
import '../../theme/theme.dart';
import '../../tools/tools.dart';
import '../../veilid_processor/veilid_processor.dart';
import '../account_manager.dart';
import 'profile_edit_form.dart';
import 'edit_profile_form.dart';
class NewAccountPage extends StatefulWidget {
const NewAccountPage({super.key});
@ -29,7 +27,7 @@ class _NewAccountPageState extends WindowSetupState<NewAccountPage> {
orientationCapability: OrientationCapability.portraitOnly);
Widget _newAccountForm(BuildContext context,
{required Future<void> Function(GlobalKey<FormBuilderState>) onSubmit}) {
{required Future<void> Function(AccountSpec) onSubmit}) {
final networkReady = context
.watch<ConnectionStateCubit>()
.state
@ -47,28 +45,19 @@ class _NewAccountPageState extends WindowSetupState<NewAccountPage> {
onSubmit: !canSubmit ? null : onSubmit);
}
Future<void> _onSubmit(GlobalKey<FormBuilderState> formKey) async {
Future<void> _onSubmit(AccountSpec accountSpec) async {
// dismiss the keyboard by unfocusing the textfield
FocusScope.of(context).unfocus();
try {
final name = formKey
.currentState!.fields[EditProfileForm.formFieldName]!.value as String;
final pronouns = formKey.currentState!
.fields[EditProfileForm.formFieldPronouns]!.value as String? ??
'';
final newProfile = proto.Profile()
..name = name
..pronouns = pronouns;
setState(() {
_isInAsyncCall = true;
});
try {
final writableSuperIdentity = await AccountRepository.instance
.createWithNewSuperIdentity(newProfile);
.createWithNewSuperIdentity(accountSpec);
GoRouterHelper(context).pushReplacement('/new_account/recovery_key',
extra: [writableSuperIdentity, newProfile.name]);
extra: [writableSuperIdentity, accountSpec.name]);
} finally {
if (mounted) {
setState(() {