import 'package:provider/provider.dart'; import 'package:fcs/model/main_model.dart'; import 'package:fcs/model/report_model.dart'; import 'package:fcs/pages/report_user_list.dart'; import 'package:fcs/reports/fixed_header.dart'; import 'package:fcs/vo/popup_menu.dart'; import 'package:fcs/vo/report.dart'; import 'package:fcs/widget/localization/app_translations.dart'; import 'package:fcs/widget/popupmenu.dart'; import 'package:flutter/material.dart'; import 'package:fcs/widget/progress.dart'; import '../fcs/common/helpers/theme.dart'; import 'reports_data_table.dart'; class ReportList extends StatefulWidget { @override _ReportListState createState() => _ReportListState(); } class _ReportListState extends State { bool _isLoading = false; Report _report = new Report(); @override void initState() { super.initState(); } @override void dispose() { super.dispose(); } @override Widget build(BuildContext context) { ReportModel reportModel = Provider.of(context); MainModel mainModel = Provider.of(context); bool isOwnerAndAbove = mainModel.user != null && mainModel.user.isOwnerAndAbove(); bool hasAdmin = mainModel.user != null && mainModel.user.hasAdmin(); bool hasOwner = mainModel.user != null && mainModel.user.isOwner(); return LocalProgress( inAsyncCall: _isLoading, child: Scaffold( appBar: AppBar( backgroundColor: primaryColor, title: Text(AppTranslations.of(context).text("report.title")), // actions: [ // IconButton( // onPressed: () { // reportModel.addreport(); // }, // iconSize: 30, // icon: Icon(Icons.filter_list), // ), // ], ), floatingActionButton: mainModel.isSysAdmin() ? FloatingActionButton( backgroundColor: primaryColor, onPressed: () async {}, child: Icon( Icons.add, color: Colors.white, ), ) : null, body: new ListView.builder( scrollDirection: Axis.vertical, padding: EdgeInsets.only(top: 15), shrinkWrap: true, itemCount: reportModel.reportList.length, itemBuilder: (BuildContext context, int index) { return Container( padding: EdgeInsets.only(left: 10, right: 10), child: Card( elevation: 10, color: Colors.white, child: Row(children: [ new Expanded( child: InkWell( onTap: () { Navigator.of(context).push(MaterialPageRoute( builder: (_) => ReportsDataTable( report: reportModel.reportList[index], ))); }, child: new Padding( padding: const EdgeInsets.symmetric(vertical: 10.0), child: new Row(children: [ Padding( padding: const EdgeInsets.all(8.0), child: Image.asset( "assets/report.png", width: 40, height: 40, // color: primaryColor, ), ), Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( reportModel.reportList[index].display == null ? "" : reportModel.reportList[index].display, style: new TextStyle( fontSize: 17.0, color: Colors.black), ), ], ), ])), )), isOwnerAndAbove || hasAdmin ? hasOwner || hasAdmin ? PopupMenuButton( elevation: 3.2, tooltip: 'This is tooltip', onSelected: _select, itemBuilder: (BuildContext context) { this._report = reportModel.reportList[index]; return reportUserPopup .map((PopupMenu choice) { return PopupMenuItem( value: choice, child: Text(choice.status), ); }).toList(); }) : PopupMenuButton( elevation: 3.2, tooltip: 'This is tooltip', onSelected: _select, itemBuilder: (BuildContext context) { this._report = reportModel.reportList[index]; return reportpopup.map((PopupMenu choice) { return PopupMenuItem( value: choice, child: Text(choice.status), ); }).toList(); }) : Container() ]), ), ); }), ), ); } void _select(PopupMenu popupMenu) { if (popupMenu.index == 3) { Navigator.push( context, MaterialPageRoute( builder: (context) => ReportUserList(report: this._report)), ); } } }