Files
quiver-launcher/Services/CatalogReviewGridLayout.cs
T
Thomas GeorgiadisandCursor 2c85fa0370 feat: update Quiver Launcher to support .NET 10 and enhance UI/UX
- Introduce Android app
- Migrate project files to .NET 10, updating dependencies and workflows.
- Migrate project to Avalonia 12
- Refactor App.axaml to include a ResourceDictionary for theme management.
- Introduce new styles for gamepad navigation and focus rings.
- Implement hosted main view management for better application lifecycle handling.
- Remove deprecated MainWindow.Mods.cs file and related code.
- Update README to reflect changes in project structure and requirements.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-01 20:06:33 +10:00

39 lines
1.4 KiB
C#

namespace QuiverLauncher.Services;
/// <summary>
/// Column count for catalog-review grid cards on a phone.
/// Portrait fills two stretched columns when the viewport is wide enough;
/// otherwise one full-width column. Landscape uses as many as fit.
/// </summary>
public static class CatalogReviewGridLayout
{
public const double PortraitMinCardWidth = 128;
public const double LandscapeMinCardWidth = 168;
public const double CardGutter = 8;
public const int PortraitMaxColumns = 2;
public static int GetColumns(double viewportWidth, bool landscape)
{
if (viewportWidth <= 1 || double.IsNaN(viewportWidth) || double.IsInfinity(viewportWidth))
return 1;
var minCard = landscape ? LandscapeMinCardWidth : PortraitMinCardWidth;
var columns = Math.Max(1, (int)Math.Floor(viewportWidth / (minCard + CardGutter)));
if (!landscape)
columns = Math.Min(columns, PortraitMaxColumns);
return columns;
}
/// <summary>
/// Width of one card so <see cref="GetColumns"/> items plus 4px side margins fill the viewport.
/// </summary>
public static double GetCardWidth(double viewportWidth, bool landscape)
{
var columns = GetColumns(viewportWidth, landscape);
if (viewportWidth <= 1 || double.IsNaN(viewportWidth) || double.IsInfinity(viewportWidth))
return 1;
return Math.Max(1, Math.Floor(viewportWidth / columns) - CardGutter);
}
}