Newer
Older
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'data_model.dart';
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
void main() {
runApp(MaterialApp(
title: 'Mobile Event Log',
theme: ThemeData(
primarySwatch: Colors.blue,
),
initialRoute: '/',
routes: {
'/': (context) => Overview(),
'/second': (context) => AddEvent(),
'/third': (context) => ViewEvents(),
'/forth': (context) => Configuration(),
},
));
}
class Overview extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Mobile Event Log')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
ElevatedButton(
child: const Text('Add Event'),
onPressed: () {
Navigator.pushNamed(context, '/second');
},
),
ElevatedButton(
child: const Text('View Added Events'),
onPressed: () {
Navigator.pushNamed(context, '/third');
},
),
ElevatedButton(
child: const Text('Configuration'),
onPressed: () {
Navigator.pushNamed(context, '/forth');
},
),
],
)),
);
}
}
class AddEvent extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Add Event"),
),
body: Center(
child: ElevatedButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text('Back!'),
),
),
bottomNavigationBar: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: const [
FloatingActionButton(
heroTag: null,
onPressed: null,
tooltip: 'Add Event locally',
child: Icon(Icons.add),
)
],
),
);
}
}
class ViewEvents extends StatelessWidget {
List<Event> events = []
..add(Event(
id: 8311,
urn: 'station:neumayer_iii:awi_snow_sampler_1',
label: 'SML_KO21_SC01',
type: 'Deployment',
description: 'Remi tool Tag1 1 Traverse',
status: 'PENDING'))
..add(Event(
id: 8311,
urn: 'station:neumayer_iii:awi_snow_sampler_1',
label: 'SML_KO21_SC01',
type: 'Deployment',
description: 'Remi tool Tag1 1 Traverse',
status: 'PENDING'))
..add(Event(
id: 8311,
urn: 'station:neumayer_iii:awi_snow_sampler_1',
label: 'SML_KO21_SC01',
type: 'Deployment',
description: 'Remi tool Tag1 1 Traverse',
status: 'PENDING'));
//for (var i = 0; i<100; i++){
// events.add(Event(id: i, urn: 'station:neumayer_iii:awi_snow_sampler_1', label: 'SML_KO21_SC01', type: 'Deployment', description: 'Remi tool Tag1 1 Traverse', status: 'PENDING'));
//}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("View Added Events"),
),
body: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: DataTable(
columns: const <DataColumn>[
DataColumn(
label: Text(
'Id',
style: TextStyle(fontStyle: FontStyle.italic),
),
DataColumn(
label: Text(
'URN',
style: TextStyle(fontStyle: FontStyle.italic),
),
DataColumn(
label: Text(
'Label',
style: TextStyle(fontStyle: FontStyle.italic),
),
DataColumn(
label: Text(
'Type',
style: TextStyle(fontStyle: FontStyle.italic),
),
DataColumn(
label: Text(
'Description',
style: TextStyle(fontStyle: FontStyle.italic),
),
DataColumn(
label: Text(
'Status',
style: TextStyle(fontStyle: FontStyle.italic),
),
),
],
rows: <DataRow>[
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
for (var event in events)
DataRow(
cells: <DataCell>[
DataCell(Text(event.id.toString())),
DataCell(Text(event.urn)),
DataCell(
TextFormField(
initialValue: event.label,
onFieldSubmitted: (val) {
event.label = val; //Update Database
},
),
),
DataCell(Text(event.type)),
DataCell(
TextFormField(
initialValue: event.description,
onFieldSubmitted: (val) {
event.description = val; //Update Database
},
),
),
DataCell(
DropdownButtonFormField(
//value: Text('abe'),
items: <DropdownMenuItem>[
DropdownMenuItem(
child: Text('abs'),
value: Text('1'),
),
DropdownMenuItem(
child: Text('abc'),
value: Text('1'),
),
],
onChanged: null,
),
),
],
),
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
),
),
);
}
}
class Configuration extends StatefulWidget {
@override
State<Configuration> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<Configuration> {
int _counter = 0;
int _factor = 1;
String selectedValue = '1';
var available_items = [
'1',
'10',
'100',
];
late Future<String> eventTypes;
@override
void initState() {
super.initState();
}
void _incrementCounter() {
setState(() {
_counter = _counter + _factor;
});
}
void _decrementCounter() {
setState(() {
_counter = _counter - _factor;
});
}
void _resetCounter() {
setState(() {
_counter = 0;
});
}
void _getCollections() {
setState(() {});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Configuration'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline2,
),
DropdownButton(
value: selectedValue,
icon: const Icon(Icons.keyboard_arrow_down),
items: available_items.map((String available_items) {
return DropdownMenuItem(
value: available_items,
child: Text(available_items),
);
}).toList(),
onChanged: (String? newValue) {
setState(() {
selectedValue = newValue!;
_factor = int.parse(selectedValue);
});
},
),
Text('blabla'),
],
),
),
bottomNavigationBar: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
FloatingActionButton(
heroTag: null,
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
FloatingActionButton(
heroTag: null,
onPressed: _decrementCounter,
tooltip: 'Decrement',
child: const Text('-'),
),
FloatingActionButton(
heroTag: null,
onPressed: _resetCounter,
tooltip: 'Reset to 0',
child: const Icon(Icons.delete),
),
FloatingActionButton(
heroTag: null,
onPressed: _getCollections,
tooltip: 'Reset to 0',
child: const Text('Update'),
),
],
),
);
}
}