mirror of
https://github.com/block/buzz.git
synced 2026-11-27 19:52:31 +00:00
fix(mobile): align the New menu with desktop (#9883)
## Summary Match the desktop New menu on mobile. New chat, New channel, and New DM appear above a divider, with New workspace and its folder icon below. Remove the Solo and Team headings and keep the action order fixed in UIKit. On iOS, fade the search icon and avatar as they move toward New. Restore them when the menu closes and respect Reduce Motion. ## Testing - Full Flutter suite passed (5,987 passed, 71 skipped). The Home widget test covers the menu order, divider, and opacity during opening and dismissal. - The focused UIKit simulator check passed for workspace grouping and selection. The broader native harness stops at an unrelated dismissal assertion that also fails on the base commit. - Built, installed, and launched the updated preview on a physical iPhone Duo. Related work: #9840. --------- Signed-off-by: kenny lopez <klopez4212@gmail.com> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
This commit is contained in:
1
.github/workflows/_ci-clients.yml
vendored
1
.github/workflows/_ci-clients.yml
vendored
@@ -279,6 +279,7 @@ jobs:
|
||||
/bin/bash scripts/test-mobile-pagination-accessibility.sh "$device"
|
||||
/bin/bash scripts/test-mobile-carousel.sh "$device"
|
||||
/bin/bash scripts/test-mobile-member-picker.sh "$device"
|
||||
/bin/bash scripts/test-mobile-setting-menu.sh "$device"
|
||||
if ! wait "$build"; then
|
||||
cat "$build_log"
|
||||
exit 1
|
||||
|
||||
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -110,6 +110,7 @@ jobs:
|
||||
- 'scripts/test-mobile-pagination-accessibility.sh'
|
||||
- 'scripts/test-mobile-carousel.sh'
|
||||
- 'scripts/test-mobile-member-picker.sh'
|
||||
- 'scripts/test-mobile-setting-menu.sh'
|
||||
- 'scripts/mobile-release.sh'
|
||||
- 'scripts/mobile-release-source.sh'
|
||||
- 'scripts/mobile-worktree-overrides.sh'
|
||||
@@ -139,6 +140,7 @@ jobs:
|
||||
- 'scripts/test-mobile-pagination-accessibility.sh'
|
||||
- 'scripts/test-mobile-carousel.sh'
|
||||
- 'scripts/test-mobile-member-picker.sh'
|
||||
- 'scripts/test-mobile-setting-menu.sh'
|
||||
- '.github/workflows/ci.yml'
|
||||
- '.github/workflows/_ci-clients.yml'
|
||||
- name: Select runtime suites conservatively at the PR file-list limit
|
||||
|
||||
@@ -22,7 +22,7 @@ private final class SettingMenuMessenger: NSObject, FlutterBinaryMessenger {
|
||||
|
||||
@main
|
||||
struct SettingMenuSelectionTests {
|
||||
@MainActor static func main() {
|
||||
@MainActor static func main() async {
|
||||
let merging = MergingNavigationGlass(frame: CGRect(x: 0, y: 0, width: 256, height: 56))
|
||||
merging.layoutIfNeeded()
|
||||
UIView.setAnimationsEnabled(false)
|
||||
@@ -88,6 +88,10 @@ struct SettingMenuSelectionTests {
|
||||
precondition(messenger.selections == (deferred ? [] : [0]))
|
||||
if deferred {
|
||||
button.contextMenuInteraction(interaction, willEndFor: configuration, animator: nil)
|
||||
// The no-animator dismissal queues delivery on the main dispatch queue.
|
||||
await withCheckedContinuation { continuation in
|
||||
DispatchQueue.main.async { continuation.resume() }
|
||||
}
|
||||
precondition(messenger.selections == [0])
|
||||
}
|
||||
}
|
||||
@@ -95,21 +99,21 @@ struct SettingMenuSelectionTests {
|
||||
let grouped = NavigationGlassButtonPlatformView(
|
||||
frame: CGRect(x: 0, y: 0, width: 112, height: 56),
|
||||
viewIdentifier: 2,
|
||||
arguments: ["deferMenuActions": false, "menu": [
|
||||
["id": 0, "label": "New chat", "sectionTitle": "Solo", "enabled": true],
|
||||
["id": 1, "label": "New workspace", "enabled": true],
|
||||
["id": 2, "label": "New DM", "sectionTitle": "Team", "dividerBefore": true, "enabled": true],
|
||||
["id": 3, "label": "New channel", "enabled": true],
|
||||
arguments: ["deferMenuActions": false, "fixedMenuOrder": true, "menu": [
|
||||
["id": 0, "label": "New chat", "symbol": "message.circle", "enabled": true],
|
||||
["id": 1, "label": "New channel", "symbol": "number", "enabled": true],
|
||||
["id": 2, "label": "New DM", "symbol": "person.circle", "enabled": true],
|
||||
["id": 3, "label": "New workspace", "symbol": "folder", "dividerBefore": true, "enabled": true],
|
||||
]], messenger: messenger
|
||||
)
|
||||
let button = grouped.view().subviews.compactMap { $0 as? NavigationGlassButton }.first!
|
||||
precondition(button.preferredMenuElementOrder == .fixed)
|
||||
let groups = button.menu!.children.compactMap { $0 as? UIMenu }
|
||||
precondition(groups.map(\.title) == ["Solo", "Team"])
|
||||
precondition(groups.map { $0.children.count } == [2, 2])
|
||||
let teamAction = groups[1].children[0] as! UIAction
|
||||
UIButton(primaryAction: teamAction).sendActions(for: .touchUpInside)
|
||||
precondition(messenger.selections == [2])
|
||||
precondition(groups.map(\.title) == ["", ""])
|
||||
precondition(groups.map { $0.children.count } == [3, 1])
|
||||
let workspaceAction = groups[1].children[0] as! UIAction
|
||||
UIButton(primaryAction: workspaceAction).sendActions(for: .touchUpInside)
|
||||
precondition(messenger.selections == [3])
|
||||
print("Native setting menu selection checks passed")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -560,9 +560,9 @@ final class NavigationGlassButtonPlatformView: NSObject, FlutterPlatformView {
|
||||
button.accessibilityLabel = accessibilityLabel
|
||||
}
|
||||
if let menu = arguments?["menu"] as? [[String: Any]] {
|
||||
// Keep titled sections in reading order even above a bottom-bar trigger.
|
||||
// Keep creation actions and titled sections in reading order even above a bottom-bar trigger.
|
||||
let hasImages = menu.contains { !(($0["symbol"] as? String) ?? "").isEmpty }
|
||||
button.preferredMenuElementOrder = !hasImages || menu.contains { $0["sectionTitle"] is String } ? .fixed : .automatic
|
||||
button.preferredMenuElementOrder = arguments?["fixedMenuOrder"] as? Bool == true || !hasImages || menu.contains { $0["sectionTitle"] is String } ? .fixed : .automatic
|
||||
var groups: [[UIMenuElement]] = [[]]
|
||||
var groupTitles = [""]
|
||||
for item in menu {
|
||||
|
||||
@@ -105,6 +105,9 @@ enum NativeTabler {
|
||||
"doc": 0xeaa4, // file
|
||||
"plus": 0xeb0b, // plus
|
||||
"building.2.crop.circle": 0xebf6, // building-community
|
||||
"message.circle": 0xeaed, // message-circle
|
||||
"person.circle": 0xef68, // user-circle
|
||||
"folder": 0xeaad, // folder
|
||||
"workspace": 0xecd7, // cube-3d-sphere
|
||||
"folder.badge.plus": 0xeaab, // folder-plus
|
||||
"headphones": 0xeabd, // headphones
|
||||
|
||||
@@ -346,18 +346,14 @@ class HomePage extends HookConsumerWidget {
|
||||
child: Builder(builder: defaultAgentBuilder),
|
||||
),
|
||||
creationActions: [
|
||||
(
|
||||
label: 'New chat',
|
||||
symbol: 'square.and.pencil',
|
||||
onPressed: newChat.value,
|
||||
),
|
||||
(label: 'New chat', symbol: 'message.circle', onPressed: newChat.value),
|
||||
(label: 'New channel', symbol: 'number', onPressed: newChannel.value),
|
||||
(label: 'New DM', symbol: 'person.circle', onPressed: newDm.value),
|
||||
(
|
||||
label: 'New workspace',
|
||||
symbol: 'workspace',
|
||||
symbol: 'folder',
|
||||
onPressed: newWorkspace.value,
|
||||
),
|
||||
(label: 'New DM', symbol: 'bubble.left', onPressed: newDm.value),
|
||||
(label: 'New channel', symbol: 'number', onPressed: newChannel.value),
|
||||
],
|
||||
);
|
||||
return DuoWorkspaceScaffold(
|
||||
|
||||
@@ -13,6 +13,11 @@ import '../../shared/widgets/navigation_button_surface.dart';
|
||||
import '../../shared/widgets/android_expanding_menu_button.dart';
|
||||
import '../../shared/widgets/ios_message_create_button.dart';
|
||||
|
||||
bool _reduceShortcutMotion(BuildContext context) =>
|
||||
MediaQuery.disableAnimationsOf(context) ||
|
||||
(defaultTargetPlatform == TargetPlatform.iOS &&
|
||||
View.of(context).platformDispatcher.accessibilityFeatures.reduceMotion);
|
||||
|
||||
/// Separate glass shortcuts for search and creation.
|
||||
class MessagesNavigationBar extends HookWidget {
|
||||
const MessagesNavigationBar({
|
||||
@@ -34,10 +39,9 @@ class MessagesNavigationBar extends HookWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final menuOpen = useState(false);
|
||||
final menuMoving = useState(false);
|
||||
final disableAnimations = MediaQuery.disableAnimationsOf(context);
|
||||
void menuVisibilityChanged(bool visible) {
|
||||
if (menuOpen.value == visible) return;
|
||||
menuMoving.value = !disableAnimations;
|
||||
menuMoving.value = !_reduceShortcutMotion(context);
|
||||
menuOpen.value = visible;
|
||||
}
|
||||
|
||||
@@ -76,8 +80,7 @@ class MessagesNavigationBar extends HookWidget {
|
||||
navigationAxis: Axis.vertical,
|
||||
onMenuVisibilityChanged: menuVisibilityChanged,
|
||||
actions: creationActions,
|
||||
dividerBefore: const {2},
|
||||
sectionTitles: const {0: 'Solo', 2: 'Team'},
|
||||
dividerBefore: const {3},
|
||||
accessibilityLabel: 'New',
|
||||
width: 56,
|
||||
height: 168 + Grid.xs * 2,
|
||||
@@ -143,8 +146,7 @@ class MessagesNavigationBar extends HookWidget {
|
||||
mergingNavigation: true,
|
||||
onMenuVisibilityChanged: menuVisibilityChanged,
|
||||
actions: creationActions,
|
||||
dividerBefore: const {2},
|
||||
sectionTitles: const {0: 'Solo', 2: 'Team'},
|
||||
dividerBefore: const {3},
|
||||
label: 'New',
|
||||
showIconWithLabel: true,
|
||||
accessibilityLabel: 'New',
|
||||
@@ -212,8 +214,7 @@ class MessagesNavigationBar extends HookWidget {
|
||||
AndroidExpandingMenuButton(
|
||||
expansionBoundsContext: controlsContext,
|
||||
actions: creationActions,
|
||||
dividerBefore: const {2},
|
||||
sectionTitles: const {0: 'Solo', 2: 'Team'},
|
||||
dividerBefore: const {3},
|
||||
),
|
||||
const SizedBox(width: Grid.xs),
|
||||
const SizedBox.square(dimension: 56),
|
||||
@@ -262,7 +263,7 @@ class _MenuNudge extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final duration = MediaQuery.disableAnimationsOf(context)
|
||||
final duration = _reduceShortcutMotion(context)
|
||||
? Duration.zero
|
||||
: const Duration(milliseconds: 180);
|
||||
final scale = menuOpen ? .9 : 1.0;
|
||||
@@ -280,7 +281,12 @@ class _MenuNudge extends StatelessWidget {
|
||||
axis == Axis.vertical ? offset : 0,
|
||||
0,
|
||||
)..scaleByDouble(scale, scale, 1, 1),
|
||||
child: child,
|
||||
child: AnimatedOpacity(
|
||||
duration: duration,
|
||||
curve: Curves.easeOutCubic,
|
||||
opacity: menuOpen ? 0 : 1,
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -391,6 +391,9 @@ abstract final class BuzzIcons {
|
||||
/// Tabler `user`.
|
||||
static const user = IconData(0xeb4d, fontFamily: 'BuzzTabler');
|
||||
|
||||
/// Tabler `user-circle`.
|
||||
static const userCircle = IconData(0xef68, fontFamily: 'BuzzTabler');
|
||||
|
||||
/// Tabler `user-minus`.
|
||||
static const userMinus = IconData(0xeb4a, fontFamily: 'BuzzTabler');
|
||||
|
||||
|
||||
@@ -337,6 +337,14 @@ class _CreateMenuRoute extends PopupRoute<int> {
|
||||
.desktop_windows_outlined,
|
||||
'square.and.pencil' =>
|
||||
BuzzIcons.edit,
|
||||
'message.circle' =>
|
||||
BuzzIcons
|
||||
.messageCircle,
|
||||
'person.circle' =>
|
||||
BuzzIcons
|
||||
.userCircle,
|
||||
'folder' =>
|
||||
BuzzIcons.folder,
|
||||
'workspace' =>
|
||||
BuzzIcons
|
||||
.workspace,
|
||||
|
||||
@@ -156,6 +156,7 @@ class IosMessageCreateButton extends HookConsumerWidget {
|
||||
'showIconWithLabel': showIconWithLabel,
|
||||
'accessibilityLabel': accessibilityLabel,
|
||||
'menu': menu,
|
||||
'fixedMenuOrder': mergingNavigation,
|
||||
'deferMenuActions': deferMenuActions,
|
||||
};
|
||||
// Keep one handler per channel. Replacing this effect on enabled changes
|
||||
|
||||
@@ -576,31 +576,32 @@ void main() {
|
||||
await tester.tap(find.byTooltip('New'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('New workspace'), findsOneWidget);
|
||||
final menuBounds = tester.getRect(
|
||||
find
|
||||
.ancestor(
|
||||
of: find.text('New workspace'),
|
||||
matching: find.byType(Material),
|
||||
)
|
||||
.first,
|
||||
);
|
||||
final menu = find
|
||||
.ancestor(
|
||||
of: find.text('New workspace'),
|
||||
matching: find.byType(Material),
|
||||
)
|
||||
.first;
|
||||
final menuBounds = tester.getRect(menu);
|
||||
expect(menuBounds.left, closeTo(controlsBounds.left, .01));
|
||||
expect(menuBounds.right, closeTo(controlsBounds.right, .01));
|
||||
expect(menuBounds.bottom, closeTo(controlsBounds.bottom, .01));
|
||||
expect(
|
||||
tester.getTopLeft(find.text('Solo').last).dy,
|
||||
lessThan(tester.getTopLeft(find.text('New chat')).dy),
|
||||
final rows = ['New chat', 'New channel', 'New DM', 'New workspace'];
|
||||
final positions = rows.map(
|
||||
(label) => tester.getCenter(find.text(label)).dy,
|
||||
);
|
||||
expect(positions, orderedEquals(positions.toList()..sort()));
|
||||
final divider = find.descendant(of: menu, matching: find.byType(Divider));
|
||||
expect(
|
||||
tester.getTopLeft(find.text('Team').last).dy,
|
||||
greaterThan(tester.getBottomLeft(find.text('New workspace')).dy),
|
||||
tester.getCenter(divider).dy,
|
||||
inExclusiveRange(positions.elementAt(2), positions.last),
|
||||
);
|
||||
expect(
|
||||
tester.getTopLeft(find.text('Team').last).dy,
|
||||
lessThan(tester.getTopLeft(find.text('New DM')).dy),
|
||||
);
|
||||
expect(find.text('New DM'), findsOneWidget);
|
||||
expect(find.text('New channel'), findsOneWidget);
|
||||
for (final heading in ['Solo', 'Team']) {
|
||||
expect(
|
||||
find.descendant(of: menu, matching: find.text(heading)),
|
||||
findsNothing,
|
||||
);
|
||||
}
|
||||
await tester.tap(find.text('New chat'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(created, 1);
|
||||
@@ -994,7 +995,7 @@ void main() {
|
||||
)
|
||||
.actions
|
||||
.map((a) => a.label),
|
||||
['New chat', 'New workspace', 'New DM', 'New channel'],
|
||||
['New chat', 'New channel', 'New DM', 'New workspace'],
|
||||
);
|
||||
final creationMenu = tester.widget<IosMessageCreateButton>(
|
||||
find.byWidgetPredicate(
|
||||
@@ -1002,12 +1003,20 @@ void main() {
|
||||
),
|
||||
);
|
||||
final search = find.byTooltip('Search');
|
||||
final shortcuts = [search, find.byType(DefaultAgentLauncher)];
|
||||
Iterable<double> shortcutOpacities() => shortcuts.map((shortcut) {
|
||||
final fade = find
|
||||
.ancestor(of: shortcut, matching: find.byType(FadeTransition))
|
||||
.first;
|
||||
return tester.widget<FadeTransition>(fade).opacity.value;
|
||||
});
|
||||
final initialX = tester.getCenter(search).dx;
|
||||
final initialWidth =
|
||||
(tester.getTopRight(search).dx - tester.getTopLeft(search).dx);
|
||||
creationMenu.onMenuVisibilityChanged!(true);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 90));
|
||||
expect(shortcutOpacities(), everyElement(inExclusiveRange(0, 1)));
|
||||
final midwayX = tester.getCenter(search).dx;
|
||||
expect(midwayX, greaterThan(initialX + 50));
|
||||
expect(midwayX, lessThan(initialX + 100));
|
||||
@@ -1017,6 +1026,7 @@ void main() {
|
||||
(tester.getTopRight(search).dx - tester.getTopLeft(search).dx),
|
||||
closeTo(initialWidth * .9, .01),
|
||||
);
|
||||
expect(shortcutOpacities(), [0.0, 0.0]);
|
||||
expect(search.hitTestable(), findsNothing);
|
||||
creationMenu.onMenuVisibilityChanged!(false);
|
||||
await tester.pumpAndSettle();
|
||||
@@ -1025,7 +1035,22 @@ void main() {
|
||||
(tester.getTopRight(search).dx - tester.getTopLeft(search).dx),
|
||||
closeTo(initialWidth, .01),
|
||||
);
|
||||
expect(shortcutOpacities(), [1.0, 1.0]);
|
||||
expect(search.hitTestable(), findsOneWidget);
|
||||
final dispatcher = tester.platformDispatcher;
|
||||
dispatcher.accessibilityFeaturesTestValue =
|
||||
const FakeAccessibilityFeatures(reduceMotion: true);
|
||||
addTearDown(dispatcher.clearAccessibilityFeaturesTestValue);
|
||||
expect(MediaQuery.disableAnimationsOf(tester.element(search)), isFalse);
|
||||
for (final open in [true, false]) {
|
||||
creationMenu.onMenuVisibilityChanged!(open);
|
||||
await tester.pump();
|
||||
expect(shortcutOpacities(), everyElement(open ? 0.0 : 1.0));
|
||||
expect(
|
||||
tester.getCenter(search).dx,
|
||||
closeTo(initialX + (open ? 100 : 0), .01),
|
||||
);
|
||||
}
|
||||
final inbox = find.byWidgetPredicate(
|
||||
(w) => w is IosGlassNavigationButton && w.semanticLabel == 'Activity',
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user