You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.7 KiB
Dart
54 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:matrix/matrix.dart';
|
|
|
|
import 'package:fluffychat/config/routes.dart';
|
|
import 'package:fluffychat/config/themes.dart';
|
|
import 'package:fluffychat/widgets/theme_builder.dart';
|
|
import '../config/app_config.dart';
|
|
import '../utils/custom_scroll_behaviour.dart';
|
|
import 'matrix.dart';
|
|
|
|
class FluffyChatApp extends StatelessWidget {
|
|
final Widget? testWidget;
|
|
final List<Client> clients;
|
|
|
|
const FluffyChatApp({
|
|
Key? key,
|
|
this.testWidget,
|
|
required this.clients,
|
|
}) : super(key: key);
|
|
|
|
/// getInitialLink may rereturn the value multiple times if this view is
|
|
/// opened multiple times for example if the user logs out after they logged
|
|
/// in with qr code or magic link.
|
|
static bool gotInitialLink = false;
|
|
|
|
// Router must be outside of build method so that hot reload does not reset
|
|
// the current path.
|
|
static final GoRouter router = GoRouter(routes: AppRoutes.routes);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ThemeBuilder(
|
|
builder: (context, themeMode, primaryColor) => MaterialApp.router(
|
|
title: AppConfig.applicationName,
|
|
themeMode: themeMode,
|
|
theme: FluffyThemes.buildTheme(Brightness.light, primaryColor),
|
|
darkTheme: FluffyThemes.buildTheme(Brightness.dark, primaryColor),
|
|
scrollBehavior: CustomScrollBehavior(),
|
|
localizationsDelegates: L10n.localizationsDelegates,
|
|
supportedLocales: L10n.supportedLocales,
|
|
routerConfig: router,
|
|
builder: (context, child) => Matrix(
|
|
context: context,
|
|
clients: clients,
|
|
child: testWidget ?? child,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|