primera pagina empresa y negocios alfa

This commit is contained in:
Abraham
2025-07-16 21:54:10 -07:00
parent 8670f90068
commit 3e7a26dadc
8 changed files with 5729 additions and 997 deletions

View File

@@ -3,7 +3,10 @@ import 'package:provider/provider.dart';
import 'package:nethive_neo/providers/nethive/empresas_negocios_provider.dart';
import 'package:nethive_neo/pages/empresa_negocios/widgets/empresa_selector_sidebar.dart';
import 'package:nethive_neo/pages/empresa_negocios/widgets/negocios_table.dart';
import 'package:nethive_neo/pages/empresa_negocios/widgets/negocios_cards_view.dart';
import 'package:nethive_neo/pages/empresa_negocios/widgets/mobile_empresa_selector.dart';
import 'package:nethive_neo/theme/theme.dart';
import 'package:nethive_neo/helpers/globals.dart';
class EmpresaNegociosPage extends StatefulWidget {
const EmpresaNegociosPage({Key? key}) : super(key: key);
@@ -12,135 +15,380 @@ class EmpresaNegociosPage extends StatefulWidget {
State<EmpresaNegociosPage> createState() => _EmpresaNegociosPageState();
}
class _EmpresaNegociosPageState extends State<EmpresaNegociosPage> {
class _EmpresaNegociosPageState extends State<EmpresaNegociosPage>
with TickerProviderStateMixin {
bool showMapView = false;
late AnimationController _animationController;
late Animation<double> _fadeAnimation;
late Animation<Offset> _slideAnimation;
@override
void initState() {
super.initState();
_animationController = AnimationController(
duration: const Duration(milliseconds: 800),
vsync: this,
);
_fadeAnimation = Tween<double>(
begin: 0.0,
end: 1.0,
).animate(CurvedAnimation(
parent: _animationController,
curve: Curves.easeInOut,
));
_slideAnimation = Tween<Offset>(
begin: const Offset(0, 0.3),
end: Offset.zero,
).animate(CurvedAnimation(
parent: _animationController,
curve: Curves.easeOutCubic,
));
_animationController.forward();
}
@override
void dispose() {
_animationController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final isLargeScreen = MediaQuery.of(context).size.width > 1200;
final isMediumScreen = MediaQuery.of(context).size.width > 800;
return Scaffold(
backgroundColor: AppTheme.of(context).primaryBackground,
body: Consumer<EmpresasNegociosProvider>(
builder: (context, provider, child) {
return Row(
children: [
// Sidebar izquierdo con empresas
SizedBox(
width: 300,
child: EmpresaSelectorSidebar(
provider: provider,
onEmpresaSelected: (empresaId) {
provider.setEmpresaSeleccionada(empresaId);
},
),
),
// Área principal
Expanded(
child: Container(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Header con título y switch
_buildHeader(provider),
const SizedBox(height: 16),
// Contenido principal (tabla o mapa)
Expanded(
child: showMapView
? _buildMapView()
: _buildTableView(provider),
body: Container(
decoration: BoxDecoration(
gradient: AppTheme.of(context).darkBackgroundGradient,
),
child: Consumer<EmpresasNegociosProvider>(
builder: (context, provider, child) {
if (isLargeScreen) {
// Vista de escritorio
return Row(
children: [
// Sidebar izquierdo con empresas
SlideTransition(
position: Tween<Offset>(
begin: const Offset(-1, 0),
end: Offset.zero,
).animate(CurvedAnimation(
parent: _animationController,
curve: Curves.easeOutCubic,
)),
child: SizedBox(
width: 320,
child: EmpresaSelectorSidebar(
provider: provider,
onEmpresaSelected: (empresaId) {
provider.setEmpresaSeleccionada(empresaId);
},
),
],
),
),
),
),
],
);
},
// Área principal
Expanded(
child: SlideTransition(
position: _slideAnimation,
child: FadeTransition(
opacity: _fadeAnimation,
child: Container(
padding: const EdgeInsets.all(24),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Header con título y switch
_buildEnhancedHeader(provider),
const SizedBox(height: 24),
// Contenido principal (tabla o mapa)
Expanded(
child: showMapView
? _buildMapView()
: _buildTableView(provider),
),
],
),
),
),
),
),
],
);
} else {
// Vista móvil/tablet
return Column(
children: [
// Header móvil
_buildMobileHeader(provider),
// Contenido principal
Expanded(
child: showMapView
? _buildMapView()
: NegociosCardsView(provider: provider),
),
],
);
}
},
),
),
// FAB para vista móvil
floatingActionButton: MediaQuery.of(context).size.width <= 800
? _buildMobileFAB(context)
: null,
);
}
Widget _buildHeader(EmpresasNegociosProvider provider) {
Widget _buildEnhancedHeader(EmpresasNegociosProvider provider) {
return Container(
padding: const EdgeInsets.all(16),
padding: const EdgeInsets.all(24),
decoration: BoxDecoration(
color: AppTheme.of(context).secondaryBackground,
borderRadius: BorderRadius.circular(12),
gradient: AppTheme.of(context).primaryGradient,
borderRadius: BorderRadius.circular(20),
boxShadow: [
BoxShadow(
color: AppTheme.of(context).primaryColor.withOpacity(0.3),
blurRadius: 20,
offset: const Offset(0, 8),
),
BoxShadow(
color: Colors.black.withOpacity(0.1),
blurRadius: 4,
offset: const Offset(0, 2),
blurRadius: 10,
offset: const Offset(0, 4),
),
],
),
child: Row(
children: [
// Icono animado
TweenAnimationBuilder<double>(
duration: const Duration(milliseconds: 1000),
tween: Tween(begin: 0.0, end: 1.0),
builder: (context, value, child) {
return Transform.rotate(
angle: value * 0.1,
child: Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.2),
borderRadius: BorderRadius.circular(16),
border: Border.all(
color: Colors.white.withOpacity(0.3),
width: 2,
),
),
child: Icon(
Icons.business_center,
color: Colors.white,
size: 32,
),
),
);
},
),
const SizedBox(width: 20),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
provider.empresaSeleccionada != null
? 'Sucursales de ${provider.empresaSeleccionada!.nombre}'
: 'Selecciona una empresa para ver sus sucursales',
style: TextStyle(
color: AppTheme.of(context).primaryText,
fontSize: 24,
fontWeight: FontWeight.bold,
// Título principal con gradiente
ShaderMask(
shaderCallback: (bounds) => LinearGradient(
colors: [Colors.white, Colors.white.withOpacity(0.8)],
).createShader(bounds),
child: Text(
provider.empresaSeleccionada != null
? 'Sucursales de ${provider.empresaSeleccionada!.nombre}'
: 'Gestión de Empresas y Sucursales',
style: const TextStyle(
color: Colors.white,
fontSize: 28,
fontWeight: FontWeight.bold,
letterSpacing: 0.5,
),
),
),
const SizedBox(height: 8),
if (provider.empresaSeleccionada != null)
const SizedBox(height: 12),
if (provider.empresaSeleccionada != null) ...[
Row(
children: [
Container(
padding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 6,
),
decoration: BoxDecoration(
color: AppTheme.of(context).primaryColor,
borderRadius: BorderRadius.circular(20),
),
child: Text(
'${provider.negocios.length} sucursales',
style: const TextStyle(
color: Colors.white,
fontSize: 14,
fontWeight: FontWeight.w600,
),
),
// Badge animado
TweenAnimationBuilder<double>(
duration: const Duration(milliseconds: 600),
tween: Tween(begin: 0.0, end: 1.0),
builder: (context, value, child) {
return Transform.scale(
scale: value,
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 8,
),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.9),
borderRadius: BorderRadius.circular(25),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
blurRadius: 8,
offset: const Offset(0, 2),
),
],
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.store,
color: AppTheme.of(context).primaryColor,
size: 18,
),
const SizedBox(width: 8),
Text(
'${provider.negocios.length} sucursales',
style: TextStyle(
color: AppTheme.of(context).primaryColor,
fontSize: 14,
fontWeight: FontWeight.bold,
),
),
],
),
),
);
},
),
const SizedBox(width: 12),
Text(
provider.empresaSeleccionada!.nombre,
style: TextStyle(
color: AppTheme.of(context).secondaryText,
fontSize: 16,
const SizedBox(width: 16),
Expanded(
child: Text(
provider.empresaSeleccionada!.rfc,
style: TextStyle(
color: Colors.white.withOpacity(0.9),
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
),
],
),
],
],
),
),
// Switch para cambiar vista
Column(
// Switch mejorado para cambiar vista
Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.1),
borderRadius: BorderRadius.circular(16),
border: Border.all(
color: Colors.white.withOpacity(0.2),
),
),
child: Column(
children: [
Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.table_chart,
color: Colors.white,
size: 20,
),
const SizedBox(width: 8),
Text(
'Vista',
style: TextStyle(
color: Colors.white,
fontSize: 14,
fontWeight: FontWeight.w600,
),
),
const SizedBox(width: 8),
Icon(
Icons.map,
color: Colors.white,
size: 20,
),
],
),
const SizedBox(height: 12),
Switch(
value: showMapView,
onChanged: (value) {
setState(() {
showMapView = value;
});
},
activeColor: Colors.white,
activeTrackColor: Colors.white.withOpacity(0.3),
inactiveThumbColor: Colors.white.withOpacity(0.7),
inactiveTrackColor: Colors.white.withOpacity(0.1),
),
],
),
),
],
),
);
}
Widget _buildMobileHeader(EmpresasNegociosProvider provider) {
return Container(
padding: const EdgeInsets.fromLTRB(20, 40, 20, 20),
decoration: BoxDecoration(
gradient: AppTheme.of(context).primaryGradient,
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(30),
bottomRight: Radius.circular(30),
),
boxShadow: [
BoxShadow(
color: AppTheme.of(context).primaryColor.withOpacity(0.3),
blurRadius: 15,
offset: const Offset(0, 5),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text(
'Vista de Mapa',
style: TextStyle(
color: AppTheme.of(context).primaryText,
fontSize: 14,
fontWeight: FontWeight.w500,
Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.2),
borderRadius: BorderRadius.circular(12),
),
child: Icon(
Icons.business,
color: Colors.white,
size: 24,
),
),
const SizedBox(height: 8),
const SizedBox(width: 16),
Expanded(
child: Text(
'NETHIVE',
style: const TextStyle(
color: Colors.white,
fontSize: 24,
fontWeight: FontWeight.bold,
letterSpacing: 1.2,
),
),
),
// Switch para modo vista
Switch(
value: showMapView,
onChanged: (value) {
@@ -148,10 +396,37 @@ class _EmpresaNegociosPageState extends State<EmpresaNegociosPage> {
showMapView = value;
});
},
activeColor: AppTheme.of(context).primaryColor,
activeColor: Colors.white,
),
],
),
if (provider.empresaSeleccionada != null) ...[
const SizedBox(height: 16),
Text(
provider.empresaSeleccionada!.nombre,
style: const TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 8),
Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.2),
borderRadius: BorderRadius.circular(20),
),
child: Text(
'${provider.negocios.length} sucursales',
style: const TextStyle(
color: Colors.white,
fontSize: 14,
fontWeight: FontWeight.w500,
),
),
),
],
],
),
);
@@ -159,74 +434,89 @@ class _EmpresaNegociosPageState extends State<EmpresaNegociosPage> {
Widget _buildTableView(EmpresasNegociosProvider provider) {
if (provider.empresaSeleccionada == null) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.business,
size: 80,
color: AppTheme.of(context).secondaryText,
),
const SizedBox(height: 16),
Text(
'Selecciona una empresa para ver sus sucursales',
style: TextStyle(
color: AppTheme.of(context).secondaryText,
fontSize: 18,
),
),
],
),
);
return _buildEmptyState();
}
return Container(
decoration: BoxDecoration(
color: AppTheme.of(context).secondaryBackground,
borderRadius: BorderRadius.circular(12),
borderRadius: BorderRadius.circular(20),
border: Border.all(
color: AppTheme.of(context).primaryColor.withOpacity(0.2),
width: 1,
),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
blurRadius: 4,
offset: const Offset(0, 2),
blurRadius: 15,
offset: const Offset(0, 5),
),
],
),
child: Column(
children: [
// Header de la tabla
// Header de la tabla mejorado
Container(
padding: const EdgeInsets.all(16),
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: AppTheme.of(context).primaryColor,
gradient: AppTheme.of(context).modernGradient,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(12),
topRight: Radius.circular(12),
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
),
),
child: Row(
children: [
Icon(
Icons.store,
color: Colors.white,
size: 24,
),
const SizedBox(width: 12),
Text(
'Sucursales',
style: const TextStyle(
Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.2),
borderRadius: BorderRadius.circular(8),
),
child: Icon(
Icons.store,
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.bold,
size: 20,
),
),
const Spacer(),
Text(
'Mostrando 1 a ${provider.negocios.length} de ${provider.negocios.length} sucursales',
style: const TextStyle(
color: Colors.white70,
fontSize: 14,
const SizedBox(width: 16),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Sucursales',
style: const TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold,
letterSpacing: 0.5,
),
),
Text(
'Gestión y control de ubicaciones',
style: TextStyle(
color: Colors.white.withOpacity(0.8),
fontSize: 14,
),
),
],
),
),
Container(
padding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.2),
borderRadius: BorderRadius.circular(20),
),
child: Text(
'${provider.negocios.length} registros',
style: const TextStyle(
color: Colors.white,
fontSize: 14,
fontWeight: FontWeight.w600,
),
),
),
],
@@ -242,44 +532,185 @@ class _EmpresaNegociosPageState extends State<EmpresaNegociosPage> {
);
}
Widget _buildEmptyState() {
return Center(
child: TweenAnimationBuilder<double>(
duration: const Duration(milliseconds: 1000),
tween: Tween(begin: 0.0, end: 1.0),
builder: (context, value, child) {
return Transform.scale(
scale: value,
child: Container(
padding: const EdgeInsets.all(40),
decoration: BoxDecoration(
gradient: AppTheme.of(context).primaryGradient,
borderRadius: BorderRadius.circular(20),
boxShadow: [
BoxShadow(
color: AppTheme.of(context).primaryColor.withOpacity(0.3),
blurRadius: 20,
offset: const Offset(0, 10),
),
],
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.business_center,
size: 80,
color: Colors.white,
),
const SizedBox(height: 20),
Text(
'Selecciona una empresa',
style: const TextStyle(
color: Colors.white,
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 12),
Text(
'Elige una empresa del panel lateral\npara ver y gestionar sus sucursales',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white.withOpacity(0.9),
fontSize: 16,
),
),
],
),
),
);
},
),
);
}
Widget _buildMapView() {
return Container(
decoration: BoxDecoration(
color: Colors.blue.withOpacity(0.3),
borderRadius: BorderRadius.circular(12),
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Colors.blue.withOpacity(0.1),
Colors.blue.withOpacity(0.3),
AppTheme.of(context).primaryColor.withOpacity(0.2),
],
),
borderRadius: BorderRadius.circular(20),
border: Border.all(
color: Colors.blue,
color: AppTheme.of(context).primaryColor,
width: 2,
),
boxShadow: [
BoxShadow(
color: AppTheme.of(context).primaryColor.withOpacity(0.2),
blurRadius: 20,
offset: const Offset(0, 10),
),
],
),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.map,
size: 80,
color: Colors.blue[700],
),
const SizedBox(height: 16),
Text(
'Vista de Mapa',
style: TextStyle(
color: Colors.blue[700],
fontSize: 24,
fontWeight: FontWeight.bold,
child: TweenAnimationBuilder<double>(
duration: const Duration(milliseconds: 1500),
tween: Tween(begin: 0.0, end: 1.0),
builder: (context, value, child) {
return Transform.scale(
scale: 0.8 + (0.2 * value),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
gradient: AppTheme.of(context).modernGradient,
borderRadius: BorderRadius.circular(20),
),
child: Icon(
Icons.map,
size: 80,
color: Colors.white,
),
),
const SizedBox(height: 24),
Text(
'Vista de Mapa',
style: TextStyle(
color: AppTheme.of(context).primaryColor,
fontSize: 28,
fontWeight: FontWeight.bold,
letterSpacing: 1,
),
),
const SizedBox(height: 12),
Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.9),
borderRadius: BorderRadius.circular(15),
),
child: Text(
'Próximamente se implementará el mapa interactivo\ncon las ubicaciones de todas las sucursales',
style: TextStyle(
color: AppTheme.of(context).primaryColor,
fontSize: 16,
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.center,
),
),
],
),
);
},
),
),
);
}
Widget _buildMobileFAB(BuildContext context) {
return Consumer<EmpresasNegociosProvider>(
builder: (context, provider, child) {
return FloatingActionButton.extended(
onPressed: () {
_showMobileEmpresaSelector(context, provider);
},
backgroundColor: AppTheme.of(context).primaryColor,
icon: const Icon(Icons.business, color: Colors.white),
label: Text(
provider.empresaSeleccionada != null
? provider.empresaSeleccionada!.nombre.length > 15
? '${provider.empresaSeleccionada!.nombre.substring(0, 15)}...'
: provider.empresaSeleccionada!.nombre
: 'Empresas',
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
const SizedBox(height: 8),
Text(
'Próximamente se implementará el mapa con las ubicaciones de las sucursales',
style: TextStyle(
color: Colors.blue[600],
fontSize: 16,
),
textAlign: TextAlign.center,
),
],
),
);
},
);
}
void _showMobileEmpresaSelector(
BuildContext context, EmpresasNegociosProvider provider) {
showModalBottomSheet(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (context) => DraggableScrollableSheet(
initialChildSize: 0.7,
maxChildSize: 0.95,
minChildSize: 0.3,
builder: (context, scrollController) => MobileEmpresaSelector(
provider: provider,
onEmpresaSelected: (empresaId) {
provider.setEmpresaSeleccionada(empresaId);
},
),
),
);