2021-06-19 15:41:19 +00:00
|
|
|
import 'package:app_flowy/startup/startup.dart';
|
2021-07-13 00:47:26 +00:00
|
|
|
import 'package:flowy_infra/theme.dart';
|
2021-07-29 14:22:35 +00:00
|
|
|
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
2021-06-19 15:41:19 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:window_size/window_size.dart';
|
2021-10-11 05:15:41 +00:00
|
|
|
import 'package:app_flowy/startup/launcher.dart';
|
2021-06-19 15:41:19 +00:00
|
|
|
|
|
|
|
class AppWidgetTask extends LaunchTask {
|
|
|
|
@override
|
|
|
|
LaunchTaskType get type => LaunchTaskType.appLauncher;
|
|
|
|
|
|
|
|
@override
|
2021-07-12 15:27:58 +00:00
|
|
|
Future<void> initialize(LaunchContext context) {
|
2021-09-12 14:19:59 +00:00
|
|
|
final widget = context.getIt<EntryPoint>().create();
|
2021-07-22 03:23:15 +00:00
|
|
|
final app = ApplicationWidget(child: widget);
|
2021-06-19 15:41:19 +00:00
|
|
|
runApp(app);
|
2021-07-12 15:27:58 +00:00
|
|
|
|
|
|
|
return Future(() => {});
|
2021-06-19 15:41:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-22 03:23:15 +00:00
|
|
|
class ApplicationWidget extends StatelessWidget {
|
2021-06-19 15:41:19 +00:00
|
|
|
final Widget child;
|
2021-07-22 03:23:15 +00:00
|
|
|
const ApplicationWidget({
|
2021-06-19 15:41:19 +00:00
|
|
|
Key? key,
|
|
|
|
required this.child,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-10-11 01:05:53 +00:00
|
|
|
const ratio = 1.73;
|
2021-10-11 05:15:41 +00:00
|
|
|
const minWidth = 500.0;
|
|
|
|
setWindowMinSize(const Size(minWidth, minWidth / ratio));
|
2021-10-11 14:57:27 +00:00
|
|
|
// const launchWidth = 1310.0;
|
|
|
|
// setWindowFrame(const Rect.fromLTWH(0, 0, launchWidth, launchWidth / ratio));
|
2021-06-19 15:41:19 +00:00
|
|
|
|
|
|
|
final theme = AppTheme.fromType(ThemeType.light);
|
2021-10-11 10:26:27 +00:00
|
|
|
FlowyOverlayConfig config = FlowyOverlayConfig(barrierColor: Colors.transparent);
|
2021-06-19 15:41:19 +00:00
|
|
|
return Provider.value(
|
2021-10-13 15:11:45 +00:00
|
|
|
value: theme,
|
|
|
|
child: MaterialApp(
|
|
|
|
builder: overlayManagerBuilder(config: config),
|
|
|
|
debugShowCheckedModeBanner: false,
|
|
|
|
theme: theme.themeData,
|
|
|
|
navigatorKey: AppGlobals.rootNavKey,
|
|
|
|
home: child,
|
|
|
|
),
|
|
|
|
);
|
2021-06-19 15:41:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class AppGlobals {
|
|
|
|
static GlobalKey<NavigatorState> rootNavKey = GlobalKey();
|
|
|
|
static NavigatorState get nav => rootNavKey.currentState!;
|
|
|
|
}
|