Skip to content
34 changes: 34 additions & 0 deletions app/Devnull/Beat.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace App\Devnull;

use Native\Mobile\AsyncTask;

/**
* Waits $milliseconds on one of NativePHP's background PHP threads, so a
* screen can draw a frame, then change it once the phone has drawn it.
*
* EDGE animates a node from what it showed to what the next frame says
* (`animate-duration`), but it can't play a sequence or animate a row as it
* comes into a list. A screen draws the first step, and the next one when its
* Beat comes back: replies drawn see-through then faded in, a star scaled up
* then sprung back (see Concerns\ExpandsThreads and Concerns\PopsReactions).
*/
final class Beat extends AsyncTask
{
/**
* How long a frame waits for the next step of an animation, so the phone
* has drawn it first.
*/
public const int Step = 60;

public function handle(int $milliseconds): bool
{
// Tests run tasks inline, where only the order of the steps counts.
if (! app()->runningUnitTests()) {
usleep(max(0, $milliseconds) * 1000);
}

return true;
}
}
14 changes: 14 additions & 0 deletions app/Devnull/ComposerMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ public static function items(bool $photosFull, bool $voiceNotesGoAlone, string $
];
}

/**
* What the photo button in the reply bar on a commit's page opens: the photo library, or the camera, as the
* composer sheet's two photo buttons do.
*
* @return list<TopBarAction>
*/
public static function photoItems(): array
{
return [
self::item('reply-pick-photos', 'Choose photos', Lucide::ImagePlus, 'pickPhotos'),
self::item('reply-take-photo', 'Take a photo', Lucide::Camera, 'takePhoto'),
];
}

private static function item(string $ref, string $label, Lucide $icon, string $method, bool $disabled = false): TopBarAction
{
return NavAction::make($ref)
Expand Down
38 changes: 20 additions & 18 deletions app/Devnull/Display.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,19 @@
final class Display
{
/**
* The commit page's reply bar with one line of draft: its hairline, the
* field and the padding around them, as drawn on an iPhone.
* How much a line of draft adds to a composer bar's field.
*/
public const int ReplyBarHeight = 53;

public const int ReplyBarLineHeight = 21;

public const int ReplyBarMaxLines = 5;

public const int ReplyBarCharactersPerLine = 34;

/**
* The row under the reply bar's field that marks a restored draft (see partials/stash-label) and counts its photos.
* The photos on a reply's draft, above the field in the reply bar (see partials/composer-photos), and the
* description of one under them while it's open.
*/
public const int ReplyBarStashLabelHeight = 28;
public const int ReplyBarPhotosHeight = 88;

public const int ReplyBarDescriptionHeight = 100;

/**
* A bar holding partials/composer-box with one line of draft, as drawn on an iPhone: the bar's padding, then the
Expand All @@ -47,8 +45,7 @@ final class Display
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.
* About how many characters fit on a line of the box's field, which runs the width of the box.
*/
public const int ComposerBoxCharactersPerLine = 46;

Expand Down Expand Up @@ -240,16 +237,21 @@ public static function maskedKey(string $openSsh): string
* How far a commit page has to scroll past its last reply to clear the
* reply bar. A pushed screen is drawn under its bottom bar and the home
* indicator, with no inset for either, so the page pads its own end: the
* bar as the draft grows to its five lines, and the indicator below it.
* With the keyboard up the bar sits on the keyboard instead, which only
* leaves a little more room. A restored draft, or one with photos, adds
* the row under the field ($draftRow).
* fade over its foot (partials/composer-fade), the bar
* (partials/composer-box) as the draft grows to its five lines, and the
* indicator below it. With the keyboard up the bar sits on the keyboard
* instead, which only leaves a little more room. Photos on the draft add
* their row above the field ($hasPhotos), and an open description of one
* its box under them ($describing). A link too long for devnull adds the
* line that says so.
*/
public static function replyBarClearance(string $draft, bool $draftRow = false): int
public static function replyBarClearance(string $draft, bool $hasPhotos = false, bool $describing = false): int
{
return self::ReplyBarHeight
+ (min(self::ReplyBarMaxLines, self::lineCount($draft, self::ReplyBarCharactersPerLine)) - 1) * self::ReplyBarLineHeight
+ ($draftRow ? self::ReplyBarStashLabelHeight : 0)
return self::ComposerFadeHeight
+ self::ComposerBoxBarHeight
+ self::composerBoxGrowth($draft)
+ ($hasPhotos ? self::ReplyBarPhotosHeight : 0)
+ ($hasPhotos && $describing ? self::ReplyBarDescriptionHeight : 0)
+ (CommitBody::hasOversizedUrl($draft) ? 3 * self::ReplyBarLineHeight : 0)
+ self::HomeIndicatorHeight;
}
Expand Down
2 changes: 0 additions & 2 deletions app/Icons/Lucide.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ enum Lucide
case Eye;
case EyeOff;
case Plus;
case Maximize2;
case Vibrate;

// The achievement badges, named as devnull names their icons (see forBadge()).
Expand Down Expand Up @@ -213,7 +212,6 @@ public function custom(bool $filled = false): string
self::Eye => 'eye',
self::EyeOff => 'eye-off',
self::Plus => 'plus',
self::Maximize2 => 'maximize-2',
self::Vibrate => 'vibrate',
self::Terminal => 'terminal',
self::FileCode => 'file-code',
Expand Down
Loading
Loading