Se agrego el sdk para el pda de honeywell
This commit is contained in:
@@ -3,9 +3,14 @@ import 'package:qrscanner/models/auth_session.dart';
|
||||
import 'package:qrscanner/screens/login_screen.dart';
|
||||
import 'package:qrscanner/screens/scanner_screen.dart';
|
||||
import 'package:qrscanner/services/auth_service.dart';
|
||||
import 'package:qrscanner/services/hardware_scanner_service.dart';
|
||||
import 'package:qrscanner/services/scan_launch_service.dart';
|
||||
import 'package:qrscanner/theme/app_theme.dart';
|
||||
|
||||
class HomeScreen extends StatelessWidget {
|
||||
final RouteObserver<ModalRoute<void>> homeRouteObserver =
|
||||
RouteObserver<ModalRoute<void>>();
|
||||
|
||||
class HomeScreen extends StatefulWidget {
|
||||
const HomeScreen({
|
||||
super.key,
|
||||
required this.session,
|
||||
@@ -13,7 +18,29 @@ class HomeScreen extends StatelessWidget {
|
||||
|
||||
final AuthSession session;
|
||||
|
||||
@override
|
||||
State<HomeScreen> createState() => _HomeScreenState();
|
||||
}
|
||||
|
||||
class _HomeScreenState extends State<HomeScreen> {
|
||||
bool _hardwareAvailable = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_checkHardware();
|
||||
}
|
||||
|
||||
Future<void> _checkHardware() async {
|
||||
final available = await ScanLaunchService.instance.isSupported();
|
||||
if (mounted) {
|
||||
setState(() => _hardwareAvailable = available);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _logout(BuildContext context) async {
|
||||
await HardwareScannerService.instance.ensureStopped();
|
||||
await ScanLaunchService.instance.releaseScanner();
|
||||
await AuthService().clearSession();
|
||||
|
||||
if (!context.mounted) return;
|
||||
@@ -30,11 +57,12 @@ class HomeScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
void _openScanner(BuildContext context) {
|
||||
Navigator.of(context).push(
|
||||
Future<void> _openScanner(BuildContext context) async {
|
||||
await Navigator.of(context).push(
|
||||
PageRouteBuilder<void>(
|
||||
settings: const RouteSettings(name: '/scanner'),
|
||||
pageBuilder: (context, animation, secondaryAnimation) =>
|
||||
ScannerScreen(session: session),
|
||||
ScannerScreen(session: widget.session),
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) {
|
||||
return FadeTransition(
|
||||
opacity: animation,
|
||||
@@ -57,7 +85,7 @@ class HomeScreen extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final expiresHours = (session.expiresIn / 3600).round();
|
||||
final expiresHours = (widget.session.expiresIn / 3600).round();
|
||||
|
||||
return Scaffold(
|
||||
body: Stack(
|
||||
@@ -140,7 +168,7 @@ class HomeScreen extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 28),
|
||||
Text(
|
||||
'Hola, ${session.username}',
|
||||
'Hola, ${widget.session.username}',
|
||||
style:
|
||||
Theme.of(context).textTheme.headlineSmall?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -175,6 +203,40 @@ class HomeScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_hardwareAvailable) ...[
|
||||
const SizedBox(height: 16),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 14,
|
||||
vertical: 8,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.primary.withValues(alpha: 0.12),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(
|
||||
color: AppTheme.primary.withValues(alpha: 0.25),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.barcode_reader,
|
||||
size: 16,
|
||||
color: AppTheme.primary.withValues(alpha: 0.9),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'Escáner activo · abre la app al escanear',
|
||||
style: TextStyle(
|
||||
color: Colors.white.withValues(alpha: 0.7),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 48),
|
||||
_ScanButton(onPressed: () => _openScanner(context)),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user