Files
buzz/mobile/lib/shared/widgets/avatar_editor_option_button.dart
klopez4212 0cde1fe2f4 Make mobile Agents a full-page owned-agent directory (#8693)
Replace the mobile Agents sheet with a full-page directory of verified
owned agents. Add dedicated creation and avatar pages with
catalog-backed model selection, reuse the profile emoji/photo/camera
controls, and expose Builderbot model settings while labeling desktop
agents “Manage on desktop.” Share one account-scoped model catalog
across editable cards and retries. Choose Bestie from the agent profile
using the shared encrypted main-agent record (text-only action, filled
star once selected), and move confirmed deletion to a top-left trash
control with native iOS glass. Include uploaded avatars in owner
registrations so desktop can display them.

Validation: mobile analysis and all 3,958 hosted-enabled app tests
passed; default-build tests run by the push hook. Earlier iPhone build
installed and iterated with the user; the current iOS build succeeds,
but final changes still need a device pass. Independent review found no
new blockers. Actual camera capture and live Bestie sync remain
unconfirmed; the existing shared `main-agent` wire format and Bestie
terminology are retained.

### Snapshots

Widget-harness captures with test data (not native iOS chrome).

| Agents directory | Image avatar editor |
| --- | --- |
| ![Agents
directory](https://github.com/user-attachments/assets/c68a0505-90a5-41db-980f-e3197cac63ac)
| ![Image avatar
editor](https://github.com/user-attachments/assets/9b126186-1e7c-4169-9a74-8f7f252cfa93)
|

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
2026-10-29 18:30:17 +00:00

150 lines
4.3 KiB
Dart

import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../theme/theme.dart';
import '../widgets/ios_glass_navigation_button.dart';
/// Space between avatar-editor controls and their labels.
const avatarEditorOptionLabelGap = Grid.half;
/// A labelled circular option used by the profile avatar editor rails.
class AvatarEditorOptionButton extends StatelessWidget {
/// Creates a selectable avatar-editor rail option.
const AvatarEditorOptionButton({
super.key,
required this.icon,
this.iosIcon,
required this.label,
required this.selected,
required this.onTap,
this.labelMaxWidth,
});
/// The symbol displayed inside the circular control.
final IconData icon;
/// Native symbol used by the iOS liquid-glass control.
final IosGlassNavigationIcon? iosIcon;
/// The text displayed beneath the control.
final String label;
/// Whether this option represents the active editor section.
final bool selected;
/// Called when the option is selected, or null when disabled.
final VoidCallback? onTap;
/// Optional width constraint for the label's overflow region.
final double? labelMaxWidth;
@override
Widget build(BuildContext context) {
final handleTap = onTap == null
? null
: () {
unawaited(HapticFeedback.selectionClick());
onTap!();
};
Widget labelWidget() {
final width = labelMaxWidth;
if (width != null) {
return SizedBox(
height: 20,
child: OverflowBox(
maxWidth: width,
maxHeight: 20,
child: Text(
label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: context.textTheme.labelSmall?.copyWith(
color: selected
? context.colors.onSurface
: context.colors.onSurfaceVariant,
),
),
),
);
}
return Text(
label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: context.textTheme.labelSmall?.copyWith(
color: selected
? context.colors.onSurface
: context.colors.onSurfaceVariant,
),
);
}
if (defaultTargetPlatform == TargetPlatform.iOS && iosIcon != null) {
return Column(
children: [
IosGlassNavigationButton(
icon: iosIcon!,
semanticLabel: label,
onPressed: handleTap,
width: 64,
height: 64,
controlSize: 64,
foregroundColor: selected
? context.colors.primary
: context.colors.onSurface,
isSelected: selected,
),
const SizedBox(height: avatarEditorOptionLabelGap),
ExcludeSemantics(child: labelWidget()),
],
);
}
return Semantics(
label: label,
button: true,
selected: selected,
enabled: handleTap != null,
onTap: handleTap,
child: ExcludeSemantics(
child: InkResponse(
radius: 34,
onTap: handleTap,
child: SizedBox(
width: double.infinity,
child: Column(
children: [
AnimatedContainer(
duration: MediaQuery.disableAnimationsOf(context)
? Duration.zero
: const Duration(milliseconds: 150),
curve: Curves.easeOutCubic,
width: 64,
height: 64,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: selected
? context.colors.onSurface
: context.colors.surfaceContainerHighest,
),
child: Icon(
icon,
size: 26,
color: selected
? context.colors.surface
: context.colors.onSurface,
),
),
const SizedBox(height: avatarEditorOptionLabelGap),
labelWidget(),
],
),
),
),
),
);
}
}