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;
|
2021-09-19 13:48:23 +02:00
|
|
|
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-06-23 15:35:23 +02:00
|
|
|
|
2021-02-07 17:18:38 +01:00
|
|
|
if (PlatformInfos.isMobile) {
|
2021-09-19 13:48:23 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2022-08-14 16:18:18 +02:00
|
|
|
runApp(
|
|
|
|
PlatformInfos.isMobile
|
2021-01-18 08:38:19 +01:00
|
|
|
? AppLock(
|
2021-07-08 18:42:46 +02:00
|
|
|
builder: (args) => FluffyChatApp(
|
2021-09-19 13:48:23 +02:00
|
|
|
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
|
|
|
}
|