Skip to content

Commit

Permalink
[gui] take screen aspect ratio into consideration
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-toterman committed Dec 12, 2024
1 parent 2b21fb0 commit ff25418
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/client/gui/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ Size deriveWindowSize(SharedPreferences sharedPreferences, Size? screenSize) {
Size computeDefaultWindowSize(Size? screenSize) {
const windowSizeFactor = 0.8;
final (screenWidth, screenHeight) = (screenSize?.width, screenSize?.height);
final aspectRatioFactor = screenSize?.flipped.aspectRatio;

final defaultWidth = switch (screenWidth) {
null || <= 1024 => 750.0,
Expand All @@ -276,7 +277,9 @@ Size computeDefaultWindowSize(Size? screenSize) {
final defaultHeight = switch (screenHeight) {
null || <= 576 => 450.0,
>= 900 => 822.0,
_ => defaultWidth * 9 / 16,
_ => aspectRatioFactor != null
? defaultWidth * aspectRatioFactor
: screenHeight * windowSizeFactor,
};

final size = Size(defaultWidth, defaultHeight);
Expand Down

0 comments on commit ff25418

Please sign in to comment.