Compare commits
18 Commits
6fbc5d947c
...
refactor-n
| Author | SHA1 | Date | |
|---|---|---|---|
| 123c006a1e | |||
| 415811f592 | |||
| 31066a4d8f | |||
| b700c2de8d | |||
| fda5b8fe2e | |||
| b7a525056a | |||
| 7a11e829b3 | |||
| 361b61a694 | |||
| 0cb060c89c | |||
| 4b9cbf65f9 | |||
| 813fc9dd38 | |||
| f574d6197b | |||
| 2fac3117a4 | |||
| 7b072a219d | |||
| 23d3356e6b | |||
| 5b2702daed | |||
| b9c3eb7091 | |||
| 8b8dd0a427 |
@@ -1,52 +1,90 @@
|
|||||||
name: Build and Release FLUX Windows
|
name: Build and Release FLUX (Multi-Platform)
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- 'v*' # Si attiva solo quando crei un tag tipo v1.0.0
|
- 'v*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
# -----------------------------------------------------------------
|
||||||
runs-on: windows-native # Richiama esattamente l'etichetta del PC del collega
|
# JOB 1: WINDOWS (Gira sul PC del collega appena si libera)
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
build-windows:
|
||||||
|
runs-on: windows-native
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout del codice
|
- name: Checkout del codice
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# 1. Facciamo una build finta. Genererà i symlinks e poi fallirà per il bug,
|
- name: Crea file .env
|
||||||
# ma il 'continue-on-error' dirà a Gitea di ignorare l'errore e andare avanti.
|
run: |
|
||||||
- name: Pre-build per generare l'ambiente (Fallirà apposta)
|
Set-Content -Path ".env" -Value "${{ secrets.ENV_FILE_CONTENT }}"
|
||||||
continue-on-error: true
|
|
||||||
|
- name: Build Flutter Windows
|
||||||
run: flutter build windows --release
|
run: flutter build windows --release
|
||||||
|
|
||||||
# 2. Ora la cartella ephemeral esiste! Applichiamo il fix.
|
- name: Build Windows Installer
|
||||||
- name: Fix bug CMake di pdfx
|
|
||||||
run: |
|
run: |
|
||||||
$cmakeFile = "windows\flutter\ephemeral\.plugin_symlinks\pdfx\windows\DownloadProject.cmake"
|
$TagVersion = "${{ github.ref_name }}".Substring(1)
|
||||||
|
& "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" "/DMyAppVersion=$TagVersion" "win_installer.iss"
|
||||||
|
|
||||||
if (Test-Path $cmakeFile) {
|
# Nel dubbio usiamo l'action per caricare l'asset
|
||||||
(Get-Content $cmakeFile) -replace 'VERSION 2.8.2', 'VERSION 3.5' | Set-Content $cmakeFile
|
- name: Upload Windows Asset
|
||||||
Write-Host "Il cerotto CMake è stato applicato con successo!"
|
|
||||||
} else {
|
|
||||||
Write-Error "File non trovato. La pre-build non ha generato i symlink."
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# 3. Ora che il file è corretto, la build vera arriverà fino in fondo
|
|
||||||
- name: Build Flutter Definitiva
|
|
||||||
env:
|
|
||||||
CMAKE_BUILD_PARALLEL_LEVEL: 2
|
|
||||||
run: flutter build windows --release
|
|
||||||
|
|
||||||
- name: Compila Installer Inno Setup
|
|
||||||
run: |
|
|
||||||
$TagVersion = "${{ gitea.ref_name }}".Substring(1)
|
|
||||||
"C:\Program Files (x86)\Inno Setup 6\ISCC.exe" /DMyAppVersion=$TagVersion "win_installer.iss"
|
|
||||||
|
|
||||||
# Usa un'action standard per caricare il file su Gitea Releases
|
|
||||||
- name: Upload Release Asset
|
|
||||||
uses: https://gitea.com/actions/release-action@main
|
uses: https://gitea.com/actions/release-action@main
|
||||||
with:
|
with:
|
||||||
files: "build/windows/installer/FLUX_Setup_x64.exe"
|
files: "build/windows/installer/FluxInstaller.exe"
|
||||||
api_key: ${{ secrets.GITEA_TOKEN }}
|
api_key: ${{ secrets.MYRELEASE_TOKEN }}
|
||||||
- name: Pulisci Workspace
|
|
||||||
if: always() # Esegue questo step anche se la build fallisce
|
- name: Pulisci Workspace Windows
|
||||||
|
if: always()
|
||||||
run: Remove-Item -Recurse -Force ./*
|
run: Remove-Item -Recurse -Force ./*
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
# JOB 2: ANDROID APK (Gira sul tuo MacBook)
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
build-android:
|
||||||
|
runs-on: macos-runner # <--- Etichetta del tuo Mac
|
||||||
|
steps:
|
||||||
|
- name: Checkout del codice
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
# Logica Bash per Mac: usiamo le virgolette singole forti per evitare escape strani
|
||||||
|
- name: Crea file .env
|
||||||
|
run: |
|
||||||
|
cat << 'EOF' > .env
|
||||||
|
${{ secrets.ENV_FILE_CONTENT }}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
- name: Build Flutter APK
|
||||||
|
run: flutter build apk --release
|
||||||
|
|
||||||
|
# Carichiamo l'APK universale o quelli splittati nelle release di Gitea
|
||||||
|
- name: Upload Android Asset
|
||||||
|
uses: https://gitea.com/actions/release-action@main
|
||||||
|
with:
|
||||||
|
files: "build/app/outputs/flutter-apk/app-release.apk"
|
||||||
|
api_key: ${{ secrets.MYRELEASE_TOKEN }}
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
# JOB 3: WEB & CLOUDFLARE DEPLOY (Gira sul tuo MacBook)
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
build-web:
|
||||||
|
runs-on: macos-runner # <--- Etichetta del tuo Mac
|
||||||
|
steps:
|
||||||
|
- name: Checkout del codice
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Crea file .env
|
||||||
|
run: |
|
||||||
|
cat << 'EOF' > .env
|
||||||
|
${{ secrets.ENV_FILE_CONTENT }}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
- name: Build Flutter Web
|
||||||
|
run: flutter build web --release
|
||||||
|
|
||||||
|
# Sfruttiamo npx (incluso in Node.js) per lanciare wrangler al volo senza installarlo globalmente
|
||||||
|
# Sto assumendo che usi Cloudflare Pages che è perfetto per Flutter Web statico
|
||||||
|
- name: Deploy su Cloudflare Pages
|
||||||
|
env:
|
||||||
|
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||||
|
run: |
|
||||||
|
npx wrangler pages deploy build/web --project-name="flux" --branch="main"
|
||||||
@@ -1,97 +1,370 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flux/core/routes/routes.dart';
|
||||||
import 'package:flux/core/utils/extensions.dart';
|
import 'package:flux/core/utils/extensions.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
|
// ==========================================
|
||||||
|
// 1. IL GUSCIO (QUELLO CHE PASSI AL ROUTER)
|
||||||
|
// ==========================================
|
||||||
class AppShell extends StatelessWidget {
|
class AppShell extends StatelessWidget {
|
||||||
final Widget child;
|
final Widget child;
|
||||||
|
|
||||||
const AppShell({super.key, required this.child});
|
const AppShell({super.key, required this.child});
|
||||||
|
|
||||||
// Calcoliamo l'indice attivo in base all'URL corrente!
|
|
||||||
int _calculateSelectedIndex(BuildContext context) {
|
|
||||||
final String location = GoRouterState.of(context).uri.path;
|
|
||||||
if (location.startsWith('/master-data')) return 1;
|
|
||||||
if (location.startsWith('/settings')) return 2;
|
|
||||||
return 0; // Default: Dashboard
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onItemTapped(int index, BuildContext context) {
|
|
||||||
switch (index) {
|
|
||||||
case 0:
|
|
||||||
context.go('/');
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
context.go('/master-data');
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
context.go('/settings');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final currentIndex = _calculateSelectedIndex(context);
|
// Breakpoint a 900px: sotto è Mobile/Tablet (Drawer), sopra è Desktop (Sidebar)
|
||||||
// Breakpoint: se lo schermo è più largo di 600px, usiamo la Rail laterale
|
final isDesktop = MediaQuery.sizeOf(context).width >= 900;
|
||||||
final isDesktop = MediaQuery.sizeOf(context).width >= 600;
|
final currentPath = GoRouterState.of(context).uri.path;
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
// Su mobile usiamo un'AppBar minimale per avere il bottone "Hamburger" nativo
|
||||||
|
appBar: isDesktop
|
||||||
|
? null
|
||||||
|
: AppBar(
|
||||||
|
title: const Text(
|
||||||
|
"FLUX",
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
centerTitle: true,
|
||||||
|
elevation: 0,
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||||
|
surfaceTintColor: Colors.transparent,
|
||||||
|
),
|
||||||
|
drawer: isDesktop
|
||||||
|
? null
|
||||||
|
: Drawer(
|
||||||
|
// Su mobile inietta il menu qui!
|
||||||
|
child: AppMenu(currentPath: currentPath, isDrawer: true),
|
||||||
|
),
|
||||||
body: isDesktop
|
body: isDesktop
|
||||||
? Row(
|
? Row(
|
||||||
children: [
|
children: [
|
||||||
NavigationRail(
|
// Su desktop inietta il menu a sinistra!
|
||||||
selectedIndex: currentIndex,
|
AppMenu(currentPath: currentPath, isDrawer: false),
|
||||||
onDestinationSelected: (index) =>
|
|
||||||
_onItemTapped(index, context),
|
|
||||||
labelType: NavigationRailLabelType.all,
|
|
||||||
destinations: [
|
|
||||||
NavigationRailDestination(
|
|
||||||
icon: Icon(Icons.dashboard_outlined),
|
|
||||||
selectedIcon: Icon(Icons.dashboard),
|
|
||||||
label: Text(context.l10n.commonDashboard),
|
|
||||||
),
|
|
||||||
NavigationRailDestination(
|
|
||||||
icon: Icon(Icons.folder_special_outlined),
|
|
||||||
selectedIcon: Icon(Icons.folder_special),
|
|
||||||
label: Text(context.l10n.commonMasterData),
|
|
||||||
),
|
|
||||||
NavigationRailDestination(
|
|
||||||
icon: Icon(Icons.settings_outlined),
|
|
||||||
selectedIcon: Icon(Icons.settings),
|
|
||||||
label: Text(context.l10n.commonSettings),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const VerticalDivider(thickness: 1, width: 1),
|
const VerticalDivider(thickness: 1, width: 1),
|
||||||
// Il contenuto della pagina
|
|
||||||
Expanded(child: child),
|
Expanded(child: child),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: child, // Su mobile il contenuto prende tutto lo schermo...
|
: child, // Su mobile il child prende tutto lo schermo sotto l'AppBar
|
||||||
// ... e mettiamo la barra in basso!
|
|
||||||
bottomNavigationBar: isDesktop
|
|
||||||
? null
|
|
||||||
: NavigationBar(
|
|
||||||
selectedIndex: currentIndex,
|
|
||||||
onDestinationSelected: (index) => _onItemTapped(index, context),
|
|
||||||
destinations: [
|
|
||||||
NavigationDestination(
|
|
||||||
icon: Icon(Icons.dashboard_outlined),
|
|
||||||
selectedIcon: Icon(Icons.dashboard),
|
|
||||||
label: context.l10n.commonDashboard,
|
|
||||||
),
|
|
||||||
NavigationDestination(
|
|
||||||
icon: Icon(Icons.folder_special_outlined),
|
|
||||||
selectedIcon: Icon(Icons.folder_special),
|
|
||||||
label: context.l10n.commonMasterData,
|
|
||||||
),
|
|
||||||
NavigationDestination(
|
|
||||||
icon: Icon(Icons.settings_outlined),
|
|
||||||
selectedIcon: Icon(Icons.settings),
|
|
||||||
label: context.l10n.commonSettings,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class AppMenu extends StatefulWidget {
|
||||||
|
final String currentPath; // Lo usiamo ancora per capire cosa accendere
|
||||||
|
final bool isDrawer;
|
||||||
|
|
||||||
|
const AppMenu({super.key, required this.currentPath, required this.isDrawer});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<AppMenu> createState() => _AppMenuState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AppMenuState extends State<AppMenu> {
|
||||||
|
bool _isCollapsed = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
final bool effectivelyCollapsed = _isCollapsed && !widget.isDrawer;
|
||||||
|
|
||||||
|
return AnimatedContainer(
|
||||||
|
duration: const Duration(milliseconds: 200),
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
width: effectivelyCollapsed ? 72 : 260,
|
||||||
|
child: SafeArea(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
// --- HEADER ---
|
||||||
|
Container(
|
||||||
|
height: 80,
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||||
|
alignment: effectivelyCollapsed
|
||||||
|
? Alignment.center
|
||||||
|
: Alignment.centerLeft,
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.bolt, color: theme.colorScheme.primary, size: 32),
|
||||||
|
if (!effectivelyCollapsed) ...[
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Text(
|
||||||
|
"FLUX",
|
||||||
|
style: theme.textTheme.titleLarge?.copyWith(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// --- VOCI DI MENU ---
|
||||||
|
Expanded(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
child: SizedBox(
|
||||||
|
width: effectivelyCollapsed ? 72 : 260,
|
||||||
|
child: ListView(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||||
|
children: [
|
||||||
|
_buildRouteItem(
|
||||||
|
title: context.l10n.commonDashboard,
|
||||||
|
icon: Icons.dashboard_outlined,
|
||||||
|
routeName: Routes.home, // <--- Usiamo la tua costante!
|
||||||
|
pathToCheck:
|
||||||
|
'/', // Il path da controllare per colorarlo
|
||||||
|
isCollapsed: effectivelyCollapsed,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
|
||||||
|
// --- IL MENU GERARCHICO (ANAGRAFICHE) ---
|
||||||
|
_buildHierarchicalItem(
|
||||||
|
title: context.l10n.commonMasterData,
|
||||||
|
icon: Icons.folder_special_outlined,
|
||||||
|
basePathToCheck:
|
||||||
|
'/master-data', // Se il path inizia così, espandi
|
||||||
|
isCollapsed: effectivelyCollapsed,
|
||||||
|
subItems: [
|
||||||
|
_SubMenuItem(
|
||||||
|
"Clienti",
|
||||||
|
Routes.customers,
|
||||||
|
'/master-data/customers',
|
||||||
|
),
|
||||||
|
_SubMenuItem(
|
||||||
|
"Fornitori",
|
||||||
|
Routes.providers,
|
||||||
|
'/master-data/providers',
|
||||||
|
),
|
||||||
|
_SubMenuItem(
|
||||||
|
"Prodotti",
|
||||||
|
Routes.products,
|
||||||
|
'/master-data/products',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
_buildRouteItem(
|
||||||
|
title: context.l10n.commonSettings,
|
||||||
|
icon: Icons.settings_outlined,
|
||||||
|
routeName: Routes.settings,
|
||||||
|
pathToCheck: '/settings',
|
||||||
|
isCollapsed: effectivelyCollapsed,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// --- PULSANTE TOGGLE (Solo Desktop) ---
|
||||||
|
if (!widget.isDrawer)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: IconButton(
|
||||||
|
tooltip: _isCollapsed ? 'Espandi Menu' : 'Riduci Menu',
|
||||||
|
icon: Icon(
|
||||||
|
_isCollapsed
|
||||||
|
? Icons.keyboard_double_arrow_right
|
||||||
|
: Icons.keyboard_double_arrow_left,
|
||||||
|
color: theme.iconTheme.color?.withValues(alpha: 0.5),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
_isCollapsed = !_isCollapsed;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==========================================
|
||||||
|
// WIDGET HELPER AGGIORNATI
|
||||||
|
// ==========================================
|
||||||
|
|
||||||
|
Widget _buildRouteItem({
|
||||||
|
required String title,
|
||||||
|
required IconData icon,
|
||||||
|
required String routeName,
|
||||||
|
required String pathToCheck,
|
||||||
|
required bool isCollapsed,
|
||||||
|
}) {
|
||||||
|
final isSelected = widget.currentPath == pathToCheck;
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
|
||||||
|
if (isCollapsed) {
|
||||||
|
return Tooltip(
|
||||||
|
message: title,
|
||||||
|
preferBelow: false,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () {
|
||||||
|
if (widget.isDrawer) Navigator.pop(context);
|
||||||
|
context.goNamed(routeName); // <--- goNamed!
|
||||||
|
},
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
child: Container(
|
||||||
|
height: 48,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: isSelected
|
||||||
|
? theme.colorScheme.primaryContainer.withValues(alpha: 0.4)
|
||||||
|
: Colors.transparent,
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
child: Icon(
|
||||||
|
icon,
|
||||||
|
color: isSelected ? theme.colorScheme.primary : null,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ListTile(
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||||
|
selectedTileColor: theme.colorScheme.primaryContainer.withValues(
|
||||||
|
alpha: 0.4,
|
||||||
|
),
|
||||||
|
selected: isSelected,
|
||||||
|
leading: Icon(icon, color: isSelected ? theme.colorScheme.primary : null),
|
||||||
|
title: Text(
|
||||||
|
title,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||||
|
),
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.clip,
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
if (widget.isDrawer) Navigator.pop(context);
|
||||||
|
context.goNamed(routeName); // <--- goNamed!
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildHierarchicalItem({
|
||||||
|
required String title,
|
||||||
|
required IconData icon,
|
||||||
|
required String basePathToCheck,
|
||||||
|
required bool isCollapsed,
|
||||||
|
required List<_SubMenuItem> subItems,
|
||||||
|
}) {
|
||||||
|
final isSelected = widget.currentPath.startsWith(basePathToCheck);
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
|
||||||
|
if (isCollapsed) {
|
||||||
|
return PopupMenuButton<String>(
|
||||||
|
tooltip: title,
|
||||||
|
offset: const Offset(60, 0),
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||||
|
onSelected: (routeName) {
|
||||||
|
// Il routeName arriva dal value del menu
|
||||||
|
if (widget.isDrawer) Navigator.pop(context);
|
||||||
|
context.goNamed(routeName); // <--- goNamed!
|
||||||
|
},
|
||||||
|
itemBuilder: (context) => subItems
|
||||||
|
.map(
|
||||||
|
(item) => PopupMenuItem(
|
||||||
|
value: item
|
||||||
|
.routeName, // Passiamo il nome della rotta (Routes.customers)
|
||||||
|
child: Text(
|
||||||
|
item.title,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: widget.currentPath == item.pathToCheck
|
||||||
|
? FontWeight.bold
|
||||||
|
: FontWeight.normal,
|
||||||
|
color: widget.currentPath == item.pathToCheck
|
||||||
|
? theme.colorScheme.primary
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
child: Container(
|
||||||
|
height: 48,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: isSelected
|
||||||
|
? theme.colorScheme.primaryContainer.withValues(alpha: 0.4)
|
||||||
|
: Colors.transparent,
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
child: Icon(
|
||||||
|
icon,
|
||||||
|
color: isSelected ? theme.colorScheme.primary : null,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Theme(
|
||||||
|
data: theme.copyWith(dividerColor: Colors.transparent),
|
||||||
|
child: ExpansionTile(
|
||||||
|
initiallyExpanded: isSelected,
|
||||||
|
maintainState: true,
|
||||||
|
tilePadding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
leading: Icon(
|
||||||
|
icon,
|
||||||
|
color: isSelected ? theme.colorScheme.primary : null,
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
title,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||||
|
),
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.clip,
|
||||||
|
),
|
||||||
|
children: subItems.map((item) {
|
||||||
|
final isSubSelected = widget.currentPath == item.pathToCheck;
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 32.0, bottom: 4.0),
|
||||||
|
child: ListTile(
|
||||||
|
dense: true,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
selectedTileColor: theme.colorScheme.primaryContainer.withValues(
|
||||||
|
alpha: 0.2,
|
||||||
|
),
|
||||||
|
selected: isSubSelected,
|
||||||
|
title: Text(
|
||||||
|
item.title,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: isSubSelected
|
||||||
|
? FontWeight.bold
|
||||||
|
: FontWeight.normal,
|
||||||
|
color: isSubSelected
|
||||||
|
? theme.colorScheme.primary
|
||||||
|
: theme.textTheme.bodyMedium?.color,
|
||||||
|
),
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.clip,
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
if (widget.isDrawer) Navigator.pop(context);
|
||||||
|
context.goNamed(item.routeName); // <--- goNamed!
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Struttura dati per le voci dei sottomenu aggiornata
|
||||||
|
class _SubMenuItem {
|
||||||
|
final String title;
|
||||||
|
final String routeName; // Es: Routes.customers
|
||||||
|
final String pathToCheck; // Es: '/master-data/customers'
|
||||||
|
_SubMenuItem(this.title, this.routeName, this.pathToCheck);
|
||||||
|
}
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ import 'package:flux/features/master_data/providers/ui/provider_list_screen.dart
|
|||||||
import 'package:flux/features/master_data/staff/models/staff_member_model.dart';
|
import 'package:flux/features/master_data/staff/models/staff_member_model.dart';
|
||||||
import 'package:flux/features/master_data/staff/ui/staff_screen.dart';
|
import 'package:flux/features/master_data/staff/ui/staff_screen.dart';
|
||||||
import 'package:flux/features/master_data/store/ui/stores_screen.dart';
|
import 'package:flux/features/master_data/store/ui/stores_screen.dart';
|
||||||
|
import 'package:flux/features/notes/models/note_model.dart';
|
||||||
|
import 'package:flux/features/notes/ui/notes_form_screen.dart';
|
||||||
|
import 'package:flux/features/notes/ui/notes_list_screen.dart';
|
||||||
import 'package:flux/features/onboarding/blocs/onboarding_cubit.dart';
|
import 'package:flux/features/onboarding/blocs/onboarding_cubit.dart';
|
||||||
import 'package:flux/features/onboarding/ui/onboarding_screen.dart';
|
import 'package:flux/features/onboarding/ui/onboarding_screen.dart';
|
||||||
import 'package:flux/features/attachments/blocs/attachments_bloc.dart';
|
import 'package:flux/features/attachments/blocs/attachments_bloc.dart';
|
||||||
@@ -123,83 +126,99 @@ class AppRouter {
|
|||||||
ShellRoute(
|
ShellRoute(
|
||||||
builder: (context, state, child) => AppShell(child: child),
|
builder: (context, state, child) => AppShell(child: child),
|
||||||
routes: [
|
routes: [
|
||||||
|
// ==========================================
|
||||||
// 1. DASHBOARD
|
// 1. DASHBOARD
|
||||||
|
// ==========================================
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/',
|
path: '/',
|
||||||
name: Routes.home,
|
name: Routes.home,
|
||||||
builder: (context, state) => const HomeScreen(),
|
builder: (context, state) => const HomeScreen(),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// ==========================================
|
||||||
// 2. HUB ANAGRAFICHE E SOTTO-ROTTE
|
// 2. HUB ANAGRAFICHE E SOTTO-ROTTE
|
||||||
|
// ==========================================
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/master-data',
|
path: '/master-data',
|
||||||
name: Routes.masterData,
|
name: Routes.masterData,
|
||||||
builder: (context, state) => const MasterDataHubScreen(),
|
builder: (context, state) => const MasterDataHubScreen(),
|
||||||
routes: [
|
routes: [
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: 'products', // Diventa /master-data/products
|
path:
|
||||||
|
'customers', // Niente slash iniziale per le sottorotte! -> /master-data/customers
|
||||||
|
name: Routes.customers,
|
||||||
|
builder: (context, state) => const CustomersListScreen(),
|
||||||
|
),
|
||||||
|
GoRoute(
|
||||||
|
path: 'providers', // -> /master-data/providers
|
||||||
|
name: Routes.providers,
|
||||||
|
builder: (context, state) => const ProviderListScreen(),
|
||||||
|
),
|
||||||
|
GoRoute(
|
||||||
|
path: 'products', // -> /master-data/products
|
||||||
name: Routes.products,
|
name: Routes.products,
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
context.read<ProductsCubit>().refreshCubit();
|
context.read<ProductsCubit>().refreshCubit();
|
||||||
|
|
||||||
return const ProductsScreen();
|
return const ProductsScreen();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: 'company-settings',
|
path: 'staff', // -> /master-data/staff
|
||||||
|
name: Routes.staff,
|
||||||
|
builder: (context, state) => const StaffScreen(),
|
||||||
|
),
|
||||||
|
GoRoute(
|
||||||
|
path:
|
||||||
|
'stores', // Sistemata l'inversione path/name -> /master-data/stores
|
||||||
|
name: Routes.stores,
|
||||||
|
builder: (context, state) => const StoresScreen(),
|
||||||
|
),
|
||||||
|
GoRoute(
|
||||||
|
path: 'company-settings', // -> /master-data/company-settings
|
||||||
name: Routes.companySettings,
|
name: Routes.companySettings,
|
||||||
builder: (context, state) => BlocProvider(
|
builder: (context, state) => BlocProvider(
|
||||||
create: (context) => CompanySettingsCubit(),
|
create: (context) => CompanySettingsCubit(),
|
||||||
child: const CompanySettingsScreen(),
|
child: const CompanySettingsScreen(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
GoRoute(
|
|
||||||
path: 'staff',
|
|
||||||
name: Routes.staff, // Diventa /master-data/staff
|
|
||||||
builder: (context, state) => const StaffScreen(),
|
|
||||||
),
|
|
||||||
GoRoute(
|
|
||||||
path: Routes.stores,
|
|
||||||
name: 'stores', // Diventa /master-data/stores
|
|
||||||
builder: (context, state) => const StoresScreen(),
|
|
||||||
),
|
|
||||||
GoRoute(
|
|
||||||
path: '/providers',
|
|
||||||
name: Routes.providers,
|
|
||||||
builder: (context, state) => const ProviderListScreen(),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// ==========================================
|
||||||
// 3. IMPOSTAZIONI
|
// 3. IMPOSTAZIONI
|
||||||
|
// ==========================================
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/settings',
|
path: '/settings',
|
||||||
name: Routes.settings,
|
name: Routes.settings,
|
||||||
builder: (context, state) => const SettingsScreen(),
|
builder: (context, state) => const SettingsScreen(),
|
||||||
routes: [
|
routes: [
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: 'themeSettings',
|
path: 'themeSettings', // -> /settings/themeSettings
|
||||||
name: Routes.themeSettings,
|
name: Routes.themeSettings,
|
||||||
builder: (context, state) => const ThemeSettingsView(),
|
builder: (context, state) => const ThemeSettingsView(),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// ==========================================
|
||||||
|
// 4. SCHERMATE PRINCIPALI EXTRA NELLA SHELL
|
||||||
|
// (Accessibili ad es. dalla dashboard, mantengono la sidebar)
|
||||||
|
// ==========================================
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/operations',
|
path: '/operations',
|
||||||
name: Routes.operations,
|
name: Routes.operations,
|
||||||
builder: (context, state) => const OperationListScreen(),
|
builder: (context, state) => const OperationListScreen(),
|
||||||
),
|
),
|
||||||
GoRoute(
|
|
||||||
path: '/customers',
|
|
||||||
name: Routes.customers,
|
|
||||||
builder: (context, state) =>
|
|
||||||
const CustomersListScreen(), // O come si chiama il tuo widget della lista!
|
|
||||||
),
|
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/tickets',
|
path: '/tickets',
|
||||||
name: Routes.tickets,
|
name: Routes.tickets,
|
||||||
builder: (context, state) => const TicketListScreen(),
|
builder: (context, state) => const TicketListScreen(),
|
||||||
),
|
),
|
||||||
|
GoRoute(
|
||||||
|
path: '/notes',
|
||||||
|
name: Routes.notes,
|
||||||
|
builder: (context, state) => const NotesListScreen(),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
@@ -436,6 +455,28 @@ class AppRouter {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
GoRoute(
|
||||||
|
path: '/notes/edit/:id',
|
||||||
|
name: Routes.noteForm,
|
||||||
|
builder: (context, state) {
|
||||||
|
final id = state.pathParameters['id']!;
|
||||||
|
final NoteModel note = state.extra as NoteModel;
|
||||||
|
|
||||||
|
// Creiamo il BLoC "al volo" solo per questa schermata
|
||||||
|
return MultiBlocProvider(
|
||||||
|
providers: [
|
||||||
|
BlocProvider<AttachmentsBloc>(
|
||||||
|
create: (context) => AttachmentsBloc(
|
||||||
|
parentId: id,
|
||||||
|
parentType: AttachmentParentType.note,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
|
||||||
|
child: NoteFormScreen(note: note),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,4 +22,6 @@ class Routes {
|
|||||||
static const String customerDetails = 'customer-details';
|
static const String customerDetails = 'customer-details';
|
||||||
static const String upload = 'upload';
|
static const String upload = 'upload';
|
||||||
static const String ticketWorkspace = 'ticket-workspace';
|
static const String ticketWorkspace = 'ticket-workspace';
|
||||||
|
static const String noteForm = 'note-form';
|
||||||
|
static const String notes = 'notes';
|
||||||
}
|
}
|
||||||
|
|||||||
18
lib/core/utils/debouncer.dart
Normal file
18
lib/core/utils/debouncer.dart
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class Debouncer {
|
||||||
|
final int milliseconds;
|
||||||
|
Timer? _timer;
|
||||||
|
|
||||||
|
Debouncer({required this.milliseconds});
|
||||||
|
|
||||||
|
void run(VoidCallback action) {
|
||||||
|
_timer?.cancel();
|
||||||
|
_timer = Timer(Duration(milliseconds: milliseconds), action);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dispose() {
|
||||||
|
_timer?.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -50,7 +50,7 @@ class CustomerRepository {
|
|||||||
''')
|
''')
|
||||||
.eq('company_id', companyId)
|
.eq('company_id', companyId)
|
||||||
.eq('is_active', true)
|
.eq('is_active', true)
|
||||||
.order('name');
|
.order('name', ascending: true);
|
||||||
|
|
||||||
return (response as List).map((c) => CustomerModel.fromMap(c)).toList();
|
return (response as List).map((c) => CustomerModel.fromMap(c)).toList();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -45,13 +45,13 @@ class _LatestOperationsCardContent extends StatelessWidget {
|
|||||||
return Card(
|
return Card(
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(12),
|
||||||
side: BorderSide(color: theme.dividerColor.withValues(alpha: 0.5)),
|
side: BorderSide(color: theme.dividerColor.withValues(alpha: 0.3)),
|
||||||
),
|
),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () => context.pushNamed(Routes.operations),
|
onTap: () => context.pushNamed(Routes.operations),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(12.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ import 'package:flux/features/home/latest_store_tickets/ui/latest_store_tickets_
|
|||||||
import 'package:flux/features/home/ui/quick_actions_widget.dart';
|
import 'package:flux/features/home/ui/quick_actions_widget.dart';
|
||||||
import 'package:flux/features/master_data/staff/blocs/staff_cubit.dart';
|
import 'package:flux/features/master_data/staff/blocs/staff_cubit.dart';
|
||||||
import 'package:flux/features/master_data/staff/models/staff_member_model.dart';
|
import 'package:flux/features/master_data/staff/models/staff_member_model.dart';
|
||||||
|
import 'package:flux/features/notes/data/notes_repository.dart';
|
||||||
|
import 'package:flux/features/notes/models/note_model.dart';
|
||||||
|
import 'package:flux/features/notes/ui/dashboard_notes_widget.dart';
|
||||||
|
import 'package:get_it/get_it.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
class HomeScreen extends StatelessWidget {
|
class HomeScreen extends StatelessWidget {
|
||||||
@@ -62,26 +66,21 @@ class HomeScreen extends StatelessWidget {
|
|||||||
childAspectRatio: 1.3,
|
childAspectRatio: 1.3,
|
||||||
),
|
),
|
||||||
delegate: SliverChildListDelegate([
|
delegate: SliverChildListDelegate([
|
||||||
|
LatestStoreOperationsCard(),
|
||||||
|
LatestStoreTicketsCard(),
|
||||||
_buildDashboardWidget(
|
_buildDashboardWidget(
|
||||||
title: context.l10n.homeExpiringContracts,
|
title: context.l10n.homeExpiringContracts,
|
||||||
icon: Icons.assignment_late_outlined,
|
icon: Icons.assignment_late_outlined,
|
||||||
color: Colors.orange,
|
color: Colors.orange,
|
||||||
context: context,
|
context: context,
|
||||||
),
|
),
|
||||||
_buildDashboardWidget(
|
DashboardNotesWidget(),
|
||||||
title: context.l10n.commonStickyNotes,
|
|
||||||
icon: Icons.sticky_note_2_outlined,
|
|
||||||
color: Colors.yellow.shade700,
|
|
||||||
context: context,
|
|
||||||
),
|
|
||||||
_buildDashboardWidget(
|
_buildDashboardWidget(
|
||||||
title: context.l10n.homeMyTasks,
|
title: context.l10n.homeMyTasks,
|
||||||
icon: Icons.check_box_outlined,
|
icon: Icons.check_box_outlined,
|
||||||
color: Colors.green,
|
color: Colors.green,
|
||||||
context: context,
|
context: context,
|
||||||
),
|
),
|
||||||
LatestStoreOperationsCard(),
|
|
||||||
LatestStoreTicketsCard(),
|
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -211,8 +210,26 @@ class HomeScreen extends StatelessWidget {
|
|||||||
icon: Icons.note_add,
|
icon: Icons.note_add,
|
||||||
label: context.l10n.commonNote,
|
label: context.l10n.commonNote,
|
||||||
color: Colors.amber,
|
color: Colors.amber,
|
||||||
onTap: () {
|
onTap: () async {
|
||||||
// TODO: Quando faremo il modale/pagina delle note
|
final companyId = context.read<SessionCubit>().state.company!.id!;
|
||||||
|
final currentStaffId = context
|
||||||
|
.read<SessionCubit>()
|
||||||
|
.state
|
||||||
|
.currentStaffMember!
|
||||||
|
.id!;
|
||||||
|
final emptyNote = NoteModel.empty(
|
||||||
|
createdBy: currentStaffId,
|
||||||
|
companyId: companyId,
|
||||||
|
);
|
||||||
|
final noteId = await GetIt.I.get<NotesRepository>().saveNote(
|
||||||
|
emptyNote,
|
||||||
|
);
|
||||||
|
if (!context.mounted) return;
|
||||||
|
context.pushNamed(
|
||||||
|
Routes.noteForm,
|
||||||
|
pathParameters: {'id': noteId},
|
||||||
|
extra: emptyNote.copyWith(id: noteId),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
|
|||||||
@@ -20,6 +20,19 @@ class StaffRepository {
|
|||||||
return (response as List).map((s) => StaffMemberModel.fromMap(s)).toList();
|
return (response as List).map((s) => StaffMemberModel.fromMap(s)).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<StaffMemberModel?> getStaffMemberById(String staffId) async {
|
||||||
|
try {
|
||||||
|
final response = await _supabase
|
||||||
|
.from(Tables.staffMembers)
|
||||||
|
.select()
|
||||||
|
.eq('id', staffId)
|
||||||
|
.single();
|
||||||
|
return StaffMemberModel.fromMap(response);
|
||||||
|
} on Exception catch (e) {
|
||||||
|
throw ('Errore nel recupero del membro staff con ID $staffId: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<StaffMemberModel> saveStaffMember(StaffMemberModel member) async {
|
Future<StaffMemberModel> saveStaffMember(StaffMemberModel member) async {
|
||||||
final response = await _supabase
|
final response = await _supabase
|
||||||
.from(Tables.staffMembers)
|
.from(Tables.staffMembers)
|
||||||
|
|||||||
80
lib/features/notes/blocs/notes_bloc.dart
Normal file
80
lib/features/notes/blocs/notes_bloc.dart
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:flux/core/blocs/session/session_cubit.dart';
|
||||||
|
import 'package:flux/features/notes/data/notes_repository.dart';
|
||||||
|
import 'package:flux/features/notes/models/note_model.dart';
|
||||||
|
import 'package:get_it/get_it.dart';
|
||||||
|
part 'notes_event.dart';
|
||||||
|
part 'notes_state.dart';
|
||||||
|
|
||||||
|
class NotesBloc extends Bloc<NotesEvent, NotesState> {
|
||||||
|
final NotesRepository _repository = GetIt.I.get<NotesRepository>();
|
||||||
|
final String _companyId = GetIt.I.get<SessionCubit>().state.company!.id!;
|
||||||
|
final String _currentStaffId = GetIt.I
|
||||||
|
.get<SessionCubit>()
|
||||||
|
.state
|
||||||
|
.currentStaffMember!
|
||||||
|
.id!;
|
||||||
|
|
||||||
|
NotesBloc() : super(const NotesState()) {
|
||||||
|
on<SubscribeToNotesRequested>(_onSubscribeToNotesRequested);
|
||||||
|
on<NoteSavedRequested>(_onNoteSavedRequested);
|
||||||
|
on<NoteDeletedRequested>(_onNoteDeletedRequested);
|
||||||
|
|
||||||
|
// Facciamo partire l'ascolto in tempo reale al boot del BLoC
|
||||||
|
add(SubscribeToNotesRequested());
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _onSubscribeToNotesRequested(
|
||||||
|
SubscribeToNotesRequested event,
|
||||||
|
Emitter<NotesState> emit,
|
||||||
|
) async {
|
||||||
|
emit(state.copyWith(status: NotesStatus.loading));
|
||||||
|
|
||||||
|
// Usiamo l'emit.forEach sullo stream pulito del repository
|
||||||
|
await emit.forEach<List<NoteModel>>(
|
||||||
|
_repository.notesStream(
|
||||||
|
companyId: _companyId,
|
||||||
|
currentStaffId: _currentStaffId,
|
||||||
|
),
|
||||||
|
onData: (notesList) {
|
||||||
|
return state.copyWith(status: NotesStatus.success, notes: notesList);
|
||||||
|
},
|
||||||
|
onError: (error, stackTrace) {
|
||||||
|
return state.copyWith(
|
||||||
|
status: NotesStatus.failure,
|
||||||
|
errorMessage: 'Errore nello stream realtime: $error',
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _onNoteSavedRequested(
|
||||||
|
NoteSavedRequested event,
|
||||||
|
Emitter<NotesState> emit,
|
||||||
|
) async {
|
||||||
|
try {
|
||||||
|
await _repository.saveNote(event.note);
|
||||||
|
// Non serve fare l'emit! Ci pensa lo stream a far rimbalzare i dati aggiornati
|
||||||
|
} catch (e) {
|
||||||
|
emit(
|
||||||
|
state.copyWith(status: NotesStatus.failure, errorMessage: e.toString()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _onNoteDeletedRequested(
|
||||||
|
NoteDeletedRequested event,
|
||||||
|
Emitter<NotesState> emit,
|
||||||
|
) async {
|
||||||
|
try {
|
||||||
|
await _repository.deleteNote(event.noteId);
|
||||||
|
// Anche qui, lo stream rileva la cancellazione in automatico
|
||||||
|
} catch (e) {
|
||||||
|
emit(
|
||||||
|
state.copyWith(status: NotesStatus.failure, errorMessage: e.toString()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
17
lib/features/notes/blocs/notes_event.dart
Normal file
17
lib/features/notes/blocs/notes_event.dart
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
part of 'notes_bloc.dart';
|
||||||
|
|
||||||
|
sealed class NotesEvent {}
|
||||||
|
|
||||||
|
/// Fa partire lo stream e gestisce sia il caricamento iniziale che il realtime
|
||||||
|
class SubscribeToNotesRequested extends NotesEvent {}
|
||||||
|
|
||||||
|
class NoteDeletedRequested extends NotesEvent {
|
||||||
|
final String noteId;
|
||||||
|
NoteDeletedRequested(this.noteId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Salva o aggiorna una nota
|
||||||
|
class NoteSavedRequested extends NotesEvent {
|
||||||
|
final NoteModel note;
|
||||||
|
NoteSavedRequested(this.note);
|
||||||
|
}
|
||||||
39
lib/features/notes/blocs/notes_state.dart
Normal file
39
lib/features/notes/blocs/notes_state.dart
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
part of 'notes_bloc.dart';
|
||||||
|
|
||||||
|
enum NotesStatus { initial, loading, success, failure }
|
||||||
|
|
||||||
|
class NotesState {
|
||||||
|
final NotesStatus status;
|
||||||
|
final List<NoteModel> notes;
|
||||||
|
final String? errorMessage;
|
||||||
|
|
||||||
|
const NotesState({
|
||||||
|
this.status = NotesStatus.initial,
|
||||||
|
this.notes = const [],
|
||||||
|
this.errorMessage,
|
||||||
|
});
|
||||||
|
|
||||||
|
NotesState copyWith({
|
||||||
|
NotesStatus? status,
|
||||||
|
List<NoteModel>? notes,
|
||||||
|
String? errorMessage,
|
||||||
|
}) {
|
||||||
|
return NotesState(
|
||||||
|
status: status ?? this.status,
|
||||||
|
notes: notes ?? this.notes,
|
||||||
|
errorMessage: errorMessage ?? this.errorMessage,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
if (identical(this, other)) return true;
|
||||||
|
return other is NotesState &&
|
||||||
|
other.status == status &&
|
||||||
|
listEquals(other.notes, notes) &&
|
||||||
|
other.errorMessage == errorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => status.hashCode ^ notes.hashCode ^ errorMessage.hashCode;
|
||||||
|
}
|
||||||
150
lib/features/notes/data/notes_repository.dart
Normal file
150
lib/features/notes/data/notes_repository.dart
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
import 'package:flux/core/blocs/session/session_cubit.dart';
|
||||||
|
import 'package:flux/core/enums_and_consts/consts.dart';
|
||||||
|
import 'package:flux/features/notes/models/note_model.dart';
|
||||||
|
import 'package:get_it/get_it.dart';
|
||||||
|
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||||
|
|
||||||
|
class NotesRepository {
|
||||||
|
final _supabase = GetIt.I.get<SupabaseClient>();
|
||||||
|
|
||||||
|
String get _companyId => GetIt.I.get<SessionCubit>().state.company!.id!;
|
||||||
|
String get _currentStaffId =>
|
||||||
|
GetIt.I.get<SessionCubit>().state.currentStaffMember!.id!;
|
||||||
|
|
||||||
|
/// Recupera tutte le note visibili dall'utente corrente:
|
||||||
|
/// 1. Note create da lui
|
||||||
|
/// 2. Note condivise a tutti (is_shared_all = true)
|
||||||
|
/// 3. Note in cui l'utente è esplicitamente un collaboratore
|
||||||
|
Future<List<NoteModel>> getNotes() async {
|
||||||
|
try {
|
||||||
|
// Usiamo la sintassi avanzata di Supabase per fare il filtro OR sulle relazioni
|
||||||
|
// Inoltre tiriamo giù note_collaborators e l'anagrafica dei membri dello staff associati
|
||||||
|
final response = await _supabase
|
||||||
|
.from(Tables.notes)
|
||||||
|
.select('''
|
||||||
|
*,
|
||||||
|
${Tables.noteCollaborators}!inner (
|
||||||
|
staff_id,
|
||||||
|
${Tables.staffMembers} (*)
|
||||||
|
)
|
||||||
|
''')
|
||||||
|
// Filtro multi-tenant di sicurezza (già ridondante con RLS ma ottimo per performance)
|
||||||
|
.eq('company_id', _companyId)
|
||||||
|
// Questa è la magia: l'utente vede la nota se è sua, se è pubblica o se è tra i collaboratori
|
||||||
|
.or(
|
||||||
|
'created_by.eq.$_currentStaffId,is_shared_all.eq.true,note_collaborators.staff_id.eq.$_currentStaffId',
|
||||||
|
)
|
||||||
|
// Ordiniamo prima per sticky (pinned) e poi per data di aggiornamento
|
||||||
|
.order('is_pinned', ascending: false)
|
||||||
|
.order('updated_at', ascending: false);
|
||||||
|
|
||||||
|
return (response as List)
|
||||||
|
.map((json) => NoteModel.fromMap(json as Map<String, dynamic>))
|
||||||
|
.toList();
|
||||||
|
} catch (e) {
|
||||||
|
// In caso di errore sulla join !inner se non ci sono collaboratori,
|
||||||
|
// facciamo un fallback pulito su una query standard e uniamo i dati.
|
||||||
|
return _getNotesFallback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Fallback sicuro nel caso la query complessa con !inner si inceppi se la lista collaboratori è vuota
|
||||||
|
Future<List<NoteModel>> _getNotesFallback() async {
|
||||||
|
final response = await _supabase
|
||||||
|
.from(Tables.notes)
|
||||||
|
.select('''
|
||||||
|
*,
|
||||||
|
${Tables.noteCollaborators} (
|
||||||
|
staff_id,
|
||||||
|
${Tables.staffMembers} (*)
|
||||||
|
)
|
||||||
|
''')
|
||||||
|
.eq('company_id', _companyId)
|
||||||
|
.order('is_pinned', ascending: false)
|
||||||
|
.order('updated_at', ascending: false);
|
||||||
|
|
||||||
|
final allNotes = (response as List)
|
||||||
|
.map((json) => NoteModel.fromMap(json as Map<String, dynamic>))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
// Filtriamo lato codice per essere sicuri della visibilità
|
||||||
|
return allNotes.where((note) {
|
||||||
|
return note.createdBy == _currentStaffId ||
|
||||||
|
note.isSharedAll ||
|
||||||
|
note.collaboratorIds.contains(_currentStaffId);
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
Stream<List<NoteModel>> notesStream({
|
||||||
|
required String companyId,
|
||||||
|
required String currentStaffId,
|
||||||
|
}) {
|
||||||
|
return _supabase
|
||||||
|
.from(Tables.notes)
|
||||||
|
.stream(primaryKey: ['id'])
|
||||||
|
.eq('company_id', companyId)
|
||||||
|
.order('is_pinned', ascending: false)
|
||||||
|
// Nota: puoi ordinare solo per un campo alla volta nello stream nativo di Supabase.
|
||||||
|
// Ordiniamo per is_pinned, l'ordinamento per data lo facciamo al volo in RAM se serve,
|
||||||
|
// oppure ordiniamo per updated_at e il pin lo gestiamo via software.
|
||||||
|
.map((rawNotes) {
|
||||||
|
return rawNotes.map((json) => NoteModel.fromMap(json)).where((note) {
|
||||||
|
// Filtro multi-tenant di sicurezza in memoria
|
||||||
|
return note.createdBy == currentStaffId ||
|
||||||
|
note.isSharedAll ||
|
||||||
|
note.collaboratorIds.contains(currentStaffId);
|
||||||
|
}).toList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> saveNote(NoteModel note) async {
|
||||||
|
// 1. Eseguiamo l'upsert sulla tabella principale 'notes'
|
||||||
|
// Supabase gestisce in automatico: se l'id è null inserisce, se c'è fa update.
|
||||||
|
// Usiamo il .select().single() per farci restituire l'id generato (in caso di nuova nota)
|
||||||
|
final noteResponse = await _supabase
|
||||||
|
.from(Tables.notes)
|
||||||
|
.upsert({
|
||||||
|
if (note.id != null) 'id': note.id,
|
||||||
|
'company_id': note.companyId,
|
||||||
|
'created_by': note.createdBy,
|
||||||
|
'title': note.title,
|
||||||
|
'content': note.content,
|
||||||
|
'color': note.color,
|
||||||
|
'is_pinned': note.isPinned,
|
||||||
|
'is_shared_all': note.isSharedAll,
|
||||||
|
'updated_at': DateTime.now().toIso8601String(),
|
||||||
|
})
|
||||||
|
.select('id')
|
||||||
|
.single();
|
||||||
|
|
||||||
|
final noteId = noteResponse['id'] as String;
|
||||||
|
|
||||||
|
// Se la nota è condivisa con tutti, spazziamo via eventuali collaboratori singoli e usciamo
|
||||||
|
if (note.isSharedAll) {
|
||||||
|
await _supabase.from('note_collaborators').delete().eq('note_id', noteId);
|
||||||
|
return noteId;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. LA STRATEGIA DEL PIAZZA PULITA SUI COLLABORATORI
|
||||||
|
// Prima di tutto eliminiamo TUTTI i collaboratori attuali per questa specifica nota
|
||||||
|
await _supabase.from('note_collaborators').delete().eq('note_id', noteId);
|
||||||
|
|
||||||
|
// 3. RE-INSERIMENTO DELLA LISTA AGGIORNATA
|
||||||
|
// Se ci sono collaboratori da inserire, li prepariamo in blocco (Bulk Insert)
|
||||||
|
if (note.collaboratorIds.isNotEmpty) {
|
||||||
|
final collaboratorsToInsert = note.collaboratorIds
|
||||||
|
.map((staffId) => {'note_id': noteId, 'staff_id': staffId})
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
await _supabase.from('note_collaborators').insert(collaboratorsToInsert);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restituiamo l'id alla UI (fondamentale per la nostra logica Ninja di creazione)
|
||||||
|
return noteId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Elimina una nota (i collaboratori si cancellano in cascata grazie al vincolo del DB)
|
||||||
|
Future<void> deleteNote(String noteId) async {
|
||||||
|
await _supabase.from(Tables.notes).delete().eq('id', noteId);
|
||||||
|
}
|
||||||
|
}
|
||||||
131
lib/features/notes/models/note_model.dart
Normal file
131
lib/features/notes/models/note_model.dart
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class NoteModel extends Equatable {
|
||||||
|
final String? id;
|
||||||
|
final DateTime? createdAt;
|
||||||
|
final DateTime? updatedAt;
|
||||||
|
final String companyId;
|
||||||
|
final String createdBy;
|
||||||
|
final String? title;
|
||||||
|
final String? content;
|
||||||
|
final String color;
|
||||||
|
final bool isPinned;
|
||||||
|
final bool isSharedAll;
|
||||||
|
final List<String> collaboratorIds;
|
||||||
|
|
||||||
|
// Campi di utilità per la UI e le relazioni
|
||||||
|
//final List<StaffMemberModel> collaborators;
|
||||||
|
|
||||||
|
const NoteModel({
|
||||||
|
this.id,
|
||||||
|
this.createdAt,
|
||||||
|
this.updatedAt,
|
||||||
|
required this.companyId,
|
||||||
|
required this.createdBy,
|
||||||
|
this.title,
|
||||||
|
this.content,
|
||||||
|
this.color = '#FFF59D',
|
||||||
|
this.isPinned = false,
|
||||||
|
this.isSharedAll = false,
|
||||||
|
required this.collaboratorIds,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// Trasforma il colore Hex String in un oggetto Color di Flutter
|
||||||
|
Color get flutterColor {
|
||||||
|
final hexCode = color.replaceAll('#', '');
|
||||||
|
return Color(int.parse('FF$hexCode', radix: 16));
|
||||||
|
}
|
||||||
|
|
||||||
|
NoteModel copyWith({
|
||||||
|
String? id,
|
||||||
|
DateTime? createdAt,
|
||||||
|
DateTime? updatedAt,
|
||||||
|
String? companyId,
|
||||||
|
String? createdBy,
|
||||||
|
String? title,
|
||||||
|
String? content,
|
||||||
|
String? color,
|
||||||
|
bool? isPinned,
|
||||||
|
bool? isSharedAll,
|
||||||
|
List<String>? collaboratorIds,
|
||||||
|
}) {
|
||||||
|
return NoteModel(
|
||||||
|
id: id ?? this.id,
|
||||||
|
createdAt: createdAt ?? this.createdAt,
|
||||||
|
updatedAt: updatedAt ?? this.updatedAt,
|
||||||
|
companyId: companyId ?? this.companyId,
|
||||||
|
createdBy: createdBy ?? this.createdBy,
|
||||||
|
title: title ?? this.title,
|
||||||
|
content: content ?? this.content,
|
||||||
|
color: color ?? this.color,
|
||||||
|
isPinned: isPinned ?? this.isPinned,
|
||||||
|
isSharedAll: isSharedAll ?? this.isSharedAll,
|
||||||
|
collaboratorIds: collaboratorIds ?? this.collaboratorIds,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
factory NoteModel.empty({
|
||||||
|
required String createdBy,
|
||||||
|
required String companyId,
|
||||||
|
}) {
|
||||||
|
return NoteModel(
|
||||||
|
createdBy: createdBy,
|
||||||
|
companyId: companyId,
|
||||||
|
collaboratorIds: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap() {
|
||||||
|
return {
|
||||||
|
if (id != null) 'id': id,
|
||||||
|
'created_by': createdBy,
|
||||||
|
'title': title,
|
||||||
|
'content': content,
|
||||||
|
'color': color,
|
||||||
|
'is_pinned': isPinned,
|
||||||
|
'is_shared_all': isSharedAll,
|
||||||
|
'company_id': companyId,
|
||||||
|
// I collaboratori vanno in una tabella separata, quindi non li inseriamo qui
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
factory NoteModel.fromMap(Map<String, dynamic> map) {
|
||||||
|
return NoteModel(
|
||||||
|
id: map['id'] as String?,
|
||||||
|
createdAt: map['created_at'] != null
|
||||||
|
? DateTime.parse(map['created_at'] as String)
|
||||||
|
: null,
|
||||||
|
updatedAt: map['updated_at'] != null
|
||||||
|
? DateTime.parse(map['updated_at'] as String)
|
||||||
|
: null,
|
||||||
|
companyId: map['company_id'] as String,
|
||||||
|
createdBy: map['created_by'] as String,
|
||||||
|
title: map['title'] as String?,
|
||||||
|
content: map['content'] as String?,
|
||||||
|
color: map['color'] as String? ?? '#FFF59D',
|
||||||
|
isPinned: map['is_pinned'] as bool? ?? false,
|
||||||
|
isSharedAll: map['is_shared_all'] as bool? ?? false,
|
||||||
|
// TRUCCO NINJA: Castiamo l'array di Postgres in una List<String> pulita
|
||||||
|
collaboratorIds: map['collaborator_ids'] != null
|
||||||
|
? List<String>.from(map['collaborator_ids'] as List)
|
||||||
|
: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [
|
||||||
|
id,
|
||||||
|
createdAt,
|
||||||
|
updatedAt,
|
||||||
|
createdBy,
|
||||||
|
title,
|
||||||
|
content,
|
||||||
|
color,
|
||||||
|
isPinned,
|
||||||
|
isSharedAll,
|
||||||
|
companyId,
|
||||||
|
collaboratorIds,
|
||||||
|
//collaborators,
|
||||||
|
];
|
||||||
|
}
|
||||||
193
lib/features/notes/ui/dashboard_notes_widget.dart
Normal file
193
lib/features/notes/ui/dashboard_notes_widget.dart
Normal file
@@ -0,0 +1,193 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:flux/core/routes/routes.dart';
|
||||||
|
import 'package:flux/core/theme/theme.dart';
|
||||||
|
import 'package:flux/features/notes/blocs/notes_bloc.dart';
|
||||||
|
import 'package:flux/features/notes/models/note_model.dart';
|
||||||
|
import 'package:go_router/go_router.dart'; // Supponendo tu usi GoRouter per la navigazione
|
||||||
|
|
||||||
|
class DashboardNotesWidget extends StatelessWidget {
|
||||||
|
const DashboardNotesWidget({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Card(
|
||||||
|
elevation: 0,
|
||||||
|
clipBehavior: Clip.antiAlias,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
side: BorderSide(
|
||||||
|
color: Theme.of(context).dividerColor.withValues(alpha: 0.3),
|
||||||
|
style: BorderStyle.solid,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () => context.pushNamed(Routes.notes),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(12.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
// Intestazione del riquadro
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.yellow.shade700.withValues(alpha: 0.1),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
child: Icon(
|
||||||
|
Icons.sticky_note_2_outlined,
|
||||||
|
size: 16,
|
||||||
|
color: Colors.yellow.shade700,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Text(
|
||||||
|
'Le mie Note',
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 16,
|
||||||
|
color: context.primaryText,
|
||||||
|
),
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
|
||||||
|
// Il corpo del widget collegato al Bloc
|
||||||
|
BlocBuilder<NotesBloc, NotesState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
if (state.status == NotesStatus.loading &&
|
||||||
|
state.notes.isEmpty) {
|
||||||
|
return const Center(child: CircularProgressIndicator());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.status == NotesStatus.failure) {
|
||||||
|
return const Center(
|
||||||
|
child: Text(
|
||||||
|
'Errore nel caricamento delle note.',
|
||||||
|
style: TextStyle(color: Colors.red),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.notes.isEmpty) {
|
||||||
|
return _buildEmptyState(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prendiamo solo le prime 4 note per non intaccare troppo spazio in Dashboard
|
||||||
|
final displayNotes = state.notes.take(4).toList();
|
||||||
|
|
||||||
|
return SizedBox(
|
||||||
|
height: 140, // Altezza fissa per lo scroll orizzontale
|
||||||
|
child: ListView.builder(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
itemCount: displayNotes.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return _buildMiniPostIt(context, displayNotes[index]);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildMiniPostIt(BuildContext context, NoteModel note) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
// Vai al form di dettaglio passando l'ID o l'oggetto
|
||||||
|
context.push('/notes/edit/${note.id}');
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
width: 140,
|
||||||
|
margin: const EdgeInsets.only(right: 12, bottom: 8),
|
||||||
|
padding: const EdgeInsets.all(12),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: note.flutterColor,
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
boxShadow: const [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black12,
|
||||||
|
blurRadius: 4,
|
||||||
|
offset: Offset(2, 2),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
note.title?.isNotEmpty == true
|
||||||
|
? note.title!
|
||||||
|
: 'Senza titolo',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 14,
|
||||||
|
color: Colors.black87,
|
||||||
|
),
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (note.isPinned)
|
||||||
|
const Icon(Icons.push_pin, size: 14, color: Colors.black54),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
note.content ?? '',
|
||||||
|
style: const TextStyle(fontSize: 12, color: Colors.black87),
|
||||||
|
maxLines: 4,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildEmptyState(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
width: double.infinity,
|
||||||
|
padding: const EdgeInsets.all(24),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.grey.withValues(alpha: 0.1),
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
border: Border.all(
|
||||||
|
color: Colors.grey.withValues(alpha: 0.3),
|
||||||
|
style: BorderStyle.solid,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
const Icon(
|
||||||
|
Icons.sticky_note_2_outlined,
|
||||||
|
size: 32,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
const Text('Nessuna nota presente.'),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => context.push('/notes/create'),
|
||||||
|
child: const Text('Creane una ora'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
460
lib/features/notes/ui/notes_form_screen.dart
Normal file
460
lib/features/notes/ui/notes_form_screen.dart
Normal file
@@ -0,0 +1,460 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:flux/core/blocs/session/session_cubit.dart';
|
||||||
|
import 'package:flux/core/utils/debouncer.dart';
|
||||||
|
import 'package:flux/features/master_data/staff/blocs/staff_cubit.dart';
|
||||||
|
import 'package:flux/features/notes/blocs/notes_bloc.dart';
|
||||||
|
import 'package:flux/features/notes/models/note_model.dart';
|
||||||
|
|
||||||
|
class NoteFormScreen extends StatefulWidget {
|
||||||
|
final NoteModel
|
||||||
|
note; // La nota DEVE essere già stata creata (anche vuota) dal DB prima di arrivare qui
|
||||||
|
|
||||||
|
const NoteFormScreen({super.key, required this.note});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<NoteFormScreen> createState() => _NoteFormScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _NoteFormScreenState extends State<NoteFormScreen> {
|
||||||
|
NoteModel get _note => widget.note;
|
||||||
|
late TextEditingController _titleController;
|
||||||
|
late TextEditingController _contentController;
|
||||||
|
late final NotesBloc _notesBloc;
|
||||||
|
late String _selectedColor;
|
||||||
|
late bool _isPinned;
|
||||||
|
late bool _isSharedAll;
|
||||||
|
late List<String> _selectedStaffIds;
|
||||||
|
|
||||||
|
// Inizializziamo il Debouncer a 500 millisecondi
|
||||||
|
final _debouncer = Debouncer(milliseconds: 500);
|
||||||
|
|
||||||
|
final List<String> _noteColors = [
|
||||||
|
'#FFF59D',
|
||||||
|
'#FFCDD2',
|
||||||
|
'#C8E6C9',
|
||||||
|
'#BBDEFB',
|
||||||
|
'#E1BEE7',
|
||||||
|
'#F5F5F5',
|
||||||
|
];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_titleController = TextEditingController(text: widget.note.title ?? '');
|
||||||
|
_contentController = TextEditingController(text: widget.note.content ?? '');
|
||||||
|
_notesBloc = context.read<NotesBloc>();
|
||||||
|
_selectedColor = widget.note.color;
|
||||||
|
_isPinned = widget.note.isPinned;
|
||||||
|
_isSharedAll = widget.note.isSharedAll;
|
||||||
|
_selectedStaffIds = List.from(widget.note.collaboratorIds);
|
||||||
|
|
||||||
|
// Mettiamo i controller in ascolto per scatenare l'auto-salvataggio
|
||||||
|
_titleController.addListener(_onFieldsChanged);
|
||||||
|
_contentController.addListener(_onFieldsChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_titleController.removeListener(_onFieldsChanged);
|
||||||
|
_contentController.removeListener(_onFieldsChanged);
|
||||||
|
_titleController.dispose();
|
||||||
|
_contentController.dispose();
|
||||||
|
_debouncer.dispose();
|
||||||
|
|
||||||
|
// --- IL BOTTO FINALE: PULIZIA SILENZIOSA ---
|
||||||
|
_checkAndCleanupIfEmpty(_note.id!);
|
||||||
|
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Chiamata ogni volta che l'utente digita una lettera
|
||||||
|
void _onFieldsChanged() {
|
||||||
|
_debouncer.run(() => _triggerAutoSave());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Salva in background notificando il BLoC (così la bacheca si aggiorna in tempo reale)
|
||||||
|
void _triggerAutoSave() {
|
||||||
|
final companyId = context.read<SessionCubit>().state.company!.id!;
|
||||||
|
|
||||||
|
final updatedNote = NoteModel(
|
||||||
|
id: widget.note.id,
|
||||||
|
createdBy: widget.note.createdBy,
|
||||||
|
companyId: companyId,
|
||||||
|
title: _titleController.text.trim(),
|
||||||
|
content: _contentController.text.trim(),
|
||||||
|
color: _selectedColor,
|
||||||
|
isPinned: _isPinned,
|
||||||
|
isSharedAll: _isSharedAll,
|
||||||
|
collaboratorIds: _selectedStaffIds,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Spariamo l'evento al Bloc, che salverà silente sul DB tramite Repository
|
||||||
|
_notesBloc.add(NoteSavedRequested(updatedNote));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Se l'utente esce e la nota è totalmente vuota, la eliminiamo dal DB "al secchio"
|
||||||
|
void _checkAndCleanupIfEmpty(String noteId) {
|
||||||
|
final titleEmpty = _titleController.text.trim().isEmpty;
|
||||||
|
final contentEmpty = _contentController.text.trim().isEmpty;
|
||||||
|
|
||||||
|
//Se hai un modo per verificare se ci sono allegati associati (es. tramite una query locale o un contatore),
|
||||||
|
// assicurati che non ce ne siano prima di eliminare.
|
||||||
|
// Assumiamo che se non ha scritto testo ed è appena stata creata, sia vuota.
|
||||||
|
if (titleEmpty && contentEmpty) {
|
||||||
|
// Notifichiamo anche il Bloc dell'avvenuta cancellazione così pulisce lo stato locale
|
||||||
|
_notesBloc.add(NoteDeletedRequested(noteId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _deleteNote() {
|
||||||
|
_notesBloc.add(NoteDeletedRequested(widget.note.id!));
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _exportNote() {
|
||||||
|
// La logica di export che abbiamo concordato ieri!
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text('Funzione di esportazione/stampa in arrivo! 🚀'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showStaffPickerBottomSheet() {
|
||||||
|
final allStaff = context.read<StaffCubit>().state.storeStaff;
|
||||||
|
// Recuperiamo l'ID del creatore della nota
|
||||||
|
final creatorId = widget.note.createdBy;
|
||||||
|
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
shape: const RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
|
||||||
|
),
|
||||||
|
builder: (context) {
|
||||||
|
return StatefulBuilder(
|
||||||
|
builder: (context, setModalState) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Text(
|
||||||
|
'Seleziona Collaboratori',
|
||||||
|
style: Theme.of(context).textTheme.titleLarge,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: ListView.builder(
|
||||||
|
itemCount: allStaff.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final staff = allStaff[index];
|
||||||
|
|
||||||
|
// Capiamo se questo membro dello staff è il creatore
|
||||||
|
final isCreator = staff.id == creatorId;
|
||||||
|
// È spuntato se è il creatore OPPURE se è nella lista dei collaboratori
|
||||||
|
final isSelected =
|
||||||
|
isCreator || _selectedStaffIds.contains(staff.id);
|
||||||
|
|
||||||
|
return CheckboxListTile(
|
||||||
|
title: RichText(
|
||||||
|
text: TextSpan(
|
||||||
|
style: Theme.of(context).textTheme.bodyLarge,
|
||||||
|
children: [
|
||||||
|
TextSpan(text: staff.name),
|
||||||
|
if (isCreator)
|
||||||
|
const TextSpan(
|
||||||
|
text: ' (Proprietario)',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.grey,
|
||||||
|
fontStyle: FontStyle.italic,
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
value: isSelected,
|
||||||
|
activeColor: Theme.of(context).colorScheme.primary,
|
||||||
|
// IL TRUCCO NINJA: se è il creatore, passiamo null per disabilitare la spunta!
|
||||||
|
onChanged: isCreator
|
||||||
|
? null
|
||||||
|
: (bool? value) {
|
||||||
|
setModalState(() {
|
||||||
|
if (value == true) {
|
||||||
|
_selectedStaffIds.add(staff.id!);
|
||||||
|
} else {
|
||||||
|
_selectedStaffIds.remove(staff.id!);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
setState(() {});
|
||||||
|
_triggerAutoSave();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: FilledButton(
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
|
child: const Text('Fatto'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final noteColor = Color(
|
||||||
|
int.parse('FF${_selectedColor.replaceAll('#', '')}', radix: 16),
|
||||||
|
);
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
// 1. Sfondo scuro e riposante per l'intera schermata
|
||||||
|
backgroundColor: Colors.grey.shade900,
|
||||||
|
appBar: AppBar(
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
elevation: 0,
|
||||||
|
// Freccia indietro chiara per fare contrasto sullo sfondo grigio scuro
|
||||||
|
iconTheme: const IconThemeData(color: Colors.white70),
|
||||||
|
),
|
||||||
|
body: Center(
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: const BoxConstraints(maxWidth: 680),
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.only(bottom: 64, left: 16, right: 16),
|
||||||
|
child: Container(
|
||||||
|
// 2. IL NOSTRO POST-IT FISICO
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: noteColor,
|
||||||
|
borderRadius: BorderRadius.circular(16), // Bordi arrotondati
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black.withValues(alpha: 0.4), // Ombra morbida
|
||||||
|
blurRadius: 24,
|
||||||
|
offset: const Offset(0, 12),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.all(24.0),
|
||||||
|
child: Column(
|
||||||
|
// 3. MainAxisSize.min fa sì che il Post-it sia alto solo quanto serve!
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
// --- HEADER DEL POST-IT (Tavolozza + Azioni) ---
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
// Tavolozza Colori
|
||||||
|
Expanded(
|
||||||
|
child: SizedBox(
|
||||||
|
height: 40,
|
||||||
|
child: ListView.builder(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
itemCount: _noteColors.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final colorHex = _noteColors[index];
|
||||||
|
final isSelected = _selectedColor == colorHex;
|
||||||
|
final c = Color(
|
||||||
|
int.parse(
|
||||||
|
'FF${colorHex.replaceAll('#', '')}',
|
||||||
|
radix: 16,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
setState(() => _selectedColor = colorHex);
|
||||||
|
_triggerAutoSave();
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.only(right: 12),
|
||||||
|
width: 40,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: c,
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
border: Border.all(
|
||||||
|
color: isSelected
|
||||||
|
? Colors.black54
|
||||||
|
: Colors.black12,
|
||||||
|
width: isSelected ? 3 : 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: isSelected
|
||||||
|
? const Icon(
|
||||||
|
Icons.check,
|
||||||
|
color: Colors.black54,
|
||||||
|
size: 20,
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 16),
|
||||||
|
|
||||||
|
// Azioni spostate dentro la nota!
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.delete_outline,
|
||||||
|
color: Colors.black87,
|
||||||
|
),
|
||||||
|
tooltip: 'Elimina',
|
||||||
|
onPressed: _deleteNote,
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
_isPinned ? Icons.push_pin : Icons.push_pin_outlined,
|
||||||
|
color: Colors.black87,
|
||||||
|
),
|
||||||
|
tooltip: _isPinned
|
||||||
|
? 'Rimuovi in alto'
|
||||||
|
: 'Fissa in alto',
|
||||||
|
onPressed: () {
|
||||||
|
setState(() => _isPinned = !_isPinned);
|
||||||
|
_triggerAutoSave();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.ios_share,
|
||||||
|
color: Colors.black87,
|
||||||
|
),
|
||||||
|
tooltip: 'Esporta',
|
||||||
|
onPressed: _exportNote,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 32),
|
||||||
|
|
||||||
|
// --- TITOLO ---
|
||||||
|
TextFormField(
|
||||||
|
controller: _titleController,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 28,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Colors.black87,
|
||||||
|
),
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
hintText: 'Titolo...',
|
||||||
|
hintStyle: TextStyle(color: Colors.black38),
|
||||||
|
border: InputBorder.none,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// --- CONTENUTO ---
|
||||||
|
TextFormField(
|
||||||
|
controller: _contentController,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
color: Colors.black87,
|
||||||
|
height: 1.5,
|
||||||
|
),
|
||||||
|
maxLines: null,
|
||||||
|
minLines: 12,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
hintText: 'Scrivi qui la tua nota...',
|
||||||
|
hintStyle: TextStyle(color: Colors.black38),
|
||||||
|
border: InputBorder.none,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
const Divider(color: Colors.black12),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
|
||||||
|
// --- CONDIVISIONE ---
|
||||||
|
SwitchListTile(
|
||||||
|
title: const Text(
|
||||||
|
'Condividi con tutti',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.black87,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
value: _isSharedAll,
|
||||||
|
activeThumbColor: Colors.black87,
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
onChanged: (val) {
|
||||||
|
setState(() {
|
||||||
|
_isSharedAll = val;
|
||||||
|
if (val) _selectedStaffIds.clear();
|
||||||
|
});
|
||||||
|
_triggerAutoSave();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
|
if (!_isSharedAll) ...[
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Wrap(
|
||||||
|
spacing: 8.0,
|
||||||
|
runSpacing: 8.0,
|
||||||
|
children: [
|
||||||
|
ActionChip(
|
||||||
|
avatar: const Icon(
|
||||||
|
Icons.add,
|
||||||
|
size: 18,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
label: const Text(
|
||||||
|
'Aggiungi Colleghi',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onPressed: _showStaffPickerBottomSheet,
|
||||||
|
// Pesca in automatico il blu dei tuoi pulsanti Salva!
|
||||||
|
backgroundColor: Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.primary,
|
||||||
|
side: BorderSide
|
||||||
|
.none, // Togliamo il bordino per un look più pulito e solido
|
||||||
|
elevation:
|
||||||
|
2, // Una leggera ombra per farlo sembrare cliccabile
|
||||||
|
),
|
||||||
|
if (_selectedStaffIds.isNotEmpty)
|
||||||
|
Chip(
|
||||||
|
label: Text(
|
||||||
|
'${_selectedStaffIds.length} collaboratori',
|
||||||
|
style: const TextStyle(color: Colors.black87),
|
||||||
|
),
|
||||||
|
backgroundColor: Colors.white.withValues(
|
||||||
|
alpha: 0.6,
|
||||||
|
),
|
||||||
|
deleteIconColor: Colors.black87,
|
||||||
|
side: const BorderSide(color: Colors.black12),
|
||||||
|
onDeleted: () {
|
||||||
|
setState(() => _selectedStaffIds.clear());
|
||||||
|
_triggerAutoSave();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
const Divider(color: Colors.black12),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
|
||||||
|
// --- ALLEGATI ---
|
||||||
|
// SharedAttachmentsSection(
|
||||||
|
// parentType: AttachmentParentType.note,
|
||||||
|
// parentId: widget.note.id!,
|
||||||
|
// ),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
249
lib/features/notes/ui/notes_list_screen.dart
Normal file
249
lib/features/notes/ui/notes_list_screen.dart
Normal file
@@ -0,0 +1,249 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
||||||
|
import 'package:flux/core/routes/routes.dart';
|
||||||
|
import 'package:flux/features/notes/blocs/notes_bloc.dart';
|
||||||
|
import 'package:flux/features/notes/data/notes_repository.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:get_it/get_it.dart';
|
||||||
|
import 'package:flux/core/blocs/session/session_cubit.dart';
|
||||||
|
import 'package:flux/features/notes/models/note_model.dart';
|
||||||
|
|
||||||
|
class NotesListScreen extends StatelessWidget {
|
||||||
|
const NotesListScreen({super.key});
|
||||||
|
|
||||||
|
/// Logica Ninja: Crea la nota vuota, prende l'ID, e apre il form
|
||||||
|
Future<void> _createNewNoteAndNavigate(BuildContext context) async {
|
||||||
|
final sessionState = context.read<SessionCubit>().state;
|
||||||
|
final companyId = sessionState.company!.id!;
|
||||||
|
final currentStaffId = sessionState.currentStaffMember!.id!;
|
||||||
|
|
||||||
|
// 1. Creiamo la nota vuota
|
||||||
|
final emptyNote = NoteModel.empty(
|
||||||
|
createdBy: currentStaffId,
|
||||||
|
companyId: companyId,
|
||||||
|
).copyWith(color: '#FFF59D');
|
||||||
|
|
||||||
|
// Mostriamo un loading veloce se serve (opzionale)
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text('Creazione nota in corso...'),
|
||||||
|
duration: Duration(milliseconds: 500),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 2. Scriviamo su DB per avere l'ID
|
||||||
|
final noteId = await GetIt.I.get<NotesRepository>().saveNote(emptyNote);
|
||||||
|
if (context.mounted) {
|
||||||
|
// 3. Spingiamo l'utente nel form con la nota già provvista di ID!
|
||||||
|
context.pushNamed(
|
||||||
|
Routes.noteForm,
|
||||||
|
pathParameters: ({'id': noteId}),
|
||||||
|
extra: emptyNote.copyWith(id: noteId),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
if (context.mounted) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(content: Text('Errore: Impossibile creare la nota. $e')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor:
|
||||||
|
Colors.grey.shade900, // Sfondo neutro per far risaltare i post-it
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text(
|
||||||
|
'Bacheca Note',
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
centerTitle: false,
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
elevation: 0,
|
||||||
|
),
|
||||||
|
floatingActionButton: FloatingActionButton.extended(
|
||||||
|
onPressed: () => _createNewNoteAndNavigate(context),
|
||||||
|
icon: const Icon(Icons.add),
|
||||||
|
label: const Text('Nuova Nota'),
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
),
|
||||||
|
body: BlocBuilder<NotesBloc, NotesState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
if (state.status == NotesStatus.loading && state.notes.isEmpty) {
|
||||||
|
return const Center(child: CircularProgressIndicator());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.status == NotesStatus.failure) {
|
||||||
|
return Center(
|
||||||
|
child: Text(
|
||||||
|
'Errore nel caricamento: ${state.errorMessage}',
|
||||||
|
style: const TextStyle(color: Colors.red),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.notes.isEmpty) {
|
||||||
|
return Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
Icons.sticky_note_2_outlined,
|
||||||
|
size: 64,
|
||||||
|
color: Colors.grey.shade400,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Text(
|
||||||
|
'Nessuna nota presente.',
|
||||||
|
style: TextStyle(color: Colors.grey.shade600, fontSize: 18),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
const Text('Clicca su "Nuova Nota" per iniziare.'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ordiniamo le note: prima le pinnate, poi le altre (se non le ordina già il DB)
|
||||||
|
final sortedNotes = List<NoteModel>.from(state.notes)
|
||||||
|
..sort((a, b) {
|
||||||
|
if (a.isPinned && !b.isPinned) return -1;
|
||||||
|
if (!a.isPinned && b.isPinned) return 1;
|
||||||
|
return 0; // Se vuoi puoi aggiungere l'ordinamento per data qui
|
||||||
|
});
|
||||||
|
|
||||||
|
return _buildMasonryGrid(context, sortedNotes);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildMasonryGrid(BuildContext context, List<NoteModel> notes) {
|
||||||
|
// Calcoliamo quante colonne mostrare in base alla larghezza dello schermo
|
||||||
|
final screenWidth = MediaQuery.of(context).size.width;
|
||||||
|
int crossAxisCount = 2; // Mobile
|
||||||
|
if (screenWidth > 600) crossAxisCount = 3; // Tablet
|
||||||
|
if (screenWidth > 900) crossAxisCount = 4; // Desktop piccolo
|
||||||
|
if (screenWidth > 1200) crossAxisCount = 5; // Desktop grande
|
||||||
|
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||||
|
child: MasonryGridView.count(
|
||||||
|
crossAxisCount: crossAxisCount,
|
||||||
|
mainAxisSpacing: 12,
|
||||||
|
crossAxisSpacing: 12,
|
||||||
|
itemCount: notes.length,
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
bottom: 80,
|
||||||
|
top: 8,
|
||||||
|
), // Spazio per non coprire col FAB
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final note = notes[index];
|
||||||
|
return _buildNoteCard(context, note);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildNoteCard(BuildContext context, NoteModel note) {
|
||||||
|
final noteColor = Color(
|
||||||
|
int.parse('FF${note.color.replaceAll('#', '')}', radix: 16),
|
||||||
|
);
|
||||||
|
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: () => context.pushNamed(
|
||||||
|
Routes.noteForm,
|
||||||
|
pathParameters: {'id': note.id!},
|
||||||
|
extra: note,
|
||||||
|
),
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: noteColor,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black.withValues(alpha: 0.1),
|
||||||
|
blurRadius: 4,
|
||||||
|
offset: const Offset(2, 2),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
border: Border.all(color: Colors.black.withValues(alpha: 0.05)),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min, // Fondamentale per il Masonry!
|
||||||
|
children: [
|
||||||
|
if (note.title != null && note.title!.isNotEmpty) ...[
|
||||||
|
Text(
|
||||||
|
note.title!,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 16,
|
||||||
|
color: Colors.black87,
|
||||||
|
),
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
],
|
||||||
|
if (note.content != null && note.content!.isNotEmpty) ...[
|
||||||
|
Text(
|
||||||
|
note.content!,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: Colors.black87,
|
||||||
|
height: 1.3,
|
||||||
|
),
|
||||||
|
// Limitiamo le righe in bacheca per non avere post-it lunghi 3 metri
|
||||||
|
maxLines: 8,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
|
||||||
|
// Footer con icone di stato (Pin, Condivisione, Allegati)
|
||||||
|
_buildCardFooter(note),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildCardFooter(NoteModel note) {
|
||||||
|
final hasStatusIcons =
|
||||||
|
note.isPinned || note.isSharedAll || note.collaboratorIds.isNotEmpty;
|
||||||
|
|
||||||
|
if (!hasStatusIcons) return const SizedBox.shrink();
|
||||||
|
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 12.0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
if (note.isSharedAll || note.collaboratorIds.isNotEmpty)
|
||||||
|
const Padding(
|
||||||
|
padding: EdgeInsets.only(right: 8.0),
|
||||||
|
child: Icon(
|
||||||
|
Icons.people_alt_outlined,
|
||||||
|
size: 16,
|
||||||
|
color: Colors.black54,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
const Padding(
|
||||||
|
padding: EdgeInsets.only(right: 8.0),
|
||||||
|
child: Icon(Icons.attachment, size: 16, color: Colors.black54),
|
||||||
|
),
|
||||||
|
if (note.isPinned)
|
||||||
|
const Icon(Icons.push_pin, size: 16, color: Colors.black54),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import 'package:flux/core/blocs/session/session_cubit.dart';
|
|||||||
import 'package:flux/core/routes/routes.dart';
|
import 'package:flux/core/routes/routes.dart';
|
||||||
import 'package:flux/core/theme/theme.dart';
|
import 'package:flux/core/theme/theme.dart';
|
||||||
import 'package:flux/features/settings/blocs/settings_cubit.dart';
|
import 'package:flux/features/settings/blocs/settings_cubit.dart';
|
||||||
|
import 'package:get_it/get_it.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
class SettingsScreen extends StatelessWidget {
|
class SettingsScreen extends StatelessWidget {
|
||||||
@@ -17,20 +18,53 @@ class SettingsScreen extends StatelessWidget {
|
|||||||
body: ListView(
|
body: ListView(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
children: [
|
children: [
|
||||||
_settingsSection('Account', [
|
_settingsSection('Azienda', [
|
||||||
_settingsTile(
|
_settingsTile(
|
||||||
icon: Icons.person,
|
title: 'Impostazioni Azienda',
|
||||||
title: 'Profilo Utente',
|
icon: Icons.business,
|
||||||
subtitle: 'Configura i tuoi dati',
|
subtitle: 'Configura i dati aziendali',
|
||||||
context: context,
|
context: context,
|
||||||
onTap: () {},
|
onTap: () => context.pushNamed(Routes.companySettings),
|
||||||
),
|
),
|
||||||
const Divider(height: 30),
|
const Divider(height: 30),
|
||||||
|
_settingsTile(
|
||||||
|
title: 'Impostazione Negozi',
|
||||||
|
icon: Icons.store,
|
||||||
|
subtitle: 'Crea o configura i negozi',
|
||||||
|
context: context,
|
||||||
|
onTap: () => context.pushNamed(Routes.stores),
|
||||||
|
),
|
||||||
|
const Divider(height: 30),
|
||||||
|
_settingsTile(
|
||||||
|
title: 'Impostazione Staff / Utenti',
|
||||||
|
icon: Icons.group,
|
||||||
|
subtitle:
|
||||||
|
'Configura i membri dei negozi o invita nuovi utenti in azienda',
|
||||||
|
context: context,
|
||||||
|
onTap: () => context.pushNamed(Routes.staff),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
_settingsSection('Applicazione', [
|
||||||
BlocBuilder<SettingsCubit, SettingsState>(
|
BlocBuilder<SettingsCubit, SettingsState>(
|
||||||
builder: (context, state) => CheckboxListTile(
|
builder: (context, state) => CheckboxListTile(
|
||||||
value: state.isSingleUserMode,
|
value: state.isSingleUserMode,
|
||||||
title: const Text(
|
|
||||||
'Modalità utente singolo (dispositivo personale)',
|
title: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.person, color: FluxColors.primaryBlue),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Text(
|
||||||
|
'Modalità utente singolo (dispositivo personale)',
|
||||||
|
style: Theme.of(context).textTheme.titleLarge,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
subtitle: Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 36),
|
||||||
|
child: Text(
|
||||||
|
'Utente ${GetIt.I.get<SessionCubit>().state.currentStaffMember?.name ?? 'Nessuno'} selezionato automaticamente',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
context.read<SessionCubit>().setIsSingleUserMode(value!);
|
context.read<SessionCubit>().setIsSingleUserMode(value!);
|
||||||
@@ -39,16 +73,6 @@ class SettingsScreen extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Divider(height: 30),
|
const Divider(height: 30),
|
||||||
_settingsTile(
|
|
||||||
title: 'Impostazioni Azienda',
|
|
||||||
icon: Icons.business,
|
|
||||||
subtitle: 'Configura i dati aziendali',
|
|
||||||
context: context,
|
|
||||||
onTap: () => context.pushNamed(Routes.companySettings),
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
_settingsSection('Applicazione', [
|
|
||||||
_settingsTile(
|
_settingsTile(
|
||||||
icon: Icons.dark_mode,
|
icon: Icons.dark_mode,
|
||||||
title: 'Tema (FLUX Dark)',
|
title: 'Tema (FLUX Dark)',
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class TicketRepository {
|
|||||||
.from(_tableName)
|
.from(_tableName)
|
||||||
.select('''
|
.select('''
|
||||||
*,
|
*,
|
||||||
${Tables.customers} (*),
|
customer:${Tables.customers}!ticket_customer_id_fkey (*),
|
||||||
${Tables.shippingDocuments} (*, ${Tables.attachments} (*)),
|
${Tables.shippingDocuments} (*, ${Tables.attachments} (*)),
|
||||||
created_by:${Tables.staffMembers}!ticket_staff_id_fkey (*),
|
created_by:${Tables.staffMembers}!ticket_staff_id_fkey (*),
|
||||||
assigned_to:${Tables.staffMembers}!ticket_assigned_to_id_fkey (*),
|
assigned_to:${Tables.staffMembers}!ticket_assigned_to_id_fkey (*),
|
||||||
@@ -89,7 +89,7 @@ class TicketRepository {
|
|||||||
.from(_tableName)
|
.from(_tableName)
|
||||||
.select('''
|
.select('''
|
||||||
*,
|
*,
|
||||||
${Tables.customers} (*),
|
customer:${Tables.customers}!ticket_customer_id_fkey (*),
|
||||||
${Tables.shippingDocuments} (*, ${Tables.attachments} (*)),
|
${Tables.shippingDocuments} (*, ${Tables.attachments} (*)),
|
||||||
created_by:${Tables.staffMembers}!ticket_staff_id_fkey (*),
|
created_by:${Tables.staffMembers}!ticket_staff_id_fkey (*),
|
||||||
assigned_to:${Tables.staffMembers}!ticket_assigned_to_id_fkey (*),
|
assigned_to:${Tables.staffMembers}!ticket_assigned_to_id_fkey (*),
|
||||||
@@ -200,7 +200,7 @@ class TicketRepository {
|
|||||||
.from(_tableName)
|
.from(_tableName)
|
||||||
.select('''
|
.select('''
|
||||||
*,
|
*,
|
||||||
${Tables.customers} (*),
|
customer:${Tables.customers}!ticket_customer_id_fkey (*),
|
||||||
target_model:${Tables.models}!ticket_model_id_1_fkey (*),
|
target_model:${Tables.models}!ticket_model_id_1_fkey (*),
|
||||||
source_model:${Tables.models}!ticket_model_id_2_fkey (*),
|
source_model:${Tables.models}!ticket_model_id_2_fkey (*),
|
||||||
created_by:${Tables.staffMembers}!ticket_staff_id_fkey (*),
|
created_by:${Tables.staffMembers}!ticket_staff_id_fkey (*),
|
||||||
|
|||||||
@@ -55,6 +55,12 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
// TRUCCO ANTI-RACE-CONDITION:
|
||||||
|
// Se il ticket arriva già "pronto" (via extra), popoliamo i controller SUBITO,
|
||||||
|
// senza aspettare il listener del BLoC che si perderebbe l'emissione sincrona.
|
||||||
|
if (widget.existingTicket != null) {
|
||||||
|
_syncTextControllers(widget.existingTicket!);
|
||||||
|
}
|
||||||
context.read<TicketFormCubit>().initForm(
|
context.read<TicketFormCubit>().initForm(
|
||||||
existingTicket: widget.existingTicket,
|
existingTicket: widget.existingTicket,
|
||||||
id: widget.ticketId,
|
id: widget.ticketId,
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import 'package:flux/core/utils/version_check_service.dart';
|
|||||||
import 'package:flux/features/attachments/data/attachments_repository.dart';
|
import 'package:flux/features/attachments/data/attachments_repository.dart';
|
||||||
import 'package:flux/features/auth/bloc/auth_cubit.dart';
|
import 'package:flux/features/auth/bloc/auth_cubit.dart';
|
||||||
import 'package:flux/features/company/data/company_repository.dart';
|
import 'package:flux/features/company/data/company_repository.dart';
|
||||||
|
import 'package:flux/features/notes/blocs/notes_bloc.dart';
|
||||||
|
import 'package:flux/features/notes/data/notes_repository.dart';
|
||||||
import 'package:flux/features/tickets/data/tickets_shipping_repository.dart';
|
import 'package:flux/features/tickets/data/tickets_shipping_repository.dart';
|
||||||
import 'package:flux/features/master_data/providers/blocs/provider_list_cubit.dart';
|
import 'package:flux/features/master_data/providers/blocs/provider_list_cubit.dart';
|
||||||
import 'package:flux/features/operations/blocs/operation_list_cubit.dart';
|
import 'package:flux/features/operations/blocs/operation_list_cubit.dart';
|
||||||
@@ -75,6 +77,7 @@ void main() async {
|
|||||||
BlocProvider<TicketListCubit>(create: (_) => TicketListCubit()),
|
BlocProvider<TicketListCubit>(create: (_) => TicketListCubit()),
|
||||||
BlocProvider<OperationListCubit>(create: (_) => OperationListCubit()),
|
BlocProvider<OperationListCubit>(create: (_) => OperationListCubit()),
|
||||||
BlocProvider<TrackingCubit>(create: (_) => TrackingCubit()),
|
BlocProvider<TrackingCubit>(create: (_) => TrackingCubit()),
|
||||||
|
BlocProvider<NotesBloc>(create: (_) => NotesBloc()),
|
||||||
],
|
],
|
||||||
child: const FluxApp(),
|
child: const FluxApp(),
|
||||||
),
|
),
|
||||||
@@ -132,6 +135,7 @@ Future<void> setupLocator() async {
|
|||||||
getIt.registerLazySingleton<TicketsShippingRepository>(
|
getIt.registerLazySingleton<TicketsShippingRepository>(
|
||||||
() => TicketsShippingRepository(),
|
() => TicketsShippingRepository(),
|
||||||
);
|
);
|
||||||
|
getIt.registerLazySingleton<NotesRepository>(() => NotesRepository());
|
||||||
}
|
}
|
||||||
|
|
||||||
class FluxApp extends StatefulWidget {
|
class FluxApp extends StatefulWidget {
|
||||||
|
|||||||
49
pubspec.lock
49
pubspec.lock
@@ -125,10 +125,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: code_assets
|
name: code_assets
|
||||||
sha256: "83ccdaa064c980b5596c35dd64a8d3ecc68620174ab9b90b6343b753aa721687"
|
sha256: dad6bf6b9f4f378b0a69edbf42584d336efd1a9ce15deb1ba591cbb1b5ff440f
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.0"
|
version: "1.1.0"
|
||||||
collection:
|
collection:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -315,6 +315,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.34"
|
version: "2.0.34"
|
||||||
|
flutter_staggered_grid_view:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_staggered_grid_view
|
||||||
|
sha256: "19e7abb550c96fbfeb546b23f3ff356ee7c59a019a651f8f102a4ba9b7349395"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.7.0"
|
||||||
flutter_svg:
|
flutter_svg:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -357,14 +365,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "9.2.1"
|
version: "9.2.1"
|
||||||
glob:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: glob
|
|
||||||
sha256: c3f1ee72c96f8f78935e18aa8cecced9ab132419e8625dc187e1c2408efc20de
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.1.3"
|
|
||||||
go_router:
|
go_router:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -401,10 +401,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: hooks
|
name: hooks
|
||||||
sha256: "025f060e86d2d4c3c47b56e33caf7f93bf9283340f26d23424ebcfccf34f621e"
|
sha256: a41af4e8fc687cd6d33de9751eb936c8c0204ebe2bcb6c15ecf707504bf47f31
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.3"
|
version: "2.0.0"
|
||||||
http:
|
http:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -613,14 +613,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "2.0.0"
|
||||||
native_toolchain_c:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: native_toolchain_c
|
|
||||||
sha256: "6ba77bb18063eebe9de401f5e6437e95e1438af0a87a3a39084fbd37c90df572"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.17.6"
|
|
||||||
nested:
|
nested:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -633,10 +625,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: objective_c
|
name: objective_c
|
||||||
sha256: "100a1c87616ab6ed41ec263b083c0ef3261ee6cd1dc3b0f35f8ddfa4f996fe52"
|
sha256: "6cb691c686fa2838c6deb34980d426145c2a5d537491cb83d463c33cdbc726ed"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "9.3.0"
|
version: "9.4.1"
|
||||||
package_config:
|
package_config:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -744,10 +736,11 @@ packages:
|
|||||||
pdfx:
|
pdfx:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: pdfx
|
path: "packages/pdfx"
|
||||||
sha256: "29db9b71d46bf2335e001f91693f2c3fbbf0760e4c2eb596bf4bafab211471c1"
|
ref: main
|
||||||
url: "https://pub.dev"
|
resolved-ref: "900ad0799ebd12d6c87189275fcb6155ce8a9374"
|
||||||
source: hosted
|
url: "https://github.com/ScerIO/packages.flutter.git"
|
||||||
|
source: git
|
||||||
version: "2.9.2"
|
version: "2.9.2"
|
||||||
permission_handler:
|
permission_handler:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
@@ -1110,10 +1103,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: url_launcher_android
|
name: url_launcher_android
|
||||||
sha256: "3bb000251e55d4a209aa0e2e563309dc9bb2befea2295fd0cec1f51760aac572"
|
sha256: "17bc677f0b301615530dd1d67e0a9828cafa2d0b6b6eae4cd3679b7eac4a273c"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.3.29"
|
version: "6.3.30"
|
||||||
url_launcher_ios:
|
url_launcher_ios:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
10
pubspec.yaml
10
pubspec.yaml
@@ -1,7 +1,7 @@
|
|||||||
name: flux
|
name: flux
|
||||||
description: "Gestione attività negozio di telefonia"
|
description: "Gestione attività negozio di telefonia"
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
version: 1.0.6+6
|
version: 1.0.12+12
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.11.3
|
sdk: ^3.11.3
|
||||||
@@ -38,6 +38,14 @@ dependencies:
|
|||||||
font_awesome_flutter: ^11.0.0
|
font_awesome_flutter: ^11.0.0
|
||||||
flutter_launcher_icons: ^0.14.4
|
flutter_launcher_icons: ^0.14.4
|
||||||
package_info_plus: ^9.0.1
|
package_info_plus: ^9.0.1
|
||||||
|
flutter_staggered_grid_view: ^0.7.0
|
||||||
|
|
||||||
|
dependency_overrides:
|
||||||
|
pdfx:
|
||||||
|
git:
|
||||||
|
url: https://github.com/ScerIO/packages.flutter.git
|
||||||
|
ref: main
|
||||||
|
path: packages/pdfx
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ DefaultDirName={autopf}\Flux
|
|||||||
|
|
||||||
; Cartella di output dell'installer e nome del file generato
|
; Cartella di output dell'installer e nome del file generato
|
||||||
OutputDir=.\build\windows\installer
|
OutputDir=.\build\windows\installer
|
||||||
OutputBaseFilename=FLUX_Setup_v{#MyAppVersion}
|
OutputBaseFilename=FluxInstaller
|
||||||
|
|
||||||
; Compressione e impostazioni grafiche
|
; Compressione e impostazioni grafiche
|
||||||
Compression=lzma2/max
|
Compression=lzma2/max
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
# Project-level configuration.
|
# Project-level configuration.
|
||||||
cmake_minimum_required(VERSION 3.14)
|
cmake_minimum_required(VERSION 3.14)
|
||||||
project(flux LANGUAGES CXX)
|
project(flux LANGUAGES CXX)
|
||||||
|
add_compile_definitions(_SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS)
|
||||||
|
|
||||||
# The name of the executable created for the application. Change this to change
|
# The name of the executable created for the application. Change this to change
|
||||||
# the on-disk name of your application.
|
# the on-disk name of your application.
|
||||||
|
|||||||
Reference in New Issue
Block a user