feat-add-files-from-qr (#8)

Reviewed-on: http://catelliub.zapto.org:3000/brontomark/flux/pulls/8
Co-authored-by: Mark M2 Macbook <marco@catelli.it>
Co-committed-by: Mark M2 Macbook <marco@catelli.it>
This commit is contained in:
2026-04-26 10:15:34 +02:00
committed by brontomark
parent 90bd5ecacf
commit 1c2bcf9df7
46 changed files with 2376 additions and 327 deletions

View File

@@ -1,3 +1,6 @@
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
@@ -109,11 +112,32 @@ class _FluxAppState extends State<FluxApp> {
super.initState();
// Creiamo il router passandogli il Cubit per i redirect
_router = AppRouter.createRouter(context.read<SessionCubit>());
GetIt.I.get<SessionCubit>().setIsMobileDevice(isMobileDevice(context));
}
bool isMobileDevice(BuildContext context) {
if (kIsWeb) {
return false; // Il web non lo consideriamo "mobile nativo" per i deep link
}
return Platform.isAndroid || Platform.isIOS;
}
@override
Widget build(BuildContext context) {
return BlocBuilder<SessionCubit, SessionState>(
// Il BlocConsumer unisce Listener e Builder in un colpo solo!
return BlocConsumer<SessionCubit, SessionState>(
// --- PARTE LISTENER (Il colpo di clacson in background) ---
listenWhen: (previous, current) =>
previous.status != SessionStatus.authenticated &&
current.status == SessionStatus.authenticated,
listener: (context, state) {
// BAM! L'utente è dentro. Pre-carichiamo i Cubit leggeri.
context.read<StoreCubit>().loadStores();
context.read<StaffCubit>().loadAllStaff();
context.read<ProvidersCubit>().loadProviders();
},
// --- PARTE BUILDER (La UI che viene disegnata a schermo) ---
builder: (context, sessionState) {
if (sessionState.status == SessionStatus.initial) {
return _buildLoadingScreen();