barcode_scanner/lib/pages/home/home_page.dart
mandreshope f01c34d10c refactor: Refactors page directory structure
Moves page files from verbose `*_page` named directories to simpler, more organized paths.

This includes:
- Renaming top-level pages (e.g., `home_page` to `home`, `login_page` to `login`).
- Nesting related pages under common directories (e.g., `product_form_page` and `product_list_page` are now under `product/`).

The update improves project organization, reduces verbosity in file paths, and enhances overall maintainability.
2025-07-23 17:20:47 +03:00

153 lines
4.9 KiB
Dart

import 'package:barcode_scanner/components/components.dart';
import 'package:barcode_scanner/pages/home/home_page_model.dart';
import 'package:barcode_scanner/router/go_secure_router_builder.dart';
import 'package:barcode_scanner/themes/app_theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
class HomePage extends ConsumerStatefulWidget {
const HomePage({super.key});
@override
ConsumerState<ConsumerStatefulWidget> createState() => _HomePageState();
}
class _HomePageState extends ConsumerState<HomePage> {
@override
void initState() {
super.initState();
SchedulerBinding.instance.addPostFrameCallback((_) {
ref.read(homePageModelProvider.notifier).getUserConnected();
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
drawer: DrawerComponent(isOperationExpanded: true),
backgroundColor: AppTheme.of(context).primaryBackground,
appBar: AppBar(
title: Text('Barcode Scanner', style: AppTheme.of(context).titleLarge),
centerTitle: true,
backgroundColor: AppTheme.of(context).primaryBackground,
actions: [],
),
body: Center(
child: SingleChildScrollView(
padding: const EdgeInsets.all(24),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
/// HEADER ICON
Container(
width: 100,
height: 100,
decoration: BoxDecoration(
color: AppTheme.of(context).primary,
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: Color(0x225F3DFF),
blurRadius: 20,
offset: Offset(0, 12),
),
],
),
child: const Center(
child: Icon(
Icons.qr_code_scanner_rounded,
color: Colors.white,
size: 50,
),
),
),
const SizedBox(height: 24),
/// TITLE
const Text(
'Barcode Scanner',
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
),
const SizedBox(height: 12),
/// SUBTITLE
const Text(
'Scannez facilement tous vos code barre\nen quelques secondes',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 16, color: Colors.grey),
),
const SizedBox(height: 36),
/// SCANNER PREVIEW AREA (placeholder)
Container(
width: 260,
height: 200,
padding: const EdgeInsets.all(40),
decoration: BoxDecoration(
color: AppTheme.of(context).alternate,
borderRadius: BorderRadius.circular(24),
boxShadow: const [
BoxShadow(
color: Color(0x11000000),
blurRadius: 10,
offset: Offset(0, 8),
),
],
),
child: Icon(
Icons.qr_code_2_rounded,
size: 60,
color: AppTheme.of(context).primaryText,
),
),
const SizedBox(height: 16),
const Text(
'Pointez votre caméra vers le code\nbarre',
textAlign: TextAlign.center,
style: TextStyle(color: Colors.grey),
),
const SizedBox(height: 40),
/// START BUTTON
SizedBox(
width: double.infinity,
child: ElevatedButton.icon(
onPressed: () {
ScannerRoute().push(context);
},
style: ElevatedButton.styleFrom(
backgroundColor: AppTheme.of(context).primary,
padding: const EdgeInsets.symmetric(vertical: 18),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
),
icon: const Icon(
Icons.qr_code_scanner_rounded,
color: Colors.white,
size: 30,
),
label: const Text(
'Commencer le scan',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
),
),
],
),
),
),
);
}
}