Files
imajviewer/lib/main.dart
T
Alhan 9a7480cd68 feat: window size presets — 4x8 screen-ratio grid in settings (v1.8.0)
- Settings 'Size' section: 8 col x 4 row grid, 31 buttons labeled a:b
  (a splits H, b splits W); top-left cell empty placeholder (no 1:1 —
  title bar double click already maximizes)
- Click resizes the window to work.width/b x work.height/a of the
  display's work area (screen_retriever visibleSize, taskbar excluded);
  position unchanged, no selection state tracking
- minimumSize 400x300 -> 160x100 (4:8 cell needs it)
- Settings file-properties rows left-aligned (were centered under path)
2026-10-31 02:10:39 +03:00

52 lines
1.6 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:window_manager/window_manager.dart';
import 'app.dart';
import 'services/image_manager.dart';
import 'services/window_persistence.dart';
void main(List<String> args) async {
WidgetsFlutterBinding.ensureInitialized();
ImageManager.configureCache();
await windowManager.ensureInitialized();
// Restore saved window position/size or use defaults
final saved = WindowPersistence.restore();
final defaultSize = const Size(1280, 800);
final windowOptions = WindowOptions(
size: saved?.size ?? defaultSize,
minimumSize: const Size(160, 100),
backgroundColor: Colors.transparent,
titleBarStyle: TitleBarStyle.hidden,
);
await windowManager.waitUntilReadyToShow(windowOptions, () async {
if (saved != null) {
final position = await WindowPersistence.cascadePosition(
previousPosition: saved.position,
previousSize: saved.size,
);
await windowManager.setPosition(position);
await windowManager.setSize(saved.size);
} else {
await windowManager.center();
}
await windowManager.setResizable(true);
await windowManager.show();
await windowManager.focus();
// Açılış konumunu hemen kaydet — sıradaki pencere güncel referans okusun
final pos = await windowManager.getPosition();
final size = await windowManager.getSize();
WindowPersistence.saveSync(position: pos, size: size);
});
// Extract file paths from command-line arguments
final filePaths = args.where((a) => !a.startsWith('-') && a != Platform.script.path).toList();
runApp(ImajViewerApp(initialFiles: filePaths));
}