diff --git a/app/Devnull/Display.php b/app/Devnull/Display.php index 6648e4e7..e4f75b03 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; /** @@ -50,6 +52,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. */ @@ -253,8 +278,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) @@ -302,6 +327,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, @@ -309,12 +406,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 @@ -333,6 +442,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/Conversation.php b/app/NativeComponents/Conversation.php index 3f8767e5..7ef029b1 100644 --- a/app/NativeComponents/Conversation.php +++ b/app/NativeComponents/Conversation.php @@ -1839,7 +1839,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 5d26c304..2096768d 100644 --- a/resources/views/native/commit-detail.blade.php +++ b/resources/views/native/commit-detail.blade.php @@ -135,8 +135,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 @@ -151,9 +153,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 @@ -164,7 +166,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 5191385f..e60c8a90 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/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 591eb7f1..e560f1b2 100644 --- a/tests/Feature/Screens/CommitDetailTest.php +++ b/tests/Feature/Screens/CommitDetailTest.php @@ -10,6 +10,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']); @@ -927,6 +928,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('ends the page above the reply bar, and further as the draft grows', function () { fakeThread(replies: [replyJson(['id' => 'r1', 'parent_id' => 'c2', 'body' => 'The last reply'])]); diff --git a/tests/Feature/Screens/CommitMentionsTest.php b/tests/Feature/Screens/CommitMentionsTest.php index 471b2886..1d8b3ffc 100644 --- a/tests/Feature/Screens/CommitMentionsTest.php +++ b/tests/Feature/Screens/CommitMentionsTest.php @@ -277,3 +277,9 @@ function mentionsComposer(bool $quoting = false, ?array $mentions = null): Testa 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/ConversationTest.php b/tests/Feature/Screens/ConversationTest.php index 4a22b9cc..542dfe4e 100644 --- a/tests/Feature/Screens/ConversationTest.php +++ b/tests/Feature/Screens/ConversationTest.php @@ -1390,3 +1390,12 @@ function orgWithMembers(array $people): array ->tap('mention-ada') ->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); +}); diff --git a/tests/Feature/Screens/RemotesComposerTest.php b/tests/Feature/Screens/RemotesComposerTest.php index 6e3e0079..5678df20 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'; @@ -341,6 +342,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]); @@ -468,3 +486,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); + } + } +}