forked from fayeed/dash_chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
152 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## [0.1.3] | ||
|
||
- Quick Reply functionality added. | ||
|
||
## [0.1.2] | ||
|
||
- Chat Bubble are more customizable now. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ class MyApp extends StatelessWidget { | |
return MaterialApp( | ||
title: 'Flutter Demo', | ||
theme: ThemeData( | ||
primarySwatch: Colors.blue, | ||
primarySwatch: Colors.purple, | ||
), | ||
home: MyHomePage(), | ||
); | ||
|
@@ -31,12 +31,16 @@ class _MyHomePageState extends State<MyHomePage> { | |
name: "Fayeed", | ||
uid: "123456789", | ||
avatar: "https://www.wrappixel.com/ampleadmin/assets/images/users/4.jpg", | ||
color: Colors.white, | ||
containerColor: Colors.pinkAccent, | ||
); | ||
|
||
final ChatUser otherUser = ChatUser( | ||
name: "Mrfatty", | ||
uid: "25649654", | ||
avatar: "https://www.wrappixel.com/ampleadmin/assets/images/users/1.jpg", | ||
avatar: "", | ||
color: Colors.white, | ||
containerColor: Colors.green, | ||
); | ||
|
||
List<ChatMessage> messages = List<ChatMessage>(); | ||
|
@@ -59,10 +63,33 @@ class _MyHomePageState extends State<MyHomePage> { | |
text: "When do you want to meet tommorrow?", | ||
user: user, | ||
createdAt: d3)); | ||
messages.add(ChatMessage( | ||
messages.add( | ||
ChatMessage( | ||
text: "Ok, great meet you there [email protected]", | ||
user: otherUser, | ||
createdAt: d3)); | ||
createdAt: d3, | ||
quickReplies: QuickReplies( | ||
values: <Reply>[ | ||
Reply( | ||
title: "I will Message you later", | ||
value: "I will Message you later", | ||
), | ||
Reply( | ||
title: "Maybe not.", | ||
value: "Maybe not.", | ||
), | ||
Reply( | ||
title: "Meet me at my place", | ||
value: "Meet me at my place", | ||
), | ||
Reply( | ||
title: "What!!", | ||
value: "What!!", | ||
), | ||
], | ||
), | ||
), | ||
); | ||
|
||
super.initState(); | ||
} | ||
|
@@ -101,14 +128,27 @@ class _MyHomePageState extends State<MyHomePage> { | |
onLongPressAvatar: (ChatUser user) { | ||
print("OnLongPressAvatar: ${user.name}"); | ||
}, | ||
messageContainerDecoration: BoxDecoration( | ||
color: Colors.green, | ||
), | ||
/* messageContainerDecoration: BoxDecoration( | ||
color: Colors.green, | ||
), */ | ||
inputMaxLines: 2, | ||
messageContainerPadding: EdgeInsets.all(20.0), | ||
messageContainerPadding: EdgeInsets.all(5.0), | ||
alwaysShowSend: true, | ||
inputTextStyle: TextStyle(fontSize: 24.0), | ||
inputTextStyle: TextStyle(fontSize: 16.0), | ||
inputContainerStyle: BoxDecoration(border: Border.all(width: 0.0)), | ||
onQuickReply: (Reply reply) { | ||
setState(() { | ||
messages.add(ChatMessage( | ||
text: reply.value, createdAt: DateTime.now(), user: user)); | ||
|
||
messages = [...messages]; | ||
}); | ||
}, | ||
quickReplyStyle: BoxDecoration(), | ||
quickReplyTextStyle: TextStyle(), | ||
quickReplyBuilder: (Reply reply) { | ||
return Text(reply.value); | ||
}, | ||
), | ||
); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
part of dash_chat; | ||
|
||
class QuickReply extends StatelessWidget { | ||
final Reply reply; | ||
|
||
final Function(Reply) onReply; | ||
|
||
final BoxDecoration quickReplyStyle; | ||
|
||
final TextStyle quickReplyTextStyle; | ||
|
||
final Widget Function(Reply) quickReplyBuilder; | ||
|
||
const QuickReply({ | ||
this.quickReplyBuilder, | ||
this.quickReplyStyle, | ||
this.quickReplyTextStyle, | ||
this.onReply, | ||
this.reply, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return GestureDetector( | ||
onTap: () { | ||
onReply(reply); | ||
}, | ||
child: quickReplyBuilder != null | ||
? quickReplyBuilder(reply) | ||
: Container( | ||
margin: EdgeInsets.only( | ||
left: 5.0, right: 5.0, top: 5.0, bottom: 10.0), | ||
padding: EdgeInsets.symmetric(horizontal: 5.0, vertical: 5.0), | ||
decoration: quickReplyStyle != null | ||
? quickReplyStyle | ||
: BoxDecoration( | ||
border: Border.all( | ||
width: 1.0, color: Theme.of(context).accentColor), | ||
borderRadius: BorderRadius.circular(5.0), | ||
), | ||
constraints: BoxConstraints( | ||
maxWidth: MediaQuery.of(context).size.width / 3), | ||
child: Text( | ||
reply.title, | ||
style: quickReplyTextStyle != null | ||
? quickReplyTextStyle | ||
: TextStyle( | ||
color: Theme.of(context).accentColor, | ||
fontSize: 12.0, | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name: dash_chat | ||
description: A new Flutter package project. | ||
version: 0.1.2 | ||
version: 0.1.3 | ||
author: | ||
homepage: | ||
|
||
|