79 lines
2.4 KiB
Dart
79 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'package:sxchnge_kyc/sxchnge_kyc.dart';
|
|
|
|
import 'preview.dart';
|
|
|
|
import '../generated/i18n/app_localizations.dart';
|
|
|
|
class PhotoPanel extends StatelessWidget {
|
|
const PhotoPanel({
|
|
super.key,
|
|
required this.kind,
|
|
required this.photo,
|
|
this.onPick,
|
|
this.onRemove,
|
|
this.review = false,
|
|
});
|
|
final PhotoKind kind;
|
|
final Photo? photo;
|
|
final VoidCallback? onPick;
|
|
final VoidCallback? onRemove;
|
|
final bool review;
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final l = AppLocalizations.of(context)!;
|
|
final t = Theme.of(context);
|
|
final passport = kind == PhotoKind.passport;
|
|
final title = passport ? l.kycPassport : l.kycSelfie;
|
|
return Card(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(20),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
Text(title, style: t.textTheme.titleLarge),
|
|
const SizedBox(height: 16),
|
|
if (photo != null)
|
|
ClipRRect(
|
|
borderRadius: BorderRadius.circular(16),
|
|
child: PhotoPreview(photo: photo!, label: title),
|
|
)
|
|
else
|
|
Container(
|
|
height: 140,
|
|
decoration: BoxDecoration(
|
|
color: t.colorScheme.surfaceContainerHighest,
|
|
borderRadius: BorderRadius.circular(16),
|
|
),
|
|
child: Icon(
|
|
passport ? Icons.badge_outlined : Icons.portrait_outlined,
|
|
size: 64,
|
|
color: t.colorScheme.primary,
|
|
),
|
|
),
|
|
if (!review) ...[
|
|
const SizedBox(height: 16),
|
|
Text(passport ? l.kycPassportHelp : l.kycSelfieHelp),
|
|
const SizedBox(height: 12),
|
|
Text(l.kycFileRules, style: t.textTheme.bodySmall),
|
|
const SizedBox(height: 16),
|
|
OutlinedButton.icon(
|
|
key: ValueKey('pick-${kind.name}'),
|
|
onPressed: onPick,
|
|
icon: const Icon(Icons.add_photo_alternate_outlined),
|
|
label: Text(
|
|
photo == null ? l.kycChoose : l.kycReplace,
|
|
textAlign: TextAlign.center,
|
|
),
|
|
),
|
|
if (photo != null)
|
|
TextButton(onPressed: onRemove, child: Text(l.kycRemove)),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|