Files
buzz/mobile/lib/shared/widgets/native_conversation_menu.dart
klopez4212 e802de8777 Give mobile Solo sessions their own settings and actions (#9888)
## Summary

Long-pressing a Solo or channel in the mobile list opens a system menu
anchored to its row (UIKit context menu on iOS and a rounded Android
PopupWindow with leading icons and an anchored scale and fade). Both
menus use Buzz’s Tabler icons. The actions appear in this order when
available: Mark unread (or Mark read), Rename, Move to section (Change
workspace for personal Solos), Archive (or Unarchive). Tapping the
conversation title opens full settings.

Solo settings include Agent, Rename, workspace, members, and
role-specific management actions. Channel settings put Members below the
quick actions, include Huddle, and offer Leave to eligible members,
including co-owners. A sole owner sees Delete channel. DMs retain the
Huddle header shortcut.

## Snapshots

The iOS simulator shows a sample Solo row. The Android screenshot is
from a physical Pixel.

| UIKit context menu on iOS 26.5 | Android system popup on Pixel 10 |
| --- | --- |
| ![Simulator interaction using sample
rows](https://github.com/user-attachments/assets/dddb43e1-4d2b-4737-a3a4-0dff58ed9e63)
| ![Pixel popup cropped to its four
actions](https://github.com/user-attachments/assets/80008353-f717-41aa-a45e-2cedebafa653)
|

Flutter-rendered details previews with sample data. The previous
ellipsis opened a separate settings sheet. The updated Solo details page
includes those controls.

| Previous ellipsis sheet | Updated settings | Updated members and
management |
| --- | --- | --- |
| ![Previous Agent and Workspace
sheet](https://github.com/user-attachments/assets/75c40f2a-0093-4ebc-811e-fe31ea7acc30)
| ![Solo quick actions, agent and
workspace](https://github.com/user-attachments/assets/00a320ac-b106-4a63-9ef3-babddb98ded1)
| ![Solo roster and owner
actions](https://github.com/user-attachments/assets/3c394e74-6ad3-480d-9666-22ecabc98cb2)
|

Long-pressing a message puts Mark unread first in its quick actions.

![Message quick actions with Mark unread
first](https://github.com/user-attachments/assets/4819ad0c-473b-4f2a-b93a-e2cfb66f2e76)

## Testing

The list journey tests exercise the popover from the channel list and
Solo list, shared Solo filing, read-state changes and dismissal. The
title settings tests cover editing, roster, and lifecycle actions.

## Related issue

No matching issue found.

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
2026-11-23 20:19:55 +00:00

124 lines
3.8 KiB
Dart

import 'dart:async';
import 'dart:io';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:flutter/gestures.dart' show kTouchSlop;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
/// One UIKit interaction, from its deferred menu request through dismissal.
class ConversationMenuSession {
ConversationMenuSession({this.bridge});
final MethodChannel? bridge;
final labels = Completer<List<String>>();
final selection = Completer<String?>();
void close([String? action]) {
if (!labels.isCompleted) labels.complete([]);
if (!selection.isCompleted) selection.complete(action);
}
}
/// Flutter hit-tests the touch once. UIKit has one interaction on the host
/// view, independent of how many conversation rows are built or scrolling.
class _IosConversationMenu {
static const channel = MethodChannel('buzz/conversation_menu');
static ValueChanged<ConversationMenuSession>? target;
static ConversationMenuSession? session;
static int touchId = 0;
static final initialized = _initialize();
static Future<void> _initialize() async {
channel.setMethodCallHandler((call) async {
if (call.method == 'prepare') {
final request = target;
if (request == null || call.arguments != touchId) return <String>[];
session?.close();
final next = ConversationMenuSession(bridge: channel);
session = next;
request(next);
return next.labels.future;
}
if (call.method == 'end') {
session?.close(call.arguments as String?);
session = null;
}
return null;
});
await channel.invokeMethod<void>('attach');
}
}
bool get usesIosConversationMenu => Platform.isIOS;
class IosConversationMenuRow extends HookWidget {
const IosConversationMenuRow({
super.key,
required this.child,
required this.onMenu,
});
final Widget child;
final ValueChanged<ConversationMenuSession> onMenu;
@override
Widget build(BuildContext context) {
if (!usesIosConversationMenu) return child;
final latest = useRef(onMenu)..value = onMenu;
final request = useMemoized(
() => (ConversationMenuSession session) {
if (context.mounted) latest.value(session);
},
);
final down = useRef<Offset?>(null);
void clear() {
if (down.value == null) return;
down.value = null;
if (_IosConversationMenu.target != request) return;
unawaited(_IosConversationMenu.channel.invokeMethod<void>('disarm'));
}
useEffect(() {
unawaited(_IosConversationMenu.initialized);
return () {
clear();
if (_IosConversationMenu.target == request) {
_IosConversationMenu.target = null;
if (_IosConversationMenu.session != null) {
unawaited(
_IosConversationMenu.channel.invokeMethod<void>('dismiss'),
);
}
}
};
}, const []);
return Listener(
behavior: HitTestBehavior.translucent,
onPointerDown: (event) {
down.value = event.position;
final box = context.findRenderObject() as RenderBox;
final rect = box.localToGlobal(Offset.zero) & box.size;
_IosConversationMenu.target = request;
unawaited(
_IosConversationMenu.channel.invokeMethod<void>('arm', [
rect.left,
rect.top,
rect.width,
rect.height,
++_IosConversationMenu.touchId,
]),
);
},
onPointerMove: (event) {
final start = down.value;
if (start != null && (event.position - start).distance > kTouchSlop) {
clear();
}
},
onPointerUp: (_) => clear(),
onPointerCancel: (_) => clear(),
child: child,
);
}
}
bool get usesAndroidConversationMenu => Platform.isAndroid;