2022-10-04 13:12:54 +03:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2022 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.
|
|
|
|
*/
|
|
|
|
|
2022-08-05 11:40:36 +03:00
|
|
|
import 'package:flutter/material.dart';
|
2023-02-28 13:34:29 +03:00
|
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
2022-08-05 11:40:36 +03:00
|
|
|
|
2022-09-12 13:58:17 +03:00
|
|
|
import '../keys.dart' as keys;
|
2022-08-05 11:40:36 +03:00
|
|
|
import 'qr_scanner_scan_status.dart';
|
|
|
|
import 'qr_scanner_util.dart';
|
|
|
|
|
|
|
|
class QRScannerUI extends StatelessWidget {
|
|
|
|
final ScanStatus status;
|
|
|
|
final Size screenSize;
|
|
|
|
|
|
|
|
const QRScannerUI({
|
|
|
|
super.key,
|
|
|
|
required this.status,
|
|
|
|
required this.screenSize,
|
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-02-28 13:34:29 +03:00
|
|
|
final l10n = AppLocalizations.of(context)!;
|
|
|
|
final scannerAreaWidth = getScannerAreaWidth(screenSize);
|
2022-08-05 11:40:36 +03:00
|
|
|
|
|
|
|
return Stack(children: [
|
|
|
|
/// instruction text under the scanner area
|
|
|
|
Positioned.fromRect(
|
|
|
|
rect: Rect.fromCenter(
|
|
|
|
center: Offset(screenSize.width / 2,
|
|
|
|
screenSize.height + scannerAreaWidth / 2.0 + 8.0),
|
|
|
|
width: screenSize.width,
|
|
|
|
height: screenSize.height),
|
2023-08-30 15:20:15 +03:00
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(4.0),
|
|
|
|
child: Text(
|
|
|
|
status != ScanStatus.error
|
|
|
|
? l10n.l_point_camera_scan
|
|
|
|
: l10n.l_invalid_qr,
|
|
|
|
style: const TextStyle(color: Colors.white),
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
2022-08-05 11:40:36 +03:00
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
/// button for manual entry
|
|
|
|
Positioned.fromRect(
|
|
|
|
rect: Rect.fromCenter(
|
|
|
|
center: Offset(screenSize.width / 2,
|
|
|
|
screenSize.height + scannerAreaWidth / 2.0 + 80.0),
|
|
|
|
width: screenSize.width,
|
|
|
|
height: screenSize.height),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
2023-02-28 13:34:29 +03:00
|
|
|
Text(
|
2023-02-28 17:02:12 +03:00
|
|
|
l10n.q_no_qr,
|
2022-08-05 11:40:36 +03:00
|
|
|
textScaleFactor: 0.7,
|
2023-02-28 13:34:29 +03:00
|
|
|
style: const TextStyle(color: Colors.white),
|
2022-08-05 11:40:36 +03:00
|
|
|
),
|
|
|
|
OutlinedButton(
|
|
|
|
onPressed: () {
|
2022-09-15 12:47:39 +03:00
|
|
|
Navigator.of(context).pop('');
|
2022-08-05 11:40:36 +03:00
|
|
|
},
|
2022-09-12 13:58:17 +03:00
|
|
|
key: keys.manualEntryButton,
|
2023-02-28 13:34:29 +03:00
|
|
|
child: Text(
|
2023-03-02 14:45:55 +03:00
|
|
|
l10n.s_enter_manually,
|
2023-02-28 13:34:29 +03:00
|
|
|
style: const TextStyle(color: Colors.white),
|
|
|
|
)),
|
2022-08-05 11:40:36 +03:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|