mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-07-22 06:08:54 -04:00
52 lines
1.9 KiB
Dart
52 lines
1.9 KiB
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 '../../proto/proto.dart' as proto;
|
|
import '../../tools/tools.dart';
|
|
import '../contacts.dart';
|
|
|
|
class ContactDetailsWidget extends StatefulWidget {
|
|
const ContactDetailsWidget(
|
|
{required this.contact, this.onModifiedState, super.key});
|
|
|
|
@override
|
|
State<ContactDetailsWidget> createState() => _ContactDetailsWidgetState();
|
|
|
|
@override
|
|
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
|
super.debugFillProperties(properties);
|
|
properties
|
|
..add(DiagnosticsProperty<proto.Contact>('contact', contact))
|
|
..add(ObjectFlagProperty<void Function(bool p1)?>.has(
|
|
'onModifiedState', onModifiedState));
|
|
}
|
|
|
|
final proto.Contact contact;
|
|
final void Function(bool)? onModifiedState;
|
|
}
|
|
|
|
class _ContactDetailsWidgetState extends State<ContactDetailsWidget>
|
|
with SingleTickerProviderStateMixin {
|
|
@override
|
|
Widget build(BuildContext context) => SingleChildScrollView(
|
|
child: EditContactForm(
|
|
contact: widget.contact,
|
|
submitText: translate('button.update'),
|
|
submitDisabledText: translate('button.waiting_for_network'),
|
|
onModifiedState: widget.onModifiedState,
|
|
onSubmit: (updatedContactSpec) async {
|
|
final contactList = context.read<ContactListCubit>();
|
|
try {
|
|
await contactList.updateContactFields(
|
|
localConversationRecordKey:
|
|
widget.contact.localConversationRecordKey.toVeilid(),
|
|
updatedContactSpec: updatedContactSpec);
|
|
} on Exception catch (e) {
|
|
log.debug('error updating contact: $e', e);
|
|
return false;
|
|
}
|
|
return true;
|
|
}));
|
|
}
|