fluffychat/lib/main.dart

55 lines
1.7 KiB
Dart
Raw Normal View History

2020-02-24 10:24:58 +01:00
import 'package:flutter/foundation.dart';
2020-01-01 19:10:13 +01:00
import 'package:flutter/material.dart';
2021-10-26 18:50:34 +02:00
2022-11-13 12:40:10 +01:00
import 'package:collection/collection.dart';
2021-01-18 08:38:19 +01:00
import 'package:flutter_app_lock/flutter_app_lock.dart';
2022-11-02 09:57:06 +01:00
import 'package:matrix/matrix.dart';
2021-04-21 14:19:54 +02:00
import 'package:universal_html/html.dart' as html;
2020-01-01 19:10:13 +01:00
2021-10-26 18:50:34 +02:00
import 'package:fluffychat/utils/client_manager.dart';
import 'package:fluffychat/utils/platform_infos.dart';
2021-02-07 17:18:38 +01:00
import 'utils/background_push.dart';
2022-08-25 18:31:30 +02:00
import 'widgets/fluffy_chat_app.dart';
2021-10-26 18:50:34 +02:00
import 'widgets/lock_screen.dart';
2020-09-08 10:55:32 +02:00
2020-12-11 14:14:33 +01:00
void main() async {
2021-02-07 17:18:38 +01:00
// Our background push shared isolate accesses flutter-internal things very early in the startup proccess
// To make sure that the parts of flutter needed are started up already, we need to ensure that the
// widget bindings are initialized already.
WidgetsFlutterBinding.ensureInitialized();
2022-11-02 09:57:06 +01:00
Logs().nativeColors = !PlatformInfos.isIOS;
final clients = await ClientManager.getClients();
2022-11-13 12:40:10 +01:00
// Preload first client
final firstClient = clients.firstOrNull;
await firstClient?.roomsLoading;
await firstClient?.accountDataLoading;
2021-02-07 17:18:38 +01:00
if (PlatformInfos.isMobile) {
BackgroundPush.clientOnly(clients.first);
2021-02-07 17:18:38 +01:00
}
2021-07-08 18:42:46 +02:00
final queryParameters = <String, String>{};
if (kIsWeb) {
queryParameters
.addAll(Uri.parse(html.window.location.href).queryParameters);
}
runApp(
PlatformInfos.isMobile
2021-01-18 08:38:19 +01:00
? AppLock(
2021-07-08 18:42:46 +02:00
builder: (args) => FluffyChatApp(
clients: clients,
2021-07-08 18:42:46 +02:00
queryParameters: queryParameters,
),
2021-10-14 18:09:30 +02:00
lockScreen: const LockScreen(),
2021-01-18 17:31:27 +01:00
enabled: false,
2021-01-18 08:38:19 +01:00
)
2022-08-25 18:31:30 +02:00
: FluffyChatApp(
clients: clients,
queryParameters: queryParameters,
),
2020-09-08 10:55:32 +02:00
);
2020-01-02 22:31:39 +01:00
}