2023-02-11 06:16:38 +00:00
|
|
|
import 'dart:ui';
|
|
|
|
|
2023-02-26 08:27:17 +00:00
|
|
|
import 'package:appflowy/core/helpers/helpers.dart';
|
2023-02-11 06:16:38 +00:00
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:window_manager/window_manager.dart';
|
|
|
|
|
|
|
|
/// Represents the main window of the app.
|
|
|
|
class AppWindow {
|
|
|
|
/// The singleton instance of the window.
|
|
|
|
static late AppWindow instance;
|
|
|
|
|
|
|
|
AppWindow._() {
|
|
|
|
instance = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Initializes the window.
|
|
|
|
static Future<AppWindow?> initialize() async {
|
|
|
|
// Don't initialize on mobile or web.
|
|
|
|
if (!defaultTargetPlatform.isDesktop) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
await windowManager.ensureInitialized();
|
|
|
|
|
|
|
|
WindowOptions windowOptions = const WindowOptions(
|
|
|
|
minimumSize: Size(600, 400),
|
|
|
|
title: 'AppFlowy',
|
|
|
|
);
|
|
|
|
|
|
|
|
await windowManager.waitUntilReadyToShow(windowOptions, () async {
|
|
|
|
await windowManager.show();
|
|
|
|
await windowManager.focus();
|
|
|
|
});
|
|
|
|
|
|
|
|
return AppWindow._();
|
|
|
|
}
|
|
|
|
}
|