aboutsummaryrefslogtreecommitdiffstats
path: root/lib/page_home.dart
blob: b985570390d8c9e87b9424d04e08eda3329bdca3 (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
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
import 'package:flutter/material.dart';
import 'package:flutter_homescreen/layout_size_helper.dart';

// The Home page.
class HomePage extends StatelessWidget {
  final Function(int index) onSetNavigationIndex;

  const HomePage({Key? key, required this.onSetNavigationIndex})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    var sizeHelper = LayoutSizeHelper(context);
    return Container(
        decoration: BoxDecoration(
            gradient: LinearGradient(
                begin: Alignment.topRight,
                end: Alignment.bottomLeft,
                colors: [Colors.blueGrey.shade800, Colors.grey.shade900])),
        constraints: BoxConstraints.expand(),
        alignment: Alignment.center,
        child: Wrap(
          spacing: sizeHelper.largePadding,
          runSpacing: sizeHelper.largePadding,
          children: <Widget>[
            _HomePageEntry(
              label: "DASHBOARD",
              icon: Icons.drive_eta,
              onPressed: () {
                onSetNavigationIndex(1);
              },
            ),
            _HomePageEntry(
              label: "HVAC",
              icon: Icons.thermostat,
              onPressed: () {
                onSetNavigationIndex(2);
              },
            ),
            _HomePageEntry(
              label: "MEDIA",
              icon: Icons.music_note,
              onPressed: () {
                onSetNavigationIndex(3);
              },
            ),
          ],
        ));
  }
}

// Each one of the items on the Home page.
class _HomePageEntry extends StatelessWidget {
  final String label;
  final IconData icon;
  final Null Function() onPressed;

  const _HomePageEntry(
      {Key? key,
      required this.label,
      required this.icon,
      required this.onPressed})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    var sizeHelper = LayoutSizeHelper(context);
    return Padding(
        padding: const EdgeInsets.symmetric(vertical: 8.0),
        child: Column(
          children: [
            OutlinedButton(
              style: ElevatedButton.styleFrom(
                shape: CircleBorder(),
                padding: EdgeInsets.all(sizeHelper.largePadding),
                side: BorderSide(
                    width: sizeHelper.defaultBorder,
                    color: Colors.lightBlue.shade100),
              ),
              onPressed: onPressed,
              child: Icon(
                icon,
                color: Colors.lightBlue.shade50,
                size: sizeHelper.largeIconSize,
              ),
            ),
            Padding(
              padding: EdgeInsets.all(sizeHelper.defaultPadding),
              child: Text(
                label,
                style: DefaultTextStyle.of(context).style.copyWith(
                      fontSize: sizeHelper.baseFontSize,
                      color: Colors.lightBlue.shade100,
                    ),
              ),
            ),
          ],
        ));
  }
}