/
drawer.dart
113 lines (103 loc) · 4.02 KB
/
drawer.dart
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
112
113
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:pocket_statistics/widgets/Grim.dart';
import 'package:pocket_statistics/widgets/Partial_nSquare_and_wSquare.dart';
import 'package:pocket_statistics/widgets/correlated_samples.dart';
import 'package:pocket_statistics/widgets/ds_from_t_for_independent_samples.dart';
import 'package:pocket_statistics/widgets/ds_from_t_for_independent_samples_with_group_ns.dart';
import 'package:pocket_statistics/widgets/dz_from_t_correlated_samples.dart';
import 'package:pocket_statistics/widgets/independent_samples.dart';
Map<String, Function> pages = {
CorrelatedSamplesTitle: () => CorrelatedSamples(),
DsFromTForIndependentSamplesTitle: () => DsFromTForIndependentSamples(),
DsFromTForIndependentSamplesWithNsTitle: () =>
DsFromTForIndependentSamplesWithNs(),
DsFromTCorrelatedSamplesTitle: () => DsFromTCorrelatedSamples(),
IndependentSamplesTitle: () => IndependentSamples(),
PartialNSquareAndWSquareTitle: () => PartialNSquareAndWSquare(),
GrimTitle: () => Grim(),
};
class StatsDrawer extends StatefulWidget {
@required
Function selectedCallback;
StatsDrawer({this.selectedCallback});
@override
StatsDrawerState createState() {
return new StatsDrawerState();
}
}
class StatsDrawerState extends State<StatsDrawer> {
TextEditingController searchController = TextEditingController();
@override
Widget build(BuildContext ctxt) {
List<MapEntry<String, Function>> pagesList = pages.entries.toList();
String searchFor = searchController.text.toLowerCase();
if (searchFor.length > 0) {
pagesList = pagesList.where((MapEntry<String, Function> pe) {
return pe.key.toLowerCase().contains(searchFor);
}).toList();
}
return new Drawer(child:
new ListView.builder(itemBuilder: (BuildContext context, int index) {
if (index == 0)
return DrawerHeader(
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Align(
alignment: Alignment.centerLeft,
child: Row(
children: <Widget>[
Text("POCKET STATISTICS"),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: InkWell(
onTap: () {
showAboutDialog(
context: context,
applicationLegalese:
'github.com/andytwoods/pocket_statistics\n\nGNU General Public License v3.0');
},
child: Icon(
Icons.info,
color: Colors.black45,
),
),
)
],
)),
Container(
decoration: new BoxDecoration(
borderRadius: new BorderRadius.all(Radius.circular(10.0))),
child: TextField(
controller: searchController,
onChanged: (_) => setState(() {}),
//pokes for a regeneration
decoration: InputDecoration(
contentPadding: const EdgeInsets.all(1.0),
border: InputBorder.none,
icon: Icon(Icons.search),
labelText: 'search...',
),
),
)
],
),
decoration: new BoxDecoration(color: Colors.lightGreenAccent),
);
index -= 1;
if (index < pagesList.length) {
MapEntry<String, Function> m = pagesList[index];
return new ListTile(
title: new Text(m.key),
onTap: () {
widget.selectedCallback(m.value());
Navigator.of(context).pop();
},
);
}
return null;
}));
}
}