Merge pull request 'fix message bubble rendering errors/lag' (#60) from flix into trunk
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
Reviewed-on: #60
This commit is contained in:
commit
141a5b8f3d
|
@ -30,8 +30,8 @@ class CwtchNotifier {
|
|||
break;
|
||||
case "PeerCreated":
|
||||
profileCN.getProfile(data["ProfileOnion"]).contactList.add(ContactInfoState(
|
||||
profileOnion: data["ProfileOnion"],
|
||||
onion: data["RemotePeer"],
|
||||
data["ProfileOnion"],
|
||||
data["RemotePeer"],
|
||||
nickname: data["nick"],
|
||||
status: data["status"],
|
||||
imagePath: data["picture"],
|
||||
|
@ -97,8 +97,14 @@ class CwtchNotifier {
|
|||
print("new group invite: $data");
|
||||
// TODO Add Group Dynamically
|
||||
dynamic groupInvite = jsonDecode(data["GroupInvite"]);
|
||||
profileCN.getProfile(data["ProfileOnion"]).contactList.add(
|
||||
ContactInfoState(onion: groupInvite["GroupID"], isInvitation: true, imagePath: data["PicturePath"], nickname: groupInvite["GroupName"], server: groupInvite["ServerHost"], isGroup: true));
|
||||
profileCN.getProfile(data["ProfileOnion"]).contactList.add(ContactInfoState(
|
||||
"",
|
||||
groupInvite["GroupID"],
|
||||
isInvitation: true,
|
||||
imagePath: data["PicturePath"],
|
||||
nickname: groupInvite["GroupName"],
|
||||
server: groupInvite["ServerHost"],
|
||||
isGroup: true));
|
||||
break;
|
||||
case "ServerStateChange":
|
||||
print("server state change: $data");
|
||||
|
|
|
@ -92,7 +92,10 @@ class ContactListState extends ChangeNotifier {
|
|||
}
|
||||
|
||||
void updateLastMessageTime(String forOnion, DateTime newVal) {
|
||||
getContact(forOnion).lastMessageTime = newVal;
|
||||
var contact = getContact(forOnion);
|
||||
if (contact == null) return;
|
||||
|
||||
contact.lastMessageTime = newVal;
|
||||
_contacts.sort((ContactInfoState a, ContactInfoState b) {
|
||||
if (a.lastMessageTime == null && b.lastMessageTime == null) return 0;
|
||||
if (a.lastMessageTime == null) return 1;
|
||||
|
@ -139,8 +142,8 @@ class ProfileInfoState extends ChangeNotifier {
|
|||
List<dynamic> contacts = jsonDecode(contactsJson);
|
||||
this._contacts.addAll(contacts.map((contact) {
|
||||
return ContactInfoState(
|
||||
profileOnion: this.onion,
|
||||
onion: contact["onion"],
|
||||
this.onion,
|
||||
contact["onion"],
|
||||
nickname: contact["name"],
|
||||
status: contact["status"],
|
||||
imagePath: contact["picture"],
|
||||
|
@ -228,9 +231,9 @@ class ContactInfoState extends ChangeNotifier {
|
|||
bool _isGroup;
|
||||
String _server;
|
||||
|
||||
ContactInfoState({
|
||||
ContactInfoState(
|
||||
this.profileOnion,
|
||||
this.onion,
|
||||
this.onion,{
|
||||
nickname = "",
|
||||
isGroup = false,
|
||||
isInvitation = false,
|
||||
|
|
|
@ -20,13 +20,13 @@ class _MessageViewState extends State<MessageView> {
|
|||
final ctrlrCompose = TextEditingController();
|
||||
final focusNode = FocusNode();
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
if (Provider.of<ContactInfoState>(context, listen: false).unreadMessages > 0) {
|
||||
Provider.of<ContactInfoState>(context, listen: false).unreadMessages = 0;
|
||||
}
|
||||
}
|
||||
// @override
|
||||
// void didChangeDependencies() {
|
||||
// super.didChangeDependencies();
|
||||
// if (Provider.of<ContactInfoState>(context, listen: false).unreadMessages > 0) {
|
||||
// Provider.of<ContactInfoState>(context, listen: false).unreadMessages = 0;
|
||||
// }
|
||||
// }
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
|
@ -105,46 +105,19 @@ class _MessageViewState extends State<MessageView> {
|
|||
onSubmitted: _sendMessage,
|
||||
)),
|
||||
SizedBox(
|
||||
width: 90,
|
||||
height: 80,
|
||||
child: Column(children: <Widget>[
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(2, 2, 2, 2),
|
||||
child: ElevatedButton(
|
||||
child: Icon(Icons.send, color: Provider.of<Settings>(context).theme.mainTextColor()),
|
||||
style: ButtonStyle(
|
||||
fixedSize: MaterialStateProperty.all(Size(86, 40)),
|
||||
backgroundColor: MaterialStateProperty.all(Provider.of<Settings>(context).theme.defaultButtonColor()),
|
||||
),
|
||||
onPressed: _sendMessage,
|
||||
)),
|
||||
Row(children: <Widget>[
|
||||
Padding(
|
||||
padding: EdgeInsets.all(2),
|
||||
child: SizedBox(
|
||||
width: 41,
|
||||
child: ElevatedButton(
|
||||
child: Icon(Icons.emoji_emotions_outlined, color: Provider.of<Settings>(context).theme.mainTextColor()),
|
||||
style: ButtonStyle(
|
||||
fixedSize: MaterialStateProperty.all(Size(41, 40)),
|
||||
backgroundColor: MaterialStateProperty.all(Provider.of<Settings>(context).theme.defaultButtonColor()),
|
||||
),
|
||||
onPressed: placeHolder,
|
||||
))),
|
||||
Padding(
|
||||
padding: EdgeInsets.all(2),
|
||||
child: SizedBox(
|
||||
width: 41,
|
||||
child: ElevatedButton(
|
||||
child: Icon(Icons.attach_file, color: Provider.of<Settings>(context).theme.mainTextColor()),
|
||||
style: ButtonStyle(
|
||||
fixedSize: MaterialStateProperty.all(Size(41, 40)),
|
||||
backgroundColor: MaterialStateProperty.all(Provider.of<Settings>(context).theme.defaultButtonColor()),
|
||||
),
|
||||
onPressed: placeHolder,
|
||||
))),
|
||||
])
|
||||
]),
|
||||
width: 100,
|
||||
height: 90,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.fromLTRB(2, 2, 2, 2),
|
||||
child: ElevatedButton(
|
||||
child: Icon(Icons.send, color: Provider.of<Settings>(context).theme.mainTextColor()),
|
||||
style: ButtonStyle(
|
||||
fixedSize: MaterialStateProperty.all(Size(86, 40)),
|
||||
backgroundColor: MaterialStateProperty.all(Provider.of<Settings>(context).theme.defaultButtonColor()),
|
||||
),
|
||||
onPressed: _sendMessage,
|
||||
)
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
@ -11,51 +11,67 @@ class MessageBubble extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _MessageBubbleState extends State<MessageBubble> {
|
||||
FocusNode _focus = FocusNode();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var fromMe = Provider.of<MessageState>(context).senderOnion == Provider.of<ProfileInfoState>(context).onion;
|
||||
var prettyDate = "";
|
||||
var borderRadiousEh = 15.0;
|
||||
var myKey = Provider.of<MessageState>(context).profileOnion + "::" + Provider.of<MessageState>(context).contactHandle + "::" + Provider.of<MessageState>(context).messageIndex.toString();
|
||||
|
||||
if (Provider.of<MessageState>(context).timestamp != null) {
|
||||
// user-configurable timestamps prolly ideal? #todo
|
||||
prettyDate = DateFormat.yMd().add_jm().format(Provider.of<MessageState>(context).timestamp);
|
||||
}
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeBackgroundColor() : Provider.of<Settings>(context).theme.messageFromOtherBackgroundColor(),
|
||||
border: Border.all(color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeBackgroundColor() : Provider.of<Settings>(context).theme.messageFromOtherBackgroundColor(), width: 1),
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(borderRadiousEh),
|
||||
topRight: Radius.circular(borderRadiousEh),
|
||||
bottomLeft: fromMe ? Radius.circular(borderRadiousEh) : Radius.zero,
|
||||
bottomRight: fromMe ? Radius.zero : Radius.circular(borderRadiousEh),
|
||||
return LayoutBuilder(builder: (context, constraints) {
|
||||
//print(constraints.toString()+", "+constraints.maxWidth.toString());
|
||||
return Container(child:Container(
|
||||
decoration: BoxDecoration(
|
||||
color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeBackgroundColor() : Provider.of<Settings>(context).theme.messageFromOtherBackgroundColor(),
|
||||
border: Border.all(color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeBackgroundColor() : Provider.of<Settings>(context).theme.messageFromOtherBackgroundColor(), width: 1),
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(borderRadiousEh),
|
||||
topRight: Radius.circular(borderRadiousEh),
|
||||
bottomLeft: fromMe ? Radius.circular(borderRadiousEh) : Radius.zero,
|
||||
bottomRight: fromMe ? Radius.zero : Radius.circular(borderRadiousEh),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(9.0),
|
||||
child: Column(crossAxisAlignment: fromMe ? CrossAxisAlignment.end : CrossAxisAlignment.start, children: [
|
||||
SelectableText(
|
||||
Provider.of<MessageState>(context).message,
|
||||
style: TextStyle(
|
||||
color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeTextColor() : Provider.of<Settings>(context).theme.messageFromOtherTextColor(),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(9.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: fromMe ? CrossAxisAlignment.end : CrossAxisAlignment.start,
|
||||
mainAxisAlignment: fromMe ? MainAxisAlignment.end : MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
//Flexible(
|
||||
//fit: BoxFit.contain,
|
||||
SelectableText(
|
||||
(Provider.of<MessageState>(context).message ?? "") + '\u202F',
|
||||
key: Key(myKey),
|
||||
focusNode: _focus,
|
||||
style: TextStyle(
|
||||
color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeTextColor() : Provider.of<Settings>(context).theme.messageFromOtherTextColor(),
|
||||
),
|
||||
textAlign: TextAlign.left,
|
||||
textWidthBasis: TextWidthBasis.longestLine,
|
||||
),
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text(prettyDate,
|
||||
style: TextStyle(
|
||||
fontSize: 9.0,
|
||||
color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeTextColor() : Provider.of<Settings>(context).theme.messageFromOtherTextColor(),
|
||||
),
|
||||
textAlign: fromMe ? TextAlign.right : TextAlign.left),
|
||||
Provider.of<MessageState>(context).ackd
|
||||
? Icon(Icons.check_circle_outline, color: Provider.of<Settings>(context).theme.messageFromMeTextColor(), size: 12)
|
||||
: Icon(Icons.hourglass_bottom_outlined, color: Provider.of<Settings>(context).theme.messageFromMeTextColor(), size: 12)
|
||||
],
|
||||
)
|
||||
])),
|
||||
);
|
||||
Center(widthFactor: 1.0, child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(prettyDate,
|
||||
style: TextStyle(
|
||||
fontSize: 9.0,
|
||||
color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeTextColor() : Provider.of<Settings>(context).theme.messageFromOtherTextColor(),
|
||||
),
|
||||
textAlign: fromMe ? TextAlign.right : TextAlign.left),
|
||||
Provider.of<MessageState>(context).ackd
|
||||
? Icon(Icons.check_circle_outline, color: Provider.of<Settings>(context).theme.messageFromMeTextColor(), size: 12)
|
||||
: Icon(Icons.hourglass_bottom_outlined, color: Provider.of<Settings>(context).theme.messageFromMeTextColor(), size: 12)
|
||||
],
|
||||
)
|
||||
)])),
|
||||
));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ class _MessageListState extends State<MessageList> {
|
|||
});
|
||||
}
|
||||
} else {
|
||||
setState(() => null);
|
||||
//setState(() => null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ class _MessageRowState extends State<MessageRow> {
|
|||
Widget build(BuildContext context) {
|
||||
var fromMe = Provider.of<MessageState>(context).senderOnion == Provider.of<ProfileInfoState>(context).onion;
|
||||
|
||||
Widget wdgBubble = MessageBubble();
|
||||
Widget wdgBubble = Flexible(flex: 3, fit: FlexFit.loose, child: MessageBubble());
|
||||
Widget wdgIcons = Icon(Icons.delete_forever_outlined, color: Provider.of<Settings>(context).theme.dropShadowColor());
|
||||
Widget wdgSpacer = Expanded(child: SizedBox(width: 60, height: 10));
|
||||
var widgetRow = <Widget>[];
|
||||
|
@ -34,7 +34,7 @@ class _MessageRowState extends State<MessageRow> {
|
|||
Widget wdgPortrait = ProfileImage(
|
||||
diameter: 48.0,
|
||||
imagePath: contact.imagePath,
|
||||
maskOut: contact.status != "Authenticated",
|
||||
//maskOut: contact.status != "Authenticated",
|
||||
border: contact.status == "Authenticated" ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor() : Provider.of<Settings>(context).theme.portraitOfflineBorderColor());
|
||||
|
||||
widgetRow = <Widget>[
|
||||
|
@ -45,34 +45,6 @@ class _MessageRowState extends State<MessageRow> {
|
|||
];
|
||||
}
|
||||
|
||||
return Padding(padding: EdgeInsets.all(2), child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: widgetRow));
|
||||
}
|
||||
|
||||
void _pushMessageView(String handle) {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute<void>(
|
||||
builder: (BuildContext builderContext) {
|
||||
return MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider.value(value: Provider.of<ProfileInfoState>(context)),
|
||||
ChangeNotifierProvider.value(value: Provider.of<ProfileInfoState>(context).contactList.getContact(handle)),
|
||||
],
|
||||
child: MessageView(),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _btnApprove() {
|
||||
Provider.of<FlwtchState>(context, listen: false)
|
||||
.cwtch
|
||||
.AcceptContact(Provider.of<ContactInfoState>(context, listen: false).profileOnion, Provider.of<ContactInfoState>(context, listen: false).onion);
|
||||
}
|
||||
|
||||
void _btnReject() {
|
||||
Provider.of<FlwtchState>(context, listen: false)
|
||||
.cwtch
|
||||
.BlockContact(Provider.of<ContactInfoState>(context, listen: false).profileOnion, Provider.of<ContactInfoState>(context, listen: false).onion);
|
||||
return Padding(padding: EdgeInsets.all(2), child: Row(mainAxisAlignment: fromMe ? MainAxisAlignment.end : MainAxisAlignment.start, children: widgetRow));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue