home_page.dart 3.43 KB
Newer Older
nayeli92433 committed
1 2
import 'package:flutter/material.dart';

nayeli92433 committed
3 4 5 6
void main() => runApp(const DrawerApp());

class DrawerApp extends StatelessWidget {
  const DrawerApp({super.key});
nayeli92433 committed
7 8 9

  @override
  Widget build(BuildContext context) {
nayeli92433 committed
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
    return MaterialApp(
      theme: ThemeData(useMaterial3: true),
      home: const HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  String selectedPage = '';

nayeli92433 committed
27 28 29 30 31 32 33 34 35 36
  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')),
    );
  }

nayeli92433 committed
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
  @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: Drawer(
          child: ListView(
            padding: EdgeInsets.zero,
            children: <Widget>[
              const DrawerHeader(
                decoration: BoxDecoration(
                  color: Colors.blue,
                ),
                child: Text(
                  'Menu App',
                  style: TextStyle(
                    color: Colors.white,
                    fontSize: 24,
                  ),
                ),
              ),
              ListTile(
                leading: const Icon(Icons.message),
                title: const Text('Mensajes'),
                onTap: () {
                  setState(() {
                    selectedPage = 'Messages';
                  });
                  Navigator.pop(context); // Close the drawer
                },
              ),
              ListTile(
                leading: const Icon(Icons.settings),
                title: const Text('Configuraciones'),
                onTap: () {
                  setState(() {
                    selectedPage = 'Settings';
                  });
                  Navigator.pop(context); // Close the drawer
                },
              ),
            ],
          ),
        ),
        body: TabBarView(
          children: [
nayeli92433 committed
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
            Column(
              mainAxisAlignment: MainAxisAlignment.start,
              children: [
                Expanded(
                  child: Center(

                  ),
                ),
                Padding(
                  padding: const EdgeInsets.all(50.0),
                  child: ElevatedButton(
                    onPressed: _handleNewCategory,
                    child: const Text('Nueva categoria'),
                  ),
                ),
              ],
            ),
nayeli92433 committed
120 121
            Center(child: Text('Tab 2 Contenido')),
          ],
nayeli92433 committed
122 123 124 125 126
        ),
      ),
    );
  }
}