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