diff --git a/app/Devnull/ComposerSheet.php b/app/Devnull/ComposerSheet.php new file mode 100644 index 00000000..8f08c2b6 --- /dev/null +++ b/app/Devnull/ComposerSheet.php @@ -0,0 +1,151 @@ +fieldHeight); + $bottom = max(0.0, $caret->bottom()); + + return [ + 'bottom' => $field > 0 ? min($bottom, $field) : $bottom, + 'line_height' => max(0.0, $caret->height), + 'field_height' => $field, + ]; + } + + /** + * The caret to keep after the field reports a new one. While the field is shorter for the list, it reports + * itself at that height, scrolled to the caret, which says nothing about where the caret is at its full height, + * so the sheet keeps what it had. Any other report is the field at its full height. + * + * @param array{bottom: float, line_height: float, field_height: float}|null $kept + * @param int|null $shortened how tall the sheet has made the field, or null when it fills + * @return array{bottom: float, line_height: float, field_height: float} + */ + public static function reported(Caret $caret, ?array $kept, ?int $shortened): array + { + if ($kept !== null && $shortened !== null && abs($caret->fieldHeight - $shortened) <= 1) { + return $kept; + } + + return self::caret($caret); + } + + /** The mention list's height with all its rows showing, up to six: its padding, its heading, then its rows. */ + public static function mentionHeight(int $rows, bool $heading = false): int + { + return self::MentionPadding + + ($heading ? self::MentionHeadingHeight : 0) + + min(max($rows, 1), self::MentionRowsShown) * self::MentionRowHeight; + } + + /** + * Where the mention list goes, and how tall the field is while it shows. + * + * - `field`: the field's height, or null when it fills as usual. + * - `top`: the list's top. + * - `height`: the list's height, or null when it runs down to the toolbar. + * + * With room for the whole list (up to six rows) between the caret's line and the field's bottom, it floats there + * over the field and nothing moves. Without it, the field ends on the caret's line, shortened by as much as the + * list needs but never under two lines, and the list starts under it and runs to the toolbar, over anything + * under the field (which comes up with the field's bottom). So the list never covers the caret's line. + * + * The room is measured to the field's bottom, since nothing reports how tall what's under it is. + * + * @param array{bottom: float, line_height: float, field_height: float}|null $caret + * @return array{field: int|null, top: int, height: int|null} + */ + public static function mentionLayout(?array $caret, int $rows, bool $heading = false): array + { + if ($caret === null || $caret['field_height'] <= 0) { + $line = $caret === null ? self::FirstLineHeight : (int) ceil($caret['bottom']); + + return ['field' => null, 'top' => self::FieldTop + $line + self::MentionGap, 'height' => null]; + } + + $list = self::mentionHeight($rows, $heading); + $field = (int) floor($caret['field_height']); + $bottom = (int) ceil($caret['bottom']); + $room = $field - $bottom - self::MentionGap - self::MentionInset; + + if ($room >= $list) { + return ['field' => null, 'top' => self::FieldTop + $bottom + self::MentionGap, 'height' => $list]; + } + + $line = $caret['line_height'] > 0 ? (int) ceil($caret['line_height']) : self::FirstLineHeight; + $shortened = max(self::MinFieldLines * $line, $field - self::MentionGap - self::MentionInset - $list); + + if ($shortened >= $bottom) { + // The caret is in the field's first lines already: shortening it frees nothing, so the list takes what + // room there is under the caret, at least a row. + return [ + 'field' => null, + 'top' => self::FieldTop + $bottom + self::MentionGap, + 'height' => max($room, self::MentionPadding + self::MentionRowHeight), + ]; + } + + return ['field' => $shortened, 'top' => self::FieldTop + $shortened + self::MentionGap, 'height' => null]; + } + + /** Whether the sheet's mention list has the "People you follow" heading: a bare "@" in a new commit. */ + public static function mentionHeading(?array $mention, string $view): bool + { + return ($mention['query'] ?? null) === '' && $view === 'compose'; + } +} diff --git a/app/Devnull/Display.php b/app/Devnull/Display.php index 24ed8091..765d915c 100644 --- a/app/Devnull/Display.php +++ b/app/Devnull/Display.php @@ -5,6 +5,8 @@ use App\Devnull\Data\CommitBody; use Carbon\CarbonImmutable; use Carbon\CarbonInterface; +use Native\Mobile\Edge\Elements\BottomBar; +use Native\Mobile\Facades\System; use Native\Mobile\Platform; /** @@ -58,6 +60,29 @@ final class Display */ public const int ComposerGlassOpacity = 80; + /** + * The first iOS whose scroll views draw a scroll edge effect under a bar (see hasScrollEdge()). + */ + public const int ScrollEdgeIosVersion = 26; + + /** + * Whether a composer's field and its row of tools sit in a rounded Liquid Glass box over the scroll edge effect, + * as in Messages (see composerInGlassBox()). Off, they sit straight on the effect. Only on iOS 26 and later. + */ + public const bool ComposerInGlassBox = true; + + /** + * Which scroll edge effect iOS 26 and later draw under a composer bar (see composerEdgeBlur()): "soft", the + * progressive blur under the system's own toolbars, or "hard", an opaque fade. + */ + public const string ComposerEdgeBlur = 'soft'; + + /** + * A bar holding partials/composer-box in its glass box with one line of draft: ComposerBoxBarHeight, plus the + * box's own padding over and under what it holds (see composerBox()). + */ + public const int ComposerGlassBoxBarHeight = 100; + /** * About how many characters fit on a line of the box's field, which runs the width of the box. */ @@ -264,8 +289,8 @@ public static function maskedKey(string $openSsh): string */ public static function replyBarClearance(string $draft, bool $hasPhotos = false, bool $describing = false): int { - return self::ComposerFadeHeight - + self::ComposerBoxBarHeight + return self::composerFadeHeight() + + self::composerBoxBarHeight() + self::composerBoxGrowth($draft) + ($hasPhotos ? self::ReplyBarPhotosHeight : 0) + ($hasPhotos && $describing ? self::ReplyBarDescriptionHeight : 0) @@ -313,6 +338,78 @@ public static function fadesInBar(): bool return Platform::isIos(); } + /** + * Whether the composer bars stand on iOS's own scroll edge effect: iOS 26 and later blur what scrolls under the + * bar, as under its own toolbars, from the bar's edge-blur attribute (see composerEdgeBlur()). That stands in for + * the fade and the tinted glass, so a bar there draws neither and lets the effect show. Older iOS keeps the fade + * over glass, and Android its fade over the surface. + * + * It needs a mobile-air that takes edge-blur on a bottom bar and says which iOS the phone runs + * (System::osVersion()). Without one this is false and every iOS keeps the fade. + */ + public static function hasScrollEdge(): bool + { + if (! Platform::isIos() + || ! method_exists(\Native\Mobile\System::class, 'osVersion') + || ! method_exists(BottomBar::class, 'edgeBlurStyle')) { + return false; + } + + return (int) System::osVersion() >= self::ScrollEdgeIosVersion; + } + + /** + * Whether a composer bar draws partials/composer-fade as its first row: on iOS, before the scroll edge effect. + */ + public static function fadeRowInBar(): bool + { + return self::fadesInBar() && ! self::hasScrollEdge(); + } + + /** + * Whether the composer's field and tools sit in a rounded Liquid Glass box on the bar (ComposerInGlassBox): on + * iOS 26 and later, over the scroll edge effect. Older iOS and Android draw them straight on the bar, as before. + */ + public static function composerInGlassBox(): bool + { + return self::ComposerInGlassBox && self::hasScrollEdge(); + } + + /** + * The classes for partials/composer-box's outer column. In the glass box it's rounded to match the send button + * inside it, which sits 8pt in from its right and bottom edges: the row of tools leaves 6pt at its end and 2pt + * under the button, and the box 2pt more under the row. + */ + public static function composerBox(): string + { + return self::composerInGlassBox() ? 'rounded-[24] glass pb-[2]' : ''; + } + + /** + * The padding over the field inside partials/composer-box. In the glass box the field sits as far under the + * box's top edge as the row of tools sits under the field, 16pt to the text either way. + */ + public static function composerFieldTop(): string + { + return self::composerInGlassBox() ? 'pt-2' : 'pt-1'; + } + + /** + * How tall a composer bar is with one line of draft (see ComposerBoxBarHeight and ComposerGlassBoxBarHeight). + */ + public static function composerBoxBarHeight(): int + { + return self::composerInGlassBox() ? self::ComposerGlassBoxBarHeight : self::ComposerBoxBarHeight; + } + + /** + * How tall the composer fade is where it's drawn: none where the scroll edge effect replaces it. + */ + public static function composerFadeHeight(): int + { + return self::hasScrollEdge() ? 0 : self::ComposerFadeHeight; + } + /** * The classes for a composer's native:bottom-bar. On iOS that's Liquid Glass: what scrolls under the bar shows * through it, blurred. A patched mobile-air draws the glass behind the whole bar, under the home indicator too, @@ -320,12 +417,24 @@ public static function fadesInBar(): bool * an element can't be faded, and stops short of the home indicator. The glass stops at ComposerGlassOpacity * percent (glass/N), so a little of the screen under the bar shows through. Android has no glass, so the bar * stays the surface there. + * + * From iOS 26 the bar's edge-blur takes the glass's place (see composerEdgeBlur()). */ public static function composerBarGlass(): string { return self::fadesInBar() ? 'glass/'.self::ComposerGlassOpacity : ''; } + /** + * The edge-blur attribute for a composer's native:bottom-bar: on iOS, ComposerEdgeBlur, so iOS 26 and later draw + * the system's scroll edge effect under the bar, and mobile-air leaves the bar's glass out there. Older iOS ignores + * it and keeps the glass. Android has no such effect, so nothing is asked there. + */ + public static function composerEdgeBlur(): string + { + return self::fadesInBar() ? self::ComposerEdgeBlur : ''; + } + /** * The composer bar's own classes. On Android it's the surface. On iOS it has no background at all: mobile-air * paints a bar's background colour behind the whole bar, which would cover the fade at its top, so the bar's @@ -344,6 +453,10 @@ public static function composerBar(): string */ public static function composerSurface(): string { + if (self::hasScrollEdge()) { + return ''; + } + return self::fadesInBar() ? 'bg-theme-surface/'.self::ComposerGlassTint : 'bg-theme-surface'; } diff --git a/app/NativeComponents/Concerns/OpensCommitSheet.php b/app/NativeComponents/Concerns/OpensCommitSheet.php index cb2ad637..9f771335 100644 --- a/app/NativeComponents/Concerns/OpensCommitSheet.php +++ b/app/NativeComponents/Concerns/OpensCommitSheet.php @@ -3,6 +3,7 @@ namespace App\NativeComponents\Concerns; use App\Devnull\Client; +use App\Devnull\ComposerSheet; use App\Devnull\Data\Commit; use App\Devnull\Data\Draft; use App\Devnull\Data\PollDraft; @@ -21,6 +22,7 @@ use Carbon\CarbonImmutable; use Closure; use Native\Mobile\Facades\System; +use Native\Mobile\UI\Caret; /** * The sheet under a commit (see partials/commit-sheet). Report commit, in the @@ -122,6 +124,14 @@ trait OpensCommitSheet */ public string $sheetBody = ''; + /** + * Where the sheet's field last said its caret is drawn at its full height, for the mention list to go under (see + * ComposerSheet). Null until it has said, and again once the sheet is gone. + * + * @var array{bottom: float, line_height: float, field_height: float}|null + */ + public ?array $sheetCaret = null; + /** * The handle of the organization the sheet posts as, or null for you (see PostAs). */ @@ -328,6 +338,33 @@ public function openScheduledCommits(): void $this->sheetOpen = false; } + /** + * The sheet's field drew its caret somewhere else: it moved, the text wrapped differently, or the field scrolled. + */ + public function sheetCaretMoved(Caret $caret): void + { + $this->sheetCaret = ComposerSheet::reported($caret, $this->sheetCaret, $this->sheetMentionLayout()['field'] ?? null); + } + + /** + * Where the sheet's mention list goes and how tall its field is meanwhile (see ComposerSheet::mentionLayout()), or + * null while there's no list. + * + * @return array{field: int|null, top: int, height: int|null}|null + */ + public function sheetMentionLayout(): ?array + { + if (($this->mention['field'] ?? null) !== 'sheetBody' || ($this->mentionPeople === [] && $this->mentionOrganizations === [])) { + return null; + } + + return ComposerSheet::mentionLayout( + $this->sheetCaret, + count($this->mentionPeople) + count($this->mentionOrganizations), + ComposerSheet::mentionHeading($this->mention, $this->sheetView), + ); + } + /** * Stashes the draft as it changes (see stashSheetDraft()). */ @@ -536,6 +573,7 @@ private function closeCommitSheet(): void { $this->sheetClosing = $this->sheetClosing || ($this->sheetOpen && System::isIos()); $this->sheetOpen = false; + $this->sheetCaret = null; $this->forgetMention('sheetBody'); } @@ -666,6 +704,7 @@ private function forgetCommitSheet(): void $this->reportReason = ''; $this->reportDetails = ''; $this->sheetBody = ''; + $this->sheetCaret = null; $this->sheetAuthor = null; $this->sheetRestored = false; $this->sheetError = null; diff --git a/app/NativeComponents/Conversation.php b/app/NativeComponents/Conversation.php index e615c5de..ce1cb605 100644 --- a/app/NativeComponents/Conversation.php +++ b/app/NativeComponents/Conversation.php @@ -1856,7 +1856,7 @@ private function longPins(): array */ private static function composerClearance(string $draft, bool $replying, bool $hasPhotos, bool $describing): int { - return Display::ComposerFadeHeight + self::ComposerBarHeight + Display::composerBoxGrowth($draft) + return Display::composerFadeHeight() + Display::composerBoxBarHeight() + Display::composerBoxGrowth($draft) + ($replying ? self::ReplyingBarHeight : 0) + ($hasPhotos ? self::PhotosHeight : 0) + ($hasPhotos && $describing ? self::DescriptionHeight : 0) diff --git a/resources/views/native/commit-detail.blade.php b/resources/views/native/commit-detail.blade.php index 8e9851ea..d5f4c550 100644 --- a/resources/views/native/commit-detail.blade.php +++ b/resources/views/native/commit-detail.blade.php @@ -106,8 +106,10 @@ The reply bar, drawn as the Remotes composer is: the field across the top and a row under it with the tools on the left and the round send button on the right (see partials/composer-box), with the page fading out above it (see partials/composer-fade). On iOS the bar is Liquid Glass, faded in at the top, so the page - shows through it blurred (see Display::composerBarGlass()). On Android it's the surface, painted from this - column. Either fills the strip under the home indicator. + shows through it blurred (see Display::composerBarGlass()). From iOS 26 the system's scroll edge effect + blurs the page under the bar instead, with no fade or glass (see Display::composerEdgeBlur()), and the + field and tools sit in a rounded glass box on it (Display::composerInGlassBox()). On Android it's the + surface, painted from this column. Either fills the strip under the home indicator. The bar does everything the composer sheet did for a reply, so a reply never needs the sheet, whose presenting takes the keyboard down and back up on both platforms. The photo button adds photos from the @@ -122,9 +124,9 @@ --}} @php($replyPostingMe = app(\App\Devnull\Account::class)->user()) @php($replyPostsAs = $replyPostingMe !== null && \App\Devnull\PostAs::offered($replyAuthor)) - + - @if (\App\Devnull\Display::fadesInBar()) + @if (\App\Devnull\Display::fadeRowInBar()) @include('native.partials.composer-fade', ['ref' => 'reply-fade', 'inBar' => true]) @endif @@ -140,7 +142,7 @@ otherwise take 10pt of the bar, and EDGE drops a height of 0. --}} @php($mentioning = ($mention['field'] ?? null) === 'reply' && ($mentionPeople !== [] || $mentionOrganizations !== [])) - + @include('native.partials.mention-suggestions', ['field' => 'reply', 'label' => 'Mention a developer']) @php($showsPhotos = $replyImages !== [] && ! $replyPreviewing) diff --git a/resources/views/native/conversation.blade.php b/resources/views/native/conversation.blade.php index 637911d2..07f45bf8 100644 --- a/resources/views/native/conversation.blade.php +++ b/resources/views/native/conversation.blade.php @@ -81,14 +81,17 @@ The composer: the field over a row holding the + and the round send button (see partials/composer-box), with the thread fading out above it (see partials/composer-fade) rather than meeting a line. On iOS the bar is Liquid Glass, faded in at the top, so the thread shows through it blurred (see - Display::composerBarGlass()). On Android it's the surface. Either fills the strip under the home indicator. + Display::composerBarGlass()). From iOS 26 the system's scroll edge effect blurs the thread under the bar + instead, with no fade or glass (see Display::composerEdgeBlur()), and the field and tools sit in a rounded + glass box on it (Display::composerInGlassBox()). On Android it's the surface. Either fills the strip under + the home indicator. The web's tools, photos, the microphone and Ping, open from the one +. Above the field sit the people to mention, what you're replying to and the photos on the draft. While the thread can't take a message, why goes in the field's place. --}} - + - @if (\App\Devnull\Display::fadesInBar()) + @if (\App\Devnull\Display::fadeRowInBar()) @include('native.partials.composer-fade', ['ref' => 'composer-fade', 'inBar' => true]) @endif @@ -100,10 +103,10 @@ h-[0.1]: on iOS an empty one otherwise takes 10 points of the bar, and EDGE drops a height of 0. --}} @php($mentioning = ($mention['field'] ?? null) === 'draft' && ($mentionPeople !== [] || $mentionOrganizations !== [])) - + @include('native.partials.mention-suggestions', ['field' => 'draft', 'heading' => ($mention['query'] ?? null) === '' ? 'Members' : null]) - + @if ($replyTo) diff --git a/resources/views/native/partials/commit-sheet.blade.php b/resources/views/native/partials/commit-sheet.blade.php index d0efea50..67e43903 100644 --- a/resources/views/native/partials/commit-sheet.blade.php +++ b/resources/views/native/partials/commit-sheet.blade.php @@ -28,11 +28,17 @@ A commit's page opens its reply here too, as "Reply to @handle", with the commit being answered as a static card over the field, for the photos and the preview its reply bar has no room for. Commit says Reply there. - While the caret is after an "@handle", the people to mention show right under the field, as the web's composer lists - them (see SuggestsMentions): for a bare "@" in a new commit, the people you follow, under that heading. The field - keeps the keyboard up through presses in the sheet (keep-focus), so picking someone leaves you typing after them. + While the caret is after an "@handle", the people to mention show as the web's composer lists them (see + SuggestsMentions): for a bare "@" in a new commit, the people you follow, under that heading. They float over the + field just under the caret's line, which the field reports (@caretChange), as tall as their rows, up to six. When + that doesn't fit above the field's bottom, the field gets shorter instead, ending on the caret's line, and the + list goes under it, down to the toolbar and over a quoted commit or poll (see ComposerSheet). The field fills + again once they're gone, and both moves are animated. The field keeps the keyboard up through presses in the sheet + (keep-focus), so picking someone leaves you typing after them. - Under what's being written come its photos and the poll editor. A toolbar is pinned to the bottom of the sheet, so + The sheet doesn't scroll. The field fills the space between the author row and the toolbar, less what's under it: + the photos as a strip of 80pt squares, the poll editor, the commit being quoted, or "Submit at", each at its own + height, with 12pt clear of the toolbar, as the field leaves under "Replying to". Only the field scrolls its text. A toolbar is pinned to the bottom of the sheet, so it stays just above the keyboard: the tools on the left, photos, the camera, a poll (not on a reply) and the preview, which shows the draft as the commit it would become in place of the field (see AttachesToCommits), and stash@{0} and the counter on the right. An issue draft has no tools, as on the web. With photos, Commit spins while @@ -72,72 +78,95 @@ @endif - - - @if ($postsAs) - - @include('native.partials.post-as', ['ref' => 'sheet-post-as', 'me' => $postingMe, 'picked' => $sheetAuthor, 'method' => 'postAsInSheet', 'size' => 36, 'withName' => true]) - - @endif - - @if ($sheetError) - {{ $sheetError }} - @endif + {{-- + Nothing here scrolls but the field (or the preview in its place). What's over the field and under + it take their own height, and the field (h-full in a flex-1 slot) takes what's left between them + and the toolbar. Each part has a keyed slot that's always drawn, empty or not, so the field never + moves among its siblings: Android rebuilds a node that does, and the keyboard goes down with it. + --}} + @php($sheetLayout = \App\Devnull\ComposerSheet::class) + @php($linkTooLong = ! $issueCommand && \App\Devnull\Data\CommitBody::hasOversizedUrl($sheetBody)) + @php($pollShown = $sheetPoll !== null && ! $replying) + @php($guildHint = $sheetGuild !== null && $sheetView === 'compose') + @php($offersIssues = ! $quoting && ! $scheduling && ! $replying && ! $issueCommand && $sheetGuild === null) + @php($issueCommands = $offersIssues && $sheetTyped ? \App\Devnull\IssueCommand::suggested($sheetBody) : []) + @php($issueHint = $offersIssues && ! $issueHintsDismissed ? \App\Devnull\IssueCommand::hinted($sheetBody) : null) + @php($hasAbove = $postsAs || $sheetError || $issueCommand || $replying) + + @if ($postsAs) + + @include('native.partials.post-as', ['ref' => 'sheet-post-as', 'me' => $postingMe, 'picked' => $sheetAuthor, 'method' => 'postAsInSheet', 'size' => 36, 'withName' => true]) + + @endif - @if ($issueCommand) - @include('native.partials.issue-badge', ['command' => $issueCommand]) - @endif + @if ($sheetError) + {{ $sheetError }} + @endif - @if ($replying) - @include('native.partials.quoted-commit', ['quoted' => $sheetCommit, 'static' => true, 'label' => 'Replying to']) - @endif + @if ($issueCommand) + @include('native.partials.issue-badge', ['command' => $issueCommand]) + @endif - @if ($previewing) - @include('native.partials.composer-preview', [ - 'ref' => 'sheet-draft', - 'body' => $sheetBody, - 'preview' => $sheetPreview, - 'images' => $sheetImages, - 'poll' => $replying ? null : $sheetPoll, - 'pollLength' => $sheetPollLength, - 'quoted' => $quoting ? $sheetCommit : null, - ]) - @else + @if ($replying) + @include('native.partials.quoted-commit', ['quoted' => $sheetCommit, 'static' => true, 'label' => 'Replying to']) + @endif + + @php($sheetMentionsShown = ! $previewing && ($mention['field'] ?? null) === 'sheetBody' && ($mentionPeople !== [] || $mentionOrganizations !== [])) + @php($sheetMentions = $sheetMentionsShown ? $sheetLayout::mentionLayout($sheetCaret, count($mentionPeople) + count($mentionOrganizations), $sheetLayout::mentionHeading($mention, $sheetView)) : null) + {{-- + animate-layout: when the mention list comes or goes (or photos, the poll, the preview), the field + slot's new height and the parts under it slide into place rather than jump. The parts keep their + keys, so they're matched from one frame to the next. + --}} + + @if ($previewing) + + + @include('native.partials.composer-preview', [ + 'ref' => 'sheet-draft', + 'body' => $sheetBody, + 'preview' => $sheetPreview, + 'images' => $sheetImages, + 'poll' => $replying ? null : $sheetPoll, + 'pollLength' => $sheetPollLength, + 'quoted' => $quoting ? $sheetCommit : null, + ]) + + + @else + {{-- Shorter while the mention list needs the room under it (see ComposerSheet::mentionLayout()), the slot keeps its key and place, so the field stays the same view. --}} + - - @include('native.partials.mention-suggestions', [ - 'field' => 'sheetBody', - 'heading' => ($mention['query'] ?? null) === '' && $sheetView === 'compose' ? 'People you follow' : null, - 'label' => 'Mention a developer', - 'class' => 'w-full py-1 rounded-md border border-theme-hairline bg-theme-surface', - ]) - - @if ($sheetGuild !== null && $sheetView === 'compose') + + @php($hasBelow = $guildHint || $linkTooLong || $sheetImages !== [] || $pollShown || $quoting || $scheduling || $issueCommands !== [] || $issueHint !== null) + + @if ($guildHint) Posted to this guild, not your profile log. @endif - @if (! $issueCommand && \App\Devnull\Data\CommitBody::hasOversizedUrl($sheetBody)) + @if ($linkTooLong) Each link must not be greater than {{ \App\Devnull\Data\BodyLink::MaxLength }} characters. @endif @include('native.partials.composer-photos') - @if ($sheetPoll !== null && ! $replying) + @if ($pollShown) @include('native.partials.poll-editor') @endif @@ -145,17 +174,39 @@ class="w-full text-theme-ink" @include('native.partials.quoted-commit', ['quoted' => $sheetCommit, 'static' => true]) @elseif ($scheduling) @include('native.partials.schedule-picker') - @elseif (! $replying && ! $issueCommand && $sheetGuild === null) - @include('native.partials.issue-suggestions', [ - 'suggestions' => $sheetTyped ? \App\Devnull\IssueCommand::suggested($sheetBody) : [], - 'hint' => $issueHintsDismissed ? null : \App\Devnull\IssueCommand::hinted($sheetBody), - ]) + @elseif ($offersIssues) + @include('native.partials.issue-suggestions', ['suggestions' => $issueCommands, 'hint' => $issueHint]) @endif - @endif + - - - {{-- Pinned under the scroll view, so it rides just above the keyboard, and above the home indicator without it. --}} + {{-- + The people to mention, out of the layout so nothing moves when they come and go unless the + field has to make room for them: just under the caret's line, as tall as their rows, or + under the shortened field down to the toolbar (see ComposerSheet::mentionLayout()). They + scroll inside past six rows, or when even the shortened field leaves less room. On Liquid + Glass on iOS, like the reply bar's, and on a raised surface on Android. + --}} + @if ($sheetMentions !== null) + + + @include('native.partials.mention-suggestions', [ + 'field' => 'sheetBody', + 'heading' => $sheetLayout::mentionHeading($mention, $sheetView) ? 'People you follow' : null, + 'label' => 'Mention a developer', + 'class' => 'w-full py-1', + // This scroll view scrolls them; the partial's own six-row one would be a second. + 'scrolls' => false, + ]) + + + @endif + @endif + + {{-- Pinned under the field and what's around it, so it rides just above the keyboard, and above the home indicator without it. --}} @unless ($issueCommand) diff --git a/resources/views/native/partials/composer-box.blade.php b/resources/views/native/partials/composer-box.blade.php index c706afc0..fb84f564 100644 --- a/resources/views/native/partials/composer-box.blade.php +++ b/resources/views/native/partials/composer-box.blade.php @@ -1,8 +1,10 @@ {{-- A composer bar's field, tools and send button, laid out the way the Claude and Messages apps lay theirs out: the field across the top, growing to its five lines, and under it a row with the tools on the left and a round send - button in your colour on the right. The same on both platforms. Nothing is drawn around them: they sit straight on - the bar, which is glass on iOS and the surface on Android, under the fade at its top (see partials/composer-fade). + button in your colour on the right. The same on both platforms. Before iOS 26 nothing is drawn around them: they sit + straight on the bar, which is glass on iOS and the surface on Android, under the fade at its top (see + partials/composer-fade). From iOS 26 they sit in a rounded Liquid Glass box over the system's scroll edge effect, + unless Display::ComposerInGlassBox is off (see Display::composerBox()). $ref names the box ("{$ref}-box", also its key, so the field keeps its place as rows above it come and go) and its rows ("{$ref}-field-row", "{$ref}-actions"). $field is the partial that draws the field, keyed itself, so it stays @@ -12,12 +14,13 @@ send-button's: its ref, label, method, and whether it can send yet. The field's text lines up with the tools' icons under it. The field sits a little nearer the fade above it than - the row under it: the row around the box has no top padding, and the field row leaves 8pt under the field. + the row under it: the row around the box has no top padding, and the field row leaves 8pt under the field. In the + glass box the field sits as far under the box's edge as above the tools (Display::composerFieldTop()). --}} @php($lead ??= []) @php($trail ??= []) - - + + @include($field) diff --git a/resources/views/native/partials/composer-fade.blade.php b/resources/views/native/partials/composer-fade.blade.php index 7a817f43..023b2a87 100644 --- a/resources/views/native/partials/composer-fade.blade.php +++ b/resources/views/native/partials/composer-fade.blade.php @@ -6,7 +6,8 @@ Where it goes depends on the platform (Display::fadesInBar()). On iOS the screen runs on under the bar, so the fade is the bar's first row ($inBar), over what runs under it, and the bar's glass fades in under it over the same height (see Display::composerBarGlass()). On Android the screen stops at the bar, so the fade lies over the foot of - the screen's scroll view, at the bottom of the stack around it. $ref names it. + the screen's scroll view, at the bottom of the stack around it. From iOS 26 there's no fade at all: the system's + scroll edge effect blurs what runs under the bar (Display::fadeRowInBar()). $ref names it. --}} @php($inBar ??= false) diff --git a/tests/Feature/Devnull/ComposerScrollEdgeTest.php b/tests/Feature/Devnull/ComposerScrollEdgeTest.php new file mode 100644 index 00000000..c56f3556 --- /dev/null +++ b/tests/Feature/Devnull/ComposerScrollEdgeTest.php @@ -0,0 +1,59 @@ +toBe($edge) + ->and(Display::fadeRowInBar())->toBe($platform === 'ios' && ! $edge) + ->and(Display::composerFadeHeight())->toBe($edge ? 0 : Display::ComposerFadeHeight) + ->and(Display::composerSurface() === '')->toBe($edge) + ->and(Display::composerInGlassBox())->toBe($edge && Display::ComposerInGlassBox) + ->and(Display::composerBoxBarHeight())->toBe($edge && Display::ComposerInGlassBox ? Display::ComposerGlassBoxBarHeight : Display::ComposerBoxBarHeight) + ->and(Display::composerBox() === '')->toBe(! ($edge && Display::ComposerInGlassBox)); + } finally { + System::rememberPlatform(null); + } + }); +})->with([ + 'iOS 18' => ['ios', '18.5', false], + 'iOS 26' => ['ios', '26.0', true], + 'iOS 26.1' => ['ios', '26.1', true], + 'iOS 27' => ['ios', '27.0.1', true], + 'Android 16' => ['android', '16', false], + 'Android 26' => ['android', '26', false], +]); + +it('asks iOS for the composer edge blur on the bar, over glass for older iOS, and Android for neither', function () { + System::rememberPlatform('ios'); + + try { + expect(Display::composerBarGlass())->toBe('glass/'.Display::ComposerGlassOpacity) + ->and(Display::composerEdgeBlur())->toBe(Display::ComposerEdgeBlur); + } finally { + System::rememberPlatform(null); + } + + System::rememberPlatform('android'); + + try { + expect(Display::composerBarGlass())->toBe('') + ->and(Display::composerEdgeBlur())->toBe(''); + } finally { + System::rememberPlatform(null); + } +}); + +it('asks for an edge blur mobile-air takes', function () { + expect(Display::ComposerEdgeBlur)->toBeIn(['soft', 'hard']); +}); + +it('keeps the glass box as tall as the bar it replaces, plus its own padding', function () { + // The field's padding over it grows from 4 to 8, and the box adds 2 under the row of tools. + expect(Display::ComposerGlassBoxBarHeight)->toBe(Display::ComposerBoxBarHeight + 4 + 2); +}); diff --git a/tests/Feature/Screens/CommitDetailTest.php b/tests/Feature/Screens/CommitDetailTest.php index 1044acb9..e429ab2b 100644 --- a/tests/Feature/Screens/CommitDetailTest.php +++ b/tests/Feature/Screens/CommitDetailTest.php @@ -12,6 +12,7 @@ use Native\Mobile\Events\Alert\ButtonPressed; use Native\Mobile\Testing\Native; use Tests\Support\GlassOpacity; +use Tests\Support\ScrollEdge; beforeEach(function () { config(['devnull.url' => 'http://devnull.test']); @@ -954,6 +955,36 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): expect($bottomBar['props']['glass_opacity'] ?? null)->toBe($platform === 'ios' ? Display::ComposerGlassOpacity / 100 : null); })->with(['ios', 'android']); +it('stands the reply bar on the scroll edge effect from iOS 26, with no fade or tint, and glass for older iOS', function () { + fakeThread(replies: [replyJson(['id' => 'r1', 'parent_id' => 'c2', 'body' => 'The last reply'])]); + + ScrollEdge::onIos('26.1', function (): void { + $screen = Native::visit('/log/commits/c2', platform: 'ios'); + $bottomBar = findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'bottom_bar'); + + // The bar asks for the edge effect and keeps its glass for older iOS, which mobile-air leaves out here. + // The field and tools sit in the glass box. The page ends where the bar starts, with no fade above it. + expect($bottomBar['props']['edge_blur'] ?? null)->toBe(Display::ComposerEdgeBlur) + ->and($bottomBar['props']['glass'] ?? null)->toBe(1) + ->and(childRefs($screen, 'reply-bar'))->toBe(['reply-rows']) + ->and(nodeByRef($screen, 'reply-rows')['style']['bg_color'] ?? null)->toBeNull() + ->and(findNode($screen->tree(), fn (array $node): bool => ($node['ref'] ?? null) === 'reply-fade'))->toBeNull() + ->and(nodeByRef($screen, 'reply-box')['props']['glass'] ?? null)->toBe(Display::ComposerInGlassBox ? 1 : null) + ->and(nodeByRef($screen, 'reply-bar-clearance')['layout']['height'])->toEqual(24 + Display::composerBoxBarHeight() + 34); + }); +}); + +it('keeps the fade at the top of the reply bar before iOS 26', function () { + fakeThread(); + + ScrollEdge::onIos('18.5', function (): void { + $screen = Native::visit('/log/commits/c2', platform: 'ios'); + + expect(childRefs($screen, 'reply-bar'))->toBe(['reply-fade', 'reply-rows']) + ->and(nodeByRef($screen, 'reply-box')['props']['glass'] ?? null)->toBeNull(); + }); +}); + it("keeps the reply bar's root full width and centres a readable column in it, for Android's full-width bar box", function (string $platform) { fakeThread(); diff --git a/tests/Feature/Screens/CommitMentionsTest.php b/tests/Feature/Screens/CommitMentionsTest.php index c8a4ef8a..69c2e0b0 100644 --- a/tests/Feature/Screens/CommitMentionsTest.php +++ b/tests/Feature/Screens/CommitMentionsTest.php @@ -1,9 +1,12 @@ 'http://devnull.test']); @@ -70,11 +73,11 @@ function mentionsCommitPage(?array $mentions = null): TestableComponent * The Log, with Ada's c1 in it and devnull's mention search answering, and the composer sheet open: for a new commit, * or for a quote of c1. */ -function mentionsComposer(bool $quoting = false): TestableComponent +function mentionsComposer(bool $quoting = false, ?array $mentions = null): TestableComponent { fakeApi([ 'GET /api/v1/log/following' => [pageJson([commitJson(['id' => 'c1', 'body' => 'Required reading.', 'author' => userJson(['id' => 'u2', 'handle' => 'ada', 'name' => 'Ada Lovelace'])])])], - 'GET /api/v1/search/mentions' => mentionsFound(), + 'GET /api/v1/search/mentions' => $mentions ?? mentionsFound(), ]); $screen = Native::visit('/log', platform: 'ios'); @@ -206,3 +209,95 @@ function mentionsComposer(bool $quoting = false): TestableComponent ->assertSet('mention', null) ->assertSet('mentionPeople', []); }); + +it('floats the suggestions over the quoted commit on glass, just under the caret line and as tall as their rows', function () { + $screen = mentionsComposer(quoting: true) + ->input('sheet-body', "see\n@a", 6) + ->moveCaretTo('sheet-body', new Caret(x: 20, y: 22, width: 2, height: 22, line: 1, fieldWidth: 350, fieldHeight: 240)); + $overlay = nodeByRef($screen, 'sheet-mentions'); + + // Out of the layout, over the field and the card under it, so neither moves. + expect($overlay['layout']['position_type'])->toBe(1) + ->and($overlay['layout']['position'])->toEqual([ + ComposerSheet::FieldTop + 44 + ComposerSheet::MentionGap, + 12, + null, + 12, + ]) + ->and($overlay['layout']['height'] ?? null)->toEqual(ComposerSheet::mentionHeight(3)) + // There's room for them under the caret, so the field still fills. + ->and(nodeByRef($screen, 'sheet-field-slot')['layout']['flex_grow'] ?? null)->toEqual(1) + ->and($overlay['props']['glass'])->toBe(1) + ->and(childRefs($screen, 'sheet-body-area'))->toBe(['sheet-field-slot', 'sheet-below', 'sheet-mentions']) + ->and(findNode(nodeByRef($screen, 'sheet-below'), fn (array $node): bool => ($node['ref'] ?? null) === 'quote-card'))->not->toBeNull() + // The list scrolls inside it when there are more than fit. + ->and(findNode($overlay, fn (array $node): bool => $node['type'] === 'scroll_view' && ($node['ref'] ?? null) === 'sheet-mentions-scroll'))->not->toBeNull() + ->and(childRefs($screen, 'mention-suggestions'))->toBe(['mention-ada', 'mention-adam', 'mention-adaptive']); +}); + +it('scrolls a long list of suggestions in the sheet with one scroll view, its own', function () { + $people = array_map(fn (int $n): array => userJson(['id' => "u{$n}", 'handle' => "ada{$n}", 'name' => "Ada {$n}"]), range(1, 9)); + $screen = mentionsComposer(mentions: [['data' => $people]]) + ->input('sheet-body', "see\n\n\n\n\n\n@a", 12) + ->moveCaretTo('sheet-body', new Caret(x: 20, y: 132, width: 2, height: 22, line: 6, fieldWidth: 350, fieldHeight: 240)); + $overlay = nodeByRef($screen, 'sheet-mentions'); + + // Nine rows is past the six the mention list scrolls by itself, but the sheet scrolls it already, so there is no + // second scroll view inside (two scroll bars on a short phone). + expect(findNodes($overlay, fn (array $node): bool => $node['type'] === 'scroll_view'))->toHaveCount(1) + ->and(nodeByRef($screen, 'sheet-mentions-scroll')['type'])->toBe('scroll_view') + ->and(rendersRef($screen, 'mention-scroll'))->toBeFalse() + ->and(childRefs($screen, 'mention-suggestions'))->toBe(array_map(fn (int $n): string => "mention-ada{$n}", range(1, 9))); +}); + +it('shortens the field to end on the caret line when the suggestions would not fit under it, and fills it again once they go', function () { + $screen = mentionsComposer(quoting: true)->input('sheet-body', "see\n\n\n\n\n\n\n\n@a", 14); + $field = idsDownTo($screen->tree(), 'sheet-body'); + + // The caret's line ends 20pt above the field's bottom, where three people don't fit. + $screen->moveCaretTo('sheet-body', new Caret(x: 20, y: 196, width: 2, height: 24, line: 8, fieldWidth: 350, fieldHeight: 240)); + $shortened = 240 - ComposerSheet::MentionGap - ComposerSheet::MentionInset - ComposerSheet::mentionHeight(3); + $overlay = nodeByRef($screen, 'sheet-mentions'); + + expect(nodeByRef($screen, 'sheet-field-slot')['layout']['height'] ?? null)->toEqual(ComposerSheet::FieldTop + $shortened) + ->and(nodeByRef($screen, 'sheet-field-slot')['layout']['flex_grow'] ?? 0)->toEqual(0) + // Under the shortened field, so off the caret's line, and down to the toolbar over the quoted commit. + ->and($overlay['layout']['position'])->toEqual([ComposerSheet::FieldTop + $shortened + ComposerSheet::MentionGap, 12, ComposerSheet::MentionInset, 12]) + ->and(childRefs($screen, 'sheet-body-area'))->toBe(['sheet-field-slot', 'sheet-below', 'sheet-mentions']) + ->and(idsDownTo($screen->tree(), 'sheet-body'))->toBe($field); + + // The shortened field reports its caret at its new height, which doesn't move anything. + $screen->moveCaretTo('sheet-body', new Caret(x: 20, y: $shortened - 24, width: 2, height: 24, line: 8, fieldWidth: 350, fieldHeight: $shortened)) + ->assertSet('sheetCaret', ['bottom' => 220.0, 'line_height' => 24.0, 'field_height' => 240.0]); + + // Picked, the list goes and the field fills again, the same view. + $screen->tap('mention-ada'); + expect(findNode($screen->tree(), fn (array $node): bool => ($node['ref'] ?? null) === 'sheet-mentions'))->toBeNull() + ->and(nodeByRef($screen, 'sheet-field-slot')['layout']['flex_grow'] ?? null)->toEqual(1) + ->and(nodeByRef($screen, 'sheet-field-slot')['layout'])->not->toHaveKey('height') + ->and(idsDownTo($screen->tree(), 'sheet-body'))->toBe($field); +}); + +it('animates the field and the suggestions moving in the sheet', function () { + LayoutAnimation::skipUnlessSupported(); + + expect(nodeByRef(mentionsComposer(), 'sheet-body-area')['props'])->toHaveKey('animate_layout', true); +}); + +it('draws the floating suggestions on a raised surface on Android', function () { + fakeApi([ + 'GET /api/v1/log/following' => [pageJson([])], + 'GET /api/v1/search/mentions' => mentionsFound(), + ]); + + $overlay = nodeByRef(Native::visit('/log', platform: 'android')->press('composeInSheet')->input('sheet-body', 'hi @a', 5), 'sheet-mentions'); + + expect($overlay['props'])->not->toHaveKey('glass') + ->and(strtolower($overlay['style']['bg_color']))->toBe(strtolower(config('native-ui.theme.light.surface'))); +}); + +it('leaves a gap between the suggestions and the reply box under them on iOS', function () { + $screen = mentionsCommitPage()->input('reply-input', 'thanks @ad', 10); + + expect(nodeByRef($screen, 'reply-mention-slot')['layout']['padding'][2])->toBe(8.0); +}); diff --git a/tests/Feature/Screens/ComposeSheetTest.php b/tests/Feature/Screens/ComposeSheetTest.php index 7158888c..9a5af929 100644 --- a/tests/Feature/Screens/ComposeSheetTest.php +++ b/tests/Feature/Screens/ComposeSheetTest.php @@ -1,11 +1,13 @@ 'http://devnull.test']); @@ -281,6 +283,52 @@ function sheetCommitDisabled(TestableComponent $screen): bool ->and(idsDownTo($screen->tree(), 'sheet-body'))->toBe($field); }); +it('fills the sheet with the field, with nothing scrolling around it', function () { + $screen = composeSheetOnLog(); + $field = nodeByRef($screen, 'sheet-body')['props']; + + expect(findNodes(nodeByRef($screen, 'sheet'), fn (array $node): bool => $node['type'] === 'scroll_view'))->toBe([]) + // As tall as the space between the author row and the toolbar, scrolling its own text. + ->and($field['fills_height'] ?? null)->toBeTrue() + ->and($field['min_lines'])->toBe(ComposerSheet::MinFieldLines) + ->and($field)->not->toHaveKey('max_lines') + ->and(nodeByRef($screen, 'sheet-field-slot')['layout']['flex_grow'] ?? null)->toEqual(1) + // It says where its caret is drawn, for the mention list. + ->and($field['on_caret_change'] ?? null)->toBeInt(); +}); + +it('puts the poll under the field, which gives up the room it takes', function () { + $screen = composeSheetOnLog()->tap('sheet-poll'); + + expect(childRefs($screen, 'sheet-body-area'))->toBe(['sheet-field-slot', 'sheet-below']) + ->and(findNode(nodeByRef($screen, 'sheet-below'), fn (array $node): bool => ($node['ref'] ?? null) === 'poll-editor'))->not->toBeNull(); +}); + +it('keeps where the field says its caret is until the sheet goes', function () { + $screen = composeSheetOnLog() + ->moveCaretTo('sheet-body', new Caret(y: 48, height: 24, line: 2, fieldWidth: 350, fieldHeight: 240)) + ->assertSet('sheetCaret', ['bottom' => 72.0, 'line_height' => 24.0, 'field_height' => 240.0]); + + $screen->press('hideCommitSheet')->assertSet('sheetCaret', null); +}); + +it('keeps the field the same view while photos, a poll and mentions come and go around it', function () { + fakeApi([ + 'GET /api/v1/log/following' => [pageJson([])], + 'GET /api/v1/search/mentions' => [['data' => [userJson(['id' => 'u9', 'handle' => 'ada'])], 'organizations' => []]], + ]); + $screen = Native::visit('/log', platform: 'ios')->press('composeInSheet'); + $field = idsDownTo($screen->tree(), 'sheet-body'); + + $screen->input('sheet-body', 'hi @a', 5); + expect(nodeByRef($screen, 'sheet-mentions'))->not->toBeEmpty() + ->and(idsDownTo($screen->tree(), 'sheet-body'))->toBe($field); + + $screen->input('sheet-body', 'hi', 2)->tap('sheet-poll'); + expect(nodeByRef($screen, 'poll-editor'))->not->toBeEmpty() + ->and(idsDownTo($screen->tree(), 'sheet-body'))->toBe($field); +}); + it('only commits from a sheet that has a composer in it', function () { fakeApi(['GET /api/v1/log/following' => [pageJson([commitJson(['id' => 'c1', 'author' => userJson(['id' => 'u2', 'handle' => 'ada'])])])]]); diff --git a/tests/Feature/Screens/ComposerPhotosTest.php b/tests/Feature/Screens/ComposerPhotosTest.php index 1bba8cca..5600ab62 100644 --- a/tests/Feature/Screens/ComposerPhotosTest.php +++ b/tests/Feature/Screens/ComposerPhotosTest.php @@ -41,11 +41,11 @@ function isTool(TestableComponent $screen, string $ref): bool return nodeByRef($screen, $ref)['type'] === 'pressable'; } -it('pins the toolbar under the scroll view, so it stays just above the keyboard', function () { +it('pins the toolbar under the field and what is around it, so it stays just above the keyboard', function () { $screen = composerOnLog(); $toolbar = nodeByRef($screen, 'sheet-toolbar'); - expect(findNode(nodeByRef($screen, 'sheet-composer'), fn (array $node): bool => ($node['ref'] ?? null) === 'sheet-toolbar'))->toBeNull() + expect(findNode(nodeByRef($screen, 'sheet-body-area'), fn (array $node): bool => ($node['ref'] ?? null) === 'sheet-toolbar'))->toBeNull() ->and(findNode($toolbar, fn (array $node): bool => ($node['ref'] ?? null) === 'sheet-tools'))->not->toBeNull() ->and(findNode($toolbar, fn (array $node): bool => ($node['ref'] ?? null) === 'sheet-preview'))->not->toBeNull(); }); diff --git a/tests/Feature/Screens/ConversationTest.php b/tests/Feature/Screens/ConversationTest.php index 9ada3351..9d2a9f55 100644 --- a/tests/Feature/Screens/ConversationTest.php +++ b/tests/Feature/Screens/ConversationTest.php @@ -1396,6 +1396,15 @@ function orgWithMembers(array $people): array ->assertSet('draft', 'hi'); }); +it('leaves a gap between the suggestions and the message box under them on iOS', function () { + serveOrgThread(orgWithMembers([['ada', 'Ada Lovelace']])); + + $screen = finishRefreshes(Native::visit('/remotes/orgs/org-1', platform: 'ios'))->input('message-input', '@ADA', 4); + + expect(childRefs($screen, 'mention-suggestions'))->not->toBe([]) + ->and(nodeByRef($screen, 'mention-slot')['layout']['padding'][2])->toBe(8.0); +}); + /** * A message's photos as devnull sends them: $count of them, numbered from $first, the first described. * diff --git a/tests/Feature/Screens/QuoteTest.php b/tests/Feature/Screens/QuoteTest.php index 3ce4a7b5..38d28c21 100644 --- a/tests/Feature/Screens/QuoteTest.php +++ b/tests/Feature/Screens/QuoteTest.php @@ -211,3 +211,13 @@ function quoteButtonDisabled(TestableComponent $screen): bool expect(nodeByRef($screen, 'sheet')['props']['visible'])->toBeFalse() ->and($screen->instance()->commit->id)->toBe('c2'); }); + +it('puts the quoted commit right under the field, which gives up the room it takes', function () { + $screen = quoteSheetOnLog(); + + expect(childRefs($screen, 'sheet-below'))->toBe(['quote-card']) + ->and(childRefs($screen, 'sheet-body-area'))->toBe(['sheet-field-slot', 'sheet-below']) + ->and(nodeByRef($screen, 'sheet-body')['props']['fills_height'] ?? null)->toBeTrue() + // [top, right, bottom, left]: the card keeps clear of the toolbar, as the field does of "Replying to". + ->and(nodeByRef($screen, 'sheet-below')['layout']['padding'])->toEqual([12, 20, 12, 20]); +}); diff --git a/tests/Feature/Screens/RemotesComposerTest.php b/tests/Feature/Screens/RemotesComposerTest.php index c0173491..e8948222 100644 --- a/tests/Feature/Screens/RemotesComposerTest.php +++ b/tests/Feature/Screens/RemotesComposerTest.php @@ -11,6 +11,7 @@ use Native\Mobile\Testing\Native; use Native\Mobile\Testing\TestableComponent; use Tests\Support\GlassOpacity; +use Tests\Support\ScrollEdge; const ComposerViewerId = '0199e5c4-0000-7000-8000-000000000001'; @@ -343,6 +344,23 @@ function threadWithAda(string $platform = 'ios'): TestableComponent } })->with(['ios', 'android']); +it('stands the message bar on the scroll edge effect from iOS 26, with no fade or tint', function () { + serveThreadWithAda([remoteMessageJson(['id' => 1])], ['read_through_id' => 1]); + + ScrollEdge::onIos('26.0', function (): void { + $screen = threadWithAda(); + $bottomBar = findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'bottom_bar'); + + expect($bottomBar['props']['edge_blur'] ?? null)->toBe(Display::ComposerEdgeBlur) + ->and(nodeByRef($screen, 'message-box')['props']['glass'] ?? null)->toBe(Display::ComposerInGlassBox ? 1 : null) + ->and(childRefs($screen, 'composer-bar'))->toBe(['composer-rows']) + ->and(nodeByRef($screen, 'composer-bar')['style']['bg_color'] ?? null)->toBeNull() + ->and(nodeByRef($screen, 'composer-rows')['style']['bg_color'] ?? null)->toBeNull() + ->and(findNode($screen->tree(), fn (array $node): bool => ($node['ref'] ?? null) === 'composer-fade'))->toBeNull() + ->and(nodeByRef($screen, 'composer-clearance')['layout']['height'] ?? null)->toEqual(Display::composerBoxBarHeight() + 8); + }); +}); + it('fades to the dark surface in dark mode, and draws again when the phone switches', function () { serveThreadWithAda([remoteMessageJson(['id' => 1])], ['read_through_id' => 1]); @@ -470,3 +488,11 @@ function threadWithAda(string $platform = 'ios'): TestableComponent expect(sentTo('POST', 'remotes/orgs/org-1/ping'))->toBe(['']); }); + +it('leaves a gap between what you are replying to and the message box under it on iOS', function () { + serveThreadWithAda([remoteMessageJson(['id' => 1])], ['read_through_id' => 1]); + + $screen = threadWithAda()->trigger('swipe-1')->assertSee('Replying to Ada Lovelace'); + + expect(nodeByRef($screen, 'replying-slot')['layout']['padding'][2])->toBe(8.0); +}); diff --git a/tests/Support/ScrollEdge.php b/tests/Support/ScrollEdge.php new file mode 100644 index 00000000..13616b6f --- /dev/null +++ b/tests/Support/ScrollEdge.php @@ -0,0 +1,48 @@ +markTestSkipped('Needs a mobile-air with edge-blur on a bottom bar and System::osVersion()'); + } + } + + /** + * Run $test as on a phone with this iOS, then forget it again. + * + * @template T + * + * @param callable(): T $test + * @return T + */ + public static function onIos(string $version, callable $test): mixed + { + self::skipUnlessSupported(); + + System::rememberOsVersion($version); + + try { + return $test(); + } finally { + System::rememberOsVersion(null); + } + } +} diff --git a/tests/Unit/Devnull/ComposerSheetTest.php b/tests/Unit/Devnull/ComposerSheetTest.php new file mode 100644 index 00000000..c5cdf23f --- /dev/null +++ b/tests/Unit/Devnull/ComposerSheetTest.php @@ -0,0 +1,83 @@ +toBe([ + 'field' => null, + 'top' => ComposerSheet::FieldTop + 72 + ComposerSheet::MentionGap, + 'height' => ComposerSheet::MentionPadding + 3 * ComposerSheet::MentionRowHeight, + ]); +}); + +it('holds the list to six rows, plus its heading, and scrolls the rest', function () { + expect(ComposerSheet::mentionHeight(10))->toBe(ComposerSheet::MentionPadding + 6 * ComposerSheet::MentionRowHeight) + ->and(ComposerSheet::mentionHeight(2, heading: true))->toBe(ComposerSheet::MentionPadding + ComposerSheet::MentionHeadingHeight + 2 * ComposerSheet::MentionRowHeight); +}); + +it('shortens the field to end on the caret\'s line when the list would not fit under it, and puts the list under the field', function () { + // The caret low in the field, as in build 42: six people need 272pt, and there's 360 - 300 under the caret. + $layout = ComposerSheet::mentionLayout(composerCaret(300), rows: 8); + $list = ComposerSheet::mentionHeight(8); + $field = 360 - ComposerSheet::MentionGap - ComposerSheet::MentionInset - $list; + + expect($layout)->toBe(['field' => $field, 'top' => ComposerSheet::FieldTop + $field + ComposerSheet::MentionGap, 'height' => null]) + // The list starts under the caret's line, never over it: the field ends on that line. + ->and($layout['top'])->toBeGreaterThan(ComposerSheet::FieldTop + $layout['field']) + // And the list has its six rows from there to the toolbar. + ->and(ComposerSheet::FieldTop + 360 - ComposerSheet::MentionInset - $layout['top'])->toBe($list); +}); + +it('shortens the field only as far as the list needs', function () { + $layout = ComposerSheet::mentionLayout(composerCaret(300), rows: 2); + + expect($layout['field'])->toBe(360 - ComposerSheet::MentionGap - ComposerSheet::MentionInset - ComposerSheet::mentionHeight(2)) + ->and($layout['field'])->toBeLessThan(300); +}); + +it('keeps two lines of field on a short phone, and the list scrolls in what\'s left', function () { + $layout = ComposerSheet::mentionLayout(composerCaret(140, fieldHeight: 160), rows: 6); + + expect($layout)->toBe(['field' => ComposerSheet::MinFieldLines * 24, 'top' => ComposerSheet::FieldTop + 48 + ComposerSheet::MentionGap, 'height' => null]); +}); + +it('leaves the field alone when the caret is already in its first lines', function () { + $layout = ComposerSheet::mentionLayout(composerCaret(24, fieldHeight: 160), rows: 6); + + expect($layout['field'])->toBeNull() + ->and($layout['top'])->toBe(ComposerSheet::FieldTop + 24 + ComposerSheet::MentionGap) + ->and($layout['height'])->toBe(160 - 24 - ComposerSheet::MentionGap - ComposerSheet::MentionInset); +}); + +it('keeps where the caret is at the field\'s full height while the field is shortened', function () { + $kept = composerCaret(300); + $shortened = ComposerSheet::mentionLayout($kept, rows: 8)['field']; + + // The shortened field reports itself scrolled to the caret: that's not where the caret is at full height. + expect(ComposerSheet::reported(new Caret(y: $shortened - 24, height: 24, fieldHeight: $shortened), $kept, $shortened))->toBe($kept) + // A report at another height is the field at its full height again. + ->and(ComposerSheet::reported(new Caret(y: 48, height: 24, fieldHeight: 360), $kept, $shortened))->toBe(composerCaret(72)) + ->and(ComposerSheet::reported(new Caret(y: 48, height: 24, fieldHeight: 360), $kept, null))->toBe(composerCaret(72)); +}); + +it('keeps a caret the field has scrolled out of view to the field\'s edges', function () { + expect(ComposerSheet::caret(new Caret(y: -60, height: 24, fieldHeight: 300)))->toBe(['bottom' => 0.0, 'line_height' => 24.0, 'field_height' => 300.0]) + ->and(ComposerSheet::caret(new Caret(y: 400, height: 24, fieldHeight: 300)))->toBe(['bottom' => 300.0, 'line_height' => 24.0, 'field_height' => 300.0]); +}); + +it('puts the list under about one line, down to the toolbar, before the field has said where its caret is', function () { + expect(ComposerSheet::mentionLayout(null, rows: 3))->toBe([ + 'field' => null, + 'top' => ComposerSheet::FieldTop + ComposerSheet::FirstLineHeight + ComposerSheet::MentionGap, + 'height' => null, + ]); +});