You need to sign in or sign up before continuing.
home_page.dart 2.37 KB
Newer Older
nayeli92433 committed
1
import 'package:flutter/material.dart';
nayeli92433 committed
2 3
import 'package:miapp_flutter/src/specific_widgets/menu.dart';
import 'NewCategoryPage.dart';
nayeli92433 committed
4
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
  void _handleNewCategory() {
nayeli92433 committed
31 32 33 34
    // Navega a la página de nueva categoría
    Navigator.push(
      context,
      MaterialPageRoute(builder: (context) => const NewCategoryPage()),
nayeli92433 committed
35 36 37
    );
  }

nayeli92433 committed
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
  @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
63
        drawer: MenuWidget(),
nayeli92433 committed
64 65
        body: TabBarView(
          children: [
nayeli92433 committed
66
            Column(
nayeli92433 committed
67 68
              children: [
                Expanded(
nayeli92433 committed
69
                  child: CategoryListWidget(),
nayeli92433 committed
70 71
                ),
                Padding(
nayeli92433 committed
72
                  padding: const EdgeInsets.all(16.0),
nayeli92433 committed
73 74
                  child: ElevatedButton(
                    onPressed: _handleNewCategory,
nayeli92433 committed
75
                    child: const Text('Nueva categoría'),
nayeli92433 committed
76 77 78
                    style: ElevatedButton.styleFrom(
                      foregroundColor: Colors.white, backgroundColor: Colors.blue,
                    ),
nayeli92433 committed
79 80 81 82
                  ),
                ),
              ],
            ),
nayeli92433 committed
83 84
            Center(child: Text('Tab 2 Contenido')),
          ],
nayeli92433 committed
85 86 87 88 89
        ),
      ),
    );
  }
}