mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-23 10:11:52 +03:00
Use TargetPlatform for isDesktop/isAndroid.
This commit is contained in:
parent
7c0814a8e0
commit
9d008bb0a6
@ -14,15 +14,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
void launchFeedbackUrl() => _launchUrl(Platform.isAndroid
|
||||
import '../core/state.dart';
|
||||
|
||||
void launchFeedbackUrl() => _launchUrl(isAndroid
|
||||
? 'https://yubi.co/ya-feedback-android'
|
||||
: 'https://yubi.co/ya-feedback-desktop');
|
||||
|
||||
void launchHelpUrl() => _launchUrl(Platform.isAndroid
|
||||
void launchHelpUrl() => _launchUrl(isAndroid
|
||||
? 'https://yubi.co/ya-help-android'
|
||||
: 'https://yubi.co/ya-help-desktop');
|
||||
|
||||
|
@ -14,8 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
@ -115,14 +113,13 @@ class _DevicePickerContent extends ConsumerWidget {
|
||||
_HeroAvatar(
|
||||
child: DeviceAvatar(
|
||||
radius: 64,
|
||||
child: Icon(Platform.isAndroid ? Icons.no_cell : Icons.usb),
|
||||
child: Icon(isAndroid ? Icons.no_cell : Icons.usb),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Center(child: Text(l10n.l_no_yk_present)),
|
||||
subtitle: Center(
|
||||
child: Text(
|
||||
Platform.isAndroid ? l10n.l_insert_or_tap_yk : l10n.s_usb)),
|
||||
child: Text(isAndroid ? l10n.l_insert_or_tap_yk : l10n.s_usb)),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
@ -16,12 +16,12 @@
|
||||
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../android/views/settings_views.dart';
|
||||
import '../../core/state.dart';
|
||||
import '../../widgets/list_title.dart';
|
||||
import '../../widgets/responsive_dialog.dart';
|
||||
import '../state.dart';
|
||||
@ -127,7 +127,7 @@ class SettingsPage extends ConsumerWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (defaultTargetPlatform == TargetPlatform.android) ...[
|
||||
if (isAndroid) ...[
|
||||
ListTitle(l10n.s_nfc_options),
|
||||
const NfcTapActionView(),
|
||||
const NfcKbdLayoutView(),
|
||||
|
@ -14,14 +14,21 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
final isDesktop = Platform.isWindows || Platform.isMacOS || Platform.isLinux;
|
||||
final isAndroid = Platform.isAndroid;
|
||||
bool get isDesktop {
|
||||
return const [
|
||||
TargetPlatform.windows,
|
||||
TargetPlatform.macOS,
|
||||
TargetPlatform.linux
|
||||
].contains(defaultTargetPlatform);
|
||||
}
|
||||
|
||||
bool get isAndroid {
|
||||
return defaultTargetPlatform == TargetPlatform.android;
|
||||
}
|
||||
|
||||
// This must be initialized before use, in main.dart.
|
||||
final prefProvider = Provider<SharedPreferences>((ref) {
|
||||
|
@ -16,7 +16,6 @@
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
@ -177,7 +176,7 @@ class _OathAddAccountPageState extends ConsumerState<OathAddAccountPage> {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
try {
|
||||
if (devicePath == null) {
|
||||
assert(Platform.isAndroid, 'devicePath is only optional for Android');
|
||||
assert(isAndroid, 'devicePath is only optional for Android');
|
||||
await ref
|
||||
.read(addCredentialToAnyProvider)
|
||||
.call(credUri, requireTouch: _touch);
|
||||
@ -334,7 +333,7 @@ class _OathAddAccountPageState extends ConsumerState<OathAddAccountPage> {
|
||||
final devicePath = deviceNode?.path;
|
||||
if (devicePath != null) {
|
||||
await _doAddCredential(devicePath: devicePath, credUri: cred.toUri());
|
||||
} else if (Platform.isAndroid) {
|
||||
} else if (isAndroid) {
|
||||
// Send the credential to Android to be added to the next YubiKey
|
||||
await _doAddCredential(devicePath: null, credUri: cred.toUri());
|
||||
} else {
|
||||
|
@ -14,8 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
@ -24,6 +22,7 @@ import 'package:yubico_authenticator/oath/icon_provider/icon_pack_dialog.dart';
|
||||
import '../../app/message.dart';
|
||||
import '../../app/models.dart';
|
||||
import '../../app/state.dart';
|
||||
import '../../core/state.dart';
|
||||
import '../../exception/cancellation_exception.dart';
|
||||
import '../../widgets/list_title.dart';
|
||||
import '../models.dart';
|
||||
@ -59,7 +58,7 @@ Widget oathBuildActions(
|
||||
? () async {
|
||||
Navigator.of(context).pop();
|
||||
CredentialData? otpauth;
|
||||
if (Platform.isAndroid) {
|
||||
if (isAndroid) {
|
||||
final scanner = ref.read(qrScannerProvider);
|
||||
if (scanner != null) {
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user