Skip to content
Snippets Groups Projects
Commit 7fa0b900 authored by vjrj's avatar vjrj
Browse files

Allow edit contacts

parent a9a8d979
No related branches found
No related tags found
No related merge requests found
......@@ -223,11 +223,11 @@ class _PayContactSearchPageState extends State<PayContactSearchPage> {
contact,
index,
context,
() {
onTap: () {
context.read<PaymentCubit>().selectUser(contact);
Navigator.pop(context);
},
BlocBuilder<ContactsCubit, ContactsState>(
trailing: BlocBuilder<ContactsCubit, ContactsState>(
builder: (BuildContext context, ContactsState state) {
final ContactsCubit contactsCubit = context.read<ContactsCubit>();
final bool isFavorite = contactsCubit.isContact(contact.pubKey);
......
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import '../../../data/models/contact.dart';
import '../../ui_helpers.dart';
class ContactEditDialog extends StatefulWidget {
const ContactEditDialog(
{super.key, required this.contact, required this.onSave});
final Contact contact;
final Function(Contact) onSave;
@override
State<ContactEditDialog> createState() => _ContactEditDialogState();
}
class _ContactEditDialogState extends State<ContactEditDialog> {
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
late Contact _updatedContact;
@override
void initState() {
super.initState();
_updatedContact = widget.contact;
}
@override
Widget build(BuildContext context) {
return AlertDialog(
title: Text(tr('form_contact_title')),
content: Form(
key: _formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
TextFormField(
initialValue: humanizePubKey(_updatedContact.pubKey),
decoration: InputDecoration(
labelText: tr('form_contact_pub_key'),
),
enabled: false,
),
TextFormField(
initialValue: _updatedContact.name,
decoration: const InputDecoration(labelText: 'Name'),
validator: (String? value) {
if (value == null || value.isEmpty) {
return tr('form_contact_name_validation');
}
return null;
},
onChanged: (String? value) {
_updatedContact = _updatedContact.copyWith(name: value);
},
),
TextFormField(
initialValue: _updatedContact.notes,
decoration: InputDecoration(labelText: tr('form_contact_notes')),
onChanged: (String? value) {
_updatedContact = _updatedContact.copyWith(notes: value);
},
),
],
),
),
actions: <Widget>[
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text(tr('cancel')),
),
TextButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
widget.onSave(_updatedContact);
Navigator.of(context).pop();
}
},
child: Text(tr('form_save')),
),
],
);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment