home_page.dart 2.3 KB
Newer Older
nayeli92433 committed
1
import 'package:flutter/material.dart';
nayeli92433 committed
2 3 4
import 'package:miapp_flutter/src/specific_widgets/menu.dart' ;

import 'category/CategoryListWidget.dart';
nayeli92433 committed
5

nayeli92433 committed
6 7 8 9
void main() => runApp(const DrawerApp());

class DrawerApp extends StatelessWidget {
  const DrawerApp({super.key});
nayeli92433 committed
10 11 12

  @override
  Widget build(BuildContext context) {
nayeli92433 committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
    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
30 31 32 33 34 35 36 37 38 39
  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
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
  @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'),
            ],
          ),
        ),
nayeli92433 committed
65
        drawer: MenuWidget(),
nayeli92433 committed
66 67
        body: TabBarView(
          children: [
nayeli92433 committed
68
               Column(
nayeli92433 committed
69 70
              children: [
                Expanded(
nayeli92433 committed
71
                  child: CategoryListWidget(),
nayeli92433 committed
72 73
                ),
                Padding(
nayeli92433 committed
74
                  padding: const EdgeInsets.all(16.0),
nayeli92433 committed
75 76
                  child: ElevatedButton(
                    onPressed: _handleNewCategory,
nayeli92433 committed
77
                    child: const Text('Nueva categoría'),
nayeli92433 committed
78 79 80 81
                  ),
                ),
              ],
            ),
nayeli92433 committed
82 83
            Center(child: Text('Tab 2 Contenido')),
          ],
nayeli92433 committed
84 85 86 87 88
        ),
      ),
    );
  }
}