2020-02-24 09:24:58 +00:00
|
|
|
import 'package:flutter/foundation.dart';
|
2020-01-01 18:10:13 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2021-10-26 16:50:34 +00:00
|
|
|
|
2022-11-13 11:40:10 +00:00
|
|
|
import 'package:collection/collection.dart';
|
2021-01-18 07:38:19 +00:00
|
|
|
import 'package:flutter_app_lock/flutter_app_lock.dart';
|
2022-11-02 08:57:06 +00:00
|
|
|
import 'package:matrix/matrix.dart';
|
2021-04-21 12:19:54 +00:00
|
|
|
import 'package:universal_html/html.dart' as html;
|
2020-01-01 18:10:13 +00:00
|
|
|
|
2021-10-26 16:50:34 +00:00
|
|
|
import 'package:fluffychat/utils/client_manager.dart';
|
|
|
|
import 'package:fluffychat/utils/platform_infos.dart';
|
2021-02-07 16:18:38 +00:00
|
|
|
import 'utils/background_push.dart';
|
2022-08-25 16:31:30 +00:00
|
|
|
import 'widgets/fluffy_chat_app.dart';
|
2021-10-26 16:50:34 +00:00
|
|
|
import 'widgets/lock_screen.dart';
|
2020-09-08 08:55:32 +00:00
|
|
|
|
2020-12-11 13:14:33 +00:00
|
|
|
void main() async {
|
2021-02-07 16:18:38 +00: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 08:57:06 +00:00
|
|
|
Logs().nativeColors = !PlatformInfos.isIOS;
|
2021-09-19 11:48:23 +00:00
|
|
|
final clients = await ClientManager.getClients();
|
2022-11-13 11:40:10 +00:00
|
|
|
|
|
|
|
// Preload first client
|
|
|
|
final firstClient = clients.firstOrNull;
|
|
|
|
await firstClient?.roomsLoading;
|
|
|
|
await firstClient?.accountDataLoading;
|
2021-06-23 13:35:23 +00:00
|
|
|
|
2021-02-07 16:18:38 +00:00
|
|
|
if (PlatformInfos.isMobile) {
|
2021-09-19 11:48:23 +00:00
|
|
|
BackgroundPush.clientOnly(clients.first);
|
2021-02-07 16:18:38 +00:00
|
|
|
}
|
|
|
|
|
2021-07-08 16:42:46 +00:00
|
|
|
final queryParameters = <String, String>{};
|
|
|
|
if (kIsWeb) {
|
|
|
|
queryParameters
|
|
|
|
.addAll(Uri.parse(html.window.location.href).queryParameters);
|
|
|
|
}
|
|
|
|
|
2022-08-14 14:18:18 +00:00
|
|
|
runApp(
|
|
|
|
PlatformInfos.isMobile
|
2021-01-18 07:38:19 +00:00
|
|
|
? AppLock(
|
2021-07-08 16:42:46 +00:00
|
|
|
builder: (args) => FluffyChatApp(
|
2021-09-19 11:48:23 +00:00
|
|
|
clients: clients,
|
2021-07-08 16:42:46 +00:00
|
|
|
queryParameters: queryParameters,
|
|
|
|
),
|
2021-10-14 16:09:30 +00:00
|
|
|
lockScreen: const LockScreen(),
|
2021-01-18 16:31:27 +00:00
|
|
|
enabled: false,
|
2021-01-18 07:38:19 +00:00
|
|
|
)
|
2022-08-25 16:31:30 +00:00
|
|
|
: FluffyChatApp(
|
|
|
|
clients: clients,
|
|
|
|
queryParameters: queryParameters,
|
|
|
|
),
|
2020-09-08 08:55:32 +00:00
|
|
|
);
|
2020-01-02 21:31:39 +00:00
|
|
|
}
|