aboutsummaryrefslogtreecommitdiff
path: root/lib/pages/Home.dart
blob: 2930bf8c3fc74a2d39687751161dbc8043388af0 (plain) (blame)
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 'dart:async';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:device_apps/device_apps.dart';

import '../components/AppList.dart';
import '../components/FixedContainer.dart';
import '../data/config.dart';

class StatusInfoCard extends StatelessWidget {
  DateTime dateTime;

  StatusInfoCard({ this.dateTime }): super();

  final timeFormat = DateFormat('h:mm a'); // H fr 24 hrs
  final dateFormat = DateFormat('EEEE, d MMM');

  @override
  Widget build(BuildContext ctx) {
    ThemeData theme = Theme.of(ctx);

    return Container(
        height: 100,
        padding: EdgeInsets.symmetric(vertical: 8.0),
        child: Align(
            alignment: Alignment.topLeft,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.start,
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Expanded(child: Column(
                    mainAxisAlignment: MainAxisAlignment.start,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Text(timeFormat.format(dateTime),
                          key: Key('time'),
                          textAlign: TextAlign.left,
                          style: const TextStyle(
                              fontSize: 32.0,
                              fontWeight: FontWeight.bold,
                          ),
                      ),
                      Text(dateFormat.format(dateTime),
                          key: Key('date'),
                          textAlign: TextAlign.left,
                          style: const TextStyle(
                              fontSize: 16.0,
                              fontWeight: FontWeight.w300,
                          ),
                      ),
                    ]
                )),
                Container(
                    width: 40,
                    height: 30,
                    child: IconButton(
                        padding: const EdgeInsets.all(0.0),
                        visualDensity: const VisualDensity(vertical: 0.0, horizontal: 0.0),
                        icon: Icon(
                            Icons.brightness_4,
                            color: theme.primaryColor,
                            size: 16.0,
                            semanticLabel: 'Toggle dark mode',
                        ),
                        tooltip: 'Toggle dark mode',
                        enableFeedback: true,
                        onPressed: () { toggleTheme(); }
                    ),
                ),
              ],
            ),
        ),
    );
  }
}

class HomeView extends StatelessWidget {
  DateTime dateTime;
  List<Application> favoriteApps;

  HomeView({ this.dateTime, this.favoriteApps }): super();

  void noop(Application app) {}

  @override
  Widget build(BuildContext ctx) {
    return FixedContainer(
        padding: const EdgeInsets.symmetric(vertical: 36.0, horizontal: 16.0),
        child: Column(
            children: [
              StatusInfoCard(dateTime: dateTime),
              Expanded(child: Container(
                child: AppList(appList: favoriteApps, openApp: noop, openOptionsMenu: noop),
              )),
            ],
        )
    );
  }
}