fluffychat/lib/main.dart

70 lines
2.3 KiB
Dart
Raw Normal View History

2020-12-19 13:06:31 +01:00
// @dart=2.9
2020-09-08 10:55:32 +02:00
import 'dart:async';
2020-02-23 08:49:58 +01:00
2021-01-15 19:41:55 +01:00
import 'package:adaptive_theme/adaptive_theme.dart';
2021-01-16 12:46:38 +01:00
import 'package:adaptive_page_layout/adaptive_page_layout.dart';
import 'package:fluffychat/config/routes.dart';
2020-10-28 10:56:24 +01:00
import 'package:fluffychat/utils/sentry_controller.dart';
2021-01-16 12:46:38 +01:00
import 'package:flutter/cupertino.dart';
2020-02-24 10:24:58 +01:00
import 'package:flutter/foundation.dart';
2020-01-01 19:10:13 +01:00
import 'package:flutter/material.dart';
2020-01-02 22:31:39 +01:00
import 'package:flutter/services.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:universal_html/prefer_universal/html.dart' as html;
2020-01-01 19:10:13 +01:00
import 'components/matrix.dart';
2021-01-15 19:41:55 +01:00
import 'config/themes.dart';
2020-12-11 14:14:33 +01:00
import 'app_config.dart';
2020-09-08 10:55:32 +02:00
2020-12-11 14:14:33 +01:00
void main() async {
2020-01-02 22:31:39 +01:00
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(statusBarColor: Colors.transparent));
2020-10-28 18:13:04 +01:00
FlutterError.onError = (FlutterErrorDetails details) =>
Zone.current.handleUncaughtError(details.exception, details.stack);
2020-09-08 10:55:32 +02:00
runZonedGuarded(
() => runApp(App()),
2020-10-28 10:56:24 +01:00
SentryController.captureException,
2020-09-08 10:55:32 +02:00
);
2020-01-02 22:31:39 +01:00
}
2020-01-01 19:10:13 +01:00
2020-01-02 22:31:39 +01:00
class App extends StatelessWidget {
2021-01-16 12:46:38 +01:00
final GlobalKey<AdaptivePageLayoutState> _apl =
GlobalKey<AdaptivePageLayoutState>();
2020-01-01 19:10:13 +01:00
@override
Widget build(BuildContext context) {
2021-01-16 12:46:38 +01:00
return AdaptiveTheme(
light: FluffyThemes.light,
dark: FluffyThemes.dark,
initial: AdaptiveThemeMode.system,
builder: (theme, darkTheme) => MaterialApp(
title: '${AppConfig.applicationName}',
theme: theme,
darkTheme: darkTheme,
localizationsDelegates: L10n.localizationsDelegates,
supportedLocales: L10n.supportedLocales,
locale: kIsWeb
? Locale(html.window.navigator.language.split('-').first)
: null,
home: Builder(
builder: (context) => Matrix(
context: context,
apl: _apl,
child: Builder(
builder: (context) => AdaptivePageLayout(
key: _apl,
onGenerateRoute: FluffyRoutes(context).onGenerateRoute,
dividerColor: Theme.of(context).dividerColor,
columnWidth: FluffyThemes.columnWidth,
routeBuilder: (builder, settings) =>
_apl.currentState.columnMode(context)
? FadeRoute(page: builder(context))
: CupertinoPageRoute(builder: builder),
),
2021-01-15 19:41:55 +01:00
),
),
2020-01-01 19:10:13 +01:00
),
),
);
}
}