Center window on launch

This commit is contained in:
Hillel Coren 2022-08-01 11:34:40 +03:00
parent 23ec321130
commit 5cd7e64276
3 changed files with 1 additions and 14 deletions

View File

@ -93,8 +93,6 @@ const String kSharedPrefUrl = 'url';
const String kSharedPrefToken = 'checksum';
const String kSharedPrefWidth = 'width';
const String kSharedPrefHeight = 'height';
const String kSharedPrefOffsetX = 'offset_x';
const String kSharedPrefOffsetY = 'offset_y';
const String kProductProPlanMonth = 'pro_plan';
const String kProductEnterprisePlanMonth_2 = 'enterprise_plan';

View File

@ -67,6 +67,7 @@ void main({bool isTesting = false}) async {
final prefs = await SharedPreferences.getInstance();
windowManager.waitUntilReadyToShow(
WindowOptions(
center: true,
size: Size(
prefs.getDouble(kSharedPrefWidth) ?? 800,
prefs.getDouble(kSharedPrefHeight) ?? 600,
@ -152,13 +153,9 @@ void main({bool isTesting = false}) async {
}
if (isWindows()) {
final prefs = await SharedPreferences.getInstance();
final offsetX = prefs.getDouble(kSharedPrefOffsetX);
final offsetY = prefs.getDouble(kSharedPrefOffsetY);
doWhenWindowReady(() {
final win = appWindow;
win.title = 'Invoice Ninja';
win.position = Offset(offsetX, offsetY);
win.show();
});
}

View File

@ -38,14 +38,6 @@ class _WindowManagerState extends State<WindowManager> with WindowListener {
prefs.setDouble(kSharedPrefHeight, size.height);
}
@override
void onWindowMove() async {
final position = await windowManager.getPosition();
final prefs = await SharedPreferences.getInstance();
prefs.setDouble(kSharedPrefOffsetX, position.dx);
prefs.setDouble(kSharedPrefOffsetY, position.dy);
}
@override
void onWindowClose() async {
final store = StoreProvider.of<AppState>(navigatorKey.currentContext);