mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
6c895ad4fe
* feat: add TargetPlatform `isDesktop` helper Safe and convenient way to check if the current platform is a desktop platform. * refactor: move window logic to separate class This is much cleaner and better encapsulated. Sets up an area for further window management in the future. Does not try to initialize on mobile or web, which would crash. * fix: isDesktop doc comment * fix: set window title Currently only displays "app_flowy" as the window title. This commit sets the window title to "AppFlowy" as part of the init process.
38 lines
894 B
Dart
38 lines
894 B
Dart
import 'dart:ui';
|
|
|
|
import 'package:app_flowy/core/helpers/helpers.dart';
|
|
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._();
|
|
}
|
|
}
|