Offer a new share as a QR code and through the share sheet
The share created page gets "Show QR code", a dialog with the link as a QR code (black on white, full screen on a phone) that downloads as a PNG drawn in the browser, with a password reminder for protected shares; and "Share…", which opens the device's share sheet where there is one. Both carry only the link. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V9NnLxnPp8vaaurb3Z1MFy
This commit is contained in:
co-authored by
Claude Opus 5
parent
fbe358b2e5
commit
1352533667
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use BaconQrCode\Common\ErrorCorrectionLevel;
|
||||
use BaconQrCode\Encoder\Encoder;
|
||||
use BaconQrCode\Renderer\Color\Rgb;
|
||||
use BaconQrCode\Renderer\Image\SvgImageBackEnd;
|
||||
use BaconQrCode\Renderer\ImageRenderer;
|
||||
use BaconQrCode\Renderer\RendererStyle\Fill;
|
||||
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
|
||||
use BaconQrCode\Writer;
|
||||
|
||||
class QrCodeService
|
||||
{
|
||||
/**
|
||||
* The QR code's width and height in the SVG, in pixels: the size a canvas draws it at.
|
||||
*/
|
||||
public const SIZE = 1024;
|
||||
|
||||
/**
|
||||
* Draw the contents as a QR code in SVG: black on white with a four-module quiet zone and
|
||||
* error correction M, the most reliable to scan from a screen or a print. The XML declaration
|
||||
* is dropped so the markup can sit inline in a page.
|
||||
*/
|
||||
public function svg(string $contents): string
|
||||
{
|
||||
$svg = (new Writer(
|
||||
new ImageRenderer(
|
||||
new RendererStyle(self::SIZE, 4, null, null, Fill::uniformColor(new Rgb(255, 255, 255), new Rgb(0, 0, 0))),
|
||||
new SvgImageBackEnd,
|
||||
),
|
||||
))->writeString($contents, Encoder::DEFAULT_BYTE_MODE_ENCODING, ErrorCorrectionLevel::M());
|
||||
|
||||
return trim(substr($svg, strpos($svg, "\n") + 1));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user