yubioath-flutter/lib/android/init.dart

56 lines
1.9 KiB
Dart
Raw Normal View History

2022-03-03 18:43:36 +03:00
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:logging/logging.dart';
import 'package:shared_preferences/shared_preferences.dart';
2022-03-03 18:43:36 +03:00
import '../app/app.dart';
import '../app/models.dart';
import '../app/views/main_page.dart';
import '../core/state.dart';
2022-03-16 12:37:52 +03:00
import '../management/state.dart';
import 'management/state.dart';
2022-03-03 19:24:26 +03:00
import 'oath/state.dart';
import 'state.dart';
import 'views/tap_request_dialog.dart';
import '../app/state.dart';
import '../oath/state.dart';
2022-03-03 18:43:36 +03:00
2022-03-03 19:24:26 +03:00
final _log = Logger('android.init');
2022-03-03 18:43:36 +03:00
Future<Widget> initialize() async {
2022-03-03 18:43:36 +03:00
Logger.root.onRecord.listen((record) {
if (record.level >= Logger.root.level) {
debugPrint('[${record.loggerName}] ${record.level}: ${record.message}');
if (record.error != null) {
debugPrint(record.error.toString());
}
}
});
_log.info('Logging initialized, outputting to stderr');
/// initializes global handler for dialogs
TapRequestDialog.initialize();
return ProviderScope(
overrides: [
supportedAppsProvider.overrideWithValue([
Application.oath,
Application.management,
]),
prefProvider.overrideWithValue(await SharedPreferences.getInstance()),
attachedDevicesProvider
.overrideWithProvider(androidAttachedDevicesProvider),
currentDeviceDataProvider.overrideWithProvider(androidDeviceDataProvider),
oathStateProvider.overrideWithProvider(androidOathStateProvider),
credentialListProvider
.overrideWithProvider(androidCredentialListProvider),
currentAppProvider.overrideWithProvider(androidSubPageProvider),
managementStateProvider.overrideWithProvider(androidManagementState),
currentDeviceProvider.overrideWithProvider(androidCurrentDeviceProvider)
],
child: const YubicoAuthenticatorApp(page: MainPage()),
);
2022-03-03 18:43:36 +03:00
}