summaryrefslogtreecommitdiff
path: root/lib/screens/dashboard_screen.dart
blob: 3f4ae21a22e231ebe42b26e850845ad81166891e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
import 'package:flutter/material.dart';
import 'package:pmsna1/providers/theme_provider.dart';
import 'package:pmsna1/settings/themes.dart';
import 'package:pmsna1/widgets/post_list.dart';
import 'package:provider/provider.dart';

class DashboardScreen extends StatelessWidget {
  const DashboardScreen({super.key});
  @override
  Widget build(BuildContext context) {
    final ThemeProvider themeProvider = context.watch<ThemeProvider>();
    return Scaffold(
      body: CustomScrollView(
        slivers: [
          SliverAppBar.large(
            title: const Text('Inicio'),
          ),
          const SliverFillRemaining(
            child: PostList(),
          ),
        ],
      ),
      drawer: Drawer(
        child: ListView(
          children: [
            UserAccountsDrawerHeader(
              currentAccountPicture: const CircleAvatar(
                backgroundImage:
                    NetworkImage('https://avalos.me/images/pro.jpg'),
              ),
              accountName: const Text('Iván Ávalos'),
              accountEmail: const Text('avalos@disroot.org'),
            ),
            ListTile(
              leading: const Icon(Icons.home),
              title: const Text('Inicio'),
              onTap: () {},
            ),
            const Divider(),
            ListTile(
              title: const Text('Tema'),
              trailing: SegmentedButton<ThemeData?>(
                segments: [
                  const ButtonSegment<ThemeData?>(
                    value: null,
                    icon: Icon(Icons.brightness_auto),
                  ),
                  ButtonSegment<ThemeData?>(
                    value: ThemeSettings.lightTheme,
                    icon: const Icon(Icons.light_mode),
                  ),
                  ButtonSegment<ThemeData?>(
                      value: ThemeSettings.darkTheme,
                      icon: const Icon(Icons.dark_mode)),
                ],
                selected: <ThemeData?>{themeProvider.theme},
                onSelectionChanged: ((Set<ThemeData?> newSelection) {
                  themeProvider.theme = newSelection.first;
                }),
              ),
            )
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton.extended(
        label: const Text('Nuevo'),
        icon: const Icon(Icons.create),
        onPressed: () {
          Navigator.of(context).pushNamed('/new');
        },
      ),
    );
  }
}