Files
sxchnge/frontend/app/lib/kyc/profile.dart

68 lines
2.2 KiB
Dart

import 'package:flutter/material.dart';
import 'package:sxchnge_kyc/sxchnge_kyc.dart';
import '../generated/i18n/app_localizations.dart';
class ProfileForm extends StatelessWidget {
const ProfileForm({super.key, required this.provider});
final IdentityProvider provider;
@override
Widget build(BuildContext context) {
final p = provider;
final l = AppLocalizations.of(context)!;
void update({String? name, String? birth, String? country}) =>
p.updateProfile(
IdentityProfile(
fullName: name ?? p.profile.fullName,
dateOfBirth: birth ?? p.profile.dateOfBirth,
residenceCountry: country ?? p.profile.residenceCountry,
),
);
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(l.kycProfileHelp),
const SizedBox(height: 16),
TextFormField(
key: const ValueKey('kyc-name'),
initialValue: p.profile.fullName,
enabled: !p.busy,
maxLength: 200,
autofillHints: const [AutofillHints.name],
decoration: InputDecoration(labelText: l.kycFullName),
onChanged: (value) => update(name: value),
),
const SizedBox(height: 16),
TextFormField(
key: const ValueKey('kyc-birth'),
initialValue: p.profile.dateOfBirth,
enabled: !p.busy,
keyboardType: TextInputType.datetime,
autofillHints: const [AutofillHints.birthday],
decoration: InputDecoration(
labelText: l.kycBirth,
helperText: l.kycBirthHelp,
),
onChanged: (value) => update(birth: value.trim()),
),
const SizedBox(height: 16),
TextFormField(
key: const ValueKey('kyc-country'),
initialValue: p.profile.residenceCountry,
enabled: !p.busy,
maxLength: 2,
textCapitalization: TextCapitalization.characters,
decoration: InputDecoration(
labelText: l.kycCountry,
helperText: l.kycCountryHelp,
),
onChanged: (value) => update(country: value.trim().toUpperCase()),
),
if (!p.profile.isComplete) Text(l.kycProfileRequired),
],
);
}
}