diff --git a/app/Devnull/Display.php b/app/Devnull/Display.php index a6aeb0bb..6648e4e7 100644 --- a/app/Devnull/Display.php +++ b/app/Devnull/Display.php @@ -44,6 +44,12 @@ final class Display */ public const int ComposerGlassTint = 40; + /** + * How opaque, in percent, the glass under a composer bar gets on iOS once it has faded in (glass/N, see + * composerBarGlass()). Full glass over a dark screen reads as a heavy slab. + */ + public const int ComposerGlassOpacity = 80; + /** * About how many characters fit on a line of the box's field, which runs the width of the box. */ @@ -300,12 +306,13 @@ public static function fadesInBar(): bool * 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, * and fades it in over the bar's top ComposerFadeHeight points, so it has no hard top edge. EDGE's own glass on - * an element can't be faded, and stops short of the home indicator. Android has no glass, so the bar stays the - * surface there. + * 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. */ public static function composerBarGlass(): string { - return self::fadesInBar() ? 'glass' : ''; + return self::fadesInBar() ? 'glass/'.self::ComposerGlassOpacity : ''; } /** diff --git a/resources/views/native/commit-detail.blade.php b/resources/views/native/commit-detail.blade.php index bf62a9b4..5d26c304 100644 --- a/resources/views/native/commit-detail.blade.php +++ b/resources/views/native/commit-detail.blade.php @@ -173,7 +173,7 @@ @include('native.partials.composer-photos', ['photos' => $replyImages, 'photoRef' => 'reply-photo']) @endif - + @php($hasDraft = trim($reply) !== '' || $replyImages !== []) @php($photosFull = count($replyImages) >= \App\Devnull\DraftImages::MaxImages) @include('native.partials.composer-box', [ diff --git a/resources/views/native/conversation.blade.php b/resources/views/native/conversation.blade.php index e5642545..5191385f 100644 --- a/resources/views/native/conversation.blade.php +++ b/resources/views/native/conversation.blade.php @@ -124,7 +124,7 @@ The box keeps its row, and the row its place among the bar's, so the field inside never moves. A voice note takes the field's place, and the +'s, while it's recorded and waits to be pushed. --}} - + @include('native.partials.composer-box', [ 'ref' => 'message', 'field' => $recorder === null ? 'native.partials.message-field' : 'native.partials.voice-recorder', diff --git a/resources/views/native/partials/composer-box.blade.php b/resources/views/native/partials/composer-box.blade.php index 5cb53133..c706afc0 100644 --- a/resources/views/native/partials/composer-box.blade.php +++ b/resources/views/native/partials/composer-box.blade.php @@ -11,12 +11,13 @@ row, ahead of the tools, and for the end, left of the send button, such as the count of a long draft. $send is 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'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. --}} @php($lead ??= []) @php($trail ??= []) - + @include($field) diff --git a/tests/Feature/Screens/CommitDetailTest.php b/tests/Feature/Screens/CommitDetailTest.php index 8b692e51..591eb7f1 100644 --- a/tests/Feature/Screens/CommitDetailTest.php +++ b/tests/Feature/Screens/CommitDetailTest.php @@ -9,6 +9,7 @@ use Illuminate\Support\Facades\Http; use Native\Mobile\Events\Alert\ButtonPressed; use Native\Mobile\Testing\Native; +use Tests\Support\GlassOpacity; beforeEach(function () { config(['devnull.url' => 'http://devnull.test']); @@ -868,6 +869,10 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): it('puts the reply bar on glass on iOS and the surface on Android, with no line, and fades the page out above it', function (string $platform) { fakeThread(); + if ($platform === 'ios') { + GlassOpacity::skipUnlessSupported(); + } + $screen = Native::visit('/log/commits/c2', platform: $platform); $bottomBar = findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'bottom_bar'); $bar = $bottomBar['children'][0]; @@ -901,6 +906,27 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): } })->with(['ios', 'android']); +it('keeps the reply field closer to the fade than to the row of tools under it', function (string $platform) { + fakeThread(); + + $screen = Native::visit('/log/commits/c2', platform: $platform); + + // [top, right, bottom, left]. The row has no top padding, so the field starts 4pt under the fade, and the field + // row leaves 8pt between the field and the tools. + expect(nodeByRef($screen, 'reply-row')['layout']['padding'])->toEqual([0, 16, 8, 16]) + ->and(nodeByRef($screen, 'reply-field-row')['layout']['padding'])->toEqual([4, 12, 8, 16]); +})->with(['ios', 'android']); + +it('fades the glass under the reply bar to 80% on iOS only', function (string $platform) { + GlassOpacity::skipUnlessSupported(); + fakeThread(); + + $screen = Native::visit('/log/commits/c2', platform: $platform); + $bottomBar = findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'bottom_bar'); + + expect($bottomBar['props']['glass_opacity'] ?? null)->toBe($platform === 'ios' ? Display::ComposerGlassOpacity / 100 : null); +})->with(['ios', 'android']); + 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/RemotesComposerTest.php b/tests/Feature/Screens/RemotesComposerTest.php index 637ed790..6e3e0079 100644 --- a/tests/Feature/Screens/RemotesComposerTest.php +++ b/tests/Feature/Screens/RemotesComposerTest.php @@ -10,6 +10,7 @@ use Native\Mobile\Facades\System; use Native\Mobile\Testing\Native; use Native\Mobile\Testing\TestableComponent; +use Tests\Support\GlassOpacity; const ComposerViewerId = '0199e5c4-0000-7000-8000-000000000001'; @@ -285,7 +286,22 @@ function threadWithAda(string $platform = 'ios'): TestableComponent ->and(nodeByRef($screen, 'push')['props']['a11y_label'] ?? nodeByRef($screen, 'push')['a11y_label'] ?? null)->toBe('Push'); })->with(['ios', 'android']); +it('keeps the field closer to the fade than to the + and Push under it', function (string $platform) { + serveThreadWithAda([remoteMessageJson(['id' => 1])], ['read_through_id' => 1]); + + $screen = threadWithAda($platform); + + // [top, right, bottom, left]. As on a commit's reply bar: no top padding on the row, so the field starts 4pt + // under the fade, and 8pt between the field and the row under it. + expect(nodeByRef($screen, 'message-row')['layout']['padding'])->toEqual([0, 16, 8, 16]) + ->and(nodeByRef($screen, 'message-field-row')['layout']['padding'])->toEqual([4, 12, 8, 16]); +})->with(['ios', 'android']); + it('puts the bar on glass on iOS and the surface on Android, with no box or line, and fades the thread out above it', function (string $platform) { + if ($platform === 'ios') { + GlassOpacity::skipUnlessSupported(); + } + serveThreadWithAda([remoteMessageJson(['id' => 1])], ['read_through_id' => 1]); $screen = threadWithAda($platform); @@ -306,6 +322,7 @@ function threadWithAda(string $platform = 'ios'): TestableComponent // top, ending at the glass's tint, and its rows carry the tint, in either appearance. The bar itself has no // background, which iOS would paint behind the fade. expect($bottomBar['props']['glass'] ?? null)->toBe(1) + ->and($bottomBar['props']['glass_opacity'] ?? null)->toBe(Display::ComposerGlassOpacity / 100) ->and(childRefs($screen, 'composer-bar'))->toBe(['composer-fade', 'composer-rows']) ->and($bar['style']['bg_color'] ?? null)->toBeNull() ->and(nodeByRef($screen, 'composer-rows')['style']['bg_color'] ?? null)->toBe('#66'.$surface) @@ -315,6 +332,7 @@ function threadWithAda(string $platform = 'ios'): TestableComponent } else { // No glass on Android. The thread stops at the bar, so the fade lies over its foot, and the bar is the surface. expect($bottomBar['props']['glass'] ?? null)->toBeNull() + ->and($bottomBar['props']['glass_opacity'] ?? null)->toBeNull() ->and(childRefs($screen, 'composer-bar'))->toBe(['composer-rows']) ->and($bar['style']['bg_color'] ?? null)->toBe(config('native-ui.theme.light.surface')) ->and(nodeByRef($screen, 'composer-rows')['style']['bg_color'] ?? null)->toBe(config('native-ui.theme.light.surface')) diff --git a/tests/Support/GlassOpacity.php b/tests/Support/GlassOpacity.php new file mode 100644 index 00000000..4acf0dac --- /dev/null +++ b/tests/Support/GlassOpacity.php @@ -0,0 +1,24 @@ +markTestSkipped('Needs a mobile-air that reads glass/N (NativePHP/mobile-air#735)'); + } + } +}