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 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';
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue