Merge remote-tracking branch 'upstream/master'

This commit is contained in:
PhyoThandar
2020-06-02 14:59:05 +06:30
5 changed files with 297 additions and 48 deletions

View File

@@ -0,0 +1,140 @@
import 'package:fcs/model_fcs/message_model.dart';
import 'package:fcs/theme/theme.dart';
import 'package:fcs/vo/message.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
class Bubble extends StatelessWidget {
Bubble({this.message, this.time, this.delivered, this.isMe});
final String message, time;
final delivered, isMe;
@override
Widget build(BuildContext context) {
final bg = isMe ? Colors.white : Colors.greenAccent.shade100;
final align = isMe ? CrossAxisAlignment.start : CrossAxisAlignment.end;
final icon = delivered ? Icons.done_all : Icons.done;
final radius = isMe
? BorderRadius.only(
topRight: Radius.circular(5.0),
bottomLeft: Radius.circular(10.0),
bottomRight: Radius.circular(5.0),
)
: BorderRadius.only(
topLeft: Radius.circular(5.0),
bottomLeft: Radius.circular(5.0),
bottomRight: Radius.circular(10.0),
);
return Column(
crossAxisAlignment: align,
children: <Widget>[
Container(
margin: const EdgeInsets.all(3.0),
padding: const EdgeInsets.all(8.0),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
blurRadius: .5,
spreadRadius: 1.0,
color: Colors.black.withOpacity(.12))
],
color: bg,
borderRadius: radius,
),
child: Stack(
children: <Widget>[
Padding(
padding: EdgeInsets.only(right: 48.0),
child: Text(message),
),
Positioned(
bottom: 0.0,
right: 0.0,
child: Row(
children: <Widget>[
Text(time,
style: TextStyle(
color: Colors.black38,
fontSize: 10.0,
)),
SizedBox(width: 3.0),
Icon(
icon,
size: 12.0,
color: Colors.black38,
)
],
),
)
],
),
)
],
);
}
}
class MessageDetail extends StatelessWidget {
final Message msg;
const MessageDetail({Key key, this.msg}) : super(key: key);
@override
Widget build(BuildContext context) {
DateFormat dateFormat=DateFormat("HH:mm");
MessageModel messageModel = Provider.of<MessageModel>(context);
List<Message> messages = messageModel.getMessage(msg.receiverName);
List<Bubble> bubbles = messages
.map((e) => Bubble(
message: e.message,
time: dateFormat.format(e.date),
delivered: true,
isMe: e.isMe != null ? e.isMe : true))
.toList();
return Scaffold(
appBar: AppBar(
backgroundColor: primaryColor,
elevation: .9,
title: Text(
msg.receiverName,
),
actions: <Widget>[],
),
body: Padding(
padding: EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: bubbles,
// children: <Widget>[
// Bubble(
// message: 'Hi there, this is a message',
// time: '12:00',
// delivered: true,
// isMe: false,
// ),
// Bubble(
// message: 'Whatsapp like bubble talk',
// time: '12:01',
// delivered: true,
// isMe: true,
// ),
// Bubble(
// message: 'Nice one, Flutter is awesome',
// time: '12:00',
// delivered: true,
// isMe: true,
// ),
// Bubble(
// message: 'I\'ve told you so dude!',
// time: '12:00',
// delivered: true,
// isMe: false,
// ),
// ],
),
),
);
}
}

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))
);
}
}