Files
fcs/lib/pages/notification_list.dart

132 lines
4.8 KiB
Dart
Raw Normal View History

2020-06-02 14:56:38 +06:30
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';
2020-05-29 07:45:27 +06:30
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';
2020-08-30 21:26:37 +06:30
import '../fcs/common/theme.dart';
2020-05-29 16:14:17 +06:30
import '../widget/local_text.dart';
2020-05-29 07:45:27 +06:30
class NotificationList extends StatefulWidget {
@override
_NotificationListState createState() => _NotificationListState();
}
class _NotificationListState extends State<NotificationList> {
var timeFormatter = new DateFormat('KK:mm a');
2020-05-29 16:14:17 +06:30
var dateFormatter = new DateFormat('dd MMM yyyy');
2020-06-02 14:56:38 +06:30
final double dotSize = 25.0;
2020-05-29 07:45:27 +06:30
int _selectedIndex = 0;
bool _isLoading = false;
bool _isClicked = false;
@override
Widget build(BuildContext context) {
2020-06-02 14:56:38 +06:30
MessageModel messageModel = Provider.of<MessageModel>(context);
2020-05-29 07:45:27 +06:30
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
2020-05-31 15:00:11 +06:30
centerTitle: true,
leading: new IconButton(
2020-06-01 14:24:45 +06:30
icon: new Icon(
Icons.close,
),
2020-05-31 15:00:11 +06:30
onPressed: () => Navigator.of(context).pop(),
),
2020-05-29 07:45:27 +06:30
backgroundColor: primaryColor,
2020-05-29 16:14:17 +06:30
title: LocalText(
context,
2020-06-02 14:56:38 +06:30
'message.title',
2020-06-01 14:24:45 +06:30
fontSize: 20,
2020-05-29 16:14:17 +06:30
color: Colors.white,
),
2020-05-29 07:45:27 +06:30
),
body: new ListView.separated(
separatorBuilder: (context, index) => Divider(
color: Colors.black,
),
scrollDirection: Axis.vertical,
2020-06-02 14:56:38 +06:30
padding: EdgeInsets.only(top: 5),
2020-05-29 07:45:27 +06:30
shrinkWrap: true,
2020-06-02 14:56:38 +06:30
itemCount: messageModel.lastMessage.length,
2020-05-29 07:45:27 +06:30
itemBuilder: (BuildContext context, int index) {
2020-06-02 14:56:38 +06:30
Message msg = messageModel.lastMessage[index];
2020-05-29 07:45:27 +06:30
return Stack(
children: <Widget>[
InkWell(
2020-06-02 14:56:38 +06:30
onTap: () => _display(msg),
2020-05-29 07:45:27 +06:30
child: Row(
children: <Widget>[
Expanded(
child: new Padding(
2020-05-29 16:14:17 +06:30
padding: const EdgeInsets.symmetric(vertical: 10.0),
2020-05-29 07:45:27 +06:30
child: new Row(
children: <Widget>[
2020-06-01 14:24:45 +06:30
new Padding(
padding: new EdgeInsets.symmetric(
2020-06-02 14:56:38 +06:30
horizontal: 22.0 - dotSize / 2),
child: Icon(
Icons.account_circle,
color: primaryColor,
size: 60,
),
2020-06-01 14:24:45 +06:30
),
2020-05-29 07:45:27 +06:30
new Expanded(
child: new Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
new Text(
2020-06-02 14:56:38 +06:30
msg.receiverName,
2020-06-29 16:15:25 +06:30
style: new TextStyle(fontSize: 15.0),
2020-05-29 07:45:27 +06:30
),
],
),
),
],
),
),
),
2020-06-02 14:56:38 +06:30
Padding(
padding: const EdgeInsets.only(right: 18.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
2020-06-29 16:15:25 +06:30
child: Text(
timeFormatter.format(msg.date),
style: TextStyle(color: Colors.grey),
),
2020-06-02 14:56:38 +06:30
),
msg.fromToday()
? Container()
2020-06-30 16:27:56 +06:30
: Text(
dateFormatter.format(msg.date),
style: TextStyle(color: Colors.grey),
),
2020-06-02 14:56:38 +06:30
],
),
2020-05-29 07:45:27 +06:30
)
],
),
2020-06-01 14:24:45 +06:30
),
2020-05-29 07:45:27 +06:30
],
);
}),
),
);
}
2020-06-02 14:56:38 +06:30
_display(Message msg) {
2020-06-24 16:06:40 +06:30
Navigator.push(context, BottomUpPageRoute(MessageDetail(msg: msg)));
2020-06-02 14:56:38 +06:30
}
2020-05-29 07:45:27 +06:30
}