
Refactors the login page and model for improved separation of concerns. Moves navigation logic from the model to the page using success callbacks. Integrates a dedicated primary button component for the login action, showing loading state. Adds a new secure route for a product form page and updates the scanner page to navigate to it when viewing scanned product details. Simplifies the callback signature for viewing product details in the scanned product component. Also includes minor adjustments to the splash screen delay and theme definition.
66 lines
2.1 KiB
Dart
66 lines
2.1 KiB
Dart
import 'package:barcode_scanner/router/router.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:responsive_framework/responsive_framework.dart';
|
|
|
|
class App extends StatelessWidget {
|
|
const App({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ProviderScope(overrides: [routerProvider], child: _InnerApp());
|
|
}
|
|
}
|
|
|
|
class _InnerApp extends ConsumerWidget {
|
|
const _InnerApp();
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
return MaterialApp.router(
|
|
debugShowCheckedModeBanner: false,
|
|
title: "BarcodeScan",
|
|
theme: ThemeData(
|
|
fontFamily: 'Roboto',
|
|
scaffoldBackgroundColor: Colors.white,
|
|
),
|
|
locale: Locale('fr'),
|
|
supportedLocales: [Locale('fr', 'FR'), Locale('en', 'US')],
|
|
localizationsDelegates: [
|
|
GlobalMaterialLocalizations.delegate, // Support for Material widgets
|
|
GlobalWidgetsLocalizations.delegate, // Localization for widgets
|
|
GlobalCupertinoLocalizations.delegate, // Support for Cupertino widgets
|
|
],
|
|
routerConfig: ref.watch(routerProvider),
|
|
builder: (context, widget) => ResponsiveBreakpoints.builder(
|
|
child: _ResponsiveWrapper(child: widget ?? const SizedBox.shrink()),
|
|
breakpoints: [
|
|
const Breakpoint(start: 0, end: 450, name: MOBILE),
|
|
const Breakpoint(start: 451, end: 800, name: TABLET),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _ResponsiveWrapper extends StatelessWidget {
|
|
const _ResponsiveWrapper({required this.child});
|
|
final Widget child;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ResponsiveScaledBox(
|
|
width: ResponsiveValue<double?>(
|
|
context,
|
|
conditionalValues: [
|
|
const Condition.equals(name: MOBILE, value: 450),
|
|
const Condition.between(start: 800, end: 1100, value: 800),
|
|
const Condition.between(start: 1000, end: 1200, value: 1000),
|
|
],
|
|
).value,
|
|
child: child,
|
|
);
|
|
}
|
|
}
|