import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; import 'package:fcs/model/log_model.dart'; import 'package:fcs/widget/local_text.dart'; import 'package:fcs/widget/localization/app_translations.dart'; import 'package:fcs/widget/progress.dart'; import '../fcs/common/theme.dart'; class LogList extends StatefulWidget { @override _LogListState createState() => _LogListState(); } class _LogListState extends State { final double dotSize = 15.0; var dateFormatter = new DateFormat('dd MMM yyyy - hh:mm:ss a'); bool _isLoading = false; @override Widget build(BuildContext context) { LogModel logModel = Provider.of(context); return LocalProgress( inAsyncCall: _isLoading, child: Scaffold( appBar: AppBar( backgroundColor: primaryColor, title: LocalText( context, 'log.title', color: Colors.white, fontSize: 20, ), ), body: new ListView.separated( separatorBuilder: (context, index) => Divider( color: Colors.black, ), scrollDirection: Axis.vertical, padding: EdgeInsets.only(left: 15, right: 15, top: 15), shrinkWrap: true, itemCount: logModel.logs.length, itemBuilder: (BuildContext context, int index) { return Stack( children: [ InkWell( onTap: () {}, child: Row( children: [ Expanded( child: new Padding( padding: const EdgeInsets.symmetric(vertical: 0.0), child: new Row( children: [ new Padding( padding: new EdgeInsets.symmetric( horizontal: 32.0 - dotSize / 2), child: Icon( Icons.message, color: primaryColor, ), ), new Expanded( child: new Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ new Text( logModel.logs[index].deviceName, style: new TextStyle( fontSize: 15.0, color: Colors.black), ), new Text( "Last login at : ${logModel.logs[index].activeTime == null ? "" : dateFormatter.format(logModel.logs[index].activeTime)}", style: new TextStyle( fontSize: 13.0, color: Colors.grey), ), ], ), ), ], ), ), ), ], ), ), ], ); }), ), ); } }