2022-10-04 13:12:54 +03:00
|
|
|
/*
|
2023-09-21 12:40:41 +03:00
|
|
|
* Copyright (C) 2022-2023 Yubico.
|
2022-10-04 13:12:54 +03:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2022-08-05 15:04:04 +03:00
|
|
|
import 'package:flutter/material.dart';
|
2023-02-28 13:34:29 +03:00
|
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
2023-10-30 19:03:12 +03:00
|
|
|
import 'package:yubico_authenticator/android/qr_scanner/qr_scanner_provider.dart';
|
2022-08-05 15:04:04 +03:00
|
|
|
|
|
|
|
import 'qr_scanner_scan_status.dart';
|
|
|
|
|
|
|
|
class QRScannerPermissionsUI extends StatelessWidget {
|
|
|
|
final ScanStatus status;
|
|
|
|
final Size screenSize;
|
|
|
|
final Function onPermissionRequest;
|
|
|
|
|
2022-09-15 12:47:39 +03:00
|
|
|
const QRScannerPermissionsUI(
|
|
|
|
{super.key,
|
|
|
|
required this.status,
|
|
|
|
required this.screenSize,
|
|
|
|
required this.onPermissionRequest});
|
2022-08-05 15:04:04 +03:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-02-28 13:34:29 +03:00
|
|
|
final l10n = AppLocalizations.of(context)!;
|
2022-08-05 15:04:04 +03:00
|
|
|
|
2023-09-21 12:40:41 +03:00
|
|
|
return SafeArea(
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 32.0),
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.max,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
children: [
|
|
|
|
Text(
|
2023-02-28 17:02:12 +03:00
|
|
|
l10n.p_need_camera_permission,
|
2023-02-28 13:34:29 +03:00
|
|
|
style: const TextStyle(color: Colors.white),
|
2022-08-05 15:04:04 +03:00
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
2023-10-30 19:03:12 +03:00
|
|
|
Column(
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
children: [
|
|
|
|
Column(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
l10n.q_want_to_scan,
|
|
|
|
textScaleFactor: 0.7,
|
|
|
|
style: const TextStyle(color: Colors.white),
|
|
|
|
),
|
|
|
|
OutlinedButton(
|
|
|
|
onPressed: () {
|
|
|
|
onPermissionRequest();
|
|
|
|
},
|
|
|
|
child: Text(
|
|
|
|
l10n.s_review_permissions,
|
|
|
|
style: const TextStyle(color: Colors.white),
|
|
|
|
)),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
]),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
Row(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
children: [
|
|
|
|
Column(children: [
|
|
|
|
Text(
|
|
|
|
l10n.q_have_account_info,
|
|
|
|
textScaleFactor: 0.7,
|
|
|
|
style: const TextStyle(color: Colors.white),
|
|
|
|
),
|
|
|
|
])
|
|
|
|
]),
|
|
|
|
Row(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
2023-09-21 12:40:41 +03:00
|
|
|
children: [
|
|
|
|
OutlinedButton(
|
|
|
|
onPressed: () {
|
2023-10-30 19:03:12 +03:00
|
|
|
Navigator.of(context).pop(
|
|
|
|
AndroidQrScanner.kQrScannerRequestManualEntry);
|
2023-09-21 12:40:41 +03:00
|
|
|
},
|
|
|
|
child: Text(
|
|
|
|
l10n.s_enter_manually,
|
|
|
|
style: const TextStyle(color: Colors.white),
|
|
|
|
)),
|
2023-10-30 19:03:12 +03:00
|
|
|
const SizedBox(width: 16),
|
2023-09-21 12:40:41 +03:00
|
|
|
OutlinedButton(
|
|
|
|
onPressed: () {
|
2023-10-30 19:03:12 +03:00
|
|
|
Navigator.of(context).pop(
|
|
|
|
AndroidQrScanner.kQrScannerRequestReadFromFile);
|
2023-09-21 12:40:41 +03:00
|
|
|
},
|
|
|
|
child: Text(
|
2023-10-30 19:03:12 +03:00
|
|
|
l10n.s_read_from_file,
|
2023-09-21 12:40:41 +03:00
|
|
|
style: const TextStyle(color: Colors.white),
|
2023-10-30 19:03:12 +03:00
|
|
|
))
|
|
|
|
]),
|
|
|
|
],
|
|
|
|
)
|
2023-09-21 12:40:41 +03:00
|
|
|
],
|
|
|
|
),
|
2022-08-05 15:04:04 +03:00
|
|
|
),
|
2023-09-21 12:40:41 +03:00
|
|
|
);
|
2022-08-05 15:04:04 +03:00
|
|
|
}
|
|
|
|
}
|