Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions app/Devnull/Display.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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 : '';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion resources/views/native/commit-detail.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
@include('native.partials.composer-photos', ['photos' => $replyImages, 'photoRef' => 'reply-photo'])
@endif
</native:column>
<native:row native:key="reply-row" ref="reply-row" class="w-full px-4 py-2">
<native:row native:key="reply-row" ref="reply-row" class="w-full px-4 pb-2">
@php($hasDraft = trim($reply) !== '' || $replyImages !== [])
@php($photosFull = count($replyImages) >= \App\Devnull\DraftImages::MaxImages)
@include('native.partials.composer-box', [
Expand Down
2 changes: 1 addition & 1 deletion resources/views/native/conversation.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
--}}
<native:row native:key="message-row" ref="message-row" class="w-full px-4 py-2">
<native:row native:key="message-row" ref="message-row" class="w-full px-4 pb-2">
@include('native.partials.composer-box', [
'ref' => 'message',
'field' => $recorder === null ? 'native.partials.message-field' : 'native.partials.voice-recorder',
Expand Down
5 changes: 3 additions & 2 deletions resources/views/native/partials/composer-box.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ??= [])
<native:column native:key="{{ $ref }}-box" ref="{{ $ref }}-box" class="w-full">
<native:row native:key="{{ $ref }}-field-row" ref="{{ $ref }}-field-row" class="w-full pl-4 pr-3 pt-1">
<native:row native:key="{{ $ref }}-field-row" ref="{{ $ref }}-field-row" class="w-full pl-4 pr-3 pt-1 pb-2">
@include($field)
</native:row>
<native:row native:key="{{ $ref }}-actions" ref="{{ $ref }}-actions" class="w-full h-[40] pl-1 pr-[6] pb-1 gap-2 items-center">
Expand Down
26 changes: 26 additions & 0 deletions tests/Feature/Screens/CommitDetailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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'])]);

Expand Down
18 changes: 18 additions & 0 deletions tests/Feature/Screens/RemotesComposerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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);
Expand All @@ -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)
Expand All @@ -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'))
Expand Down
24 changes: 24 additions & 0 deletions tests/Support/GlassOpacity.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Tests\Support;

use Native\Mobile\Edge\TailwindParser;

/**
* Whether the installed mobile-air reads an opacity suffix on the glass class (glass/80, from
* NativePHP/mobile-air#735). Without it the composer bars' glass/N isn't parsed at all, so their glass tests skip.
*/
final class GlassOpacity
{
public static function supported(): bool
{
return array_key_exists('glassOpacity', TailwindParser::parse('glass/80'));
}

public static function skipUnlessSupported(): void
{
if (! self::supported()) {
test()->markTestSkipped('Needs a mobile-air that reads glass/N (NativePHP/mobile-air#735)');
}
}
}
Loading