47 lines
1.6 KiB
Dart
47 lines
1.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import '../core/constants/app_constants.dart';
|
|
import '../core/router/app_router.dart';
|
|
import '../core/theme/app_colors.dart';
|
|
import '../core/theme/app_theme.dart';
|
|
import '../presentation/auth/providers/auth_controller.dart';
|
|
import '../presentation/sync/providers/sync_controller.dart';
|
|
|
|
class NearlePosApp extends ConsumerWidget {
|
|
const NearlePosApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
// Watched, not awaited: the till opens immediately and the queue drains
|
|
// behind it. Nothing on screen depends on this having finished.
|
|
ref.watch(syncBootstrapProvider);
|
|
|
|
// This one *is* awaited. Re-opening a stored session is a keystore read —
|
|
// a few milliseconds — and building the router before it lands would show
|
|
// an already-signed-in terminal the login screen and then snatch it away.
|
|
final restored = ref.watch(sessionBootstrapProvider);
|
|
|
|
if (restored.isLoading) {
|
|
return const MaterialApp(
|
|
debugShowCheckedModeBanner: false,
|
|
home: ColoredBox(color: AppColors.background),
|
|
);
|
|
}
|
|
|
|
return MaterialApp.router(
|
|
title: AppConstants.appName,
|
|
debugShowCheckedModeBanner: false,
|
|
theme: AppTheme.light,
|
|
routerConfig: ref.watch(routerProvider),
|
|
builder: (context, child) {
|
|
// A POS runs on fixed hardware; ignore OS font scaling so the dense
|
|
// billing panel can never overflow.
|
|
return MediaQuery.withNoTextScaling(
|
|
child: child ?? const SizedBox.shrink(),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|