56 lines
1.7 KiB
Dart
56 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:mobile_scanner/mobile_scanner.dart';
|
|
|
|
import '../../core/i18n/app_locale.dart';
|
|
import '../../core/theme/tokens.dart';
|
|
|
|
/// 위치 Quest QR 인증 — 현장에 붙은 QR 을 스캔해 그 값을 돌려준다(원장 C-03 · PRD-05 「QR 인증」).
|
|
///
|
|
/// 판정은 서버가 한다(생성 때 발급한 코드와 대조). 이 화면은 첫 번째로 읽힌 값으로 닫힐 뿐이다.
|
|
/// 🟡 Figma 에 스캔 화면이 없어 카메라 전체 화면 + 닫기 버튼만 둔다(해석 확인 요청 영역B Q-B-10).
|
|
class QrScanScreen extends StatefulWidget {
|
|
const QrScanScreen({super.key});
|
|
|
|
@override
|
|
State<QrScanScreen> createState() => _QrScanScreenState();
|
|
}
|
|
|
|
class _QrScanScreenState extends State<QrScanScreen> {
|
|
bool _done = false;
|
|
|
|
void _onDetect(BarcodeCapture capture) {
|
|
if (_done) return;
|
|
final value = capture.barcodes
|
|
.map((b) => b.rawValue)
|
|
.whereType<String>()
|
|
.where((v) => v.isNotEmpty)
|
|
.firstOrNull;
|
|
if (value == null) return;
|
|
_done = true;
|
|
Navigator.of(context).pop(value);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Scaffold(
|
|
backgroundColor: Colors.black,
|
|
appBar: AppBar(
|
|
backgroundColor: Colors.black,
|
|
foregroundColor: AppColors.onCosmic,
|
|
title: Text(context.l10n.questScanQr),
|
|
),
|
|
body: MobileScanner(
|
|
onDetect: _onDetect,
|
|
errorBuilder: (context, error) => Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(AppSpace.s5),
|
|
child: Text(
|
|
context.l10n.questScanQrDenied,
|
|
textAlign: TextAlign.center,
|
|
style: const TextStyle(color: AppColors.onCosmic),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|