import 'package:flutter/material.dart'; import 'package:miapp_flutter/src/specific_widgets/menu.dart'; import 'NewCategoryPage.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() { // Navega a la página de nueva categoría Navigator.push( context, MaterialPageRoute(builder: (context) => const NewCategoryPage()), ); } @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'), style: ElevatedButton.styleFrom( foregroundColor: Colors.white, backgroundColor: Colors.blue, ), ), ), ], ), Center(child: Text('Tab 2 Contenido')), ], ), ), ); } }