Center window on launch
This commit is contained in:
parent
23ec321130
commit
5cd7e64276
|
|
@ -93,8 +93,6 @@ const String kSharedPrefUrl = 'url';
|
||||||
const String kSharedPrefToken = 'checksum';
|
const String kSharedPrefToken = 'checksum';
|
||||||
const String kSharedPrefWidth = 'width';
|
const String kSharedPrefWidth = 'width';
|
||||||
const String kSharedPrefHeight = 'height';
|
const String kSharedPrefHeight = 'height';
|
||||||
const String kSharedPrefOffsetX = 'offset_x';
|
|
||||||
const String kSharedPrefOffsetY = 'offset_y';
|
|
||||||
|
|
||||||
const String kProductProPlanMonth = 'pro_plan';
|
const String kProductProPlanMonth = 'pro_plan';
|
||||||
const String kProductEnterprisePlanMonth_2 = 'enterprise_plan';
|
const String kProductEnterprisePlanMonth_2 = 'enterprise_plan';
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,7 @@ void main({bool isTesting = false}) async {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
windowManager.waitUntilReadyToShow(
|
windowManager.waitUntilReadyToShow(
|
||||||
WindowOptions(
|
WindowOptions(
|
||||||
|
center: true,
|
||||||
size: Size(
|
size: Size(
|
||||||
prefs.getDouble(kSharedPrefWidth) ?? 800,
|
prefs.getDouble(kSharedPrefWidth) ?? 800,
|
||||||
prefs.getDouble(kSharedPrefHeight) ?? 600,
|
prefs.getDouble(kSharedPrefHeight) ?? 600,
|
||||||
|
|
@ -152,13 +153,9 @@ void main({bool isTesting = false}) async {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isWindows()) {
|
if (isWindows()) {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
|
||||||
final offsetX = prefs.getDouble(kSharedPrefOffsetX);
|
|
||||||
final offsetY = prefs.getDouble(kSharedPrefOffsetY);
|
|
||||||
doWhenWindowReady(() {
|
doWhenWindowReady(() {
|
||||||
final win = appWindow;
|
final win = appWindow;
|
||||||
win.title = 'Invoice Ninja';
|
win.title = 'Invoice Ninja';
|
||||||
win.position = Offset(offsetX, offsetY);
|
|
||||||
win.show();
|
win.show();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,14 +38,6 @@ class _WindowManagerState extends State<WindowManager> with WindowListener {
|
||||||
prefs.setDouble(kSharedPrefHeight, size.height);
|
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
|
@override
|
||||||
void onWindowClose() async {
|
void onWindowClose() async {
|
||||||
final store = StoreProvider.of<AppState>(navigatorKey.currentContext);
|
final store = StoreProvider.of<AppState>(navigatorKey.currentContext);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue