100 lines
3.3 KiB
Dart
100 lines
3.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'package:sxchnge_kyc/sxchnge_kyc.dart';
|
|
|
|
import 'photo.dart';
|
|
import 'profile.dart';
|
|
|
|
import '../generated/i18n/app_localizations.dart';
|
|
|
|
class IdentityForm extends StatelessWidget {
|
|
const IdentityForm({super.key, required this.provider});
|
|
final IdentityProvider provider;
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final p = provider;
|
|
final l = AppLocalizations.of(context)!;
|
|
final titles = [l.kycPassport, l.kycSelfie, l.kycReview];
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
Semantics(
|
|
header: true,
|
|
liveRegion: true,
|
|
child: Text(
|
|
'${p.step + 1} / 3 · ${titles[p.step]}',
|
|
style: Theme.of(context).textTheme.headlineSmall,
|
|
),
|
|
),
|
|
const SizedBox(height: 16),
|
|
if (p.step == 0) ...[
|
|
ProfileForm(provider: p),
|
|
const SizedBox(height: 24),
|
|
],
|
|
LinearProgressIndicator(
|
|
value: (p.step + 1) / 3,
|
|
semanticsLabel: titles[p.step],
|
|
),
|
|
const SizedBox(height: 16),
|
|
if (p.step < 2)
|
|
PhotoPanel(
|
|
kind: p.step == 0 ? PhotoKind.passport : PhotoKind.selfie,
|
|
photo: p.step == 0 ? p.passport : p.selfie,
|
|
onPick: p.busy
|
|
? null
|
|
: () => p.pick(
|
|
p.step == 0 ? PhotoKind.passport : PhotoKind.selfie,
|
|
),
|
|
onRemove: p.busy
|
|
? null
|
|
: () => p.remove(
|
|
p.step == 0 ? PhotoKind.passport : PhotoKind.selfie,
|
|
),
|
|
),
|
|
if (p.step == 2) ...[
|
|
Text(
|
|
'${p.profile.fullName}\n${p.profile.dateOfBirth} · ${p.profile.residenceCountry}',
|
|
),
|
|
const SizedBox(height: 16),
|
|
Text(l.kycReviewHelp),
|
|
const SizedBox(height: 16),
|
|
PhotoPanel(kind: PhotoKind.passport, photo: p.passport, review: true),
|
|
PhotoPanel(kind: PhotoKind.selfie, photo: p.selfie, review: true),
|
|
CheckboxListTile(
|
|
contentPadding: EdgeInsets.zero,
|
|
controlAffinity: ListTileControlAffinity.leading,
|
|
value: p.confirmed,
|
|
onChanged: p.busy ? null : (v) => p.confirm(v ?? false),
|
|
title: Text(l.kycConfirm),
|
|
),
|
|
],
|
|
const SizedBox(height: 16),
|
|
if (p.step < 2) ...[
|
|
if ((p.step == 0 ? p.passport : p.selfie) == null)
|
|
Padding(
|
|
padding: const EdgeInsets.only(bottom: 12),
|
|
child: Text(l.kycChooseFirst),
|
|
),
|
|
FilledButton(
|
|
key: const ValueKey('kyc-next'),
|
|
onPressed:
|
|
p.busy ||
|
|
(p.step == 0 && !p.profile.isComplete) ||
|
|
(p.step == 0 ? p.passport : p.selfie) == null
|
|
? null
|
|
: p.next,
|
|
child: Text(l.kycNext),
|
|
),
|
|
] else
|
|
FilledButton(
|
|
key: const ValueKey('kyc-submit'),
|
|
onPressed: p.canSubmit ? p.submit : null,
|
|
child: Text(l.kycSubmit),
|
|
),
|
|
if (p.step > 0)
|
|
TextButton(onPressed: p.busy ? null : p.back, child: Text(l.kycBack)),
|
|
],
|
|
);
|
|
}
|
|
}
|