application_task.dart 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import 'package:app_flowy/startup/startup.dart';
  2. import 'package:flowy_infra/theme.dart';
  3. import 'package:flowy_infra_ui/flowy_infra_ui.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:provider/provider.dart';
  6. import 'package:window_size/window_size.dart';
  7. import 'package:app_flowy/startup/launcher.dart';
  8. class AppWidgetTask extends LaunchTask {
  9. @override
  10. LaunchTaskType get type => LaunchTaskType.appLauncher;
  11. @override
  12. Future<void> initialize(LaunchContext context) {
  13. final widget = context.getIt<EntryPoint>().create();
  14. final app = ApplicationWidget(child: widget);
  15. runApp(app);
  16. return Future(() => {});
  17. }
  18. }
  19. class ApplicationWidget extends StatelessWidget {
  20. final Widget child;
  21. const ApplicationWidget({
  22. Key? key,
  23. required this.child,
  24. }) : super(key: key);
  25. @override
  26. Widget build(BuildContext context) {
  27. const ratio = 1.73;
  28. const minWidth = 1000.0;
  29. setWindowMinSize(const Size(minWidth, minWidth / ratio));
  30. // const launchWidth = 1310.0;
  31. // setWindowFrame(const Rect.fromLTWH(0, 0, launchWidth, launchWidth / ratio));
  32. final theme = AppTheme.fromType(ThemeType.light);
  33. return Provider.value(
  34. value: theme,
  35. child: MaterialApp(
  36. builder: overlayManagerBuilder(),
  37. debugShowCheckedModeBanner: false,
  38. theme: theme.themeData,
  39. navigatorKey: AppGlobals.rootNavKey,
  40. home: child,
  41. ),
  42. );
  43. }
  44. }
  45. class AppGlobals {
  46. static GlobalKey<NavigatorState> rootNavKey = GlobalKey();
  47. static NavigatorState get nav => rootNavKey.currentState!;
  48. }