Fuck with sizing a bit
This commit is contained in:
@@ -19,7 +19,7 @@ void main() async {
|
|||||||
|
|
||||||
// Use it only after calling `hiddenWindowAtLaunch`
|
// Use it only after calling `hiddenWindowAtLaunch`
|
||||||
WindowOptions windowOptions = const WindowOptions(
|
WindowOptions windowOptions = const WindowOptions(
|
||||||
size: Size(800, 600),
|
size: Size(1600, 900), // Increased size to 1600x900
|
||||||
center: true,
|
center: true,
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
skipTaskbar: false,
|
skipTaskbar: false,
|
||||||
@@ -131,6 +131,8 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
|||||||
// Needs `implements WindowListener` and `windowManager.addListener(this);`
|
// Needs `implements WindowListener` and `windowManager.addListener(this);`
|
||||||
// and `windowManager.removeListener(this);` in dispose
|
// and `windowManager.removeListener(this);` in dispose
|
||||||
windowManager.setPreventClose(true);
|
windowManager.setPreventClose(true);
|
||||||
|
// Set aspect ratio after ensuring initialized
|
||||||
|
_setWindowConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -222,8 +224,14 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
|||||||
Future<void> _showWindow() async {
|
Future<void> _showWindow() async {
|
||||||
bool isVisible = await windowManager.isVisible();
|
bool isVisible = await windowManager.isVisible();
|
||||||
if (!isVisible) {
|
if (!isVisible) {
|
||||||
|
// Ensure size and position before showing
|
||||||
|
await windowManager.setSize(const Size(1600, 900)); // Set desired size
|
||||||
|
await windowManager.center(); // Center the window
|
||||||
await windowManager.show();
|
await windowManager.show();
|
||||||
await windowManager.focus();
|
await windowManager.focus();
|
||||||
|
} else {
|
||||||
|
// If already visible, just bring to front and focus
|
||||||
|
await windowManager.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,6 +287,16 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
|||||||
// _currentEntryController.clear(); // Decide if you want to clear it immediately
|
// _currentEntryController.clear(); // Decide if you want to clear it immediately
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper to set initial window config like aspect ratio
|
||||||
|
Future<void> _setWindowConfig() async {
|
||||||
|
// Wait a moment to ensure window manager is fully ready after init
|
||||||
|
// Might not be strictly necessary but can prevent race conditions
|
||||||
|
// await Future.delayed(const Duration(milliseconds: 100));
|
||||||
|
await windowManager.setAspectRatio(16 / 9);
|
||||||
|
// Optionally set min/max size if desired
|
||||||
|
// await windowManager.setMinimumSize(const Size(800, 450));
|
||||||
|
}
|
||||||
|
|
||||||
// --- UI Build --- //
|
// --- UI Build --- //
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
Reference in New Issue
Block a user