From 25291cddfea0b32ef4594c2c9cb20fa61699eda7 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Thu, 26 Nov 2026 23:41:35 +0000 Subject: [PATCH] Move the guild's Commit into the nav bar and make Join a pill The guild header had Commit, Edit and Join or Leave as small theme buttons. Commit is now a pencil in the nav bar before the more menu, the same as the Log's new commit action, and it only shows while the guild takes posts. Join, Leave and the moderator's Edit use the 40pt pill the profile's Follow and Remote use: glass on iOS, Join filled in your colour, Leave and Edit clear glass, tonal pills on Android. A guild always opens pushed over its tab, never in an iOS workspace column, so the bar action uses the Lucide pencil on both platforms. Co-Authored-By: Claude Opus 5.5 --- app/NativeComponents/Guild.php | 34 ++++++++++++----- .../partials/glass-pill-button.blade.php | 9 +++-- .../native/partials/guild-header.blade.php | 18 ++++----- tests/Feature/Screens/GuildMenuTest.php | 11 ++++-- tests/Feature/Screens/GuildPostTest.php | 37 ++++++++++++++----- tests/Feature/Screens/GuildTest.php | 25 +++++++++++++ 6 files changed, 98 insertions(+), 36 deletions(-) diff --git a/app/NativeComponents/Guild.php b/app/NativeComponents/Guild.php index 5d382267..29c92506 100644 --- a/app/NativeComponents/Guild.php +++ b/app/NativeComponents/Guild.php @@ -36,7 +36,7 @@ /** * A guild's page, as the web shows it at "/guilds/{handle}": its icon or - * emoji beside Commit and Join or Leave, its name, "#handle · Public guild · + * emoji beside Join or Leave, its name, "#handle · Public guild · * N members" (the count opens its members), what it's about and how to post * there, then its bulletin board, the commits posted in it or tagged with its * hashtag, newest first, with the one its moderator pinned on top. @@ -48,7 +48,7 @@ * so a page loaded later can repeat a commit already showing: those go once, * as does the pinned commit, which devnull also sends in its place. * - * The header's Commit posts to the board, as the web's guild page does, + * New commit in the nav bar posts to the board, as the web's guild page does, * from the compose sheet (see OpensCommitSheet::composeInGuildSheet()), while * the guild isn't paused. The commit shows on top of the board, staged, until * devnull has it, as a new commit does on the Log. If devnull turns it down, @@ -157,14 +157,30 @@ public function navTitle(): string } /** - * ⋯, as on someone else's profile: Share guild, then Mute or Unmute while - * you haven't joined, as the web hides Mute once you join. Commit and Join - * are in the header, as Remote and Follow are on a profile, and so is the - * moderator's Edit. The moderator gets no Report. + * New commit, as the Log has it, while the guild takes posts. Then ⋯, as + * on someone else's profile: Share guild, then Mute or Unmute while you + * haven't joined, as the web hides Mute once you join. Join is in the + * header, as Follow is on a profile, and so is the moderator's Edit. The + * moderator gets no Report. + * + * A guild always opens over the whole tab, never in an iOS workspace's + * column (see Workspace::paneFor()), so New commit takes Lucide's pencil on + * both platforms, as the Log's does outside a workspace. */ public function navigationOptions(): ?NavBarOptions { $hashtag = '#'.($this->guild->handle ?? $this->handle()); + $options = NavBarOptions::make(); + + if ($this->takesPosts()) { + $options->action( + NavAction::make('compose') + ->icon(ios: Lucide::SquarePen->ios(), android: Lucide::SquarePen->android()) + ->a11yLabel("New commit in {$hashtag}") + ->press('composeForGuild'), + ); + } + $items = [ NavAction::make('share') ->label('Share guild') @@ -188,7 +204,7 @@ public function navigationOptions(): ?NavBarOptions ->press('reportGuild'); } - return NavBarOptions::make()->action( + return $options->action( NavAction::make('more') ->icon(ios: Lucide::Ellipsis->ios(), android: Lucide::Ellipsis->android()) ->a11yLabel("More options for {$hashtag}") @@ -334,7 +350,7 @@ public function unmute(): void } /** - * The header's Commit: the sheet, for a commit on this guild's board. + * The bar's New commit: the sheet, for a commit on this guild's board. */ public function composeForGuild(): void { @@ -526,7 +542,7 @@ protected function showCommitTurnedDown(PendingWrite $write): void } /** - * The header's Commit is this page's, so a post to this board devnull turned down opens here again. + * The bar's New commit is this page's, so a post to this board devnull turned down opens here again. */ protected function opensComposer(): bool { diff --git a/resources/views/native/partials/glass-pill-button.blade.php b/resources/views/native/partials/glass-pill-button.blade.php index 713ed7a8..73dd3f9f 100644 --- a/resources/views/native/partials/glass-pill-button.blade.php +++ b/resources/views/native/partials/glass-pill-button.blade.php @@ -1,8 +1,9 @@ {{-- - A header's main buttons on a profile or an organization's page: Follow, Unfollow and Remote. A 40pt pill, a step up - from the small theme button they were, on Liquid Glass on iOS as the app's other floating buttons are (see - sheet-bar-button). $filled draws it in your colour, tinted through the glass on iOS, for the one thing to do next, - like Follow; otherwise it's clear glass on iOS and a tonal pill on Android. + A header's main buttons on a profile, an organization's page or a guild's: Follow, Unfollow and Remote, or Join, + Leave and the moderator's Edit. A 40pt pill, a step up from the small theme button they were, on Liquid Glass on + iOS as the app's other floating buttons are (see sheet-bar-button). $filled draws it in your colour, tinted through + the glass on iOS, for the one thing to do next, like Follow or Join; otherwise it's clear glass on iOS and a tonal + pill on Android. It's a pressable rather than a theme button, which takes no glass or per-button fill. --}} diff --git a/resources/views/native/partials/guild-header.blade.php b/resources/views/native/partials/guild-header.blade.php index 5e36c71f..29bd853e 100644 --- a/resources/views/native/partials/guild-header.blade.php +++ b/resources/views/native/partials/guild-header.blade.php @@ -1,9 +1,10 @@ {{-- A guild's header, at the top of its board (see guild.blade.php), in the web's words: its icon or emoji (see - guild-mark) with Commit and Join or Leave beside it, as a profile has Remote and Follow, and Edit between them for - its moderator, as the web's pencil shows them it's theirs. Then its name, - "#handle · Public guild · N members", the count opening its members, what it's about, then how to post there, or - that it's paused while it has no moderator. Commit, which posts to the board, shows while the guild takes posts. + guild-mark) with Join or Leave beside it, as a profile has Follow, and Edit before it for its moderator, as the + web's pencil shows them it's theirs. They are the profile's 40pt pills (see glass-pill-button), with Join in your + colour as the thing to do next. Then its name, "#handle · Public guild · N members", the count opening its + members, what it's about, then how to post there, or that it's paused while it has no moderator. New commit, + which posts to the board, is in the nav bar while the guild takes posts (see Guild::navigationOptions()). --}} @php($members = \App\Devnull\Display::count($guild->memberCount, 'member', 'members')) @@ -14,16 +15,13 @@ - @unless ($guild->isPaused) - Commit - @endunless @if ($canModerate) - Edit + @include('native.partials.glass-pill-button', ['ref' => 'guild-edit', 'label' => 'Edit', 'press' => 'editGuild', 'hint' => 'Edits '.$guild->hashtag()."'s name, description and icon"]) @endif @if ($guild->isJoined) - Leave + @include('native.partials.glass-pill-button', ['ref' => 'guild-join', 'label' => 'Leave', 'press' => 'toggleJoined', 'hint' => 'Leaves '.$guild->hashtag()]) @else - Join + @include('native.partials.glass-pill-button', ['ref' => 'guild-join', 'label' => 'Join', 'press' => 'toggleJoined', 'hint' => 'Joins '.$guild->hashtag(), 'filled' => true]) @endif diff --git a/tests/Feature/Screens/GuildMenuTest.php b/tests/Feature/Screens/GuildMenuTest.php index 9dce0416..b9696a31 100644 --- a/tests/Feature/Screens/GuildMenuTest.php +++ b/tests/Feature/Screens/GuildMenuTest.php @@ -302,12 +302,15 @@ function guildSent(string $method, string $path): bool ->and($screen->instance()->guildReportOpen)->toBeFalse(); }); -it('shows the moderator Edit in the guild header, which opens the guild form', function () { +it('shows the moderator Edit in the guild header, a pill like Leave beside it, which opens the guild form', function () { fakeApi(['GET /api/v1/guilds/rust' => [boardOf(['c1'], overrides: ['can_moderate' => true, 'guild' => guildJson(['is_joined' => true])])]]); - finishRefreshes(Native::visit('/log/guilds/rust')) - ->assertSee('Edit') - ->tap('guild-edit') + $screen = finishRefreshes(Native::visit('/log/guilds/rust', platform: 'ios'))->assertSee('Edit'); + + expect(nodeByRef($screen, 'guild-edit-pill')['layout']['height'])->toEqual(nodeByRef($screen, 'guild-join-pill')['layout']['height']) + ->and(nodeByRef($screen, 'guild-edit-pill')['props']['glass'] ?? 0)->not->toBe(0); + + $screen->tap('guild-edit') ->assertNavigatedTo('/log/guilds/rust/edit', ['name' => 'Rust', 'description' => 'All about rust.', 'emoji' => '💻', 'iconUrl' => null]); }); diff --git a/tests/Feature/Screens/GuildPostTest.php b/tests/Feature/Screens/GuildPostTest.php index 01b7a2c0..183232bb 100644 --- a/tests/Feature/Screens/GuildPostTest.php +++ b/tests/Feature/Screens/GuildPostTest.php @@ -61,23 +61,42 @@ function pressEditOnToast(TestableComponent $screen, int $writeId): TestableComp return $screen->emitNative(ToastActionPressed::class, ['toastId' => 'toast-1', 'actionId' => 'edit', 'data' => ['write' => $writeId]]); } -it('offers Commit in the header, leaving Share alone in the bar', function () { +/** + * The guild page's nav bar actions, left to right, by id. The ⋯ menu's items aren't in it. + * + * @return array> + */ +function guildBar(TestableComponent $screen): array +{ + return collect($screen->tree()['children'] ?? []) + ->filter(fn (array $node): bool => ($node['type'] ?? null) === 'top_bar_action') + ->mapWithKeys(fn (array $node): array => [$node['props']['id'] => $node]) + ->all(); +} + +it('offers New commit in the bar before the ⋯, as the Log does, and not in the header', function (string $platform) { fakeApi(['GET /api/v1/guilds/rust' => [boardOf(['c1'])]]); - $screen = finishRefreshes(Native::visit('/log/guilds/rust'))->tap('guild-commit'); + $screen = finishRefreshes(Native::visit('/log/guilds/rust', platform: $platform)); + $compose = guildBar($screen)['compose'] ?? null; - expect(treeShows(nodeByRef($screen, 'guild-commit'), 'Commit'))->toBeTrue() - ->and(hasTopBarAction($screen, 'share'))->toBeTrue() - ->and(hasTopBarAction($screen, 'compose'))->toBeFalse() - ->and($screen->instance()->sheetOpen)->toBeTrue(); -}); + expect(array_keys(guildBar($screen)))->toBe(['compose', 'more']) + ->and($compose['props'] ?? null)->toMatchArray(['icon' => 'custom:square-pen', 'a11y_label' => 'New commit in #rust']) + ->and(rendersRef($screen, 'guild-commit'))->toBeFalse(); + + // Pressed as the nav bar does, at the action's own callback. + $screen->fireEvent('composeForGuild', TestableComponent::EVENT_PRESS, ['callback_id' => $compose['on_press']]); + + expect($screen->instance()->sheetOpen)->toBeTrue() + ->and(nodeByRef($screen, 'sheet')['props']['visible'])->toBeTrue(); +})->with(['ios', 'android']); -it('offers no Commit on a paused guild, as the web has no composer there', function () { +it('offers no New commit on a paused guild, as the web has no composer there', function () { fakeApi(['GET /api/v1/guilds/rust' => [boardOf(['c1'], overrides: ['guild' => guildJson(['is_paused' => true])])]]); $paused = finishRefreshes(Native::visit('/log/guilds/rust'))->call('composeForGuild'); - expect(rendersRef($paused, 'guild-commit'))->toBeFalse() + expect(array_keys(guildBar($paused)))->toBe(['more']) ->and($paused->instance()->sheetOpen)->toBeFalse(); }); diff --git a/tests/Feature/Screens/GuildTest.php b/tests/Feature/Screens/GuildTest.php index 0b83b051..e5ce88a7 100644 --- a/tests/Feature/Screens/GuildTest.php +++ b/tests/Feature/Screens/GuildTest.php @@ -1,6 +1,7 @@ and(kept('guilds/rust')['guild']['is_joined'])->toBeFalse(); }); +it('draws Join in your colour on glass on iOS, and Leave on clear glass, both 40pt pills as on a profile', function (string $platform, bool $glass) { + fakeApi([ + 'GET /api/v1/guilds/rust' => [boardOf(['c1'])], + 'POST /api/v1/guilds/rust/membership' => [null, 204], + ]); + + $screen = finishRefreshes(Native::visit('/log/guilds/rust', platform: $platform)); + $pill = nodeByRef($screen, 'guild-join-pill'); + $mine = config('native-ui.theme.light.'.Lane::token(app(Account::class)->user()?->lane())); + + expect((float) $pill['layout']['height'])->toBe(40.0) + ->and($pill['style']['bg_color'] ?? null)->toBe($mine) + ->and(($pill['props']['glass'] ?? 0) !== 0)->toBe($glass) + ->and(nodeByRef($screen, 'guild-join')['props'])->toMatchArray(['a11y_label' => 'Join', 'a11y_hint' => 'Joins #rust']); + + $pill = nodeByRef($screen->tap('guild-join'), 'guild-join-pill'); + + expect(treeShows($pill, 'Leave'))->toBeTrue() + ->and((float) $pill['layout']['height'])->toBe(40.0) + ->and(($pill['props']['glass'] ?? 0) !== 0)->toBe($glass) + ->and($pill['style']['bg_color'] ?? null)->toBe($glass ? null : config('native-ui.theme.light.surface-variant')) + ->and(nodeByRef($screen, 'guild-join')['props'])->toMatchArray(['a11y_label' => 'Leave', 'a11y_hint' => 'Leaves #rust']); +})->with(['iOS' => ['ios', true], 'Android' => ['android', false]]); + it('offers Join on a paused guild', function () { fakeApi(['GET /api/v1/guilds/rust' => [boardOf(['c1'], overrides: ['guild' => guildJson(['is_paused' => true])])]]);