summaryrefslogtreecommitdiffstats
path: root/lib/page_home.dart
blob: 1fbda1f56fadc61023dc07f3a4353df30f12dca7 (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
import 'package:flutter/material.dart';

class HomePage extends StatelessWidget {
  final Function(int index) onSetNavigationIndex;

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

  @override
  Widget build(BuildContext context) {
    final double spacing = MediaQuery.of(context).size.width / 32;
    final double runSpacing = spacing / 2;
    return Container(
        color: Colors.lightBlue.shade50,
        constraints: BoxConstraints.expand(),
        alignment: Alignment.center,
        child: Wrap(
      spacing: spacing,
      runSpacing: runSpacing,
      children: <Widget>[
        createItem(context, Icons.drive_eta, 1),
        createItem(context, Icons.thermostat, 2),
        createItem(context, Icons.music_note, 3)
      ],
    ));
  }

  Widget createItem(BuildContext context, IconData icon, int tabPosition) {
    final double size = MediaQuery.of(context).size.width / 6;
    final double padding = size / 4;
    final double border = padding / 4;
    return Padding(
      padding: const EdgeInsets.symmetric(vertical: 8.0),
      child: OutlinedButton(
        style: OutlinedButton.styleFrom(
          shape: CircleBorder(),
          padding: EdgeInsets.all(padding),
          primary: Colors.lightBlue.shade400,
            side: BorderSide(width: border, color: Colors.lightBlue.shade400)
        ),
        onPressed: () {
          onSetNavigationIndex(tabPosition);
        },
        child: Icon(
          icon,
          color: Colors.lightBlue.shade800,
          size: size / 2,
        ),
      ),
    );
  }
}