Skip to content
Snippets Groups Projects
viewevents.dart 3.31 KiB
Newer Older
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(
                  '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(
                      DropdownButtonFormField(
                        //value: Text('abe'),
                        items: <DropdownMenuItem>[
                          DropdownMenuItem(
                            child: Text('abs'),
                            value: Text('1'),
                          ),
                          DropdownMenuItem(
                            child: Text('abc'),
                            value: Text('1'),
                          ),
                        ],
                        onChanged: null,
                      ),
                    ),
                  ],
                ),
            ],
          ),
        ),
      ),
    );
  }
}