Files
buzz/mobile/lib/features/profile/profile_setup_page/form.dart
klopez4212 ebbc94cbd4 Offer image and animated avatars for human profiles (#9724)
Human profile setup and editing now offer **Image** and **Animated**.
The human editor hides Emoji through its available modes. The emoji
picker, editing controls and setup default remain in source. Existing
emoji artwork still displays, and agents can still choose Emoji.

Validation: mobile analysis and formatting passed; the complete Flutter
suite passed 5,117 tests (71 skipped). The follow-up restores the Image
→ Animated preview regression test proposed in #9734. The final pre-push
mobile checks passed, including the complete suite. A prior run at this
revision failed in the profile-cache persistence test and passed on
rerun. The crypto package passed all 27 tests.

The iPhone Air preview opened with the existing session. Physical
recording and saving still need human verification. Check setup and
Settings → Edit Photo: only Image and Animated appear, image upload and
animation recording/save work, and agent avatar editing still offers
emoji.

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
Co-authored-by: Tom Brow <tomb@block.xyz>
2026-11-23 09:38:56 +00:00

138 lines
4.4 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

part of '../profile_setup_page.dart';
class _ProfileSetupForm extends HookWidget {
const _ProfileSetupForm({
required this.avatar,
required this.onName,
required this.editAvatar,
required this.save,
required this.notNow,
});
final ValueNotifier<ProfileAvatarDraft?> avatar;
final ValueChanged<String> onName;
final Future<void> Function() editAvatar;
final Future<void> Function({bool skipAvatar}) save;
final VoidCallback notNow;
@override
Widget build(BuildContext context) {
final draft = useValueListenable(avatar);
final name = useTextEditingController();
final nameFocus = useFocusNode();
useListenable(name);
final choosingAvatar = useState(false);
final busy = useState(false);
final error = useState(false);
final validName =
name.text.trim().isNotEmpty &&
name.text.trim().characters.length <= 100;
void back() {
if (busy.value) return;
error.value = false;
choosingAvatar.value = false;
nameFocus.requestFocus();
}
Future<void> submit({bool skipAvatar = false}) async {
if (busy.value || !validName) return;
if (!choosingAvatar.value) {
nameFocus.unfocus();
choosingAvatar.value = true;
return;
}
if (!skipAvatar && draft == null) return;
busy.value = true;
error.value = false;
try {
await save(skipAvatar: skipAvatar);
} catch (_) {
if (context.mounted) error.value = true;
} finally {
if (context.mounted) busy.value = false;
}
}
final avatarLabel = draft == null
? 'Add profile photo'
: 'Edit profile photo';
return OnboardingStepPage(
title: choosingAvatar.value
? 'Choose your avatar'
: 'Choose a display name',
subtitle: choosingAvatar.value
? 'Let’s choose an avatar so people know it’s you.'
: 'Your display name is how people see you in Buzz. You can change it any time.',
onBack: choosingAvatar.value && !busy.value ? back : null,
content: choosingAvatar.value
? Padding(
padding: const EdgeInsets.symmetric(vertical: Grid.lg),
child: Center(
child: SizedBox.square(
dimension: 220,
child: IconButton(
tooltip: avatarLabel,
onPressed: busy.value ? null : editAvatar,
padding: EdgeInsets.zero,
icon: ExcludeSemantics(
child: switch (draft) {
ProfileImageAvatarDraft(:final bytes) => CircleAvatar(
radius: 110,
backgroundImage: MemoryImage(bytes),
),
ProfileAnimatedAvatarDraft(:final poster) =>
CircleAvatar(
radius: 110,
backgroundImage: MemoryImage(poster),
),
null => const ProfileSetupEmptyAvatar(),
},
),
),
),
),
)
: TextField(
controller: name,
focusNode: nameFocus,
autofocus: true,
maxLength: 100,
textCapitalization: TextCapitalization.words,
textInputAction: TextInputAction.next,
onSubmitted: (_) => submit(),
onChanged: onName,
decoration: const InputDecoration(labelText: 'Display name'),
),
actions: [
if (error.value)
Semantics(
liveRegion: true,
child: const Text(
'Could not save your profile. Try again or choose Not now to continue without saving.',
),
),
FilledButton(
onPressed:
busy.value ||
!validName ||
(choosingAvatar.value && draft == null)
? null
: submit,
child: Text(busy.value ? 'Saving…' : 'Continue'),
),
if (choosingAvatar.value)
TextButton(
onPressed: busy.value ? null : () => submit(skipAvatar: true),
child: const Text('Skip'),
),
if (error.value)
TextButton(
onPressed: busy.value ? null : notNow,
child: const Text('Not now'),
),
],
);
}
}