mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-10-11 12:48:34 -04:00
checkpoint
This commit is contained in:
parent
c516323e7d
commit
31f562119a
70 changed files with 1174 additions and 817 deletions
|
@ -2,7 +2,9 @@ import 'dart:async';
|
|||
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:veilid_support/veilid_support.dart';
|
||||
|
||||
import '../../models/models.dart';
|
||||
import '../../repository/account_repository/account_repository.dart';
|
||||
|
||||
part 'local_accounts_state.dart';
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
part of 'local_accounts_cubit.dart';
|
||||
|
||||
typedef LocalAccountsState = IList<LocalAccount>;
|
||||
|
||||
extension LocalAccountsStateExt on LocalAccountsState {
|
||||
LocalAccount? fetchLocalAccount({required TypedKey accountMasterRecordKey}) {
|
||||
final idx = indexWhere(
|
||||
(e) => e.identityMaster.masterRecordKey == accountMasterRecordKey);
|
||||
if (idx == -1) {
|
||||
return null;
|
||||
}
|
||||
return this[idx];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ import 'dart:async';
|
|||
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:veilid_support/veilid_support.dart';
|
||||
|
||||
import '../../models/models.dart';
|
||||
import '../../repository/account_repository/account_repository.dart';
|
||||
|
||||
part 'user_logins_state.dart';
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
part of 'user_logins_cubit.dart';
|
||||
|
||||
typedef UserLoginsState = IList<UserLogin>;
|
||||
|
||||
extension UserLoginsStateExt on UserLoginsState {
|
||||
UserLogin? fetchUserLogin({required TypedKey accountMasterRecordKey}) {
|
||||
final idx =
|
||||
indexWhere((e) => e.accountMasterRecordKey == accountMasterRecordKey);
|
||||
if (idx == -1) {
|
||||
return null;
|
||||
}
|
||||
return this[idx];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import 'dart:typed_data';
|
|||
import 'package:change_case/change_case.dart';
|
||||
import 'package:veilid_support/veilid_support.dart';
|
||||
|
||||
import '../../../../proto/proto.dart' as proto;
|
||||
import '../../../proto/proto.dart' as proto;
|
||||
|
||||
enum EncryptionKeyType {
|
||||
none,
|
|
@ -3,7 +3,7 @@ import 'dart:typed_data';
|
|||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:veilid_support/veilid_support.dart';
|
||||
|
||||
import 'encryption_key_type.dart';
|
||||
import '../../models/encryption_key_type.dart';
|
||||
|
||||
part 'local_account.g.dart';
|
||||
part 'local_account.freezed.dart';
|
4
lib/account_manager/models/models.dart
Normal file
4
lib/account_manager/models/models.dart
Normal file
|
@ -0,0 +1,4 @@
|
|||
export 'encryption_key_type.dart';
|
||||
export 'local_account/local_account.dart';
|
||||
export 'new_profile_spec.dart';
|
||||
export 'user_login/user_login.dart';
|
|
@ -2,16 +2,8 @@ import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
|||
import 'package:veilid_support/veilid_support.dart';
|
||||
|
||||
import '../../../../proto/proto.dart' as proto;
|
||||
import '../../models/models.dart';
|
||||
import 'active_logins.dart';
|
||||
import 'encryption_key_type.dart';
|
||||
import 'local_account.dart';
|
||||
import 'new_profile_spec.dart';
|
||||
import 'user_login.dart';
|
||||
|
||||
export 'active_logins.dart';
|
||||
export 'encryption_key_type.dart';
|
||||
export 'local_account.dart';
|
||||
export 'user_login.dart';
|
||||
|
||||
const String veilidChatAccountKey = 'com.veilid.veilidchat';
|
||||
|
||||
|
@ -73,7 +65,7 @@ class AccountRepository {
|
|||
return localAccounts[idx];
|
||||
}
|
||||
|
||||
UserLogin? fetchLogin({required TypedKey accountMasterRecordKey}) {
|
||||
UserLogin? fetchUserLogin({required TypedKey accountMasterRecordKey}) {
|
||||
final userLogins = _activeLogins.requireValue.userLogins;
|
||||
final idx = userLogins
|
||||
.indexWhere((e) => e.accountMasterRecordKey == accountMasterRecordKey);
|
||||
|
|
|
@ -3,7 +3,7 @@ import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
|||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:veilid_support/veilid_support.dart';
|
||||
|
||||
import 'user_login.dart';
|
||||
import '../../models/models.dart';
|
||||
|
||||
part 'active_logins.g.dart';
|
||||
part 'active_logins.freezed.dart';
|
||||
|
|
|
@ -5,12 +5,12 @@ import 'package:flutter_form_builder/flutter_form_builder.dart';
|
|||
import 'package:flutter_translate/flutter_translate.dart';
|
||||
import 'package:form_builder_validators/form_builder_validators.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:veilid_support/veilid_support.dart';
|
||||
|
||||
import '../../../components/default_app_bar.dart';
|
||||
import '../../../components/signal_strength_meter.dart';
|
||||
import '../../../entities/entities.dart';
|
||||
import '../../../layout/default_app_bar.dart';
|
||||
import '../../../tools/tools.dart';
|
||||
import '../../../veilid_processor/veilid_processor.dart';
|
||||
import '../../account_manager.dart';
|
||||
import '../../models/models.dart';
|
||||
|
||||
class NewAccountPage extends StatefulWidget {
|
||||
const NewAccountPage({super.key});
|
||||
|
@ -95,8 +95,7 @@ class NewAccountPageState extends State<NewAccountPage> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final displayModalHUD =
|
||||
isInAsyncCall || !localAccounts.hasValue || !logins.hasValue;
|
||||
final displayModalHUD = isInAsyncCall;
|
||||
|
||||
return Scaffold(
|
||||
// resizeToAvoidBottomInset: false,
|
||||
|
@ -116,7 +115,16 @@ class NewAccountPageState extends State<NewAccountPage> {
|
|||
onSubmit: (formKey) async {
|
||||
FocusScope.of(context).unfocus();
|
||||
try {
|
||||
await createAccount();
|
||||
final name =
|
||||
_formKey.currentState!.fields[formFieldName]!.value as String;
|
||||
final pronouns = _formKey.currentState!.fields[formFieldPronouns]!
|
||||
.value as String? ??
|
||||
'';
|
||||
final newProfileSpec =
|
||||
NewProfileSpec(name: name, pronouns: pronouns);
|
||||
|
||||
await AccountRepository.instance
|
||||
.createMasterIdentity(newProfileSpec);
|
||||
} on Exception catch (e) {
|
||||
if (context.mounted) {
|
||||
await showErrorModal(context, translate('new_account_page.error'),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue