import 'package:flutter/material.dart'; import 'package:miapp_flutter/src/specific_widgets/menu.dart' ; import 'category/CategoryListWidget.dart'; void main() => runApp(const DrawerApp()); class DrawerApp extends StatelessWidget { const DrawerApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( theme: ThemeData(useMaterial3: true), home: const HomePage(), ); } } class HomePage extends StatefulWidget { const HomePage({super.key}); @override State createState() => _HomePageState(); } class _HomePageState extends State { String selectedPage = ''; void _handleNewCategory() { // Define la acción que debe ocurrir cuando se presiona el botón "Nueva categoria" setState(() { selectedPage = 'Nueva categoria'; }); ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text('Nueva categoria presionada')), ); } @override Widget build(BuildContext context) { return DefaultTabController( length: 2, // Número de pestañas child: Scaffold( appBar: AppBar( title: const Text('Home Page'), backgroundColor: Colors.blue, leading: Builder( builder: (BuildContext context) { return IconButton( icon: const Icon(Icons.menu), onPressed: () { Scaffold.of(context).openDrawer(); }, ); }, ), bottom: const TabBar( tabs: [ Tab(icon: Icon(Icons.home), text: 'Categoria'), Tab(icon: Icon(Icons.person_2_outlined), text: 'Perfil'), ], ), ), drawer: MenuWidget(), body: TabBarView( children: [ Column( children: [ Expanded( child: CategoryListWidget(), ), Padding( padding: const EdgeInsets.all(16.0), child: ElevatedButton( onPressed: _handleNewCategory, child: const Text('Nueva categoría'), ), ), ], ), Center(child: Text('Tab 2 Contenido')), ], ), ), ); } }