mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-23 10:11:52 +03:00
update codestyle
This commit is contained in:
parent
af593289d1
commit
b3bb49aee6
@ -14,6 +14,6 @@ class FManagementApiImpl extends FManagementApi {
|
||||
@override
|
||||
Future<void> updateDeviceInfo(String deviceInfoJson) async {
|
||||
_log.info('Received: $deviceInfoJson');
|
||||
_ref.read(yubikeyDataCommandProvider.notifier).set(deviceInfoJson);
|
||||
_ref.read(androidYubikeyProvider.notifier).set(deviceInfoJson);
|
||||
}
|
||||
}
|
||||
|
@ -14,12 +14,12 @@ class FOathApiImpl extends FOathApi {
|
||||
@override
|
||||
Future<void> updateOathCredentials(String credentialListJson) async {
|
||||
_log.info('Received: $credentialListJson');
|
||||
_ref.read(oathPairsCommandProvider.notifier).set(credentialListJson);
|
||||
_ref.read(androidCredentialsProvider.notifier).set(credentialListJson);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updateSession(String sessionJson) async {
|
||||
_log.info('Received: $sessionJson');
|
||||
_ref.read(oathStateCommandProvider.notifier).set(sessionJson);
|
||||
_ref.read(androidStateProvider.notifier).set(sessionJson);
|
||||
}
|
||||
}
|
||||
|
@ -7,24 +7,27 @@ import '../app/models.dart';
|
||||
import '../core/models.dart';
|
||||
import '../management/models.dart';
|
||||
|
||||
final log = Logger('yubikeyDataCommandProvider');
|
||||
final _log = Logger('yubikeyDataCommandProvider');
|
||||
|
||||
final yubikeyDataCommandProvider =
|
||||
StateNotifierProvider<YubikeyDataCommandProvider, YubiKeyData?>((ref) {
|
||||
return YubikeyDataCommandProvider(null);
|
||||
final androidYubikeyProvider =
|
||||
StateNotifierProvider<_YubikeyProvider, YubiKeyData?>((ref) {
|
||||
return _YubikeyProvider(null);
|
||||
});
|
||||
|
||||
class YubikeyDataCommandProvider extends StateNotifier<YubiKeyData?> {
|
||||
YubikeyDataCommandProvider(YubiKeyData? yubiKeyData) : super(yubiKeyData);
|
||||
class _YubikeyProvider extends StateNotifier<YubiKeyData?> {
|
||||
_YubikeyProvider(YubiKeyData? yubiKeyData) : super(yubiKeyData);
|
||||
|
||||
void set(String input) {
|
||||
try {
|
||||
if (input.isEmpty) {
|
||||
log.info('Yubikey was detached.');
|
||||
_log.info('Yubikey was detached.');
|
||||
state = null;
|
||||
return;
|
||||
}
|
||||
|
||||
/// a workaround for yubikeys without DEVICE_INFO
|
||||
/// once we have support functionality implemented,
|
||||
/// the following block will not be needed
|
||||
if (input == 'NO_FEATURE_DEVICE_INFO') {
|
||||
// empty data to show some general information in the app
|
||||
DeviceConfig config = DeviceConfig({}, 0, 0, 0);
|
||||
@ -47,7 +50,7 @@ class YubikeyDataCommandProvider extends StateNotifier<YubiKeyData?> {
|
||||
: DeviceNode.usbYubiKey(DevicePath([]), name, -1, deviceInfo);
|
||||
state = YubiKeyData(deviceNode, name, deviceInfo);
|
||||
} on Exception catch (e) {
|
||||
log.info('Invalid data for yubikey: $input. $e');
|
||||
_log.info('Invalid data for yubikey: $input. $e');
|
||||
state = null;
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +0,0 @@
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
import '../command_providers.dart';
|
||||
import '../init.dart';
|
||||
|
||||
final log = Logger('android.info.state');
|
||||
|
||||
void setupInfoPageMethodChannel(ref) {
|
||||
methodChannel.setMethodCallHandler((call) async {
|
||||
log.info('Received: $call');
|
||||
switch (call.method) {
|
||||
case 'deviceInfo':
|
||||
ref.read(yubikeyDataCommandProvider.notifier).set(call.arguments);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
@ -1,19 +1,17 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:yubico_authenticator/android/oath/state.dart';
|
||||
import 'package:yubico_authenticator/android/state.dart';
|
||||
import 'package:yubico_authenticator/android/views/tap_request_dialog.dart';
|
||||
import 'package:yubico_authenticator/app/state.dart';
|
||||
import 'package:yubico_authenticator/oath/state.dart';
|
||||
|
||||
import 'oath/state.dart';
|
||||
import 'state.dart';
|
||||
import 'views/tap_request_dialog.dart';
|
||||
import '../app/state.dart';
|
||||
import '../oath/state.dart';
|
||||
|
||||
final _log = Logger('android.init');
|
||||
|
||||
const methodChannel = MethodChannel('com.yubico.yubikit_android/channel');
|
||||
|
||||
initializeLogging() {
|
||||
Logger.root.onRecord.listen((record) {
|
||||
if (record.level >= Logger.root.level) {
|
||||
|
@ -4,13 +4,13 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../oath/models.dart';
|
||||
|
||||
final oathStateCommandProvider =
|
||||
StateNotifierProvider<OathStateCommandProvider, OathState?>((ref) {
|
||||
return OathStateCommandProvider(null);
|
||||
final androidStateProvider =
|
||||
StateNotifierProvider<_StateProvider, OathState?>((ref) {
|
||||
return _StateProvider(null);
|
||||
});
|
||||
|
||||
class OathStateCommandProvider extends StateNotifier<OathState?> {
|
||||
OathStateCommandProvider(OathState? oathState) : super(oathState);
|
||||
class _StateProvider extends StateNotifier<OathState?> {
|
||||
_StateProvider(OathState? oathState) : super(oathState);
|
||||
|
||||
void set(String input) {
|
||||
var resultJson = jsonDecode(input);
|
||||
@ -22,15 +22,13 @@ class OathStateCommandProvider extends StateNotifier<OathState?> {
|
||||
}
|
||||
}
|
||||
|
||||
final oathPairsCommandProvider =
|
||||
StateNotifierProvider<OathCredentialsCommandProvider, List<OathPair>>(
|
||||
(ref) {
|
||||
return OathCredentialsCommandProvider([]);
|
||||
final androidCredentialsProvider =
|
||||
StateNotifierProvider<_CredentialsProvider, List<OathPair>>((ref) {
|
||||
return _CredentialsProvider([]);
|
||||
});
|
||||
|
||||
class OathCredentialsCommandProvider extends StateNotifier<List<OathPair>> {
|
||||
OathCredentialsCommandProvider(List<OathPair> credentials)
|
||||
: super(credentials);
|
||||
class _CredentialsProvider extends StateNotifier<List<OathPair>> {
|
||||
_CredentialsProvider(List<OathPair> credentials) : super(credentials);
|
||||
|
||||
void set(String input) {
|
||||
var result = jsonDecode(input);
|
||||
|
@ -24,7 +24,7 @@ final oathApiProvider = StateProvider((_) => OathApi());
|
||||
final androidOathStateProvider = StateNotifierProvider.autoDispose
|
||||
.family<OathStateNotifier, OathState?, DevicePath>((ref, devicePath) =>
|
||||
_AndroidOathStateNotifier(
|
||||
ref.watch(oathStateCommandProvider), ref.watch(oathApiProvider)));
|
||||
ref.watch(androidStateProvider), ref.watch(oathApiProvider)));
|
||||
|
||||
class _AndroidOathStateNotifier extends OathStateNotifier {
|
||||
final OathApi _api;
|
||||
@ -100,7 +100,7 @@ final androidCredentialListProvider = StateNotifierProvider.autoDispose
|
||||
(ref, devicePath) {
|
||||
var notifier = _AndroidCredentialListNotifier(
|
||||
ref.watch(oathApiProvider),
|
||||
ref.watch(oathPairsCommandProvider),
|
||||
ref.watch(androidCredentialsProvider),
|
||||
ref.watch(oathStateProvider(devicePath).select((s) => s?.locked ?? true)),
|
||||
);
|
||||
ref.listen<WindowState>(windowStateProvider, (_, windowState) {
|
||||
|
@ -42,4 +42,4 @@ final androidAttachedDevicesProvider = Provider<List<DeviceNode>>((ref) {
|
||||
});
|
||||
|
||||
final androidDeviceDataProvider =
|
||||
Provider<YubiKeyData?>((ref) => ref.watch(yubikeyDataCommandProvider));
|
||||
Provider<YubiKeyData?>((ref) => ref.watch(androidYubikeyProvider));
|
||||
|
@ -3,8 +3,8 @@ import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:yubico_authenticator/android/api/impl.dart';
|
||||
|
||||
import '../api/impl.dart';
|
||||
import '../../app/navigation_service.dart';
|
||||
|
||||
class FDialogApiImpl extends FDialogApi {
|
||||
|
@ -3,6 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import 'state.dart';
|
||||
import '../theme.dart';
|
||||
import 'navigation_service.dart';
|
||||
|
||||
class YubicoAuthenticatorApp extends ConsumerWidget {
|
||||
final Widget page;
|
||||
@ -12,6 +13,7 @@ class YubicoAuthenticatorApp extends ConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return MaterialApp(
|
||||
navigatorKey: NavigationService.navigatorKey,
|
||||
title: 'Yubico Authenticator',
|
||||
theme: AppTheme.lightTheme,
|
||||
darkTheme: AppTheme.darkTheme,
|
||||
|
@ -1,7 +1,5 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
/// Temporary service which is used to get context of the top app widget
|
||||
/// currently used by nfc operation dialogs
|
||||
class NavigationService {
|
||||
static GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
||||
}
|
||||
|
@ -22,3 +22,4 @@ class LogLevelNotifier extends StateNotifier<Level> {
|
||||
}
|
||||
|
||||
final isDesktop = Platform.isWindows || Platform.isMacOS || Platform.isLinux;
|
||||
final isAndroid = Platform.isAndroid;
|
||||
|
@ -4,14 +4,14 @@ import 'dart:io';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'android/init.dart' as android;
|
||||
import 'app/app.dart';
|
||||
import 'app/views/main_page.dart';
|
||||
import 'core/state.dart';
|
||||
import 'desktop/init.dart' as desktop;
|
||||
|
||||
import 'error_page.dart';
|
||||
|
||||
final _log = Logger('main');
|
||||
@ -26,7 +26,9 @@ void main() async {
|
||||
if (isDesktop) {
|
||||
desktop.initializeLogging();
|
||||
}
|
||||
// TODO: android.initializeLogging() to set up bridge to logcat.
|
||||
if (isAndroid) {
|
||||
android.initializeLogging();
|
||||
}
|
||||
}
|
||||
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
@ -41,6 +43,9 @@ void main() async {
|
||||
if (isDesktop) {
|
||||
_log.config('Initializing desktop platform.');
|
||||
overrides.addAll(await desktop.initializeAndGetOverrides(prefs));
|
||||
} else if (isAndroid) {
|
||||
_log.config('Initializing Android platform.');
|
||||
overrides.addAll(await android.initializeAndGetOverrides());
|
||||
}
|
||||
page = const MainPage();
|
||||
} catch (e) {
|
||||
|
Loading…
Reference in New Issue
Block a user