import 'package:fcs/model_fcs/message_model.dart'; import 'package:fcs/pages/message_detail.dart'; import 'package:fcs/vo/message.dart'; import 'package:fcs/widget/bottom_up_page_route.dart'; 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/progress.dart'; import '../fcs/common/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 = 25.0; int _selectedIndex = 0; bool _isLoading = false; bool _isClicked = false; @override Widget build(BuildContext context) { MessageModel messageModel = 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, 'message.title', fontSize: 20, color: Colors.white, ), ), body: new ListView.separated( separatorBuilder: (context, index) => Divider( color: Colors.black, ), scrollDirection: Axis.vertical, padding: EdgeInsets.only(top: 5), shrinkWrap: true, itemCount: messageModel.lastMessage.length, itemBuilder: (BuildContext context, int index) { Message msg = messageModel.lastMessage[index]; return Stack( children: [ InkWell( onTap: () => _display(msg), 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: 22.0 - dotSize / 2), child: Icon( Icons.account_circle, color: primaryColor, size: 60, ), ), new Expanded( child: new Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ new Text( msg.receiverName, style: new TextStyle(fontSize: 15.0), ), ], ), ), ], ), ), ), Padding( padding: const EdgeInsets.only(right: 18.0), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Padding( padding: const EdgeInsets.all(8.0), child: Text( timeFormatter.format(msg.date), style: TextStyle(color: Colors.grey), ), ), msg.fromToday() ? Container() : Text( dateFormatter.format(msg.date), style: TextStyle(color: Colors.grey), ), ], ), ) ], ), ), ], ); }), ), ); } _display(Message msg) { Navigator.push(context, BottomUpPageRoute(MessageDetail(msg: msg))); } }