tane/apps/app_seeds/lib/ui/avatar_edit.dart
vjrj 17612b8147 feat(profile): drop seed-glyph illustrations from the avatar picker
The picker now offers only a photo; with none, the generated DiceBear
avatar is used. Removes the seedks-ttf illustration row (and the now-dead
avatarGlyphNames/avatarGlyphToken). tane:seed:<glyph> values set before
this still render (avatarGlyphChar kept) for backward compatibility.
2026-07-12 23:22:20 +02:00

65 lines
2.3 KiB
Dart

import 'package:flutter/material.dart';
import '../i18n/strings.g.dart';
import '../services/offer_thumbnail.dart' show offerThumbnailDataUri;
import 'photo_pick.dart';
import 'theme.dart';
/// Lets the user choose a profile avatar: take/pick a photo (shrunk to a tiny
/// inline thumbnail) or remove it. With no photo, a generated avatar is used.
///
/// Returns the new avatar value (a `data:` photo thumbnail), an empty string to
/// clear it (falls back to the generated avatar), or null when cancelled.
Future<String?> showAvatarPicker(
BuildContext context, {
required String current,
}) {
return showModalBottomSheet<String>(
context: context,
isScrollControlled: true,
builder: (sheetContext) {
final t = sheetContext.t;
return SafeArea(
child: Padding(
padding: const EdgeInsets.fromLTRB(16, 12, 16, 16),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(t.avatar.title,
style: Theme.of(sheetContext).textTheme.titleMedium),
const SizedBox(height: 8),
ListTile(
key: const Key('avatar.fromPhoto'),
contentPadding: EdgeInsets.zero,
leading: const Icon(Icons.add_a_photo_outlined,
color: seedGreen),
title: Text(t.avatar.fromPhoto),
onTap: () async {
final bytes = await pickPhoto(sheetContext);
if (bytes == null) return;
final uri = offerThumbnailDataUri(bytes, maxBytes: 24000);
if (sheetContext.mounted) {
Navigator.of(sheetContext).pop(uri ?? '');
}
},
),
if (current.isNotEmpty) ...[
const SizedBox(height: 8),
Align(
alignment: AlignmentDirectional.centerStart,
child: TextButton.icon(
key: const Key('avatar.remove'),
onPressed: () => Navigator.of(sheetContext).pop(''),
icon: const Icon(Icons.delete_outline, size: 18),
label: Text(t.avatar.remove),
),
),
],
],
),
),
);
},
);
}