Newer
Older
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'data_model.dart';
class EventStoreInstance extends EventStoreBase {
static final EventStoreInstance _instance = EventStoreInstance._internal();
return _instance;
}
store = [];
}
}
//Add some dummy events to eventstore
EventStoreInstance events = EventStoreInstance();
events.store.add(Event.fromJson({
'id': 8311,
'urn': 'station:neumayer_iii:awi_snow_sampler_1',
'label': 'SML_KO21_SC01',
'type': 'Deployment',
'description': 'Remi tool Tag1 1 Traverse',
'status': 'PENDING'
}));
events.store.add(Event.fromJson({
'id': 8311,
'urn': 'station:neumayer_iii:awi_snow_sampler_1',
'label': 'SML_KO21_SC01',
'type': 'Deployment',
'description': 'Remi tool Tag1 1 Traverse',
'status': 'PENDING'
}));
events.store.add(Event.fromJson({
'id': 8311,
'urn': 'station:neumayer_iii:awi_snow_sampler_1',
'label': 'SML_KO21_SC01',
'type': 'Deployment',
'description': 'Remi tool Tag1 1 Traverse',
'status': 'PENDING'
}));
events.store.add(Event.fromJson({
'id': 8311,
'urn': 'station:neumayer_iii:awi_snow_sampler_1',
'label': 'SML_KO21_SC01',
'type': 'Deployment',
'description': 'Remi tool Tag1 1 Traverse',
'status': 'PENDING'
}));
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
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(
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
appBar: AppBar(title: const Text("Add Event")),
body:
Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
TextFormField(
decoration: InputDecoration(
labelText: 'Label'
),
),
DropdownButtonFormField(
decoration: InputDecoration(
labelText: 'Event Type',
),
items: [
DropdownMenuItem(
child: Text('Calibration'),
value: 'Calibration',
),
DropdownMenuItem(
child: Text('Information'),
value: 'Information',
)
],
onChanged: (value) {
}
),
DropdownButtonFormField(
decoration: InputDecoration(
labelText: 'URN',
),
items: [
DropdownMenuItem(
child: Text('ADCP'),
value: 'ADCP',
),
DropdownMenuItem(
child: Text('EM712'),
value: 'EM712',
)
],
onChanged: (value) {
}
),
TextFormField(
decoration: InputDecoration(
labelText: 'Description'
),
),
TextFormField(
decoration: InputDecoration(
labelText: 'Latitude'
),
),
TextFormField(
decoration: InputDecoration(
labelText: 'Longitude'
),
),
TextFormField(
decoration: InputDecoration(
labelText: 'Elevation'
),
)
]),
bottomNavigationBar: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: const [
FloatingActionButton(
heroTag: null,
onPressed: null,
tooltip: 'Add Event locally',
child: Icon(Icons.add),
)
],
),
);
}
}
class ViewEvents extends StatelessWidget {
@override
Widget build(BuildContext context) {
// Get singleton to access locally stored events:
final EventStoreInstance events = EventStoreInstance();
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>[
for (var event in events.store)
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
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,
),
),
],
),
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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
),
),
);
}
}
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'),
),
],
),
);
}
}