Newer
Older
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
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'datamodel.dart';
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(
'Latitude',
style: TextStyle(fontStyle: FontStyle.italic),
),
),
DataColumn(
label: Text(
'Longitude',
style: TextStyle(fontStyle: FontStyle.italic),
),
),
DataColumn(
label: Text(
'Elevation',
style: TextStyle(fontStyle: FontStyle.italic),
),
),
DataColumn(
label: Text(
'Status',
style: TextStyle(fontStyle: FontStyle.italic),
),
),
],
rows: <DataRow>[
for (var event in events.store)
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(
101
102
103
104
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
TextFormField(
readOnly: true,
initialValue: event.latitude,
onFieldSubmitted: (val) {
event.latitude = val; //Update Database
},
),
),
DataCell(
TextFormField(
readOnly: true,
initialValue: event.longitude,
onFieldSubmitted: (val) {
event.longitude = val; //Update Database
},
),
),
DataCell(
TextFormField(
readOnly: true,
initialValue: event.elevation,
onFieldSubmitted: (val) {
event.elevation = val; //Update Database
},
),
),
DataCell(
TextFormField(
readOnly: true,
initialValue: event.status,
onFieldSubmitted: (val) {
event.status = val; //Update Database
},
),
),
],
),
],
),
),
),
);
}
}
//TODO: allow editing fields here. Check validation of input value!