diff --git a/app/Devnull/Data/Commit.php b/app/Devnull/Data/Commit.php
index 6d19fdde..941f4ce3 100644
--- a/app/Devnull/Data/Commit.php
+++ b/app/Devnull/Data/Commit.php
@@ -34,13 +34,6 @@
*/
public const int CountFrom = 200;
- /**
- * A list shows a body longer than this, or longer than PreviewLines lines, as its start and "Show more".
- */
- public const int PreviewLength = 280;
-
- public const int PreviewLines = 8;
-
/**
* The status of a commit you made that devnull doesn't have yet, which
* stands in for it on the screen (see PendingWrite::stagedCommit()).
@@ -211,18 +204,6 @@ public static function fits(string $body): bool
&& ! CommitBody::hasOversizedUrl($body);
}
- /**
- * Whether a list would show only the start of a body, as the web's composer
- * works it out: more than PreviewLength characters or PreviewLines lines,
- * once blank lines in a run are counted as one.
- */
- public static function isFoldedInLists(string $body): bool
- {
- $normalized = CommitBody::normalize($body);
-
- return mb_strlen($normalized) > self::PreviewLength || count(explode("\n", $normalized)) > self::PreviewLines;
- }
-
/**
* This commit with $update applied to the replies under it, as a feed draws them.
*
diff --git a/app/Devnull/Display.php b/app/Devnull/Display.php
index 09d43f94..e07528b6 100644
--- a/app/Devnull/Display.php
+++ b/app/Devnull/Display.php
@@ -5,6 +5,7 @@
use App\Devnull\Data\CommitBody;
use Carbon\CarbonImmutable;
use Carbon\CarbonInterface;
+use Native\Mobile\Platform;
/**
* How the machine prints things: relative times and short hashes, as the web does.
@@ -28,6 +29,29 @@ final class Display
*/
public const int ReplyBarStashLabelHeight = 28;
+ /**
+ * A bar holding partials/composer-box with one line of draft, as drawn on an iPhone: the bar's padding, then the
+ * field over the row of tools and the send button.
+ */
+ public const int ComposerBoxBarHeight = 94;
+
+ /**
+ * The fade over the foot of a screen, just above its composer bar (see partials/composer-fade). On iOS the glass
+ * under the bar fades in over the same height (see composerBarGlass()).
+ */
+ public const int ComposerFadeHeight = 28;
+
+ /**
+ * How much of the surface, in percent, tints the glass under a composer bar on iOS (see composerSurface()).
+ */
+ public const int ComposerGlassTint = 40;
+
+ /**
+ * About how many characters fit on a line of the box's field. It runs the width of the box, so more fit than
+ * beside the reply bar's tools and button.
+ */
+ public const int ComposerBoxCharactersPerLine = 46;
+
/**
* The strip under the home indicator on Face ID iPhones. EDGE doesn't
* hand pushed screens the real inset (it's 0 inside a tab), so this errs
@@ -230,6 +254,79 @@ public static function replyBarClearance(string $draft, bool $draftRow = false):
+ self::HomeIndicatorHeight;
}
+ /**
+ * How much taller a composer-box bar is than with one line, as the draft grows to its five lines. A screen pads
+ * its end by this on top of ComposerBoxBarHeight to keep its last row clear of the bar.
+ */
+ public static function composerBoxGrowth(string $draft): int
+ {
+ return (min(self::ReplyBarMaxLines, self::lineCount($draft, self::ComposerBoxCharactersPerLine)) - 1) * self::ReplyBarLineHeight;
+ }
+
+ /**
+ * The fade's classes (see partials/composer-fade): a gradient down from see-through to the bar's surface, where
+ * the bar's rows start. EDGE takes a gradient's stops as they are, without the dark companion a theme colour gets,
+ * so the stops are the surface of the appearance the phone is in now, and a screen with the fade draws again when
+ * that changes (see RedrawsOnAppearanceChange).
+ *
+ * On Android it climbs to 70% of the surface by halfway and ends solid, so what's under it has mostly faded before
+ * it reaches the bar. On iOS it ends at the glass's tint (composerSurface()), since the bar is glass there and the
+ * glass fades in under it over the same height.
+ */
+ public static function composerFade(): string
+ {
+ $surface = strtolower((string) theme('surface', '#ffffff'));
+
+ if (self::fadesInBar()) {
+ return "bg-gradient-to-b from-{$surface}/0 to-{$surface}/".self::ComposerGlassTint;
+ }
+
+ return "bg-gradient-to-b from-{$surface}/0 via-{$surface}/70 to-{$surface}";
+ }
+
+ /**
+ * Whether the fade goes at the top of the composer bar itself, rather than over the foot of the screen above it.
+ * On iOS the screen runs on under its bottom bar, so a fade lying over the screen's foot would be under the bar,
+ * and the bar has to draw it. On Android the screen stops where the bar starts, so the fade lies over the screen.
+ */
+ public static function fadesInBar(): bool
+ {
+ return Platform::isIos();
+ }
+
+ /**
+ * 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.
+ */
+ public static function composerBarGlass(): string
+ {
+ return self::fadesInBar() ? 'glass' : '';
+ }
+
+ /**
+ * 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
+ * rows carry the tint instead (composerSurface()).
+ */
+ public static function composerBar(): string
+ {
+ return self::fadesInBar() ? '' : 'bg-theme-surface';
+ }
+
+ /**
+ * The classes for the rows of a composer bar, under its fade. On Android it's the surface. On iOS it's the
+ * surface at ComposerGlassTint percent, which tints the glass behind the bar to the screen's own colour, so in
+ * dark mode the bar doesn't come out lighter than the screen. A fill reaches under the home indicator, so the
+ * tint runs on there with the glass.
+ */
+ public static function composerSurface(): string
+ {
+ return self::fadesInBar() ? 'bg-theme-surface/'.self::ComposerGlassTint : 'bg-theme-surface';
+ }
+
/**
* About how many lines some text wraps to where $perLine characters fit on one, counting each of its own lines.
*/
diff --git a/app/Devnull/DraftImages.php b/app/Devnull/DraftImages.php
index cf3b3042..852eb88b 100644
--- a/app/Devnull/DraftImages.php
+++ b/app/Devnull/DraftImages.php
@@ -98,6 +98,10 @@ public function keep(string $path): DraftImage
throw new InvalidDraftImage(self::Unreadable);
}
+ // A moved file keeps its own time, which for a photo from the library can be years ago. Until the draft holds
+ // it, nothing does, so the next photo picked with it would prune it as long forgotten.
+ @touch($kept);
+
return new DraftImage($kept, self::Types[$info[2]], $info[0], $info[1]);
}
diff --git a/app/Icons/Lucide.php b/app/Icons/Lucide.php
index b6ea5bb9..06a56187 100644
--- a/app/Icons/Lucide.php
+++ b/app/Icons/Lucide.php
@@ -49,7 +49,6 @@ enum Lucide
case UserPlus;
case UserCheck;
case AtSign;
- case FoldVertical;
case Award;
case Ellipsis;
case Flag;
@@ -189,7 +188,6 @@ public function custom(bool $filled = false): string
self::UserPlus => 'user-plus',
self::UserCheck => 'user-check',
self::AtSign => 'at-sign',
- self::FoldVertical => 'fold-vertical',
self::Award => 'award',
self::Ellipsis => 'ellipsis',
self::Flag => 'flag',
diff --git a/app/NativeComponents/Concerns/RedrawsOnAppearanceChange.php b/app/NativeComponents/Concerns/RedrawsOnAppearanceChange.php
new file mode 100644
index 00000000..0a003add
--- /dev/null
+++ b/app/NativeComponents/Concerns/RedrawsOnAppearanceChange.php
@@ -0,0 +1,19 @@
+
diff --git a/resources/views/native/conversation.blade.php b/resources/views/native/conversation.blade.php
index c01b14b7..e5642545 100644
--- a/resources/views/native/conversation.blade.php
+++ b/resources/views/native/conversation.blade.php
@@ -69,29 +69,41 @@
@if ($pinned !== [])
@include('native.partials.pinned-bar')
@endif
+
+ {{-- The thread fades out above the composer instead of meeting it at a hard edge. On iOS the bar draws the fade. --}}
+ @if ($loaded && ! \App\Devnull\Display::fadesInBar())
+ @include('native.partials.composer-fade', ['ref' => 'composer-fade'])
+ @endif
@if ($loaded)
{{--
- The composer, drawn as the reply bar on a commit's page is (see partials/composer-plate): on iOS the bar is
- bare and the field is a Liquid Glass plate with the tools inside it, on Android the bar is the surface with
- a hairline and the tools lead it. The web's tools, photos, the microphone and Ping, open from one + here. Above the field
- sit what you're replying to and the photos on the draft, on glass of their own on iOS. While the thread
- can't take a message, the bar is solid on both, with why in the field's place.
+ 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.
+ 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())
+ @include('native.partials.composer-fade', ['ref' => 'composer-fade', 'inBar' => true])
+ @endif
+
@if ($canPush)
{{--
The members to mention, what you're replying to and the photos on the draft each keep a slot,
empty and no height when there's nothing in it, so the field's row never moves. Android rebuilds
- a row that moves among its siblings, field and all, which drops the keyboard.
+ a row that moves among its siblings, field and all, which drops the keyboard. An empty slot is
+ 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)
@@ -105,30 +117,28 @@
@endif
-
+
@include('native.partials.composer-photos', ['photos' => $photos, 'photoRef' => 'photo', 'describeClass' => 'ios:glass'])
- {{-- The same room above and below the field, so the bar sits evenly on the keyboard. --}}
-
- {{--
- The web's tools, photos, a voice note and Ping, are one + here, which opens them in a menu (see
- ComposerMenu), so the field keeps its room. A voice note takes the field's place, and the +'s,
- while it's recorded and waits to be pushed.
- --}}
- @include('native.partials.composer-plate', [
+ {{--
+ 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',
'tools' => $recorder !== null ? [] : [
['ref' => 'composer-tools', 'icon' => \App\Icons\Lucide::Plus, 'label' => 'Photos, a voice note or a ping', 'menu' => \App\Devnull\ComposerMenu::items(count($photos) >= \App\Devnull\DraftImages::MaxImages, trim($draft) !== '' || $photos !== [], $pingLabel)],
],
+ 'trail' => [['native.partials.message-length']],
+ 'send' => [
+ 'ref' => 'push',
+ 'label' => 'Push',
+ 'press' => 'send',
+ 'disabled' => $recorder === null ? trim($draft) === '' && $photos === [] : $recorder === 'stopping' || ($recorder === 'recording' && ! $recordingStarted),
+ ],
])
- @php($length = mb_strlen($draft))
- @if ($length >= 1600)
- {{ number_format($length) }}/2,000
- @endif
-
- Push
-
@else
@@ -153,6 +163,7 @@
@endif
@endif
+
@endif
diff --git a/resources/views/native/partials/body-counter.blade.php b/resources/views/native/partials/body-counter.blade.php
index 0c50a5c2..327a2a86 100644
--- a/resources/views/native/partials/body-counter.blade.php
+++ b/resources/views/native/partials/body-counter.blade.php
@@ -1,11 +1,8 @@
{{--
The web's BodyCounter, next to Commit or Reply: nothing until 200 characters are left, then the count in mono, amber
- from 20 and Rm Red at none. Before that, a body long enough to be folded in lists shows the fold icon instead.
+ from 20 and Rm Red at none.
--}}
@php($remaining = \App\Devnull\Data\Commit::MaxLength - (($literal ?? false) ? mb_strlen(\App\Devnull\Data\CommitBody::normalize($body)) : \App\Devnull\Data\CommitBody::characterCount($body)))
-@php($isCounting = $remaining <= \App\Devnull\Data\Commit::CountFrom)
-@if ($isCounting)
+@if ($remaining <= \App\Devnull\Data\Commit::CountFrom)
{{ $remaining }}
-@elseif (\App\Devnull\Data\Commit::isFoldedInLists($body))
-
@endif
diff --git a/resources/views/native/partials/composer-box.blade.php b/resources/views/native/partials/composer-box.blade.php
new file mode 100644
index 00000000..5cb53133
--- /dev/null
+++ b/resources/views/native/partials/composer-box.blade.php
@@ -0,0 +1,35 @@
+{{--
+ 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).
+
+ $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
+ the same view while the tools and everything else in the row under it change. $tools are composer-tool's, in the
+ web's order. $lead and $trail, when there are any, are partials with their data ([view, data]) for the start of the
+ 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.
+--}}
+@php($lead ??= [])
+@php($trail ??= [])
+
+
+ @include($field)
+
+
+ @foreach ($lead as $part)
+ @include($part[0], $part[1] ?? [])
+ @endforeach
+ @foreach ($tools as $tool)
+ @include('native.partials.composer-tool', $tool)
+ @endforeach
+
+ @foreach ($trail as $part)
+ @include($part[0], $part[1] ?? [])
+ @endforeach
+ @include('native.partials.send-button', $send)
+
+
diff --git a/resources/views/native/partials/composer-fade.blade.php b/resources/views/native/partials/composer-fade.blade.php
new file mode 100644
index 00000000..7a817f43
--- /dev/null
+++ b/resources/views/native/partials/composer-fade.blade.php
@@ -0,0 +1,12 @@
+{{--
+ The soft edge between a screen and its composer bar: a gradient from see-through at the top to the bar's surface at
+ the bottom, where the bar's rows start, so whatever scrolls down to the bar fades out instead of meeting a hard
+ line. Its colours come from Display::composerFade().
+
+ 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.
+--}}
+@php($inBar ??= false)
+
diff --git a/resources/views/native/partials/message-field.blade.php b/resources/views/native/partials/message-field.blade.php
index 339424b9..f990d826 100644
--- a/resources/views/native/partials/message-field.blade.php
+++ b/resources/views/native/partials/message-field.blade.php
@@ -1,12 +1,12 @@
{{--
- A Remotes thread's message field (see partials/composer-plate). It keeps the keyboard up through presses elsewhere
- in the thread (keep-focus), as the web keeps its field focused through Reply and Push, and its column is keyed, so
- the reply strip or photos coming and going above it never rebuild it. It mounts afresh only to take focus
+ A Remotes thread's message field, across the top of partials/composer-box. It keeps the keyboard up through presses
+ elsewhere in the thread (keep-focus), as the web keeps its field focused through Reply and Push, and its column is
+ keyed, so the reply strip or photos coming and going above it never rebuild it. It mounts afresh only to take focus
($composerKey): replying while the field is idle, or attaching photos. EDGE sends no focus event, so a press into
the field tells the thread it's in use. Where the caret is goes to the thread as it moves, for the "@" suggestions
in an org (see SuggestsMentions), and a picked mention comes back with where the caret goes, after it.
--}}
-
+
= 1600)
+ {{ number_format($length) }}/{{ number_format(\App\Devnull\Data\Message::MaxLength) }}
+@endif
diff --git a/resources/views/native/partials/send-button.blade.php b/resources/views/native/partials/send-button.blade.php
new file mode 100644
index 00000000..00123656
--- /dev/null
+++ b/resources/views/native/partials/send-button.blade.php
@@ -0,0 +1,23 @@
+{{--
+ A composer's send button: a 32pt circle in your colour with an up arrow, as the Claude and Messages apps send.
+ It names what it does for screen readers ($label: Push, Reply). While there's nothing to send ($disabled) it's a
+ muted circle, and not a button, as a disabled button would be. Its 36pt tap target fits the composer-tool row.
+--}}
+@php($disabled ??= false)
+@php($circle = 'rounded-full '.($disabled ? 'bg-theme-surface-variant' : 'bg-theme-'.$myColour))
+@php($arrow = $disabled ? 'text-theme-ink-muted' : 'text-theme-on-'.$myColour)
+@if ($disabled)
+
+
+
+
+
+@else
+
+
+
+
+
+
+
+@endif
diff --git a/resources/views/native/partials/voice-recorder.blade.php b/resources/views/native/partials/voice-recorder.blade.php
index 3c19a267..989ecc54 100644
--- a/resources/views/native/partials/voice-recorder.blade.php
+++ b/resources/views/native/partials/voice-recorder.blade.php
@@ -1,5 +1,5 @@
{{--
- The voice note in the composer, in the field's place (see partials/composer-plate), as the web's recorder draws
+ The voice note in the composer, in the field's place (see partials/composer-box), as the web's recorder draws
it: the trash, then "opening microphone…" until it records, then a pulsing dot, the microphone's level coming in
on the right, and the clock counting to the minute, amber in the last ten seconds, with Stop; then the recording
itself, to listen to before Push sends it. The same height as the field with one line, so the bar doesn't move.
@@ -7,9 +7,9 @@
While it records, the thread renders five times a second for the meter (RecordsVoiceNotes::MeterInterval).
--}}
@if ($recorder === 'recording')
-
+
@else
-
+
@endif
diff --git a/tests/Feature/Screens/ConversationTest.php b/tests/Feature/Screens/ConversationTest.php
index 5e0634ef..4a22b9cc 100644
--- a/tests/Feature/Screens/ConversationTest.php
+++ b/tests/Feature/Screens/ConversationTest.php
@@ -2,6 +2,7 @@
use App\Devnull\Account;
use App\Devnull\Data\Remotes;
+use App\Devnull\Display;
use App\NativeComponents\Conversation;
use Illuminate\Http\Client\Request;
use Illuminate\Support\Facades\Http;
@@ -760,18 +761,18 @@ function pulledAvatars(TestableComponent $screen, int $id): array
->assertNativeNotCalled('Browser.OpenInApp');
});
-it('pads the end of the thread for the composer bar alone, and for the reply bar while replying', function () {
+it('pads the end of the thread for the fade and the composer bar alone, and for the reply bar while replying', function () {
serveRemoteThread(threadJson([remoteMessageJson(['id' => 1])], ['read_through_id' => 1]));
$screen = finishRefreshes(Native::visit('/remotes/conversations/ada'));
$clearance = fn (): mixed => nodeByRef($screen, 'composer-clearance')['layout']['height'] ?? null;
// The scroll view adds the home indicator itself while the keyboard is down, so it isn't counted here.
- expect($clearance())->toEqual(Conversation::ComposerBarHeight + 8);
+ expect($clearance())->toEqual(Display::ComposerFadeHeight + Conversation::ComposerBarHeight + 8);
$screen->trigger('swipe-1');
- expect($clearance())->toEqual(Conversation::ComposerBarHeight + Conversation::ReplyingBarHeight + 8);
+ expect($clearance())->toEqual(Display::ComposerFadeHeight + Conversation::ComposerBarHeight + Conversation::ReplyingBarHeight + 8);
});
// ── Pins ────────────────────────────────
@@ -1026,7 +1027,7 @@ function serveOrgThread(array $thread, ?array $poll = null, ?Closure $pins = nul
->assertSee(' release checklist');
// It lies over the thread, which clears it at the top.
- expect(childRefs($screen, 'thread-stack'))->toBe(['thread', 'pinned-bar'])
+ expect(array_slice(childRefs($screen, 'thread-stack'), 0, 2))->toBe(['thread', 'pinned-bar'])
->and(childRefs($screen, 'thread')[0])->toBe('pinned-clearance')
->and(nodeByRef($screen, 'pinned-bar')['props']['a11y_label'] ?? null)->toBe('2 pinned messages. Latest from Ada Lovelace: release checklist');
diff --git a/tests/Feature/Screens/RemotesComposerTest.php b/tests/Feature/Screens/RemotesComposerTest.php
index b06a389a..637ed790 100644
--- a/tests/Feature/Screens/RemotesComposerTest.php
+++ b/tests/Feature/Screens/RemotesComposerTest.php
@@ -1,10 +1,13 @@
toBeTrue();
+ expect(canSend($screen, 'push'))->toBeFalse();
photosPicked($screen, [testPhoto(), testPhoto()])->tap('photo-0-alt')->input('photo-description-input', 'A terminal.');
- expect(nodeByRef($screen, 'push')['props']['disabled'] ?? false)->toBeFalse();
+ expect(canSend($screen, 'push'))->toBeTrue();
finishRefreshes($screen->tap('push'))->assertSet('pending', []);
@@ -193,6 +196,20 @@ function threadWithAda(string $platform = 'ios'): TestableComponent
expect(nodeByRef($screen, 'attach-photos')['props']['disabled'] ?? false)->toBeTrue();
});
+it('keeps every photo picked at once, however long ago they were taken', function () {
+ serveThreadWithAda([remoteMessageJson(['id' => 1])], ['read_through_id' => 1]);
+
+ // The library hands photos over with the time they were taken, which a photo nothing holds yet shares with one
+ // forgotten a day ago.
+ $picked = [testPhoto(), testPhoto()];
+ array_walk($picked, fn (string $path): bool => touch($path, now()->subYears(5)->getTimestamp()));
+
+ $screen = photosPicked(threadWithAda(), $picked);
+
+ expect($screen->instance()->photos)->toHaveCount(2)
+ ->and(array_filter($screen->instance()->photos, fn ($photo): bool => file_exists($photo->path)))->toHaveCount(2);
+});
+
it('takes a photo off the draft and the phone with its ✕', function () {
serveThreadWithAda([remoteMessageJson(['id' => 1])], ['read_through_id' => 1]);
@@ -213,11 +230,11 @@ function threadWithAda(string $platform = 'ios'): TestableComponent
photosPicked($screen, [testPhoto()]);
- expect($clearance())->toEqual(Conversation::ComposerBarHeight + Conversation::PhotosHeight + 8);
+ expect($clearance())->toEqual(Display::ComposerFadeHeight + Conversation::ComposerBarHeight + Conversation::PhotosHeight + 8);
$screen->tap('photo-0-alt');
- expect($clearance())->toEqual(Conversation::ComposerBarHeight + Conversation::PhotosHeight + Conversation::DescriptionHeight + 8);
+ expect($clearance())->toEqual(Display::ComposerFadeHeight + Conversation::ComposerBarHeight + Conversation::PhotosHeight + Conversation::DescriptionHeight + 8);
});
it('keeps the keyboard up through presses in the thread, and the field in place as the reply strip and photos come and go', function () {
@@ -225,7 +242,7 @@ function threadWithAda(string $platform = 'ios'): TestableComponent
$screen = threadWithAda()->input('message-input', 'on it');
$field = idsDownTo($screen->tree(), 'message-input');
- $rows = childRefs($screen, 'composer-bar');
+ $rows = childRefs($screen, 'composer-rows');
expect(nodeByRef($screen, 'message-input')['props']['keep_focus_on_submit'] ?? false)->toBeTrue();
@@ -235,7 +252,7 @@ function threadWithAda(string $platform = 'ios'): TestableComponent
// The strip fills a slot the bar always has, so the field's row keeps its place among the bar's rows, which
// Android needs as well as the same id to keep the field.
expect(idsDownTo($screen->tree(), 'message-input'))->toBe($field)
- ->and(childRefs($screen, 'composer-bar'))->toBe($rows);
+ ->and(childRefs($screen, 'composer-rows'))->toBe($rows);
$screen->tap('cancel-reply');
@@ -249,34 +266,106 @@ function threadWithAda(string $platform = 'ios'): TestableComponent
expect($withPhotos)->not->toBe($field)
->and(idsDownTo($screen->tree(), 'message-input'))->toBe($withPhotos)
- ->and(childRefs($screen, 'composer-bar'))->toBe($rows);
+ ->and(childRefs($screen, 'composer-rows'))->toBe($rows);
});
-it('puts a + for photos, a voice note and Ping inside the Liquid Glass field on iOS', function () {
+it('draws one box with the field over the + and a round Push, on both platforms', function (string $platform) {
serveThreadWithAda([remoteMessageJson(['id' => 1])], ['read_through_id' => 1]);
- $screen = threadWithAda('ios');
- $bar = findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'bottom_bar');
+ $screen = threadWithAda($platform);
+ $actions = childRefs($screen, 'message-actions');
- expect(childRefs($screen, 'message-plate'))->toBe(['message-field', 'composer-tools'])
+ expect(childRefs($screen, 'message-row'))->toBe(['message-box'])
+ ->and(childRefs($screen, 'message-box'))->toBe(['message-field-row', 'message-actions'])
+ ->and(childRefs($screen, 'message-field-row'))->toBe(['message-field'])
+ ->and($actions[0])->toBe('composer-tools')
+ ->and(end($actions))->toBe('push')
->and(array_slice(childRefs($screen, 'composer-tools'), 0, 3))->toBe(['attach-photos', 'record-voice-note', 'ping'])
- ->and(nodeByRef($screen, 'message-plate')['props']['glass'] ?? null)->toBe(1)
- ->and($bar['children'][0]['ref'] ?? null)->toBe('composer-bar')
- ->and($bar['children'][0]['style']['bg_color'] ?? null)->toBeNull()
- ->and(nodeByRef($screen, 'ping')['props']['label'])->toBe('Ping @ada');
-});
+ ->and(nodeByRef($screen, 'ping')['props']['label'])->toBe('Ping @ada')
+ ->and(nodeByRef($screen, 'push')['props']['a11y_label'] ?? nodeByRef($screen, 'push')['a11y_label'] ?? null)->toBe('Push');
+})->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) {
+ serveThreadWithAda([remoteMessageJson(['id' => 1])], ['read_through_id' => 1]);
-it('leads the bar with the + on Android, on a solid bar', function () {
+ $screen = threadWithAda($platform);
+ $bottomBar = findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'bottom_bar');
+ $bar = nodeByRef($screen, 'composer-bar');
+ $fade = nodeByRef($screen, 'composer-fade');
+ $surface = substr(strtoupper(config('native-ui.theme.light.surface')), 1);
+ $darkSurface = substr(strtoupper(config('native-ui.theme.dark.surface')), 1);
+
+ expect($bar['props']['glass'] ?? null)->toBeNull()
+ ->and(childRefs($screen, 'composer-rows')[0])->toBe('mention-slot')
+ ->and(nodeByRef($screen, 'message-box')['style']['border_width'] ?? 0)->toEqual(0)
+ ->and(nodeByRef($screen, 'message-box')['style']['bg_color'] ?? null)->toBeNull()
+ ->and($fade['layout']['height'] ?? null)->toEqual(Display::ComposerFadeHeight);
+
+ if ($platform === 'ios') {
+ // The thread runs on under the bar, which is glass, so it shows through blurred. The bar draws the fade at its
+ // 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(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)
+ ->and(nodeByRef($screen, 'composer-rows')['props']['dark_bg_color'] ?? null)->toBe('#66'.$darkSurface)
+ ->and($fade['props']['gradient_stops'] ?? null)->toBe('#00'.$surface.',#66'.$surface)
+ ->and(childRefs($screen, 'thread-stack'))->not->toContain('composer-fade');
+ } 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(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'))
+ ->and($fade['props']['gradient_stops'] ?? null)->toBe('#00'.$surface.',#B3'.$surface.',#'.$surface)
+ ->and(array_slice(childRefs($screen, 'thread-stack'), -1))->toBe(['composer-fade']);
+ }
+})->with(['ios', 'android']);
+
+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]);
- $screen = threadWithAda('android');
+ $screen = threadWithAda();
+ $light = substr(strtoupper(config('native-ui.theme.light.surface')), 1);
+ $dark = substr(strtoupper(config('native-ui.theme.dark.surface')), 1);
+
+ expect(str_ends_with(nodeByRef($screen, 'composer-fade')['props']['gradient_stops'], $light))->toBeTrue();
- expect(array_slice(childRefs($screen, 'message-row'), 0, 2))->toBe(['composer-tools', 'message-plate'])
- ->and(childRefs($screen, 'message-plate'))->toBe(['message-field'])
- ->and(nodeByRef($screen, 'message-plate')['props']['glass'] ?? null)->toBeNull()
- ->and(nodeByRef($screen, 'composer-bar')['style']['bg_color'] ?? null)->toBe(config('native-ui.theme.light.surface'));
+ System::rememberAppearance('dark');
+
+ try {
+ $screen->emitNative(AppearanceChanged::class, ['mode' => 'dark']);
+
+ expect(str_ends_with(nodeByRef($screen, 'composer-fade')['props']['gradient_stops'], $dark))->toBeTrue();
+ } finally {
+ System::rememberAppearance('light');
+ }
});
+it('counts a long message beside Push from 1,600 characters, amber from 1,900 and red at 2,000', function (int $length, ?string $colour) {
+ serveThreadWithAda([remoteMessageJson(['id' => 1])], ['read_through_id' => 1]);
+
+ $screen = threadWithAda()->input('message-input', str_repeat('a', $length));
+
+ if ($colour === null) {
+ expect(rendersRef($screen, 'message-length'))->toBeFalse();
+
+ return;
+ }
+
+ $actions = childRefs($screen, 'message-actions');
+
+ expect(nodeByRef($screen, 'message-length')['props']['text'])->toBe(number_format($length).'/2,000')
+ ->and(strtolower(nodeByRef($screen, 'message-length')['props']['color'] ?? ''))->toBe(strtolower(config("native-ui.theme.light.{$colour}")))
+ ->and(array_slice($actions, -2))->toBe(['message-length', 'push']);
+})->with([
+ 'short' => [1599, null],
+ 'long' => [1600, 'ink-muted'],
+ 'nearly full' => [1900, 'pending'],
+ 'full' => [2000, 'destructive'],
+]);
+
it('pings Ada, logging it in the thread as the web does and buzzing the phone', function () {
serveThreadWithAda([remoteMessageJson(['id' => 1, 'body' => 'you there?'])], ['read_through_id' => 1]);
diff --git a/tests/Feature/Screens/RemotesVoiceNotesTest.php b/tests/Feature/Screens/RemotesVoiceNotesTest.php
index 7dee858e..01a2038a 100644
--- a/tests/Feature/Screens/RemotesVoiceNotesTest.php
+++ b/tests/Feature/Screens/RemotesVoiceNotesTest.php
@@ -184,10 +184,11 @@ function playedBars(TestableComponent $screen, string $ref): int
&& $params['maxDuration'] == 60
&& $params['id'] === $screen->instance()->recordingId);
- expect(childRefs($screen, 'message-plate'))->toBe(['voice-recorder'])
+ expect(childRefs($screen, 'message-field-row'))->toBe(['voice-recorder'])
+ ->and(childRefs($screen, 'message-actions'))->not->toContain('composer-tools')
->and(nodeByRef($screen, 'voice-elapsed')['props']['text'] ?? null)->toBe('0:00/1:00')
->and(rendersEvery($screen))->toBe([200])
- ->and(nodeByRef($screen, 'push')['props']['disabled'] ?? false)->toBeFalse();
+ ->and(canSend($screen, 'push'))->toBeTrue();
// The level is the loudest sample since the last look, square-rooted as the web draws it, and the clock turns amber
// in the last ten seconds.
@@ -207,7 +208,7 @@ function playedBars(TestableComponent $screen, string $ref): int
$screen = voiceThread()->tap('record-voice-note')->assertSee('opening microphone…');
- expect(nodeByRef($screen, 'push')['props']['disabled'] ?? false)->toBeTrue();
+ expect(canSend($screen, 'push'))->toBeFalse();
// The clock counts from when the microphone starts, not from the tap.
$this->travel(5)->seconds();
@@ -217,7 +218,7 @@ function playedBars(TestableComponent $screen, string $ref): int
$screen->call('poll');
expect(nodeByRef($screen, 'voice-elapsed')['props']['text'])->toBe('0:02/1:00')
- ->and(nodeByRef($screen, 'push')['props']['disabled'] ?? false)->toBeFalse();
+ ->and(canSend($screen, 'push'))->toBeTrue();
});
it('stops to listen to the recording first, then pushes it staged at once and pushed once devnull has it', function () {
@@ -228,7 +229,7 @@ function playedBars(TestableComponent $screen, string $ref): int
$screen = voiceThread()->tap('record-voice-note')->tap('stop-voice-note');
$screen->assertNativeCalled('Microphone.Stop')->assertSee('encoding…');
- expect(nodeByRef($screen, 'push')['props']['disabled'] ?? false)->toBeTrue();
+ expect(canSend($screen, 'push'))->toBeFalse();
voiceRecorded($screen, $recording);
$kept = $screen->instance()->recorded->url;
@@ -245,7 +246,7 @@ function playedBars(TestableComponent $screen, string $ref): int
$screen->tap('push')->assertSee('staged')->assertSet('recorder', null)->assertNativeCalled('MediaPlayer.Stop');
$clientId = $screen->instance()->pending[0]->clientId;
- expect(childRefs($screen, 'message-plate'))->toBe(['message-field', 'composer-tools'])
+ expect(childRefs($screen, 'message-field-row'))->toBe(['message-field'])
->and(nodeByRef($screen, 'voice-'.$clientId.'-clock')['props']['text'])->toBe('0:02');
finishRefreshes($screen)->assertSee('pushed')->assertSet('pending', []);
@@ -321,7 +322,7 @@ function playedBars(TestableComponent $screen, string $ref): int
}
expect(file_exists($recording))->toBeFalse()
- ->and(childRefs($screen, 'message-plate'))->toBe(['message-field', 'composer-tools'])
+ ->and(childRefs($screen, 'message-field-row'))->toBe(['message-field'])
->and(voiceUploads())->toBe([]);
})->with(['while recording' => [true], 'once recorded' => [false]]);
diff --git a/tests/Pest.php b/tests/Pest.php
index 41e32e2e..d1bf556c 100644
--- a/tests/Pest.php
+++ b/tests/Pest.php
@@ -771,6 +771,15 @@ function sheetButtonEnabled(TestableComponent $screen, string $ref): bool
return nodeByRef($screen, $ref)['type'] === 'pressable';
}
+/**
+ * Whether a composer's round send button (partials/send-button) can be tapped. A disabled one is drawn as a plain
+ * circle, not a pressable.
+ */
+function canSend(TestableComponent $screen, string $ref): bool
+{
+ return nodeByRef($screen, $ref)['type'] === 'pressable';
+}
+
/**
* The circle of a round button in a sheet's bar, whether it can be tapped or not.
*
diff --git a/tests/Unit/Devnull/DisplayTest.php b/tests/Unit/Devnull/DisplayTest.php
index fe38524f..e7c8ed64 100644
--- a/tests/Unit/Devnull/DisplayTest.php
+++ b/tests/Unit/Devnull/DisplayTest.php
@@ -8,6 +8,16 @@
expect(Display::replyBarClearance($url))->toBe(Display::replyBarClearance(str_repeat('a', mb_strlen($url))) + 3 * Display::ReplyBarLineHeight);
});
+it('grows a composer box by a line height for each line the draft wraps to, up to five lines', function (string $draft, int $lines) {
+ expect(Display::composerBoxGrowth($draft))->toBe(($lines - 1) * Display::ReplyBarLineHeight);
+})->with([
+ 'empty' => ['', 1],
+ 'one line' => [str_repeat('a', Display::ComposerBoxCharactersPerLine), 1],
+ 'wraps once' => [str_repeat('a', Display::ComposerBoxCharactersPerLine + 1), 2],
+ 'its own lines' => ["one\ntwo\nthree", 3],
+ 'past five' => [str_repeat("line\n", 9), 5],
+]);
+
it('prints compact counts from a thousand as the web does', function (int $count, string $expected) {
expect(Display::compactCount($count))->toBe($expected);
})->with([