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

59 lines
1.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:sxchnge_kyc/sxchnge_kyc.dart';
import 'birth.dart';
import 'country.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),
BirthField(
key: const ValueKey('kyc-birth'),
value: p.profile.dateOfBirth,
enabled: !p.busy,
onChanged: (value) => update(birth: value),
),
const SizedBox(height: 16),
CountryField(
key: const ValueKey('kyc-country'),
value: p.profile.residenceCountry,
enabled: !p.busy,
onChanged: (value) => update(country: value),
),
if (!p.profile.isComplete) Text(l.kycProfileRequired),
],
);
}
}