Skip to content

Commit

Permalink
Shrink Minimum Size & Fix Calculations (#197)
Browse files Browse the repository at this point in the history
- Dynamically hide title if window is too small
- Shrink menu bar buttons
- Move update icon into tab bar

Resolves #195 and #196
  • Loading branch information
Gold872 authored Jan 19, 2025
1 parent 06291e0 commit b94b099
Show file tree
Hide file tree
Showing 14 changed files with 485 additions and 347 deletions.
16 changes: 7 additions & 9 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:convert';
import 'dart:io';
import 'dart:math';

import 'package:flutter/material.dart';

Expand Down Expand Up @@ -66,18 +65,17 @@ void main() async {
await FieldImages.loadFields('assets/fields/');

Display primaryDisplay = await screenRetriever.getPrimaryDisplay();
double scaleFactor = (primaryDisplay.scaleFactor?.toDouble() ?? 1.0);
Size screenSize =
(primaryDisplay.visibleSize ?? primaryDisplay.size) * scaleFactor;
Size screenSize = primaryDisplay.visibleSize ?? primaryDisplay.size;

double minimumWidth = min(screenSize.width * 0.77 / scaleFactor, 1280.0);
double minimumHeight = min(screenSize.height * 0.7 / scaleFactor, 720.0);
logger.debug('Display Information: - Screen Size: $screenSize');

Size minimumSize = Size(minimumWidth, minimumHeight);
const Size minimumSize = Size(436.5, 320.0);

await windowManager.setMinimumSize(minimumSize);
await windowManager.setTitleBarStyle(TitleBarStyle.hidden,
windowButtonVisibility: false);
await windowManager.setTitleBarStyle(
TitleBarStyle.hidden,
windowButtonVisibility: false,
);

if (preferences.getBool(PrefKeys.rememberWindowPosition) ?? false) {
await _restoreWindowPosition(preferences, primaryDisplay, minimumSize);
Expand Down
Loading

0 comments on commit b94b099

Please sign in to comment.