Files
buzz/mobile/lib/shared/widgets/ios_message_create_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

164 lines
4.9 KiB
Dart

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/services.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import '../theme/theme.dart';
import 'avatar_image.dart';
/// The four desktop creation destinations, presented by UIKit on iOS.
class IosMessageCreateButton extends HookWidget {
const IosMessageCreateButton({
super.key,
required this.actions,
this.label,
this.labelFontSize,
this.avatarUrl,
this.avatarInitial,
this.dividerBefore = const {},
this.icon = 'plus',
this.accessibilityLabel = 'Create',
this.width = 64,
this.height = 48,
this.plain = true,
this.showIconWithLabel = false,
});
final Set<int> dividerBefore;
final String? label;
final double? labelFontSize;
final String? avatarUrl, avatarInitial;
final String icon;
final String accessibilityLabel;
final double width, height;
final bool plain;
final bool showIconWithLabel;
final List<({String label, String symbol, VoidCallback? onPressed})> actions;
@override
Widget build(BuildContext context) {
final route = ModalRoute.of(context);
final coveringProgress = useAnimation(
route?.secondaryAnimation ?? kAlwaysDismissedAnimation,
);
final nativeControlsVisible =
(route?.isCurrent ?? true) && coveringProgress == 0;
final brightness = context.theme.brightness;
final foreground = context.colors.onSurface.toARGB32();
final avatarFuture = useMemoized(
() => avatarInitial == null
? null
: nativeAvatarImage(
url: avatarUrl,
initial: avatarInitial!,
circular: true,
background: context.colors.primaryContainer,
foreground: context.colors.onPrimaryContainer,
networkImage: NetworkImage.new,
),
[
avatarUrl,
avatarInitial,
context.colors.primaryContainer,
context.colors.onPrimaryContainer,
],
);
final avatar = useFuture(avatarFuture, preserveState: false).data;
final channel = useState<MethodChannel?>(null);
final latest = useRef(actions)..value = actions;
final menu = [
for (var i = 0; i < actions.length; i++)
{
'id': i,
'dividerBefore': dividerBefore.contains(i),
'label': actions[i].label,
'symbol': actions[i].symbol,
'enabled': actions[i].onPressed != null,
},
];
final content = <String, Object>{
'icon': icon,
'imageBytes': ?avatar,
'label': ?label,
'labelFontSize': ?labelFontSize,
'showIconWithLabel': showIconWithLabel,
'accessibilityLabel': accessibilityLabel,
'menu': menu,
};
useEffect(() {
final current = channel.value;
if (current == null) return null;
current.setMethodCallHandler((call) async {
if (call.method != 'menuAction') return;
final index = call.arguments as int;
if (index >= 0 && index < latest.value.length) {
latest.value[index].onPressed?.call();
}
});
return () => current.setMethodCallHandler(null);
}, [channel.value]);
useEffect(
() {
final current = channel.value;
if (current != null) {
unawaited(current.invokeMethod<void>('setContent', content));
unawaited(
current.invokeMethod<void>('setAppearance', {
'brightness': brightness.name,
'foregroundColor': foreground,
'enabled': true,
}),
);
}
return null;
},
[
channel.value,
avatar,
icon,
label,
labelFontSize,
accessibilityLabel,
...actions.map((a) => a.onPressed != null),
brightness,
foreground,
],
);
// UIKit glass layers can float above the incoming Flutter route during
// its transition. Remove the covered route's platform view immediately.
if (!nativeControlsVisible) {
return SizedBox(width: width, height: height);
}
return SizedBox(
width: width,
height: height,
child: UiKitView(
viewType: 'buzz/navigation_glass',
gestureRecognizers: {
Factory<EagerGestureRecognizer>(EagerGestureRecognizer.new),
},
creationParams: {
...content,
'plain': plain,
'buttonCenterX': width / 2,
'controlWidth': width,
'controlSize': height,
'hitTargetWidth': width,
'hitTargetHeight': height,
'brightness': brightness.name,
'foregroundColor': foreground,
'enabled': true,
},
creationParamsCodec: const StandardMessageCodec(),
onPlatformViewCreated: (id) =>
channel.value = MethodChannel('buzz/navigation_glass/$id'),
),
);
}
}