From ab2d8b633058022799d14003075ecb76f8315c36 Mon Sep 17 00:00:00 2001 From: erinn Date: Tue, 27 Apr 2021 13:02:27 -0700 Subject: [PATCH 1/5] fixing things --- lib/model.dart | 5 +- lib/views/messageview.dart | 67 ++++++++------------------- lib/widgets/messagebubble.dart | 84 ++++++++++++++++++++-------------- lib/widgets/messagerow.dart | 34 ++------------ 4 files changed, 76 insertions(+), 114 deletions(-) diff --git a/lib/model.dart b/lib/model.dart index b5748bc..5976c42 100644 --- a/lib/model.dart +++ b/lib/model.dart @@ -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; diff --git a/lib/views/messageview.dart b/lib/views/messageview.dart index d538eb4..ad16b89 100644 --- a/lib/views/messageview.dart +++ b/lib/views/messageview.dart @@ -20,13 +20,13 @@ class _MessageViewState extends State { final ctrlrCompose = TextEditingController(); final focusNode = FocusNode(); - @override - void didChangeDependencies() { - super.didChangeDependencies(); - if (Provider.of(context, listen: false).unreadMessages > 0) { - Provider.of(context, listen: false).unreadMessages = 0; - } - } + // @override + // void didChangeDependencies() { + // super.didChangeDependencies(); + // if (Provider.of(context, listen: false).unreadMessages > 0) { + // Provider.of(context, listen: false).unreadMessages = 0; + // } + // } @override void dispose() { @@ -105,46 +105,19 @@ class _MessageViewState extends State { onSubmitted: _sendMessage, )), SizedBox( - width: 90, - height: 80, - child: Column(children: [ - Padding( - padding: EdgeInsets.fromLTRB(2, 2, 2, 2), - child: ElevatedButton( - child: Icon(Icons.send, color: Provider.of(context).theme.mainTextColor()), - style: ButtonStyle( - fixedSize: MaterialStateProperty.all(Size(86, 40)), - backgroundColor: MaterialStateProperty.all(Provider.of(context).theme.defaultButtonColor()), - ), - onPressed: _sendMessage, - )), - Row(children: [ - Padding( - padding: EdgeInsets.all(2), - child: SizedBox( - width: 41, - child: ElevatedButton( - child: Icon(Icons.emoji_emotions_outlined, color: Provider.of(context).theme.mainTextColor()), - style: ButtonStyle( - fixedSize: MaterialStateProperty.all(Size(41, 40)), - backgroundColor: MaterialStateProperty.all(Provider.of(context).theme.defaultButtonColor()), - ), - onPressed: placeHolder, - ))), - Padding( - padding: EdgeInsets.all(2), - child: SizedBox( - width: 41, - child: ElevatedButton( - child: Icon(Icons.attach_file, color: Provider.of(context).theme.mainTextColor()), - style: ButtonStyle( - fixedSize: MaterialStateProperty.all(Size(41, 40)), - backgroundColor: MaterialStateProperty.all(Provider.of(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(context).theme.mainTextColor()), + style: ButtonStyle( + fixedSize: MaterialStateProperty.all(Size(86, 40)), + backgroundColor: MaterialStateProperty.all(Provider.of(context).theme.defaultButtonColor()), + ), + onPressed: _sendMessage, + ) + ) ), ], ), diff --git a/lib/widgets/messagebubble.dart b/lib/widgets/messagebubble.dart index 1845374..ce76935 100644 --- a/lib/widgets/messagebubble.dart +++ b/lib/widgets/messagebubble.dart @@ -11,51 +11,65 @@ class MessageBubble extends StatefulWidget { } class _MessageBubbleState extends State { + FocusNode _focus = FocusNode(); + @override Widget build(BuildContext context) { var fromMe = Provider.of(context).senderOnion == Provider.of(context).onion; var prettyDate = ""; var borderRadiousEh = 15.0; + var myKey = Provider.of(context).profileOnion + "::" + Provider.of(context).contactHandle + "::" + Provider.of(context).messageIndex.toString(); if (Provider.of(context).timestamp != null) { // user-configurable timestamps prolly ideal? #todo prettyDate = DateFormat.yMd().add_jm().format(Provider.of(context).timestamp); } - return Container( - decoration: BoxDecoration( - color: fromMe ? Provider.of(context).theme.messageFromMeBackgroundColor() : Provider.of(context).theme.messageFromOtherBackgroundColor(), - border: Border.all(color: fromMe ? Provider.of(context).theme.messageFromMeBackgroundColor() : Provider.of(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( + + //width: constraints.maxWidth/4.0,// constraints, + decoration: BoxDecoration( + color: fromMe ? Provider.of(context).theme.messageFromMeBackgroundColor() : Provider.of(context).theme.messageFromOtherBackgroundColor(), + border: Border.all(color: fromMe ? Provider.of(context).theme.messageFromMeBackgroundColor() : Provider.of(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(context).message, - style: TextStyle( - color: fromMe ? Provider.of(context).theme.messageFromMeTextColor() : Provider.of(context).theme.messageFromOtherTextColor(), - ), - textAlign: TextAlign.left, - ), - Row( - children: [ - Text(prettyDate, - style: TextStyle( - fontSize: 9.0, - color: fromMe ? Provider.of(context).theme.messageFromMeTextColor() : Provider.of(context).theme.messageFromOtherTextColor(), - ), - textAlign: fromMe ? TextAlign.right : TextAlign.left), - Provider.of(context).ackd - ? Icon(Icons.check_circle_outline, color: Provider.of(context).theme.messageFromMeTextColor(), size: 12) - : Icon(Icons.hourglass_bottom_outlined, color: Provider.of(context).theme.messageFromMeTextColor(), size: 12) - ], - ) - ])), - ); + child: Padding( + padding: EdgeInsets.all(9.0), + child: Column(crossAxisAlignment: fromMe ? CrossAxisAlignment.end : CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ + //Flexible( + //fit: BoxFit.contain, + SelectableText( + (Provider.of(context).message ?? "") + '\u202F', + key: Key(myKey), + focusNode: _focus, + style: TextStyle( + color: fromMe ? Provider.of(context).theme.messageFromMeTextColor() : Provider.of(context).theme.messageFromOtherTextColor(), + ), + textAlign: TextAlign.left, + textWidthBasis: TextWidthBasis.longestLine, + ) + , + // Row( + // children: [ + // Text(prettyDate, + // style: TextStyle( + // fontSize: 9.0, + // color: fromMe ? Provider.of(context).theme.messageFromMeTextColor() : Provider.of(context).theme.messageFromOtherTextColor(), + // ), + // textAlign: fromMe ? TextAlign.right : TextAlign.left), + // Provider.of(context).ackd + // ? Icon(Icons.check_circle_outline, color: Provider.of(context).theme.messageFromMeTextColor(), size: 12) + // : Icon(Icons.hourglass_bottom_outlined, color: Provider.of(context).theme.messageFromMeTextColor(), size: 12) + // ], + // ) + ])), + )); + }); } } diff --git a/lib/widgets/messagerow.dart b/lib/widgets/messagerow.dart index 4903603..79f72a4 100644 --- a/lib/widgets/messagerow.dart +++ b/lib/widgets/messagerow.dart @@ -18,7 +18,7 @@ class _MessageRowState extends State { Widget build(BuildContext context) { var fromMe = Provider.of(context).senderOnion == Provider.of(context).onion; - Widget wdgBubble = MessageBubble(); + Widget wdgBubble = Flexible(fit: FlexFit.loose, child: MessageBubble()); Widget wdgIcons = Icon(Icons.delete_forever_outlined, color: Provider.of(context).theme.dropShadowColor()); Widget wdgSpacer = Expanded(child: SizedBox(width: 60, height: 10)); var widgetRow = []; @@ -34,7 +34,7 @@ class _MessageRowState extends State { Widget wdgPortrait = ProfileImage( diameter: 48.0, imagePath: contact.imagePath, - maskOut: contact.status != "Authenticated", + //maskOut: contact.status != "Authenticated", border: contact.status == "Authenticated" ? Provider.of(context).theme.portraitOnlineBorderColor() : Provider.of(context).theme.portraitOfflineBorderColor()); widgetRow = [ @@ -45,34 +45,6 @@ class _MessageRowState extends State { ]; } - return Padding(padding: EdgeInsets.all(2), child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: widgetRow)); - } - - void _pushMessageView(String handle) { - Navigator.of(context).push( - MaterialPageRoute( - builder: (BuildContext builderContext) { - return MultiProvider( - providers: [ - ChangeNotifierProvider.value(value: Provider.of(context)), - ChangeNotifierProvider.value(value: Provider.of(context).contactList.getContact(handle)), - ], - child: MessageView(), - ); - }, - ), - ); - } - - void _btnApprove() { - Provider.of(context, listen: false) - .cwtch - .AcceptContact(Provider.of(context, listen: false).profileOnion, Provider.of(context, listen: false).onion); - } - - void _btnReject() { - Provider.of(context, listen: false) - .cwtch - .BlockContact(Provider.of(context, listen: false).profileOnion, Provider.of(context, listen: false).onion); + return Padding(padding: EdgeInsets.all(2), child: Row(children: widgetRow)); } } From c51da558c97f5cb7f42f889940846772d57c3851 Mon Sep 17 00:00:00 2001 From: erinn Date: Tue, 27 Apr 2021 13:39:07 -0700 Subject: [PATCH 2/5] fixing more things --- lib/widgets/messagebubble.dart | 4 +--- lib/widgets/messagerow.dart | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/widgets/messagebubble.dart b/lib/widgets/messagebubble.dart index ce76935..fcc89d0 100644 --- a/lib/widgets/messagebubble.dart +++ b/lib/widgets/messagebubble.dart @@ -25,10 +25,8 @@ class _MessageBubbleState extends State { prettyDate = DateFormat.yMd().add_jm().format(Provider.of(context).timestamp); } return LayoutBuilder(builder: (context, constraints) { - print(constraints.toString()+", "+constraints.maxWidth.toString()); + //print(constraints.toString()+", "+constraints.maxWidth.toString()); return Container(child:Container( - - //width: constraints.maxWidth/4.0,// constraints, decoration: BoxDecoration( color: fromMe ? Provider.of(context).theme.messageFromMeBackgroundColor() : Provider.of(context).theme.messageFromOtherBackgroundColor(), border: Border.all(color: fromMe ? Provider.of(context).theme.messageFromMeBackgroundColor() : Provider.of(context).theme.messageFromOtherBackgroundColor(), width: 1), diff --git a/lib/widgets/messagerow.dart b/lib/widgets/messagerow.dart index 79f72a4..8c918e9 100644 --- a/lib/widgets/messagerow.dart +++ b/lib/widgets/messagerow.dart @@ -18,7 +18,7 @@ class _MessageRowState extends State { Widget build(BuildContext context) { var fromMe = Provider.of(context).senderOnion == Provider.of(context).onion; - Widget wdgBubble = Flexible(fit: FlexFit.loose, child: MessageBubble()); + Widget wdgBubble = Flexible(flex: 3, fit: FlexFit.loose, child: MessageBubble()); Widget wdgIcons = Icon(Icons.delete_forever_outlined, color: Provider.of(context).theme.dropShadowColor()); Widget wdgSpacer = Expanded(child: SizedBox(width: 60, height: 10)); var widgetRow = []; @@ -45,6 +45,6 @@ class _MessageRowState extends State { ]; } - return Padding(padding: EdgeInsets.all(2), child: Row(children: widgetRow)); + return Padding(padding: EdgeInsets.all(2), child: Row(mainAxisAlignment: fromMe ? MainAxisAlignment.end : MainAxisAlignment.start, children: widgetRow)); } } From b166b551d961cbad4825418c2b8c0a8d99db827e Mon Sep 17 00:00:00 2001 From: erinn Date: Tue, 27 Apr 2021 14:01:36 -0700 Subject: [PATCH 3/5] fixing most things --- lib/widgets/messagebubble.dart | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/widgets/messagebubble.dart b/lib/widgets/messagebubble.dart index fcc89d0..3dbfcf5 100644 --- a/lib/widgets/messagebubble.dart +++ b/lib/widgets/messagebubble.dart @@ -51,16 +51,15 @@ class _MessageBubbleState extends State { ), textAlign: TextAlign.left, textWidthBasis: TextWidthBasis.longestLine, - ) - , + ), // Row( // children: [ - // Text(prettyDate, - // style: TextStyle( - // fontSize: 9.0, - // color: fromMe ? Provider.of(context).theme.messageFromMeTextColor() : Provider.of(context).theme.messageFromOtherTextColor(), - // ), - // textAlign: fromMe ? TextAlign.right : TextAlign.left), + Text(prettyDate, + style: TextStyle( + fontSize: 9.0, + color: fromMe ? Provider.of(context).theme.messageFromMeTextColor() : Provider.of(context).theme.messageFromOtherTextColor(), + ), + textAlign: fromMe ? TextAlign.right : TextAlign.left), // Provider.of(context).ackd // ? Icon(Icons.check_circle_outline, color: Provider.of(context).theme.messageFromMeTextColor(), size: 12) // : Icon(Icons.hourglass_bottom_outlined, color: Provider.of(context).theme.messageFromMeTextColor(), size: 12) From 5e3c3b95a41fb4ed0e01e99f7c6c7b807ffd3ad6 Mon Sep 17 00:00:00 2001 From: erinn Date: Wed, 28 Apr 2021 14:20:09 -0700 Subject: [PATCH 4/5] breaking things --- lib/cwtch/cwtchNotifier.dart | 7 ++++--- lib/model.dart | 8 ++++---- lib/widgets/messagebubble.dart | 16 ++++++++-------- lib/widgets/messagelist.dart | 2 +- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/cwtch/cwtchNotifier.dart b/lib/cwtch/cwtchNotifier.dart index 86417d3..dcb230c 100644 --- a/lib/cwtch/cwtchNotifier.dart +++ b/lib/cwtch/cwtchNotifier.dart @@ -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"], @@ -98,7 +98,8 @@ class CwtchNotifier { // TODO Add Group Dynamically dynamic groupInvite = jsonDecode(data["GroupInvite"]); profileCN.getProfile(data["ProfileOnion"]).contactList.add(ContactInfoState( - onion: groupInvite["GroupID"], + "", + groupInvite["GroupID"], isInvitation: true, imagePath: data["PicturePath"], nickname: groupInvite["GroupName"], diff --git a/lib/model.dart b/lib/model.dart index 001a189..a64d830 100644 --- a/lib/model.dart +++ b/lib/model.dart @@ -142,8 +142,8 @@ class ProfileInfoState extends ChangeNotifier { List 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"], @@ -231,9 +231,9 @@ class ContactInfoState extends ChangeNotifier { bool _isGroup; String _server; - ContactInfoState({ + ContactInfoState( this.profileOnion, - this.onion, + this.onion,{ nickname = "", isGroup = false, isInvitation = false, diff --git a/lib/widgets/messagebubble.dart b/lib/widgets/messagebubble.dart index 3dbfcf5..4d96ba4 100644 --- a/lib/widgets/messagebubble.dart +++ b/lib/widgets/messagebubble.dart @@ -52,20 +52,20 @@ class _MessageBubbleState extends State { textAlign: TextAlign.left, textWidthBasis: TextWidthBasis.longestLine, ), - // Row( - // children: [ + Align(alignment: fromMe ? Alignment.bottomLeft : Alignment.bottomRight,child: Row( + children: [ Text(prettyDate, style: TextStyle( fontSize: 9.0, color: fromMe ? Provider.of(context).theme.messageFromMeTextColor() : Provider.of(context).theme.messageFromOtherTextColor(), ), textAlign: fromMe ? TextAlign.right : TextAlign.left), - // Provider.of(context).ackd - // ? Icon(Icons.check_circle_outline, color: Provider.of(context).theme.messageFromMeTextColor(), size: 12) - // : Icon(Icons.hourglass_bottom_outlined, color: Provider.of(context).theme.messageFromMeTextColor(), size: 12) - // ], - // ) - ])), + Provider.of(context).ackd + ? Icon(Icons.check_circle_outline, color: Provider.of(context).theme.messageFromMeTextColor(), size: 12) + : Icon(Icons.hourglass_bottom_outlined, color: Provider.of(context).theme.messageFromMeTextColor(), size: 12) + ], + ) + )])), )); }); } diff --git a/lib/widgets/messagelist.dart b/lib/widgets/messagelist.dart index 6d69bcb..ee2f971 100644 --- a/lib/widgets/messagelist.dart +++ b/lib/widgets/messagelist.dart @@ -34,7 +34,7 @@ class _MessageListState extends State { }); } } else { - setState(() => null); + //setState(() => null); } } From 20f7d5c490cf3241f22f4bd888743561d504fa8d Mon Sep 17 00:00:00 2001 From: erinn Date: Wed, 28 Apr 2021 15:04:41 -0700 Subject: [PATCH 5/5] unbreaky my heart --- lib/widgets/messagebubble.dart | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/widgets/messagebubble.dart b/lib/widgets/messagebubble.dart index 4d96ba4..d79fb57 100644 --- a/lib/widgets/messagebubble.dart +++ b/lib/widgets/messagebubble.dart @@ -39,7 +39,11 @@ class _MessageBubbleState extends State { ), child: Padding( padding: EdgeInsets.all(9.0), - child: Column(crossAxisAlignment: fromMe ? CrossAxisAlignment.end : CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ + child: Column( + crossAxisAlignment: fromMe ? CrossAxisAlignment.end : CrossAxisAlignment.start, + mainAxisAlignment: fromMe ? MainAxisAlignment.end : MainAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ //Flexible( //fit: BoxFit.contain, SelectableText( @@ -52,7 +56,8 @@ class _MessageBubbleState extends State { textAlign: TextAlign.left, textWidthBasis: TextWidthBasis.longestLine, ), - Align(alignment: fromMe ? Alignment.bottomLeft : Alignment.bottomRight,child: Row( + Center(widthFactor: 1.0, child: Row( + mainAxisSize: MainAxisSize.min, children: [ Text(prettyDate, style: TextStyle(