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
4 changes: 4 additions & 0 deletions resources/views/native/log.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,9 @@ class="w-full flex-1 bg-theme-surface"
@foreach ($pages as $page)
@include('native.partials.log-page', ['page' => $page])
@endforeach

<native:pager-overlay>
@include('native.partials.new-commits-pill', ['label' => $newCommitsLabel, 'press' => 'showNewCommits', 'shown' => $newCommits !== []])
</native:pager-overlay>
</native:pager>
</native:column>
2 changes: 0 additions & 2 deletions resources/views/native/partials/log-page.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ class="w-full flex-1 bg-theme-surface"
:on-end-reached="$page['showing'] ? 'loadMore' : null"
:end-reached-buffer="5"
>
@include('native.partials.new-commits-pill', ['label' => $newCommitsLabel, 'press' => 'showNewCommits', 'shown' => $page['showing'] && $newCommits !== []])

@if (! $page['loaded'] && $page['error'] === null)
@foreach (range(1, 3) as $skeleton)
@include('native.partials.rail-loading', ['ref' => 'loading-'.$skeleton, 'label' => 'Loading commits', 'pulse' => $page['showing']])
Expand Down
50 changes: 15 additions & 35 deletions resources/views/native/partials/new-commits-pill.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,22 @@
DESIGN.md's new commits pill: Commit Blue, "↑ 3 new commits". The commits are already fetched, so a tap puts them on
top with nothing to wait for.

As on the web, it sits in a strip of its own between the top of the list (the Log's composer) and the commits, and
pins to the top once you scroll past it. EDGE tells PHP nothing about where a list is scrolled, so the list pins it
itself, as a sticky header.
It floats over the commits, hung just under the pager's tabs, in the pager's overlay. There it stays put while the
list scrolls under it, and under a profile's header it follows the tabs wherever the header has scrolled them. The
overlay lets taps on either side of it through to the commits beneath.

Its header is always in the list, hidden until there's something to show ($shown), so the list keeps its shape when
new commits come in. A node added beside a scrolled list sometimes left the list blank on iOS: its rows still in the
tree and taking taps, nothing drawn.

A profile's pager has its tabs above the list, so there it goes in the pager's overlay instead ($hanging), which
hangs it under the tabs wherever the header has scrolled them, over the commits.
Its slot is always in the overlay, hidden until there's something to show ($shown), so the pager keeps its shape
when new commits come in. A node added beside a scrolled list sometimes left the list blank on iOS: its rows still in
the tree and taking taps, nothing drawn.
--}}
@php($shown ??= true)
@php($hanging ??= false)
@if ($hanging)
<native:row ref="new-commits-slot" class="w-full pt-3 justify-center {{ $shown ? '' : 'hidden' }}">
@if ($shown)
<native:pressable ref="new-commits" @press="{{ $press }}" class="rounded-full bg-theme-primary shadow-md" a11y-label="Show {{ $label }}">
<native:row class="px-4 py-[6] gap-[6] items-center">
<native:icon :ios="\App\Icons\Lucide::ArrowUp->ios()" :android="\App\Icons\Lucide::ArrowUp->android()" :size="16" class="text-theme-on-primary" />
<native:text font="medium" class="text-sm text-theme-on-primary">{{ $label }}</native:text>
</native:row>
</native:pressable>
@endif
</native:row>
@else
<native:sticky-header ref="new-commits-slot" class="w-full bg-theme-surface {{ $shown ? '' : 'hidden' }}">
@if ($shown)
<native:row class="w-full py-3 justify-center">
<native:pressable ref="new-commits" @press="{{ $press }}" class="rounded-full bg-theme-primary shadow-md" a11y-label="Show {{ $label }}">
<native:row class="px-4 py-[6] gap-[6] items-center">
<native:icon :ios="\App\Icons\Lucide::ArrowUp->ios()" :android="\App\Icons\Lucide::ArrowUp->android()" :size="16" class="text-theme-on-primary" />
<native:text font="medium" class="text-sm text-theme-on-primary">{{ $label }}</native:text>
</native:row>
</native:pressable>
<native:row ref="new-commits-slot" class="w-full pt-3 justify-center {{ $shown ? '' : 'hidden' }}">
@if ($shown)
<native:pressable ref="new-commits" @press="{{ $press }}" class="rounded-full bg-theme-primary shadow-md" a11y-label="Show {{ $label }}">
<native:row class="px-4 py-[6] gap-[6] items-center">
<native:icon :ios="\App\Icons\Lucide::ArrowUp->ios()" :android="\App\Icons\Lucide::ArrowUp->android()" :size="16" class="text-theme-on-primary" />
<native:text font="medium" class="text-sm text-theme-on-primary">{{ $label }}</native:text>
</native:row>
<native:column class="w-full h-[1] bg-theme-hairline" />
@endif
</native:sticky-header>
@endif
</native:pressable>
@endif
</native:row>
2 changes: 1 addition & 1 deletion resources/views/native/profile.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class="w-full flex-1 bg-theme-surface"
@endforeach

<native:pager-overlay>
@include('native.partials.new-commits-pill', ['label' => $newCommitsLabel, 'press' => 'showNewCommits', 'shown' => $newCommits !== [], 'hanging' => true])
@include('native.partials.new-commits-pill', ['label' => $newCommitsLabel, 'press' => 'showNewCommits', 'shown' => $newCommits !== []])
</native:pager-overlay>
</native:pager>
@else
Expand Down
28 changes: 11 additions & 17 deletions tests/Feature/Screens/LogCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,31 +340,25 @@ function shownCommitIds(TestableComponent $screen): array
$commit->goBack()->assertDontSee('Delete me')->assertSee('Keep me');
});

it('puts the pill at the top of the list, above the commits, in a header that pins, there before it shows', function () {
it('floats the pill over the commits, hung under the tabs in the pager, there before it shows', function () {
holdRefreshes();
keep('log/following', pageJson([commitJson(['id' => 'c1'])]));
fakeFreshLog([commitJson(['id' => 'c2', 'body' => 'Newer']), commitJson(['id' => 'c1'])]);

$screen = Native::visit('/log', platform: 'ios');
$besideTheList = function () use ($screen): array {
$parent = findNode($screen->tree(), fn (array $node): bool => in_array('log', array_column($node['children'] ?? [], 'ref'), true));
$overlay = fn (): array => findNode(nodeByRef($screen, 'log-pager'), fn (array $node): bool => ($node['type'] ?? null) === 'pager_overlay');
$firstInTheList = fn (): ?string => array_values(array_filter(childRefs($screen, 'log'), fn (?string $ref): bool => $ref !== null && ! str_starts_with($ref, 'day-')))[0] ?? null;

return array_map(fn (array $node): string => $node['ref'] ?? $node['type'], $parent['children']);
};

$inTheList = fn (): array => array_slice(array_values(array_filter(childRefs($screen, 'log'), fn (?string $ref): bool => $ref !== null && ! str_starts_with($ref, 'day-'))), 0, 2);

// Hidden and empty until there are new commits, but already in its place, so showing it never changes the list's shape.
expect($besideTheList())->toBe(['log'])
->and($inTheList())->toBe(['new-commits-slot', 'commit-c1'])
->and(nodeByRef($screen, 'new-commits-slot')['type'])->toBe('sticky_header')
// Hidden and empty until there are new commits, but already in its place, outside the lists.
expect(findNode($overlay(), fn (array $node): bool => ($node['ref'] ?? null) === 'new-commits-slot'))->not->toBeNull()
->and(nodeByRef($screen, 'new-commits-slot')['layout']['display'] ?? null)->toBe(1)
->and(nodeByRef($screen, 'new-commits-slot')['children'] ?? [])->toBe([]);
->and(nodeByRef($screen, 'new-commits-slot')['children'] ?? [])->toBe([])
->and($firstInTheList())->toBe('commit-c1');

finishRefreshes($screen)->assertSee('1 new commit');

expect($besideTheList())->toBe(['log'])
->and($inTheList())->toBe(['new-commits-slot', 'commit-c1'])
->and(nodeByRef($screen, 'new-commits-slot')['layout']['display'] ?? null)->toBeNull()
->and(findNode(nodeByRef($screen, 'new-commits-slot'), fn (array $node): bool => ($node['ref'] ?? null) === 'new-commits'))->not->toBeNull();
// Over the commits, not a row above them.
expect(nodeByRef($screen, 'new-commits-slot')['layout']['display'] ?? null)->toBeNull()
->and(findNode($overlay(), fn (array $node): bool => ($node['ref'] ?? null) === 'new-commits'))->not->toBeNull()
->and($firstInTheList())->toBe('commit-c1');
});
Loading