add message

This commit is contained in:
2020-06-02 14:56:38 +06:30
parent abb34ce064
commit 5bc34b3408
5 changed files with 296 additions and 47 deletions

View File

@@ -1,3 +1,7 @@
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';
@@ -16,15 +20,14 @@ class NotificationList extends StatefulWidget {
class _NotificationListState extends State<NotificationList> {
var timeFormatter = new DateFormat('KK:mm a');
var dateFormatter = new DateFormat('dd MMM yyyy');
final double dotSize = 15.0;
final double dotSize = 25.0;
int _selectedIndex = 0;
bool _isLoading = false;
bool _isClicked = false;
@override
Widget build(BuildContext context) {
NotificationModel notificationModel =
Provider.of<NotificationModel>(context);
MessageModel messageModel = Provider.of<MessageModel>(context);
return LocalProgress(
inAsyncCall: _isLoading,
@@ -40,7 +43,7 @@ class _NotificationListState extends State<NotificationList> {
backgroundColor: primaryColor,
title: LocalText(
context,
'noti.list.title',
'message.title',
fontSize: 20,
color: Colors.white,
),
@@ -50,15 +53,15 @@ class _NotificationListState extends State<NotificationList> {
color: Colors.black,
),
scrollDirection: Axis.vertical,
padding: EdgeInsets.only(left: 15, right: 15, top: 15),
padding: EdgeInsets.only(top: 5),
shrinkWrap: true,
itemCount: notificationModel.notifications.length,
itemCount: messageModel.lastMessage.length,
itemBuilder: (BuildContext context, int index) {
Noti.Notification noti = notificationModel.notifications[index];
Message msg = messageModel.lastMessage[index];
return Stack(
children: <Widget>[
InkWell(
onTap: () => _display(noti),
onTap: () => _display(msg),
child: Row(
children: <Widget>[
Expanded(
@@ -68,8 +71,12 @@ class _NotificationListState extends State<NotificationList> {
children: <Widget>[
new Padding(
padding: new EdgeInsets.symmetric(
horizontal: 32.0 - dotSize / 2),
child: Icon(Icons.message,color: primaryColor,),
horizontal: 22.0 - dotSize / 2),
child: Icon(
Icons.account_circle,
color: primaryColor,
size: 60,
),
),
new Expanded(
child: new Column(
@@ -77,35 +84,11 @@ class _NotificationListState extends State<NotificationList> {
CrossAxisAlignment.start,
children: <Widget>[
new Text(
noti.getDesc,
msg.receiverName,
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: 15.0,
color: Colors.grey),
),
),
],
),
),
@@ -113,17 +96,20 @@ class _NotificationListState extends State<NotificationList> {
),
),
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(timeFormatter.format(noti.time)),
),
noti.fromToday()
? Container()
: Text(dateFormatter.format(noti.time)),
],
Padding(
padding: const EdgeInsets.only(right: 18.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(timeFormatter.format(msg.date)),
),
msg.fromToday()
? Container()
: Text(dateFormatter.format(msg.date)),
],
),
)
],
),
@@ -135,5 +121,8 @@ class _NotificationListState extends State<NotificationList> {
);
}
_display(Noti.Notification noti) {}
_display(Message msg) {
Navigator.push(context, BottomUpPageRoute(MessageDetail(msg:msg))
);
}
}