2023-01-12 10:56:08 +03:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2023 Yubico.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
|
|
|
|
|
|
import '../../app/message.dart';
|
|
|
|
import '../../app/models.dart';
|
|
|
|
import '../../widgets/list_title.dart';
|
|
|
|
import '../models.dart';
|
|
|
|
import 'add_fingerprint_dialog.dart';
|
|
|
|
import 'pin_dialog.dart';
|
|
|
|
import 'reset_dialog.dart';
|
|
|
|
|
|
|
|
Widget fidoBuildActions(
|
|
|
|
BuildContext context, DeviceNode node, FidoState state, int fingerprints) {
|
2023-02-28 21:05:46 +03:00
|
|
|
final l10n = AppLocalizations.of(context)!;
|
2023-02-03 11:56:23 +03:00
|
|
|
final theme = Theme.of(context).colorScheme;
|
2023-01-12 10:56:08 +03:00
|
|
|
return SimpleDialog(
|
|
|
|
children: [
|
|
|
|
if (state.bioEnroll != null) ...[
|
2023-02-28 21:05:46 +03:00
|
|
|
ListTitle(l10n.w_setup,
|
2023-01-12 10:56:08 +03:00
|
|
|
textStyle: Theme.of(context).textTheme.bodyLarge),
|
|
|
|
ListTile(
|
|
|
|
leading: const CircleAvatar(child: Icon(Icons.fingerprint_outlined)),
|
2023-02-28 21:05:46 +03:00
|
|
|
title: Text(l10n.l_add_fingerprint),
|
2023-01-12 10:56:08 +03:00
|
|
|
subtitle: state.unlocked
|
2023-02-28 21:05:46 +03:00
|
|
|
? Text(l10n.l_fingerprints_used(fingerprints))
|
2023-01-12 10:56:08 +03:00
|
|
|
: Text(state.hasPin
|
2023-02-28 21:05:46 +03:00
|
|
|
? l10n.l_unlock_pin_first
|
|
|
|
: l10n.l_set_pin_first),
|
2023-01-12 10:56:08 +03:00
|
|
|
enabled: state.unlocked && fingerprints < 5,
|
|
|
|
onTap: state.unlocked && fingerprints < 5
|
|
|
|
? () {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
showBlurDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (context) => AddFingerprintDialog(node.path),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
: null,
|
|
|
|
),
|
|
|
|
],
|
2023-02-28 21:05:46 +03:00
|
|
|
ListTitle(l10n.w_manage,
|
2023-01-12 10:56:08 +03:00
|
|
|
textStyle: Theme.of(context).textTheme.bodyLarge),
|
|
|
|
ListTile(
|
2023-01-12 19:43:29 +03:00
|
|
|
leading: const CircleAvatar(child: Icon(Icons.pin_outlined)),
|
2023-02-28 21:05:46 +03:00
|
|
|
title: Text(state.hasPin ? l10n.l_change_pin : l10n.l_set_pin),
|
2023-01-12 19:43:29 +03:00
|
|
|
subtitle: Text(state.hasPin
|
2023-02-28 21:05:46 +03:00
|
|
|
? l10n.l_fido_pin_protection
|
|
|
|
: l10n.l_fido_pin_protection_optional),
|
2023-01-12 19:43:29 +03:00
|
|
|
onTap: () {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
showBlurDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (context) => FidoPinDialog(node.path, state),
|
|
|
|
);
|
|
|
|
}),
|
2023-01-12 10:56:08 +03:00
|
|
|
ListTile(
|
|
|
|
leading: CircleAvatar(
|
|
|
|
foregroundColor: theme.onError,
|
|
|
|
backgroundColor: theme.error,
|
|
|
|
child: const Icon(Icons.delete_outline),
|
|
|
|
),
|
2023-02-28 21:05:46 +03:00
|
|
|
title: Text(l10n.l_reset_fido),
|
|
|
|
subtitle: Text(l10n.l_factory_reset_this_app),
|
2023-01-12 10:56:08 +03:00
|
|
|
onTap: () {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
showBlurDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (context) => ResetDialog(node),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|