2023-07-26 14:20:29 -04:00
|
|
|
import 'package:animated_theme_switcher/animated_theme_switcher.dart';
|
2023-07-26 15:58:38 -04:00
|
|
|
import 'package:flutter/foundation.dart';
|
2023-01-08 22:27:33 -05:00
|
|
|
import 'package:flutter/material.dart';
|
2023-12-26 20:26:54 -05:00
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
2023-07-07 19:33:28 -04:00
|
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
2023-07-26 14:20:29 -04:00
|
|
|
import 'package:flutter_translate/flutter_translate.dart';
|
2023-07-24 09:31:51 -04:00
|
|
|
import 'package:form_builder_validators/form_builder_validators.dart';
|
2023-07-26 14:20:29 -04:00
|
|
|
|
2023-12-27 22:56:24 -05:00
|
|
|
import 'account_manager/account_manager.dart';
|
2023-01-09 22:50:34 -05:00
|
|
|
import 'router/router.dart';
|
2024-01-08 21:37:08 -05:00
|
|
|
import 'settings/settings.dart';
|
2023-08-08 02:03:26 -04:00
|
|
|
import 'tick.dart';
|
2024-02-12 10:35:41 -05:00
|
|
|
import 'veilid_processor/veilid_processor.dart';
|
2023-01-08 22:27:33 -05:00
|
|
|
|
2023-12-26 20:26:54 -05:00
|
|
|
class VeilidChatApp extends StatelessWidget {
|
2023-01-08 22:27:33 -05:00
|
|
|
const VeilidChatApp({
|
2024-01-08 21:37:08 -05:00
|
|
|
required this.initialThemeData,
|
2023-07-26 15:58:38 -04:00
|
|
|
super.key,
|
2023-07-26 14:20:29 -04:00
|
|
|
});
|
2023-01-08 22:27:33 -05:00
|
|
|
|
2023-12-27 22:56:24 -05:00
|
|
|
static const String name = 'VeilidChat';
|
|
|
|
|
2024-01-08 21:37:08 -05:00
|
|
|
final ThemeData initialThemeData;
|
2023-01-08 22:27:33 -05:00
|
|
|
|
|
|
|
@override
|
2023-12-26 20:26:54 -05:00
|
|
|
Widget build(BuildContext context) {
|
2023-07-26 14:20:29 -04:00
|
|
|
final localizationDelegate = LocalizedApp.of(context).delegate;
|
2023-07-07 19:33:28 -04:00
|
|
|
|
2023-01-08 22:27:33 -05:00
|
|
|
return ThemeProvider(
|
2024-01-08 21:37:08 -05:00
|
|
|
initTheme: initialThemeData,
|
2023-08-08 02:03:26 -04:00
|
|
|
builder: (_, theme) => LocalizationProvider(
|
|
|
|
state: LocalizationProvider.of(context).state,
|
2023-12-27 22:56:24 -05:00
|
|
|
child: MultiBlocProvider(
|
|
|
|
providers: [
|
2024-02-12 10:35:41 -05:00
|
|
|
BlocProvider<ConnectionStateCubit>(
|
|
|
|
create: (context) =>
|
|
|
|
ConnectionStateCubit(ProcessorRepository.instance)),
|
2023-12-27 22:56:24 -05:00
|
|
|
BlocProvider<RouterCubit>(
|
|
|
|
create: (context) =>
|
|
|
|
RouterCubit(AccountRepository.instance),
|
|
|
|
),
|
|
|
|
BlocProvider<LocalAccountsCubit>(
|
|
|
|
create: (context) =>
|
|
|
|
LocalAccountsCubit(AccountRepository.instance),
|
|
|
|
),
|
|
|
|
BlocProvider<UserLoginsCubit>(
|
|
|
|
create: (context) =>
|
|
|
|
UserLoginsCubit(AccountRepository.instance),
|
|
|
|
),
|
2024-02-13 22:03:26 -05:00
|
|
|
BlocProvider<ActiveLocalAccountCubit>(
|
2023-12-27 22:56:24 -05:00
|
|
|
create: (context) =>
|
2024-02-13 22:03:26 -05:00
|
|
|
ActiveLocalAccountCubit(AccountRepository.instance),
|
2023-12-27 22:56:24 -05:00
|
|
|
),
|
2024-01-08 21:37:08 -05:00
|
|
|
BlocProvider<PreferencesCubit>(
|
|
|
|
create: (context) =>
|
|
|
|
PreferencesCubit(PreferencesRepository.instance),
|
|
|
|
)
|
2023-12-27 22:56:24 -05:00
|
|
|
],
|
|
|
|
child: BackgroundTicker(
|
|
|
|
builder: (context) => MaterialApp.router(
|
|
|
|
debugShowCheckedModeBanner: false,
|
2024-02-12 22:30:09 -05:00
|
|
|
routerConfig: context.watch<RouterCubit>().router(),
|
2023-12-27 22:56:24 -05:00
|
|
|
title: translate('app.title'),
|
|
|
|
theme: theme,
|
|
|
|
localizationsDelegates: [
|
|
|
|
GlobalMaterialLocalizations.delegate,
|
|
|
|
GlobalWidgetsLocalizations.delegate,
|
|
|
|
FormBuilderLocalizations.delegate,
|
|
|
|
localizationDelegate
|
|
|
|
],
|
|
|
|
supportedLocales: localizationDelegate.supportedLocales,
|
|
|
|
locale: localizationDelegate.currentLocale,
|
|
|
|
),
|
|
|
|
)),
|
2023-08-08 02:03:26 -04:00
|
|
|
));
|
2023-01-08 22:27:33 -05:00
|
|
|
}
|
2023-07-26 15:58:38 -04:00
|
|
|
|
2023-07-26 14:20:29 -04:00
|
|
|
@override
|
|
|
|
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
|
|
|
super.debugFillProperties(properties);
|
2024-01-08 21:37:08 -05:00
|
|
|
properties
|
|
|
|
.add(DiagnosticsProperty<ThemeData>('themeData', initialThemeData));
|
2023-07-26 14:20:29 -04:00
|
|
|
}
|
2023-01-08 22:27:33 -05:00
|
|
|
}
|