Solian/lib/main.dart

66 lines
2.2 KiB
Dart
Raw Normal View History

2024-04-13 00:38:20 +08:00
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:solian/providers/auth.dart';
import 'package:solian/providers/chat.dart';
2024-04-26 20:49:21 +08:00
import 'package:solian/providers/friend.dart';
2024-04-14 00:10:22 +08:00
import 'package:solian/providers/navigation.dart';
2024-04-24 23:19:26 +08:00
import 'package:solian/providers/notify.dart';
2024-05-05 23:01:08 +08:00
import 'package:solian/providers/realm.dart';
2024-04-13 00:38:20 +08:00
import 'package:solian/router.dart';
2024-05-03 12:15:54 +08:00
import 'package:solian/utils/theme.dart';
2024-04-13 19:47:31 +08:00
import 'package:solian/utils/timeago.dart';
2024-04-13 00:38:20 +08:00
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
2024-04-17 20:57:25 +08:00
import 'package:solian/utils/video_player.dart';
2024-04-30 20:31:54 +08:00
import 'package:solian/widgets/chat/call/call_overlay.dart';
2024-04-24 23:19:26 +08:00
import 'package:solian/widgets/notification_notifier.dart';
2024-04-13 00:38:20 +08:00
void main() {
2024-04-27 20:10:15 +08:00
WidgetsFlutterBinding.ensureInitialized();
2024-04-17 20:57:25 +08:00
initVideo();
2024-04-13 19:47:31 +08:00
initTimeAgo();
2024-04-13 00:38:20 +08:00
runApp(const SolianApp());
}
class SolianApp extends StatelessWidget {
const SolianApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp.router(
title: 'Solian',
2024-05-03 12:15:54 +08:00
theme: SolianTheme.build(Brightness.light),
darkTheme: SolianTheme.build(Brightness.dark),
2024-05-01 22:35:58 +08:00
themeMode: ThemeMode.system,
2024-04-13 00:38:20 +08:00
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
routerConfig: SolianRouter.router,
2024-04-13 00:38:20 +08:00
builder: (context, child) {
2024-04-30 20:31:54 +08:00
return MultiProvider(
providers: [
Provider(create: (_) => NavigationProvider()),
ChangeNotifierProvider(create: (_) => AuthProvider()),
ChangeNotifierProvider(create: (_) => ChatProvider()),
ChangeNotifierProvider(create: (_) => NotifyProvider()),
ChangeNotifierProvider(create: (_) => FriendProvider()),
2024-05-05 23:01:08 +08:00
ChangeNotifierProvider(create: (_) => RealmProvider()),
2024-04-13 00:38:20 +08:00
],
2024-04-30 20:31:54 +08:00
child: Overlay(
initialEntries: [
OverlayEntry(builder: (context) {
2024-05-03 14:04:34 +08:00
return ScaffoldMessenger(
child: Scaffold(
body: NotificationNotifier(child: child ?? Container()),
),
);
2024-04-30 20:31:54 +08:00
}),
OverlayEntry(builder: (context) => const CallOverlay()),
],
),
2024-04-13 00:38:20 +08:00
);
},
);
}
}