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-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_riverpod/flutter_riverpod.dart';
|
|
|
|
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-01-09 22:50:34 -05:00
|
|
|
import 'router/router.dart';
|
2023-01-08 22:27:33 -05:00
|
|
|
|
2023-01-09 22:50:34 -05:00
|
|
|
class VeilidChatApp extends ConsumerWidget {
|
2023-01-08 22:27:33 -05:00
|
|
|
const VeilidChatApp({
|
2023-07-26 15:58:38 -04:00
|
|
|
required this.theme,
|
|
|
|
super.key,
|
2023-07-26 14:20:29 -04:00
|
|
|
});
|
2023-01-08 22:27:33 -05:00
|
|
|
|
|
|
|
final ThemeData theme;
|
|
|
|
|
|
|
|
@override
|
2023-01-09 22:50:34 -05:00
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
|
|
final router = ref.watch(routerProvider);
|
|
|
|
|
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(
|
|
|
|
initTheme: theme,
|
2023-07-26 14:20:29 -04:00
|
|
|
builder: (_, theme) => LocalizationProvider(
|
2023-07-26 15:58:38 -04:00
|
|
|
state: LocalizationProvider.of(context).state,
|
|
|
|
child: MaterialApp.router(
|
|
|
|
debugShowCheckedModeBanner: false,
|
|
|
|
routerConfig: router,
|
|
|
|
title: translate('app.title'),
|
|
|
|
theme: theme,
|
|
|
|
localizationsDelegates: [
|
|
|
|
GlobalMaterialLocalizations.delegate,
|
|
|
|
GlobalWidgetsLocalizations.delegate,
|
|
|
|
FormBuilderLocalizations.delegate,
|
|
|
|
localizationDelegate
|
|
|
|
],
|
|
|
|
supportedLocales: localizationDelegate.supportedLocales,
|
|
|
|
locale: localizationDelegate.currentLocale,
|
|
|
|
)),
|
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);
|
|
|
|
properties.add(DiagnosticsProperty<ThemeData>('theme', theme));
|
|
|
|
}
|
2023-01-08 22:27:33 -05:00
|
|
|
}
|