2024-06-06 15:28:19 +00:00
|
|
|
import 'package:firebase_core/firebase_core.dart';
|
2024-05-18 10:17:16 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2024-06-22 15:20:31 +00:00
|
|
|
import 'package:flutter_acrylic/flutter_acrylic.dart';
|
2024-05-18 14:23:36 +00:00
|
|
|
import 'package:get/get.dart';
|
2024-07-06 11:07:46 +00:00
|
|
|
import 'package:media_kit/media_kit.dart';
|
2024-06-29 10:09:56 +00:00
|
|
|
import 'package:protocol_handler/protocol_handler.dart';
|
2024-06-01 16:42:36 +00:00
|
|
|
import 'package:sentry_flutter/sentry_flutter.dart';
|
2024-06-07 11:49:14 +00:00
|
|
|
import 'package:solian/exts.dart';
|
2024-06-06 15:28:19 +00:00
|
|
|
import 'package:solian/firebase_options.dart';
|
2024-06-22 15:20:31 +00:00
|
|
|
import 'package:solian/platform.dart';
|
2024-07-16 11:46:53 +00:00
|
|
|
import 'package:solian/providers/websocket.dart';
|
2024-05-18 14:23:36 +00:00
|
|
|
import 'package:solian/providers/auth.dart';
|
2024-05-22 15:18:01 +00:00
|
|
|
import 'package:solian/providers/content/attachment.dart';
|
2024-07-23 17:17:41 +00:00
|
|
|
import 'package:solian/providers/call.dart';
|
2024-05-25 16:11:00 +00:00
|
|
|
import 'package:solian/providers/content/channel.dart';
|
2024-07-23 10:09:41 +00:00
|
|
|
import 'package:solian/providers/content/posts.dart';
|
2024-05-25 16:11:00 +00:00
|
|
|
import 'package:solian/providers/content/realm.dart';
|
2024-07-23 17:17:41 +00:00
|
|
|
import 'package:solian/providers/relation.dart';
|
2024-06-26 17:33:03 +00:00
|
|
|
import 'package:solian/providers/account_status.dart';
|
2024-05-18 10:17:16 +00:00
|
|
|
import 'package:solian/router.dart';
|
2024-07-07 06:41:23 +00:00
|
|
|
import 'package:solian/shells/system_shell.dart';
|
2024-05-18 10:17:16 +00:00
|
|
|
import 'package:solian/theme.dart';
|
|
|
|
import 'package:solian/translations.dart';
|
|
|
|
|
2024-06-01 16:42:36 +00:00
|
|
|
void main() async {
|
|
|
|
await SentryFlutter.init(
|
|
|
|
(options) {
|
|
|
|
options.dsn =
|
|
|
|
'https://55438cdff9048aa2225df72fdc629c42@o4506965897117696.ingest.us.sentry.io/4507357676437504';
|
|
|
|
options.tracesSampleRate = 1.0;
|
|
|
|
options.profilesSampleRate = 1.0;
|
|
|
|
},
|
2024-06-09 15:30:01 +00:00
|
|
|
appRunner: () async {
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
2024-07-06 11:07:46 +00:00
|
|
|
MediaKit.ensureInitialized();
|
2024-06-09 15:30:01 +00:00
|
|
|
|
2024-07-06 10:17:54 +00:00
|
|
|
await Future.wait([
|
|
|
|
_initializeFirebase(),
|
|
|
|
_initializePlatformComponents(),
|
|
|
|
]);
|
2024-06-09 15:30:01 +00:00
|
|
|
|
|
|
|
runApp(const SolianApp());
|
|
|
|
},
|
2024-06-01 16:42:36 +00:00
|
|
|
);
|
2024-05-18 10:17:16 +00:00
|
|
|
}
|
|
|
|
|
2024-07-05 15:37:54 +00:00
|
|
|
Future<void> _initializeFirebase() async {
|
|
|
|
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> _initializePlatformComponents() async {
|
|
|
|
if (!PlatformInfo.isWeb) {
|
|
|
|
await protocolHandler.register('solink');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (PlatformInfo.isDesktop) {
|
|
|
|
await Window.initialize();
|
|
|
|
|
|
|
|
if (PlatformInfo.isMacOS) {
|
|
|
|
await Future.wait([
|
|
|
|
Window.hideTitle(),
|
|
|
|
Window.makeTitlebarTransparent(),
|
|
|
|
Window.enableFullSizeContentView(),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-18 10:17:16 +00:00
|
|
|
class SolianApp extends StatelessWidget {
|
|
|
|
const SolianApp({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return GetMaterialApp.router(
|
|
|
|
title: 'Solian',
|
|
|
|
theme: SolianTheme.build(Brightness.light),
|
|
|
|
darkTheme: SolianTheme.build(Brightness.dark),
|
|
|
|
themeMode: ThemeMode.system,
|
|
|
|
routerDelegate: AppRouter.instance.routerDelegate,
|
|
|
|
routeInformationParser: AppRouter.instance.routeInformationParser,
|
|
|
|
routeInformationProvider: AppRouter.instance.routeInformationProvider,
|
2024-07-06 12:55:53 +00:00
|
|
|
backButtonDispatcher: AppRouter.instance.backButtonDispatcher,
|
2024-05-18 10:17:16 +00:00
|
|
|
translations: SolianMessages(),
|
|
|
|
locale: Get.deviceLocale,
|
|
|
|
fallbackLocale: const Locale('en', 'US'),
|
2024-07-05 15:37:54 +00:00
|
|
|
onInit: () => _initializeProviders(context),
|
2024-05-18 10:17:16 +00:00
|
|
|
builder: (context, child) {
|
2024-07-07 06:41:23 +00:00
|
|
|
return SystemShell(
|
2024-07-12 05:15:46 +00:00
|
|
|
child: ScaffoldMessenger(
|
|
|
|
child: child ?? const SizedBox(),
|
2024-07-07 06:41:23 +00:00
|
|
|
),
|
2024-05-18 10:17:16 +00:00
|
|
|
);
|
2024-06-22 15:59:11 +00:00
|
|
|
},
|
2024-05-18 10:17:16 +00:00
|
|
|
);
|
|
|
|
}
|
2024-07-05 15:37:54 +00:00
|
|
|
|
2024-07-12 13:59:16 +00:00
|
|
|
void _initializeProviders(BuildContext context) async {
|
2024-07-05 15:37:54 +00:00
|
|
|
Get.lazyPut(() => AuthProvider());
|
2024-07-23 17:17:41 +00:00
|
|
|
Get.lazyPut(() => RelationshipProvider());
|
2024-07-23 10:09:41 +00:00
|
|
|
Get.lazyPut(() => PostProvider());
|
2024-07-05 15:37:54 +00:00
|
|
|
Get.lazyPut(() => AttachmentProvider());
|
2024-07-16 11:46:53 +00:00
|
|
|
Get.lazyPut(() => WebSocketProvider());
|
2024-07-05 15:37:54 +00:00
|
|
|
Get.lazyPut(() => StatusProvider());
|
|
|
|
Get.lazyPut(() => ChannelProvider());
|
|
|
|
Get.lazyPut(() => RealmProvider());
|
|
|
|
Get.lazyPut(() => ChatCallProvider());
|
|
|
|
|
|
|
|
final AuthProvider auth = Get.find();
|
|
|
|
|
2024-07-24 17:18:47 +00:00
|
|
|
auth.refreshAuthorizeStatus().then((_) {
|
|
|
|
if (auth.isAuthorized.isFalse) return;
|
|
|
|
|
|
|
|
Get.find<WebSocketProvider>().connect();
|
2024-07-12 13:59:16 +00:00
|
|
|
Get.find<ChannelProvider>().refreshAvailableChannel();
|
|
|
|
|
|
|
|
try {
|
2024-07-16 11:46:53 +00:00
|
|
|
Get.find<WebSocketProvider>().registerPushNotifications();
|
2024-07-12 13:59:16 +00:00
|
|
|
} catch (err) {
|
|
|
|
context.showSnackbar(
|
|
|
|
'pushNotifyRegisterFailed'.trParams({'reason': err.toString()}),
|
|
|
|
);
|
2024-07-05 15:37:54 +00:00
|
|
|
}
|
2024-07-24 17:18:47 +00:00
|
|
|
});
|
2024-07-05 15:37:54 +00:00
|
|
|
}
|
2024-05-18 10:17:16 +00:00
|
|
|
}
|