mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 15:07:49 +00:00
feat: calculate scale level, limit to 4-bit
This commit is contained in:
parent
8791a5154e
commit
85e887f8a5
2 changed files with 31 additions and 0 deletions
|
|
@ -31,6 +31,35 @@ final class DeviceModel extends Model
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if higher then 4 return 4bit
|
||||||
|
if ($this->bit_depth > 4) {
|
||||||
|
return '4bit';
|
||||||
|
}
|
||||||
|
|
||||||
return $this->bit_depth.'bit';
|
return $this->bit_depth.'bit';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the scale level based on the device width.
|
||||||
|
*/
|
||||||
|
public function getScaleLevelAttribute(): ?string
|
||||||
|
{
|
||||||
|
if (! $this->width) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->width > 800 && $this->width <= 1000) {
|
||||||
|
return 'large';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->width > 1000 && $this->width <= 1400) {
|
||||||
|
return 'xlarge';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->width > 1400) {
|
||||||
|
return 'xxlarge';
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -346,6 +346,7 @@ class Plugin extends Model
|
||||||
return view('trmnl-layouts.single', [
|
return view('trmnl-layouts.single', [
|
||||||
'colorDepth' => $device?->deviceModel?->color_depth,
|
'colorDepth' => $device?->deviceModel?->color_depth,
|
||||||
'deviceVariant' => $device?->deviceModel?->name ?? 'og',
|
'deviceVariant' => $device?->deviceModel?->name ?? 'og',
|
||||||
|
'scaleLevel' => $device?->deviceModel?->scale_level,
|
||||||
'slot' => $renderedContent,
|
'slot' => $renderedContent,
|
||||||
])->render();
|
])->render();
|
||||||
}
|
}
|
||||||
|
|
@ -358,6 +359,7 @@ class Plugin extends Model
|
||||||
return view('trmnl-layouts.single', [
|
return view('trmnl-layouts.single', [
|
||||||
'colorDepth' => $device?->deviceModel?->color_depth,
|
'colorDepth' => $device?->deviceModel?->color_depth,
|
||||||
'deviceVariant' => $device?->deviceModel?->name ?? 'og',
|
'deviceVariant' => $device?->deviceModel?->name ?? 'og',
|
||||||
|
'scaleLevel' => $device?->deviceModel?->scale_level,
|
||||||
'slot' => view($this->render_markup_view, [
|
'slot' => view($this->render_markup_view, [
|
||||||
'size' => $size,
|
'size' => $size,
|
||||||
'data' => $this->data_payload,
|
'data' => $this->data_payload,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue