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
101
102
103
104
105
106
107
108
109
110
111
|
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 {
Stream<DateTime> time$;
DateTime defaultTime;
StatusInfoCard(this.time$, { this.defaultTime }): 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 StreamBuilder<DateTime>(
stream: time$,
initialData: defaultTime,
builder: (BuildContext context, AsyncSnapshot<DateTime> snapshot) {
Widget child = Text('Loading...', key: Key('loading'));
if (snapshot.hasData) {
child = Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(timeFormat.format(snapshot.data),
key: Key('time'),
textAlign: TextAlign.left,
style: const TextStyle(
fontSize: 32.0,
fontWeight: FontWeight.bold,
),
),
Text(dateFormat.format(snapshot.data),
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(); }
),
),
],
);
}
return Container(
height: 100,
padding: EdgeInsets.symmetric(vertical: 8.0),
child: Align(alignment: Alignment.topLeft, child: child),
);
},
);
}
}
class HomeView extends StatelessWidget {
Stream<DateTime> time$;
DateTime defaultTime;
List<Application> favoriteApps;
HomeView({ this.time$, this.defaultTime, 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(time$, defaultTime: defaultTime),
Expanded(child: Container(
child: AppList(appList: favoriteApps, openApp: noop, openOptionsMenu: noop),
)),
],
)
);
}
}
|