64 lines
2.0 KiB
Dart
64 lines
2.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'package:sxchnge_kyc/sxchnge_kyc.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),
|
|
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),
|
|
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),
|
|
],
|
|
);
|
|
}
|
|
}
|