import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; import 'package:fcs/model/notification_model.dart'; import 'package:fcs/vo/notification.dart' as Noti; import 'package:fcs/widget/localization/app_translations.dart'; import 'package:fcs/widget/progress.dart'; import '../theme/theme.dart'; import '../widget/local_text.dart'; class NotificationList extends StatefulWidget { @override _NotificationListState createState() => _NotificationListState(); } class _NotificationListState extends State { var timeFormatter = new DateFormat('KK:mm a'); var dateFormatter = new DateFormat('dd MMM yyyy'); final double dotSize = 15.0; int _selectedIndex = 0; bool _isLoading = false; bool _isClicked = false; @override Widget build(BuildContext context) { NotificationModel notificationModel = Provider.of(context); return LocalProgress( inAsyncCall: _isLoading, child: Scaffold( appBar: AppBar( centerTitle: true, leading: new IconButton( icon: new Icon(Icons.close, ), onPressed: () => Navigator.of(context).pop(), ), backgroundColor: primaryColor, title: LocalText( context, 'noti.title', fontSize: 18, color: Colors.white, ), ), 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: notificationModel.notifications.length, itemBuilder: (BuildContext context, int index) { Noti.Notification noti = notificationModel.notifications[index]; return Stack( children: [ InkWell( onTap: () => _display(noti), child: Row( children: [ Expanded( child: new Padding( padding: const EdgeInsets.symmetric(vertical: 10.0), child: new Row( children: [ // new Padding( // padding: new EdgeInsets.symmetric( // horizontal: 32.0 - dotSize / 2), // child: Icon(Icons.message), // ), new Padding(padding: EdgeInsets.only(left: 10)), new Expanded( child: new Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ new Text( noti.getDesc, style: new TextStyle( fontSize: 15.0, color: primaryColor), ), noti.marketPlace == null ? Container() : Padding( padding: const EdgeInsets.only(top:8.0), child: new Text( noti.marketPlace, style: new TextStyle( fontSize: 15.0, color: primaryColor), ), ), Padding( padding: const EdgeInsets.only(top:8.0), child: new Text( noti.status == null ? "" : noti.status, style: new TextStyle( fontSize: 16.0, color: Colors.grey), ), ), ], ), ), ], ), ), ), Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Padding( padding: const EdgeInsets.all(8.0), child: Text(timeFormatter.format(noti.time)), ), noti.fromToday() ? Container() : Text(dateFormatter.format(noti.time)), ], ) ], ), ), ], ); }), ), ); } _display(Noti.Notification noti) {} }