Skip to content
Draft
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
19 changes: 0 additions & 19 deletions app/Devnull/Data/Commit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()).
Expand Down Expand Up @@ -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.
*
Expand Down
97 changes: 97 additions & 0 deletions app/Devnull/Display.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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.
*/
Expand Down
4 changes: 4 additions & 0 deletions app/Devnull/DraftImages.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

Expand Down
2 changes: 0 additions & 2 deletions app/Icons/Lucide.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ enum Lucide
case UserPlus;
case UserCheck;
case AtSign;
case FoldVertical;
case Award;
case Ellipsis;
case Flag;
Expand Down Expand Up @@ -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',
Expand Down
19 changes: 19 additions & 0 deletions app/NativeComponents/Concerns/RedrawsOnAppearanceChange.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\NativeComponents\Concerns;

use Native\Mobile\Attributes\On;
use Native\Mobile\Events\System\AppearanceChanged;

/**
* A screen that draws something in the colours of the current appearance
* itself, which EDGE won't switch for it, such as the fade above a composer
* bar (see Display::composerFade()). Theme colours have a dark companion the
* phone picks on its own, but a gradient's stops don't, so the screen draws
* again when the phone goes light or dark.
*/
trait RedrawsOnAppearanceChange
{
#[On(AppearanceChanged::class)]
public function appearanceChanged(): void {}
}
19 changes: 10 additions & 9 deletions app/NativeComponents/Conversation.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use App\NativeComponents\Concerns\OpensInTab;
use App\NativeComponents\Concerns\PlaysVoiceNotes;
use App\NativeComponents\Concerns\RecordsVoiceNotes;
use App\NativeComponents\Concerns\RedrawsOnAppearanceChange;
use App\NativeComponents\Concerns\RefreshesInBackground;
use App\NativeComponents\Concerns\SuggestsMentions;
use App\NativeComponents\Concerns\SyncsOutbox;
Expand Down Expand Up @@ -108,6 +109,7 @@ class Conversation extends NativeComponent
use OpensInTab;
use PlaysVoiceNotes;
use RecordsVoiceNotes;
use RedrawsOnAppearanceChange;
use RefreshesInBackground;
use SuggestsMentions;
use SyncsOutbox;
Expand Down Expand Up @@ -243,10 +245,10 @@ class Conversation extends NativeComponent
public bool $composing = false;

/**
* The composer bar's height with one line in its field, the same as the reply bar on a commit's page: its top
* line, then the field, its tools and Push with 8 points above and below.
* The composer bar's height with one line in its field: the field over the + and Push (see partials/composer-box),
* with 8 points above and below.
*/
public const int ComposerBarHeight = Display::ReplyBarHeight;
public const int ComposerBarHeight = Display::ComposerBoxBarHeight;

/**
* The "Replying to …" bar above the field.
Expand Down Expand Up @@ -1830,15 +1832,14 @@ private function longPins(): array
}

/**
* How far the thread pads its end to clear the composer bar: the bar with one line in its field, the lines the
* draft has grown by, the reply bar while replying, the photos and an open description, and a little room. The
* scroll view adds the home indicator itself while the keyboard is down, so this is the same either way.
* How far the thread pads its end to clear the composer bar: the fade above it, the bar with one line in its
* field, the lines the draft has grown by, the reply bar while replying, the photos and an open description, and
* a little room. The scroll view adds the home indicator itself while the keyboard is down, so this is the same
* either way.
*/
private static function composerClearance(string $draft, bool $replying, bool $hasPhotos, bool $describing): int
{
$grownBy = Display::replyBarClearance($draft) - Display::ReplyBarHeight - Display::HomeIndicatorHeight;

return self::ComposerBarHeight + $grownBy
return Display::ComposerFadeHeight + self::ComposerBarHeight + Display::composerBoxGrowth($draft)
+ ($replying ? self::ReplyingBarHeight : 0)
+ ($hasPhotos ? self::PhotosHeight : 0)
+ ($hasPhotos && $describing ? self::DescriptionHeight : 0)
Expand Down
1 change: 0 additions & 1 deletion resources/icons/fold-vertical.svg

This file was deleted.

65 changes: 38 additions & 27 deletions resources/views/native/conversation.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
</native:stack>

@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.
--}}
<native:bottom-bar>
<native:column native:key="composer-bar" ref="composer-bar" class="w-full {{ $canPush ? 'android:bg-theme-surface' : 'bg-theme-surface' }}">
<native:column class="w-full h-[1] {{ $canPush ? 'android:bg-theme-hairline' : 'bg-theme-hairline' }}" />
<native:bottom-bar class="{{ \App\Devnull\Display::composerBarGlass() }}">
<native:column native:key="composer-bar" ref="composer-bar" class="w-full {{ \App\Devnull\Display::composerBar() }}">
@if (\App\Devnull\Display::fadesInBar())
@include('native.partials.composer-fade', ['ref' => 'composer-fade', 'inBar' => true])
@endif
<native:column native:key="composer-rows" ref="composer-rows" class="w-full {{ \App\Devnull\Display::composerSurface() }}">
@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.
--}}
<native:row native:key="mention-slot" ref="mention-slot" class="w-full {{ $mentionPeople !== [] ? 'pt-1 ios:px-4' : '' }}">
@php($mentioning = ($mention['field'] ?? null) === 'draft' && ($mentionPeople !== [] || $mentionOrganizations !== []))
<native:row native:key="mention-slot" ref="mention-slot" class="w-full {{ $mentioning ? 'pt-1 ios:px-4' : 'h-[0.1]' }}">
@include('native.partials.mention-suggestions', ['field' => 'draft', 'heading' => ($mention['query'] ?? null) === '' ? 'Members' : null])
</native:row>
<native:row native:key="replying-slot" ref="replying-slot" class="w-full {{ $replyTo ? 'ios:px-4' : '' }}">
<native:row native:key="replying-slot" ref="replying-slot" class="w-full {{ $replyTo ? 'ios:px-4' : 'h-[0.1]' }}">
@if ($replyTo)
<native:row ref="replying" class="flex-1 h-[44] px-4 gap-3 items-center ios:rounded-[18] ios:glass">
<native:column class="w-[2] h-[28] rounded-full bg-theme-{{ $myColour }}" />
Expand All @@ -105,30 +117,28 @@
</native:row>
@endif
</native:row>
<native:column native:key="message-photos" ref="message-photos" class="w-full {{ $photos !== [] ? 'px-4 pt-2' : '' }}">
<native:column native:key="message-photos" ref="message-photos" class="w-full {{ $photos !== [] ? 'px-4 pt-2' : 'h-[0.1]' }}">
@include('native.partials.composer-photos', ['photos' => $photos, 'photoRef' => 'photo', 'describeClass' => 'ios:glass'])
</native:column>
{{-- The same room above and below the field, so the bar sits evenly on the keyboard. --}}
<native:row native:key="message-row" ref="message-row" class="w-full ios:pl-4 android:pl-2 pr-4 py-2 gap-2 items-center">
{{--
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.
--}}
<native:row native:key="message-row" ref="message-row" class="w-full px-4 py-2">
@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)
<native:text ref="message-length" font="mono" class="text-[11px] {{ $length >= 2000 ? 'text-theme-destructive' : ($length >= 1900 ? 'text-theme-pending' : 'text-theme-ink-muted') }}">{{ number_format($length) }}/2,000</native:text>
@endif
<native:column class="w-[72]">
<native:button ref="push" :variant="$myColour" size="sm" :disabled="$recorder === null ? trim($draft) === '' && $photos === [] : $recorder === 'stopping' || ($recorder === 'recording' && ! $recordingStarted)" @press="send" class="w-full">Push</native:button>
</native:column>
</native:row>
@else
<native:column ref="access-bar" class="w-full px-4 pt-3 pb-4 gap-3">
Expand All @@ -153,6 +163,7 @@
@endif
</native:column>
@endif
</native:column>
</native:column>
</native:bottom-bar>
@endif
Expand Down
Loading
Loading